From 7993a4ff2e7e64edd2df41ed86012e555ff9ebf8 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 20 Mar 2025 08:00:15 -0400 Subject: [PATCH 001/750] possible small complexity reduction and precision improvement --- lib_com/options.h | 3 +++ lib_enc/fd_cng_enc_fx.c | 14 +++++++++++++- lib_enc/ivas_ism_param_enc_fx.c | 8 ++++++++ lib_enc/ivas_omasa_enc_fx.c | 4 ++++ lib_enc/ivas_stereo_td_enc_fx.c | 16 ++++++++++++++++ lib_enc/ivas_td_low_rate_enc_fx.c | 4 ++++ lib_enc/subband_fft_fx.c | 7 +++++++ lib_enc/swb_tbe_enc_fx.c | 8 ++++++++ .../ivas_dirac_dec_binaural_functions_fx.c | 18 ++++++++++++++++-- 9 files changed, 79 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c9207fb3c..841eb6a2b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -175,4 +175,7 @@ #define NONBE_FIX_1402_WAVEADJUST /* VA: BASOP iisue 1402: fix waveform adjustment decoder PLC */ #define FIX_ISSUE_1376 /* VA: Fix for issue 1376 (issue with GSC excitation) */ #define OPT_SBA_AVOID_SPAR_RESCALE /* Optimization made to spar decoder and IGF */ + +#define IMPROV_PRECISION /* Place where precision can be cost free improved */ +#define IMPROV_PRECISION_EVSBE /* Place where precision can be cost free improved, might affect EVS BE */ #endif diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 9c3a236d7..c690b6a76 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2732,16 +2732,28 @@ void stereoFdCngCoherence_fx( move16(); move16(); +#ifdef IMPROV_PRECISION_EVSBE + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_mac( L_mult( pt_fftL[0], pt_fftR[0] ), pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_mac( L_mult( pt_fftL[0], pt_fftL[0] ), pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_mac( L_mult( pt_fftR[0], pt_fftR[0] ), pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ +#else cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ - +#endif FOR( i = 1; i < L_FFT / 2; i++ ) { +#ifdef IMPROV_PRECISION_EVSBE + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_mac( L_mult( pt_fftL[i], pt_fftR[i] ), pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_mac( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), pt_fftL[L_FFT - i], pt_fftR[i] ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_mac( L_mult( pt_fftL[i], pt_fftL[i] ), pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_mac( L_mult( pt_fftR[i], pt_fftR[i] ), pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ +#else cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */ eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ +#endif } test(); test(); diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index cda8cffd6..9d9b27786 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -295,7 +295,11 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = L_add( tmp, 2 * EVS_PI_FX ); } +#ifdef IMPROV_PRECISION + cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ); // Q14 +#else cardioid_left[i] = add( shr( alpha, 1 ), mult( sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ) ); // Q14 +#endif move16(); IF( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) @@ -303,7 +307,11 @@ void ivas_param_ism_stereo_dmx_fx( Word16 last_cardioid_right; last_cardioid_right = sub( ONE_IN_Q14 /* 1.0f in Q14 */, last_cardioid_left ); /* Smoothing */ +#ifdef IMPROV_PRECISION + cardioid_left[i] = mac_r( L_mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), 8192 /* 0.25f in Q15 */, last_cardioid_left ) ; // Q14 +#else cardioid_left[i] = add( mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), mult( 8192 /* 0.25f in Q15 */, last_cardioid_left ) ); // Q14 +#endif move16(); Word32 grad_32 = L_mult( sub( cardioid_left[i], last_cardioid_left ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ); /* Q14+Q16 = Q30 */ /* for the right cardioid, multiply with -1 */ /* Cardioids sum up to 1 */ diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index d31e6d53d..855a505d9 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1476,7 +1476,11 @@ static void ivas_omasa_dmx_fx( g1 = interpolator[k]; move16(); g2 = sub( MAX_WORD16, g1 ); /*q15*/ +#ifdef IMPROV_PRECISION_EVSBE + data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_mac( L_mult( g1, gains[j] ), g2, prev_gains[i][j] ) /*q31*/, data_in[i][k] ) ); /*Qx*/ +#else data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_add( L_mult( g1, gains[j] ), L_mult( g2, prev_gains[i][j] ) ) /*q31*/, data_in[i][k] ) ); /*Qx*/ +#endif move32(); } } diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 378068827..1618843f0 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -400,9 +400,15 @@ void tdm_configure_enc_fx( hStereoTD->tdm_use_IAWB_Ave_lpc = 0; /* Flag initialisation */ move16(); +#ifdef IMPROV_PRECISION + sts[0]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx ); + move16(); + sts[1]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx ); +#else sts[0]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), mult( 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx ) ); move16(); sts[1]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), mult( 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx ) ); +#endif move16(); test(); @@ -799,11 +805,21 @@ static void tdm_downmix_plain_ivas_fx( ) { Word16 i; +#ifdef IMPROV_PRECISION + Word16 One_m_Ratio_fx16, ratio_L_fx16; + One_m_Ratio_fx16 = extract_h( One_m_Ratio_fx ); + ratio_L_fx16 = extract_h( ratio_L_fx ); +#endif FOR( i = start_index; i < end_index; i++ ) { +#ifdef IMPROV_PRECISION + FR_Y_fx[i] = mac_r( L_mult( Right_in_fx[i], One_m_Ratio_fx16 ), Left_in_fx[i], ratio_L_fx16 ); + LR_X_fx[i] = msu_r( L_mult( Left_in_fx[i], One_m_Ratio_fx16 ), Right_in_fx[i], ratio_L_fx16 ); +#else FR_Y_fx[i] = add( mult( Right_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Left_in_fx[i], extract_h( ratio_L_fx ) ) ); LR_X_fx[i] = sub( mult( Left_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Right_in_fx[i], extract_h( ratio_L_fx ) ) ); +#endif move16(); move16(); } diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index c959ef758..29dd767bb 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -314,7 +314,11 @@ void encod_gen_2sbfr( lp_filt_exc_enc_ivas_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); #endif /* update long-term pitch gain for speech/music classifier */ +#ifdef IMPROV_PRECISION + st->hSpMusClas->lowrate_pitchGain = mac_r( L_mult( 29491, st->hSpMusClas->lowrate_pitchGain ), 3277 /*Q15*/, gain_pit ); // Q14 +#else st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14 +#endif move16(); /*-----------------------------------------------------------------* diff --git a/lib_enc/subband_fft_fx.c b/lib_enc/subband_fft_fx.c index 10de09fe9..8a6ee47ab 100644 --- a/lib_enc/subband_fft_fx.c +++ b/lib_enc/subband_fft_fx.c @@ -35,10 +35,17 @@ static void ComplexMult_16( const Word16 c1, const Word16 c2 ) { +#ifdef IMPROV_PRECISION_EVSBE + *y1 = mac_r( L_mult( x1, c1 ), x2, c2 ); + move16(); + *y2 = msu_r( L_mult( x2, c1 ), x1, c2 ); + move16(); +#else *y1 = add( mult( x1, c1 ), mult( x2, c2 ) ); move16(); *y2 = sub( mult( x2, c1 ), mult( x1, c2 ) ); move16(); +#endif } /*-------------------------------------------------------------------* * ffr_getSfWord32() diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index ba8ee5aa8..6cde2c5ea 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4002,7 +4002,11 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { // GainShape[i] = ( 1 - feedback ) * GainShape[i] + feedback * GainShape_Interp[i]; +#ifdef IMPROV_PRECISION_EVSBE + GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), feedback, GainShape_Interp_fx[i] ) ); +#else GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) ); +#endif move16(); } } @@ -4118,7 +4122,11 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { // GainShape[i] = ( 1 - feedback ) * GainShape[i * NUM_SHB_SUBGAINS] + feedback * GainShape_Interp[i]; +#ifdef IMPROV_PRECISION_EVSBE + GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), feedback, GainShape_Interp_fx[i] ) ); // Q15 +#else GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) ); // Q15 +#endif move16(); } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index b5dd1f8b9..70c52a210 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2551,15 +2551,21 @@ static void ivas_dirac_dec_binaural_process_output_fx( { Word16 gain; /* Mixing using the formulated processing matrix M */ +#ifdef IMPROV_PRECISION + gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ); // Q11 +#else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ) ); // Q11 - +#endif outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result move32(); move32(); +#ifdef IMPROV_PRECISION_EVSBE + gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ); // Q11 +#else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ) ); // Q11 - +#endif // interpVal * hDiracDecBin->processMtxIm[chA][chB][bin]; outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result @@ -2571,7 +2577,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( LT_16( bin, max_band_decorr ) && LT_16( chB, 2 ) ) { +#ifdef IMPROV_PRECISION_EVSBE + gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ); // Q11 +#else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ) ); // Q11 +#endif // interpVal * hDiracDecBin->processMtxDecRe[chA][chB][bin]; outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result @@ -2579,7 +2589,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( move32(); +#ifdef IMPROV_PRECISION_EVSBE + gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ); // Q11 +#else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ) ); // Q11 +#endif outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result move32(); -- GitLab From 284ba9485c53e223825e14de5c5b88984c619bcc Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 20 Mar 2025 08:30:51 -0400 Subject: [PATCH 002/750] more possible slight complexity reduction --- lib_com/ivas_pca_tools_fx.c | 9 ++++++++- lib_dec/bass_psfilter_fx.c | 4 ++++ lib_dec/ivas_sns_dec_fx.c | 8 ++++++++ lib_dec/ivas_stereo_cng_dec.c | 28 +++++++++++++++++++++++++++- lib_dec/ivas_stereo_dft_dec_fx.c | 5 ++++- lib_dec/ivas_stereo_ica_dec_fx.c | 4 ++++ 6 files changed, 55 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index c84078a7d..ea4cfce7e 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -1377,7 +1377,11 @@ void pca_enc_s3_fx( q_ang_2surv_fx( ph1_fx, n1, ph1_q_fx, ind1 ); +#ifdef IMPROV_PRECISION + tmp = mac_r( L_mac( L_mult( q_fx[1], q_fx[1] ), q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ); // Q15 + Q15 - Q15 -> Q15 +#else tmp = add( add( mult( q_fx[1], q_fx[1] ), mult( q_fx[2], q_fx[2] ) ), mult( q_fx[3], q_fx[3] ) ); // Q15 + Q15 - Q15 -> Q15 +#endif r_e = 0; move16(); r_fx = Sqrt16( tmp, &r_e ); @@ -1431,8 +1435,11 @@ void pca_enc_s3_fx( q_ang_2surv_fx( ph2_fx, n2[i], ph2_q_fx + 2 * i, ind2 + 2 * i ); } +#ifdef IMPROV_PRECISION + r_fx = Sqrt16( mac_r( L_mult( q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ), &r_e ); +#else r_fx = Sqrt16( add( mult( q_fx[2], q_fx[2] ), mult( q_fx[3], q_fx[3] ) ), &r_e ); - +#endif v_fx = BASOP_Util_Divide1616_Scale( q_fx[2], r_fx, &v_e ); v_e = add( v_e, sub( 0, r_e ) ); diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 45cf7feed..14f8008ff 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -1041,7 +1041,11 @@ Word16 res_bpf_adapt_ivas_fx( bpf_error_ratio = ONE_IN_Q14; // Q13 move16(); } +#ifdef IMPROV_PRECISION + bpf_error_ratio = mac_r( L_mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ); +#else bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); +#endif hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio; move16(); diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 3bc6d337e..327116024 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -83,7 +83,11 @@ static void sns_1st_dec_fx( FOR( i = 0; i < M / 2; i++ ) { +#ifdef IMPROV_PRECISION + snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); // Q16 +#else snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); // Q16 +#endif move32(); } @@ -91,7 +95,11 @@ static void sns_1st_dec_fx( FOR( i = M / 2; i < M; i++ ) { +#ifdef IMPROV_PRECISION + snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); /*Q16*/ +#else snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); /*Q16*/ +#endif move32(); } diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 223860db0..1994f4875 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -121,7 +121,9 @@ static void stereo_dft_generate_comfort_noise_fx( Word32 tmp32_1, tmp32_2; Word16 q_div, q_sqrt1, q_sqrt2, q_sqrt, sqrt_res; Word16 q_shift, q_shift_1, q_shift_2, min_q; - +#ifdef IMPROV_PRECISION + Word16 tmp16, tmp_p, tmp_s; +#endif hFdCngCom = st->hFdCngDec->hFdCngCom; push_wmops( "DFT_CNG" ); @@ -163,7 +165,11 @@ static void stereo_dft_generate_comfort_noise_fx( } ELSE { +#ifdef IMPROV_PRECISION + hStereoDft->g_state_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), A_GFILT_FX, hStereoDft->g_state_fx[b] ); /* Q15 */ +#else hStereoDft->g_state_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), mult( A_GFILT_FX, hStereoDft->g_state_fx[b] ) ); /* Q15 */ +#endif move16(); } @@ -190,13 +196,21 @@ static void stereo_dft_generate_comfort_noise_fx( } ELSE { +#ifdef IMPROV_PRECISION + hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ +#else hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ +#endif move16(); } } ELSE { +#ifdef IMPROV_PRECISION + hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ +#else hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ +#endif move16(); } } @@ -228,6 +242,17 @@ static void stereo_dft_generate_comfort_noise_fx( } LR_ratio = extract_h( tdm_ratio_tabl_fx[hStereoCng->last_tdm_idx] ); /* Q15 */ +#ifdef IMPROV_PRECISION + tmp16 = shr( hStereoDft->g_state_fx[b], 2 ); + tmp_p = add( ONE_IN_Q13, tmp16 ); + tmp_s = sub( ONE_IN_Q13, tmp16 ); + tmp16 = mult( gamma, 2048 ); + + c = BASOP_Util_Divide3232_Scale( + L_mac( L_mult( tmp_p, tmp_p ), gamma, tmp16 ), + L_mac( L_mult( tmp_s, tmp_s ), gamma, tmp16 ), + &c_e ); +#else c = BASOP_Util_Divide3232_Scale( L_add( L_mult( add( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ), add( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ) ), @@ -236,6 +261,7 @@ static void stereo_dft_generate_comfort_noise_fx( sub( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ) ), L_shr( L_mult( gamma, gamma ), 4 ) ), &c_e ); +#endif q_sqrt = c_e; move16(); sqrt_res = Sqrt16( mult( c, hStereoCng->cm_fx[b] ), &q_sqrt ); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 9c1b488cb..195166e7e 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -3549,8 +3549,11 @@ void stereo_dft_dec_sid_coh_fx( pred_fx = add( pred_fx, shl( mult( ( *pptr_fx++ ), cohBandq_fx[i] ), 2 ) ); /*q-13*/ } /* Weighted intra/inter-frame prediction */ +#ifdef IMPROV_PRECISION + pred_fx = mac_r( L_mult( alpha_fx, pred_fx ), sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ); /*q-13*/ +#else pred_fx = add( mult( alpha_fx, pred_fx ), mult( sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ) ); /*q-13*/ - +#endif /* Read residual index from bitstream */ IF( LT_16( *nb_bits, nr_of_sid_stereo_bits ) ) /* If the bit limit is reached, res_index = 0 is assumed for remaining indices */ { diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 694aad0b4..fa0da5cf7 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -201,7 +201,11 @@ void stereo_tca_dec_fx( IF( currentNCShift != 0 ) { +#ifdef IMPROV_PRECISION + currentNCShift = mac_r( L_mult( 19660 /* 0.6 in Q15 */, prevNCShift ), 13106 /* 0.4 in Q15 */, currentNCShift ); /* Q0 */ +#else currentNCShift = add( mult( 19660 /* 0.6 in Q15 */, prevNCShift ), mult( 13106 /* 0.4 in Q15 */, currentNCShift ) ); /* Q0 */ +#endif } prevNCShift = hStereoTCA->interp_dec_prevNCShift; /* Q0 */ -- GitLab From 0acc6afadb37f1645a716bcfb52676ccdd87b2e5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 20 Mar 2025 08:35:55 -0400 Subject: [PATCH 003/750] fix clang --- lib_dec/ivas_stereo_cng_dec.c | 6 +++--- lib_enc/fd_cng_enc_fx.c | 6 +++--- lib_enc/ivas_ism_param_enc_fx.c | 6 +++--- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 10 +++++----- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 1994f4875..2291fcea1 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -199,7 +199,7 @@ static void stereo_dft_generate_comfort_noise_fx( #ifdef IMPROV_PRECISION hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ #else - hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ + hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ #endif move16(); } @@ -209,7 +209,7 @@ static void stereo_dft_generate_comfort_noise_fx( #ifdef IMPROV_PRECISION hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ #else - hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ + hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ #endif move16(); } @@ -247,7 +247,7 @@ static void stereo_dft_generate_comfort_noise_fx( tmp_p = add( ONE_IN_Q13, tmp16 ); tmp_s = sub( ONE_IN_Q13, tmp16 ); tmp16 = mult( gamma, 2048 ); - + c = BASOP_Util_Divide3232_Scale( L_mac( L_mult( tmp_p, tmp_p ), gamma, tmp16 ), L_mac( L_mult( tmp_s, tmp_s ), gamma, tmp16 ), diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index c690b6a76..328b81762 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2737,9 +2737,9 @@ void stereoFdCngCoherence_fx( eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_mac( L_mult( pt_fftL[0], pt_fftL[0] ), pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_mac( L_mult( pt_fftR[0], pt_fftR[0] ), pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ #else - cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ - eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ - eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ #endif FOR( i = 1; i < L_FFT / 2; i++ ) { diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index 9d9b27786..c46983578 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -298,7 +298,7 @@ void ivas_param_ism_stereo_dmx_fx( #ifdef IMPROV_PRECISION cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ); // Q14 #else - cardioid_left[i] = add( shr( alpha, 1 ), mult( sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ) ); // Q14 + cardioid_left[i] = add( shr( alpha, 1 ), mult( sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ) ); // Q14 #endif move16(); @@ -307,8 +307,8 @@ void ivas_param_ism_stereo_dmx_fx( Word16 last_cardioid_right; last_cardioid_right = sub( ONE_IN_Q14 /* 1.0f in Q14 */, last_cardioid_left ); /* Smoothing */ -#ifdef IMPROV_PRECISION - cardioid_left[i] = mac_r( L_mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), 8192 /* 0.25f in Q15 */, last_cardioid_left ) ; // Q14 +#ifdef IMPROV_PRECISION + cardioid_left[i] = mac_r( L_mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), 8192 /* 0.25f in Q15 */, last_cardioid_left ); // Q14 #else cardioid_left[i] = add( mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), mult( 8192 /* 0.25f in Q15 */, last_cardioid_left ) ); // Q14 #endif diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 855a505d9..b5b9102ea 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1475,7 +1475,7 @@ static void ivas_omasa_dmx_fx( { g1 = interpolator[k]; move16(); - g2 = sub( MAX_WORD16, g1 ); /*q15*/ + g2 = sub( MAX_WORD16, g1 ); /*q15*/ #ifdef IMPROV_PRECISION_EVSBE data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_mac( L_mult( g1, gains[j] ), g2, prev_gains[i][j] ) /*q31*/, data_in[i][k] ) ); /*Qx*/ #else diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 29dd767bb..a7dd96486 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -352,9 +352,9 @@ void encod_gen_2sbfr( #ifndef FIX_1320_LOWRATE_ACELP hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); #else - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ #endif move16(); @@ -365,8 +365,8 @@ void encod_gen_2sbfr( #ifndef FIX_1320_LOWRATE_ACELP hLPDmem->mem_w0 = sub( sub( xn[2 * L_SUBFR - 1], mult_r( gain_pit, y1[2 * L_SUBFR - 1] ) ), mult_r( extract_h( gain_code ), y2[2 * L_SUBFR - 1] ) ); #else - Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ - Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ + Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ + Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[2 * L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ Ltmp = L_msu( Ltmp, y1[2 * L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 70c52a210..f93885e97 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2554,7 +2554,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( #ifdef IMPROV_PRECISION gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ); // Q11 #else - gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ) ); // Q11 + gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ) ); // Q11 #endif outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result @@ -2564,7 +2564,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( #ifdef IMPROV_PRECISION_EVSBE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ); // Q11 #else - gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ) ); // Q11 + gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ) ); // Q11 #endif // interpVal * hDiracDecBin->processMtxIm[chA][chB][bin]; outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result @@ -2594,8 +2594,8 @@ static void ivas_dirac_dec_binaural_process_output_fx( #else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ) ); // Q11 #endif - outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result - outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result + outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result + outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result move32(); move32(); } -- GitLab From db6909322b7258ae62e24eae81f38559892147a0 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 22 Oct 2025 15:10:20 +0100 Subject: [PATCH 004/750] Implement BASOP W_min and W_max functions. --- lib_basop/enh64.c | 97 +++++++++++++++++++++++++++++++++++++++++++- lib_basop/enh64.h | 2 + lib_debug/wmc_auto.c | 2 +- lib_debug/wmc_auto.h | 2 + 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index 8bffb620c..b53adb79a 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -40,7 +40,103 @@ *****************************************************************************/ #ifdef ENH_64_BIT_OPERATOR +/*______________________________________________________________________________ +| | +| Function Name : W_min | +| | +| Purpose : | +| | +| Compares L64_var1 and L64_var2 and returns the minimum value. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +Word64 W_min( Word64 L64_var1, Word64 L64_var2 ) +{ + Word64 L64_var_out; + if ( L64_var1 <= L64_var2 ) + { + L64_var_out = L64_var1; + } + else + { + L64_var_out = L64_var2; + } + +#ifdef WMOPS + multiCounter[currCounter].W_min++; +#endif /* ifdef WMOPS */ + + return ( L64_var_out ); +} + +/*______________________________________________________________________________ +| | +| Function Name : W_max | +| | +| Purpose : | +| | +| Compares L64_var1 and L64_var2 and returns the maximum value. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +Word64 W_max( Word64 L64_var1, Word64 L64_var2 ) +{ + Word64 L64_var_out; + + if ( L64_var1 >= L64_var2 ) + { + L64_var_out = L64_var1; + } + else + { + L64_var_out = L64_var2; + } + +#ifdef WMOPS + multiCounter[currCounter].W_max++; +#endif /* ifdef WMOPS */ + + return ( L64_var_out ); +} /*___________________________________________________________________________ | | @@ -84,7 +180,6 @@ Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ) return L64_var_out; } - /*___________________________________________________________________________ | | | Function Name : W_sub_nosat | diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index c3896bb0d..d690708da 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -21,6 +21,8 @@ * *****************************************************************************/ #ifdef ENH_64_BIT_OPERATOR +Word64 W_min( Word64 L64_var1, Word64 L64_var2 ); +Word64 W_max( Word64 L64_var1, Word64 L64_var2 ); Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_shl( Word64 L64_var1, Word16 var2 ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 5afd9de16..9d4d573f0 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -133,7 +133,7 @@ static BASIC_OP op_weight = { #ifdef ENH_64_BIT_OPERATOR /* Weights of new 64 bit basops */ , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 64e2c751a..6dff36f50 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -877,6 +877,8 @@ typedef struct /* New 64 bit basops */ #ifdef ENH_64_BIT_OPERATOR unsigned int move64; /* Complexity Weight of 1 */ + unsigned int W_min; /* Complexity Weight of 1 */ + unsigned int W_max; /* Complexity Weight of 1 */ unsigned int W_add_nosat; /* Complexity Weight of 1 */ unsigned int W_sub_nosat; /* Complexity Weight of 1 */ unsigned int W_shl; /* Complexity Weight of 1 */ -- GitLab From 837da740df1c1e4271842c656a31dda5c1672f74 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 27 Oct 2025 12:12:47 +0000 Subject: [PATCH 005/750] Addressed Thomas Dettbarn's comments. --- lib_basop/enh64.c | 97 ------------------------------------------ lib_basop/enh64.h | 104 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 99 deletions(-) diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index b53adb79a..7812f5af0 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -40,103 +40,6 @@ *****************************************************************************/ #ifdef ENH_64_BIT_OPERATOR -/*______________________________________________________________________________ -| | -| Function Name : W_min | -| | -| Purpose : | -| | -| Compares L64_var1 and L64_var2 and returns the minimum value. | -| | -| Complexity weight : 1 | -| | -| Inputs : | -| | -| L64_var1 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | -| | -| L64_var2 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | -| | -| Outputs : | -| | -| none | -| | -| Return Value : | -| | -| L64_var_out | -| 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | -|______________________________________________________________________________| -*/ -Word64 W_min( Word64 L64_var1, Word64 L64_var2 ) -{ - Word64 L64_var_out; - - if ( L64_var1 <= L64_var2 ) - { - L64_var_out = L64_var1; - } - else - { - L64_var_out = L64_var2; - } - -#ifdef WMOPS - multiCounter[currCounter].W_min++; -#endif /* ifdef WMOPS */ - - return ( L64_var_out ); -} - -/*______________________________________________________________________________ -| | -| Function Name : W_max | -| | -| Purpose : | -| | -| Compares L64_var1 and L64_var2 and returns the maximum value. | -| | -| Complexity weight : 1 | -| | -| Inputs : | -| | -| L64_var1 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | -| | -| L64_var2 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | -| | -| Outputs : | -| | -| none | -| | -| Return Value : | -| | -| L64_var_out | -| 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | -|______________________________________________________________________________| -*/ -Word64 W_max( Word64 L64_var1, Word64 L64_var2 ) -{ - Word64 L64_var_out; - - if ( L64_var1 >= L64_var2 ) - { - L64_var_out = L64_var1; - } - else - { - L64_var_out = L64_var2; - } - -#ifdef WMOPS - multiCounter[currCounter].W_max++; -#endif /* ifdef WMOPS */ - - return ( L64_var_out ); -} /*___________________________________________________________________________ | | diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index d690708da..ab21d5b0c 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -21,8 +21,108 @@ * *****************************************************************************/ #ifdef ENH_64_BIT_OPERATOR -Word64 W_min( Word64 L64_var1, Word64 L64_var2 ); -Word64 W_max( Word64 L64_var1, Word64 L64_var2 ); + + +/*______________________________________________________________________________ +| | +| Function Name : W_min | +| | +| Purpose : | +| | +| Compares L64_var1 and L64_var2 and returns the minimum value. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +static __inline Word64 W_min( Word64 L64_var1, Word64 L64_var2 ) +{ + Word64 L64_var_out; + + if ( L64_var1 <= L64_var2 ) + { + L64_var_out = L64_var1; + } + else + { + L64_var_out = L64_var2; + } + +#ifdef WMOPS + multiCounter[currCounter].W_min++; +#endif /* ifdef WMOPS */ + + return ( L64_var_out ); +} + + +/*______________________________________________________________________________ +| | +| Function Name : W_max | +| | +| Purpose : | +| | +| Compares L64_var1 and L64_var2 and returns the maximum value. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +static __inline Word64 W_max( Word64 L64_var1, Word64 L64_var2 ) +{ + Word64 L64_var_out; + + if ( L64_var1 >= L64_var2 ) + { + L64_var_out = L64_var1; + } + else + { + L64_var_out = L64_var2; + } + +#ifdef WMOPS + multiCounter[currCounter].W_max++; +#endif /* ifdef WMOPS */ + + return ( L64_var_out ); +} + + Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_shl( Word64 L64_var1, Word16 var2 ); -- GitLab From 024b3128dfee95ca8cc869625aae47673a70f8be Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 27 Oct 2025 12:15:21 +0000 Subject: [PATCH 006/750] Revert changes in enh64.c. --- lib_basop/enh64.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index 7812f5af0..8bffb620c 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -41,6 +41,7 @@ #ifdef ENH_64_BIT_OPERATOR + /*___________________________________________________________________________ | | | Function Name : W_add_nosat | @@ -83,6 +84,7 @@ Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ) return L64_var_out; } + /*___________________________________________________________________________ | | | Function Name : W_sub_nosat | -- GitLab From 267ec305aca39037677145fe1d314a8c7533266f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 14:57:23 +0000 Subject: [PATCH 007/750] Implement W_negate function. --- lib_basop/enh64.c | 43 +++++++++++++++++++++++++++++++++++++++++++ lib_basop/enh64.h | 1 + lib_debug/wmc_auto.c | 2 +- lib_debug/wmc_auto.h | 1 + 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index 8bffb620c..08534c8dc 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -128,6 +128,49 @@ Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) } +/*__________________________________________________________________________________ + | | + | Function Name : W_negate | + | | + | Purpose : | + | | + | Negate the 64 bit variable L64_var1 with saturation; saturate in the case | + | where input is 0x8000 0000 0000 0000. | + | | + | Complexity weight : 1 | + | | + | Inputs : | + | | + | L64_var1 64 bit long signed integer (Word64) whose value falls in the range: | + | 0x8000 0000 0000 0000 <= L64_var1 <= 0x7fff ffff ffff ffff. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | | + | L64_var_out | + | 64 bit long signed integer (Word64) whose value falls in the range: | + | 0x8000 0000 0000 0000 <= L_var_out <= 0x7fff ffff ffff ffff. | + |_________________________________________________________________________________| +*/ +Word64 W_negate( Word64 L64_var1 ) +{ + Word64 L64_var_out; + + L64_var_out = ( L64_var1 == MIN_64 ) ? MAX_64 : -L64_var1; + +#ifdef WMOPS + multiCounter[currCounter].W_negate++; +#endif + + BASOP_CHECK(); + + return ( L64_var_out ); +} + + /*___________________________________________________________________________ | | | Function Name : W_shl | diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index c3896bb0d..7358fc56b 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -23,6 +23,7 @@ #ifdef ENH_64_BIT_OPERATOR Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ); +Word64 W_negate( Word64 L64_var1 ); Word64 W_shl( Word64 L64_var1, Word16 var2 ); Word64 W_shr( Word64 L64_var1, Word16 var2 ); Word64 W_shl_nosat( Word64 L64_var1, Word16 var2 ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 5afd9de16..e7cc88031 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -133,7 +133,7 @@ static BASIC_OP op_weight = { #ifdef ENH_64_BIT_OPERATOR /* Weights of new 64 bit basops */ , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 64e2c751a..a1465df58 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -879,6 +879,7 @@ typedef struct unsigned int move64; /* Complexity Weight of 1 */ unsigned int W_add_nosat; /* Complexity Weight of 1 */ unsigned int W_sub_nosat; /* Complexity Weight of 1 */ + unsigned int W_negate; /* Complexity Weight of 1 */ unsigned int W_shl; /* Complexity Weight of 1 */ unsigned int W_shr; /* Complexity Weight of 1 */ unsigned int W_shl_nosat; /* Complexity Weight of 1 */ -- GitLab From 297ef63119fb51b2509b20bd884deeacf31885d2 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 14:57:23 +0000 Subject: [PATCH 008/750] Optimize matrixTransp1Mul_fx. --- lib_com/options.h | 6 +++ .../ivas_dirac_dec_binaural_functions_fx.c | 39 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c967fd233..729e366af 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -138,4 +138,10 @@ /* #################### End BASOP porting switches ############################ */ +/* #################### Start BASOP optimization switches ############################ */ + +#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ + +/* #################### End BASOP optimization switches ############################ */ + #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 60bbce7a9..10085a477 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3997,6 +3997,44 @@ static void matrixTransp1Mul_fx( Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +#ifdef OPT_2181_MATRIX_TRANSP_1_MUL + Word64 tmp64; + Word16 common_lsh; + common_lsh = 63; + move16(); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + tmp64 = W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ); + tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bre_fx[1][chB] ); + tmp64 = W_mac_32_32( tmp64, Aim_fx[0][chA], Bim_fx[0][chB] ); + tmp_outRe_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bim_fx[1][chB] ); + move64(); + common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); + + tmp64 = W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ); + tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bre_fx[1][chB] ); + tmp64 = W_mac_32_32( W_negate( tmp64 ), Are_fx[0][chA], Bim_fx[0][chB] ); + tmp_outIm_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); + move64(); + common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); + } + } + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], common_lsh ) ); + move32(); + outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], common_lsh ) ); + move32(); + } + } + *q_out = add( add( add( q_A, q_B ), 1 ), common_lsh ); + move16(); +#else Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word64 tmp64_1, tmp64_2; @@ -4043,6 +4081,7 @@ static void matrixTransp1Mul_fx( } *q_out = sub( q_common, 32 ); move16(); +#endif if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { *q_out = Q31; -- GitLab From a8316e76a9c61199420ebf403e19d10ebaeb2b02 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 16:01:44 +0000 Subject: [PATCH 009/750] Fix q_out. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 10085a477..93b9778a6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4032,7 +4032,7 @@ static void matrixTransp1Mul_fx( move32(); } } - *q_out = add( add( add( q_A, q_B ), 1 ), common_lsh ); + *q_out = sub( add( add( add( q_A, q_B ), 1 ), common_lsh ), 32 ); move16(); #else Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -- GitLab From d1225c4dfa009961d7dda2b164e47f5b5af62b2f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 17:11:09 +0000 Subject: [PATCH 010/750] Fix common left shift initial value. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 93b9778a6..fda10d47c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3999,8 +3999,9 @@ static void matrixTransp1Mul_fx( Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; #ifdef OPT_2181_MATRIX_TRANSP_1_MUL Word64 tmp64; - Word16 common_lsh; - common_lsh = 63; + Word16 common_lsh, q; + q = add( add( q_A, q_B ), 1 ); + common_lsh = sub( 63, q ); move16(); FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4032,7 +4033,7 @@ static void matrixTransp1Mul_fx( move32(); } } - *q_out = sub( add( add( add( q_A, q_B ), 1 ), common_lsh ), 32 ); + *q_out = sub( add( q, common_lsh ), 32 ); move16(); #else Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -- GitLab From eb67ffb1702aa8401cef4589f888f18a8474a420 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 18:37:41 +0000 Subject: [PATCH 011/750] Move scale operations outside mul operations. --- lib_com/options.h | 1 + .../ivas_dirac_dec_binaural_functions_fx.c | 83 ++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 729e366af..c6c962f3d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,6 +141,7 @@ /* #################### Start BASOP optimization switches ############################ */ #define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ +#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index fda10d47c..fb8a12a29 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -118,9 +118,17 @@ static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaE static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_fx /*q_Ein*/, Word16 q_Ein, Word32 CinRe_fx /*q_Cin*/, Word32 CinIm_fx /*q_Cin*/, Word16 q_Cin, Word32 Eout1_fx /*q_Eout*/, Word32 Eout2_fx /*q_Eout*/, Word16 q_Eout, Word32 CoutRe_fx /*q_Cout*/, Word32 CoutIm_fx /*q_Cout*/, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*Q31*/, Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word16 *q_M, const Word16 regularizationFactor_fx /*Q14*/ ); +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixScale_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A ); +#endif + static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); +#else static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 Ascale, Word32 Bscale, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); +#endif /*------------------------------------------------------------------------- @@ -2260,12 +2268,23 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } /* Make matrix multiplication M*Cx*M' to determine resulting covariance matrix of processing input with M */ +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( Mre_fx, Mim_fx, &q_M ); + matrixScale_fx( CxRe_fx, CxIm_fx, &q_Cx ); +#endif matrixMul_fx( Mre_fx, Mim_fx, &q_M, CxRe_fx, CxIm_fx, &q_Cx, tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); + matrixTransp2Mul_fx( + tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, + resultMtxRe_fx, resultMtxIm_fx, &q_res ); +#else matrixTransp2Mul_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, 1 /*int Ascale*/, 0 /*int Bscale*/, resultMtxRe_fx, resultMtxIm_fx, &q_res ); +#endif /* When below the frequency limit where decorrelation is applied, we inject the decorrelated * residual (or missing) signal component. The procedure is active when there are not enough independent @@ -3914,6 +3933,22 @@ static void matrixDiagMul_fx( return; } +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixScale_fx( + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word16 *q_A ) +{ + Word16 shift; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); + scale_sig32( Are_fx[0], size, shift ); + scale_sig32( Aim_fx[0], size, shift ); + *q_A = add( *q_A, shift ); + move16(); +} +#endif + static void matrixMul_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ @@ -3925,6 +3960,10 @@ static void matrixMul_fx( Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) { +#ifdef OPT_2182_MATRIX_SCALE_OPS + Word16 chA, chB; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); +#else Word16 chA, chB; Word16 min_q_shift1, min_q_shift2; Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); @@ -3941,6 +3980,7 @@ static void matrixMul_fx( *q_B = add( *q_B, min_q_shift2 ); move16(); move16(); +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4092,6 +4132,18 @@ static void matrixTransp1Mul_fx( return; } +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixTransp2Mul_fx( + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word16 *q_A, + Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ + Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ + Word16 *q_B, + Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ + Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ + Word16 *q_out ) +#else static void matrixTransp2Mul_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ @@ -4104,7 +4156,12 @@ static void matrixTransp2Mul_fx( Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) +#endif { +#ifdef OPT_2182_MATRIX_SCALE_OPS + Word16 chA, chB; + Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#else Word16 chA, chB; Word16 min_q_shift; Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; @@ -4126,6 +4183,7 @@ static void matrixTransp2Mul_fx( *q_B = add( *q_B, min_q_shift ); move16(); } +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4663,6 +4721,10 @@ static void formulate2x2MixingMatrix_fx( q_temp = sub( add( q_ky, q_GhatQ ), 31 ); /* A = Ky' * G_hat * Q * Kx (see publication) */ +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); + matrixScale_fx( Kxre_fx, Kxim_fx, &q_Kx ); +#endif matrixMul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Kxre_fx, Kxim_fx, &q_Kx, Are_fx, Aim_fx, &q_A ); /* Find nearest orthonormal matrix P to A = Ky' * G_hat * Q * Kx @@ -4720,6 +4782,10 @@ static void formulate2x2MixingMatrix_fx( div_fx[0] = L_min( div_fx[0], thresh ); // q_div div_fx[1] = L_min( div_fx[1], thresh ); // q_div +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( Are_fx, Aim_fx, &q_A ); + matrixScale_fx( Ure_fx, Uim_fx, &q_U ); +#endif matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp ); exp = L_norm_arr( div_fx, BINAURAL_CHANNELS ); @@ -4783,10 +4849,15 @@ static void formulate2x2MixingMatrix_fx( } } +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, + Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ +#else matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, 0 /*int Ascale*/, 0 /*int Bscale*/, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ +#endif /* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */ #if ( BINAURAL_CHANNELS != 2 ) @@ -4917,12 +4988,22 @@ static void formulate2x2MixingMatrix_fx( } } +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( KyRe_fx, KyIm_fx, &q_ky ); + matrixScale_fx( Pre_fx, Pim_fx, &q_P ); +#endif matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp ); - +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); + matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, + Mre_fx, Mim_fx, q_M ); +#else matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, 1 /*int Ascale*/, 0 /*int Bscale*/, Mre_fx, Mim_fx, q_M ); +#endif + return; } -- GitLab From b94c2a1bbd261c2f37f011588f949285c962dbb2 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 4 Nov 2025 09:03:45 +0000 Subject: [PATCH 012/750] Optimize matrix mul output-format fix. --- lib_com/options.h | 1 + .../ivas_dirac_dec_binaural_functions_fx.c | 106 +++++++++++++----- 2 files changed, 77 insertions(+), 30 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8b407ea91..c6cc18f27 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,6 +148,7 @@ #define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ #define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ +#define OPT_XXXX_MATRIX_OUT_SCALING /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 2319bd6e7..90940a2b3 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3986,7 +3986,6 @@ static void matrixMul_fx( { #ifdef OPT_2182_MATRIX_SCALE_OPS Word16 chA, chB; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); #else Word16 chA, chB; Word16 min_q_shift1, min_q_shift2; @@ -4005,6 +4004,9 @@ static void matrixMul_fx( move16(); move16(); #endif +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + Word32 not_zero = 0; +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4031,16 +4033,31 @@ static void matrixMul_fx( Are_fx[chA][1], Bim_fx[1][chB] ); move32(); #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + not_zero = L_or( not_zero, outRe_fx[chA][chB] ); + not_zero = L_or( not_zero, outIm_fx[chA][chB] ); +#endif } } - *q_out = sub( add( *q_A, *q_B ), 31 ); + *q_out = sub( add( *q_A, *q_B ), 31 ); move16(); +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + if ( !not_zero ) + { + *q_out = Q31; + move16(); + } +#else +#ifdef OPT_2182_MATRIX_SCALE_OPS + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); +#endif if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { *q_out = Q31; move16(); } +#endif return; } @@ -4057,7 +4074,6 @@ static void matrixTransp1Mul_fx( Word16 *q_out ) { Word16 chA, chB; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; @@ -4067,11 +4083,19 @@ static void matrixTransp1Mul_fx( q = add( add( q_A, q_B ), 1 ); common_lsh = sub( 63, q ); move16(); +#else + Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word64 tmp64_1, tmp64_2; + Word16 tmp16, q_common = 63; + move16(); +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { +#ifdef OPT_2181_MATRIX_TRANSP_1_MUL tmp64 = W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ); tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bre_fx[1][chB] ); tmp64 = W_mac_32_32( tmp64, Aim_fx[0][chA], Bim_fx[0][chB] ); @@ -4085,31 +4109,7 @@ static void matrixTransp1Mul_fx( tmp_outIm_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); move64(); common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); - } - } - FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) - { - FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) - { - outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], common_lsh ) ); - move32(); - outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], common_lsh ) ); - move32(); - } - } - *q_out = sub( add( q, common_lsh ), 32 ); - move16(); #else - Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - Word64 tmp64_1, tmp64_2; - Word16 tmp16, q_common = 63; - move16(); - - FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) - { - FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) - { tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bim_fx[0][chB] ), Aim_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) tmp_outRe_fx[chA][chB] = W_add( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 ) @@ -4132,26 +4132,54 @@ static void matrixTransp1Mul_fx( q_tmp_outIm_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) ); move16(); q_common = s_min( q_tmp_outIm_fx[chA][chB], q_common ); +#endif } } +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + Word32 not_zero = 0; +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { +#ifdef OPT_2181_MATRIX_TRANSP_1_MUL + outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], common_lsh ) ); + move32(); + outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], common_lsh ) ); + move32(); +#else outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], s_max( -63, sub( q_common, q_tmp_outRe_fx[chA][chB] ) ) ) ); move32(); outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], s_max( -63, sub( q_common, q_tmp_outIm_fx[chA][chB] ) ) ) ); move32(); +#endif +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + not_zero = L_or( not_zero, outRe_fx[chA][chB] ); + not_zero = L_or( not_zero, outIm_fx[chA][chB] ); +#endif } } +#ifdef OPT_2181_MATRIX_TRANSP_1_MUL + *q_out = sub( add( q, common_lsh ), 32 ); + move16(); +#else *q_out = sub( q_common, 32 ); move16(); #endif +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + if ( !not_zero ) + { + *q_out = Q31; + move16(); + } +#else + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { *q_out = Q31; move16(); } +#endif return; } @@ -4184,7 +4212,7 @@ static void matrixTransp2Mul_fx( { #ifdef OPT_2182_MATRIX_SCALE_OPS Word16 chA, chB; - Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; + // Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; #else Word16 chA, chB; Word16 min_q_shift; @@ -4208,7 +4236,9 @@ static void matrixTransp2Mul_fx( move16(); } #endif - +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + Word32 not_zero = 0; +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) @@ -4234,16 +4264,32 @@ static void matrixTransp2Mul_fx( Are_fx[chA][1], Bim_fx[chB][1] ); move32(); #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + not_zero = L_or( not_zero, outRe_fx[chA][chB] ); + not_zero = L_or( not_zero, outIm_fx[chA][chB] ); +#endif } } + *q_out = sub( add( *q_A, *q_B ), 31 ); move16(); - +#ifdef OPT_XXXX_MATRIX_OUT_SCALING + if ( !not_zero ) + { + *q_out = Q31; + move16(); + } +#else +#ifdef OPT_2182_MATRIX_SCALE_OPS + Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#endif if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { *q_out = Q31; move16(); } +#endif + return; } -- GitLab From eb3d61ef476996fa5ac9dfaf8eb2a6551f2a8cd2 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 09:53:47 +0000 Subject: [PATCH 013/750] Set task number in OPT_2185_MATRIX_OUT_SCALING. --- lib_com/options.h | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c6cc18f27..5b823bc57 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,7 @@ #define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ #define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ -#define OPT_XXXX_MATRIX_OUT_SCALING +#define OPT_2185_MATRIX_OUT_SCALING /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 90940a2b3..025d133ff 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4004,7 +4004,7 @@ static void matrixMul_fx( move16(); move16(); #endif -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; #endif @@ -4033,7 +4033,7 @@ static void matrixMul_fx( Are_fx[chA][1], Bim_fx[1][chB] ); move32(); #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, outRe_fx[chA][chB] ); not_zero = L_or( not_zero, outIm_fx[chA][chB] ); #endif @@ -4042,7 +4042,7 @@ static void matrixMul_fx( *q_out = sub( add( *q_A, *q_B ), 31 ); move16(); -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { *q_out = Q31; @@ -4135,7 +4135,7 @@ static void matrixTransp1Mul_fx( #endif } } -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; #endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4153,7 +4153,7 @@ static void matrixTransp1Mul_fx( outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], s_max( -63, sub( q_common, q_tmp_outIm_fx[chA][chB] ) ) ) ); move32(); #endif -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, outRe_fx[chA][chB] ); not_zero = L_or( not_zero, outIm_fx[chA][chB] ); #endif @@ -4166,7 +4166,7 @@ static void matrixTransp1Mul_fx( *q_out = sub( q_common, 32 ); move16(); #endif -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { *q_out = Q31; @@ -4236,7 +4236,7 @@ static void matrixTransp2Mul_fx( move16(); } #endif -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; #endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4264,7 +4264,7 @@ static void matrixTransp2Mul_fx( Are_fx[chA][1], Bim_fx[chB][1] ); move32(); #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, outRe_fx[chA][chB] ); not_zero = L_or( not_zero, outIm_fx[chA][chB] ); #endif @@ -4273,7 +4273,7 @@ static void matrixTransp2Mul_fx( *q_out = sub( add( *q_A, *q_B ), 31 ); move16(); -#ifdef OPT_XXXX_MATRIX_OUT_SCALING +#ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { *q_out = Q31; -- GitLab From 8cd1cc04a5ff9dc5bd7a78295aed966e13cb4418 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 11:38:52 +0000 Subject: [PATCH 014/750] Optimize matrixDiagMul_fx format fix. --- lib_dec/ivas_ism_metadata_dec_fx.c | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 54cc5da15..4d3c06b9c 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -40,6 +39,7 @@ #include "ivas_stat_enc.h" #include #include "wmc_auto.h" +#include "move.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 025d133ff..6b09d9030 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3932,7 +3932,10 @@ static void matrixDiagMul_fx( Word16 *q_Out ) { Word16 chA, chB; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + +#ifdef OPT_2185_MATRIX_OUT_SCALING + Word32 not_zero = 0; +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -3942,17 +3945,30 @@ static void matrixDiagMul_fx( imOut_fx[chA][chB] = Mpy_32_32( imIn_fx[chA][chB], D_fx[chB] ); move32(); move32(); +#ifdef OPT_2185_MATRIX_OUT_SCALING + not_zero = L_or( not_zero, reOut_fx[chA][chB] ); + not_zero = L_or( not_zero, imOut_fx[chA][chB] ); +#endif } } *q_Out = sub( add( q_In, q_D ), 31 ); move16(); - +#ifdef OPT_2185_MATRIX_OUT_SCALING + if ( !not_zero ) + { + *q_Out = Q31; + move16(); + } +#else + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); if ( L_and( is_zero_arr( reOut_fx[0], size ), is_zero_arr( imOut_fx[0], size ) ) ) { *q_Out = Q31; move16(); } +#endif + return; } -- GitLab From 24c1c3724a1a46256b537595b0f2e8c9b14e877f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 13:59:43 +0000 Subject: [PATCH 015/750] Use W_neg instead of W_negate. --- lib_basop/enh64.c | 43 ------------------- lib_basop/enh64.h | 1 - lib_debug/wmc_auto.c | 2 +- lib_debug/wmc_auto.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 2 +- 5 files changed, 2 insertions(+), 47 deletions(-) diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index 08534c8dc..8bffb620c 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -128,49 +128,6 @@ Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) } -/*__________________________________________________________________________________ - | | - | Function Name : W_negate | - | | - | Purpose : | - | | - | Negate the 64 bit variable L64_var1 with saturation; saturate in the case | - | where input is 0x8000 0000 0000 0000. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | L64_var1 64 bit long signed integer (Word64) whose value falls in the range: | - | 0x8000 0000 0000 0000 <= L64_var1 <= 0x7fff ffff ffff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L64_var_out | - | 64 bit long signed integer (Word64) whose value falls in the range: | - | 0x8000 0000 0000 0000 <= L_var_out <= 0x7fff ffff ffff ffff. | - |_________________________________________________________________________________| -*/ -Word64 W_negate( Word64 L64_var1 ) -{ - Word64 L64_var_out; - - L64_var_out = ( L64_var1 == MIN_64 ) ? MAX_64 : -L64_var1; - -#ifdef WMOPS - multiCounter[currCounter].W_negate++; -#endif - - BASOP_CHECK(); - - return ( L64_var_out ); -} - - /*___________________________________________________________________________ | | | Function Name : W_shl | diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index 7358fc56b..c3896bb0d 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -23,7 +23,6 @@ #ifdef ENH_64_BIT_OPERATOR Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ); -Word64 W_negate( Word64 L64_var1 ); Word64 W_shl( Word64 L64_var1, Word16 var2 ); Word64 W_shr( Word64 L64_var1, Word16 var2 ); Word64 W_shl_nosat( Word64 L64_var1, Word16 var2 ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index e7cc88031..5afd9de16 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -133,7 +133,7 @@ static BASIC_OP op_weight = { #ifdef ENH_64_BIT_OPERATOR /* Weights of new 64 bit basops */ , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index a1465df58..64e2c751a 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -879,7 +879,6 @@ typedef struct unsigned int move64; /* Complexity Weight of 1 */ unsigned int W_add_nosat; /* Complexity Weight of 1 */ unsigned int W_sub_nosat; /* Complexity Weight of 1 */ - unsigned int W_negate; /* Complexity Weight of 1 */ unsigned int W_shl; /* Complexity Weight of 1 */ unsigned int W_shr; /* Complexity Weight of 1 */ unsigned int W_shl_nosat; /* Complexity Weight of 1 */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 154e75762..416a8a71c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4041,7 +4041,7 @@ static void matrixTransp1Mul_fx( tmp64 = W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ); tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bre_fx[1][chB] ); - tmp64 = W_mac_32_32( W_negate( tmp64 ), Are_fx[0][chA], Bim_fx[0][chB] ); + tmp64 = W_mac_32_32( W_neg( tmp64 ), Are_fx[0][chA], Bim_fx[0][chB] ); tmp_outIm_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); move64(); common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); -- GitLab From b916c938510d273a1bc04f45666f44ddcac6852e Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 14:03:17 +0000 Subject: [PATCH 016/750] Fix build failure. --- lib_dec/ivas_ism_metadata_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 54cc5da15..4d3c06b9c 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -40,6 +39,7 @@ #include "ivas_stat_enc.h" #include #include "wmc_auto.h" +#include "move.h" #include "ivas_prot_fx.h" -- GitLab From dc425ca49daf5f04ff2dd451f522fff73351ff09 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 14:27:45 +0000 Subject: [PATCH 017/750] Add comment to OPT_2185_MATRIX_OUT_SCALING definition. --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index d0dbb1f38..412585fdb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,7 +151,7 @@ #define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ #define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ -#define OPT_2185_MATRIX_OUT_SCALING +#define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From 43fbc9099773a79057aca3347e9ccdfed611c65c Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 15:12:02 +0000 Subject: [PATCH 018/750] Apply clang format. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index f019172f9..8492128df 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3932,7 +3932,7 @@ static void matrixDiagMul_fx( Word16 *q_Out ) { Word16 chA, chB; - + #ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; #endif @@ -3968,7 +3968,7 @@ static void matrixDiagMul_fx( move16(); } #endif - + return; } -- GitLab From a791a1528846174d2c55887b248b0fd3b05cf1a2 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 6 Nov 2025 10:02:44 +0000 Subject: [PATCH 019/750] Optimize eig2x2_fx part 1. --- lib_dec/ivas_ism_metadata_dec_fx.c | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 131 ++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 54cc5da15..4d3c06b9c 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -40,6 +39,7 @@ #include "ivas_stat_enc.h" #include #include "wmc_auto.h" +#include "move.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 3211b0e46..c689c449a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3518,6 +3518,31 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( return; } +#if 0 +static void check( + Word32 computed_fx, + Word16 computed_q, + Word32 expected_fx, + Word16 expected_q, + Word32 max_abs_err ); + +static void check( + Word32 computed_fx, + Word16 computed_q, + Word32 expected_fx, + Word16 expected_q, + Word32 max_abs_err ) +{ + Word16 qd = computed_q - expected_q; + Word32 cf = computed_fx >> +max( qd, 0 ); + Word32 ef = expected_fx >> -min( qd, 0 ); + Word32 abs_error = abs( cf - ef ); + if ( abs_error >= max_abs_err ) + { + assert( false ); + } +} +#endif static void eig2x2_fx( const Word32 E1_fx, /*q_E*/ @@ -3532,6 +3557,7 @@ static void eig2x2_fx( Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/ Word16 *q_D ) { +#if 0 Word16 chA, chB, ch; Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx; Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im; @@ -3672,7 +3698,112 @@ static void eig2x2_fx( *q_D = sub( q_tmp2, 1 ); move16(); } +#else + Word16 chA, chB, ch; + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + Ure_fx[chA][chB] = 0; + move32(); + Uim_fx[chA][chB] = 0; + move32(); + } + } + // =================================================================================================== + /*crossSquare_fx = (c_re * c_re) + (c_im * c_im) + a_fx = (e1 + e2) * (e1 + e2) - 4.0f * ((e1 * e2) - crossSquare_fx) = (e1 - e2)^2 + 4 * crossSquare_fx + pm_fx = 0.5f * sqrtf(max(0.0f, a_fx)) + add_fx = 0.5f * (e1 + e2)*/ + + Word16 q1, q2, qm, qd, lshift; + + // (e1 - e2)^2 -> Q: 2 * q_E + q1 = shl( q_E, 1 ); + // 4 * ((c_re * c_re) + (c_im * c_im)) -> Q: 2 * q_C - 2 + q2 = sub( shl( q_C, 1 ), 2 ); + + // (e1 - e2)^2 + Word32 es = L_sub( E1_fx, E2_fx ); + Word64 es2 = W_mult0_32_32( es, es ); + lshift = sub( W_norm( es2 ), 1 ); + es2 = W_shl( es2, lshift ); + q1 = add( q1, lshift ); + if ( !es2 ) + { + q1 = 63; + move16(); + } + + // 4 * ((c_re * c_re) + (c_im * c_im)) + Word64 cs = W_add( W_mult0_32_32( Cre_fx, Cre_fx ), W_mult0_32_32( Cim_fx, Cim_fx ) ); // 2*q_C-2 + lshift = sub( W_norm( cs ), 1 ); + cs = W_shl( cs, lshift ); + q2 = add( q2, lshift ); + if ( !cs ) + { + q2 = 63; + move16(); + } + + Word32 crossSquare_fx = (Word32) ( cs >> 32 ); // FIXME + Word16 q_crossSquare = 2 * q_C + lshift - 32; // FIXME + + // a = max(0, (e1 - e2)^2 + 4 * crossSquare_fx) + qm = s_min( q1, q2 ); + qd = sub( q1, q2 ); + Word64 a = W_max( W_add( W_shr( es2, s_max( qd, 0 ) ), W_shr( cs, negate( s_min( qd, 0 ) ) ) ), 0 ); + + // pm = 0.5f * sqrtf(a) + // a = 0.5f * ( E1 + E2 ); + lshift = W_norm( a ); + Word32 pm = W_extract_h( W_shl( a, lshift ) ); + Word16 e = sub( sub( 63, lshift ), qm ); + pm = L_shr( Sqrt32( pm, &e ), 1 ); + q2 = sub( 31, e ); + // check( pm, q2, pm_fx, q_tmp2, 1 << 16 ); + a = L_add( E1_fx, E2_fx ); + lshift = sub( norm_l( a ), 1 ); + a = W_shl( a, lshift ); + q1 = add( add( q_E, 1 ), lshift ); + // check( a, q1, add_fx, q_tmp1, 1 << 16 ); + + Word32 add_fx = a; // FIXME + Word16 q_tmp1 = q1; // FIXME + Word32 pm_fx = pm; // FIXME + Word16 q_tmp2 = q2; // FIXME + + // D[0] = add + pm; + // D[1] = max( 0.0f, add - pm ); + qm = s_min( q1, q2 ); + qd = sub( q1, q2 ); + a = W_shr( a, s_max( qd, 0 ) ); + pm = W_shr( pm, negate( s_min( qd, 0 ) ) ); + Word32 d0 = L_add( a, pm ); + Word32 d1 = L_max( L_sub( a, pm ), 0 ); + // check( d0, qm, D_fx[0], *q_D, 1 << 16 ); + // check( d1, qm, D_fx[1], *q_D, 1 << 16 ); + + D_fx[0] = d0; // FIXME + D_fx[1] = d1; // FIXME + *q_D = qm; // FIXME + + Word32 tmp1, tmp2, tmp3, e1, e2, s_fx, normVal_fx, c_re, c_im; // FIXME + Word16 q_U_1, q_U_2, q_c, q_e, exp, exp_tmp3; // FIXME + Word32 epsilon_mant = 1180591621; // FIXME + Word16 epsilon_exp = -39; // FIXME + + exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); // FIXME + c_re = L_shl( Cre_fx, exp ); // FIXME + c_im = L_shl( Cim_fx, exp ); // FIXME + q_c = add( q_C, exp ); // FIXME + + exp = sub( get_min_scalefactor( E1_fx, E2_fx ), 2 ); // FIXME + e1 = L_shl( E1_fx, exp ); // FIXME + e2 = L_shl( E2_fx, exp ); // FIXME + q_e = add( q_E, exp ); // FIXME +#endif /* Numeric case, when input is practically zeros */ // IF( D_fx[0] < EPSILON_FX ) -- GitLab From f4d6f56eb196c8dd629d0e7013da5f737c35a32d Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 6 Nov 2025 17:51:15 +0000 Subject: [PATCH 020/750] Fix MSVC build failure. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index c689c449a..4ddbdcc45 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3763,13 +3763,13 @@ static void eig2x2_fx( pm = L_shr( Sqrt32( pm, &e ), 1 ); q2 = sub( 31, e ); // check( pm, q2, pm_fx, q_tmp2, 1 << 16 ); - a = L_add( E1_fx, E2_fx ); - lshift = sub( norm_l( a ), 1 ); - a = W_shl( a, lshift ); + Word32 ea = L_add( E1_fx, E2_fx ); + lshift = sub( norm_l( ea ), 1 ); + ea = L_shl( ea, lshift ); q1 = add( add( q_E, 1 ), lshift ); - // check( a, q1, add_fx, q_tmp1, 1 << 16 ); + // check( ea, q1, add_fx, q_tmp1, 1 << 16 ); - Word32 add_fx = a; // FIXME + Word32 add_fx = ea; // FIXME Word16 q_tmp1 = q1; // FIXME Word32 pm_fx = pm; // FIXME Word16 q_tmp2 = q2; // FIXME -- GitLab From db555574e65c07102d845662be1e0531cb3ee055 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 6 Nov 2025 17:54:13 +0000 Subject: [PATCH 021/750] Apply clang format. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 4ddbdcc45..4fc279344 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3769,7 +3769,7 @@ static void eig2x2_fx( q1 = add( add( q_E, 1 ), lshift ); // check( ea, q1, add_fx, q_tmp1, 1 << 16 ); - Word32 add_fx = ea; // FIXME + Word32 add_fx = ea; // FIXME Word16 q_tmp1 = q1; // FIXME Word32 pm_fx = pm; // FIXME Word16 q_tmp2 = q2; // FIXME -- GitLab From 9219bfbcf5650e3bb98a4ec81a0a1f1ad3ba647d Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 6 Nov 2025 18:08:14 +0000 Subject: [PATCH 022/750] Fix MSVC build failure. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 4fc279344..b79a62c26 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3778,10 +3778,10 @@ static void eig2x2_fx( // D[1] = max( 0.0f, add - pm ); qm = s_min( q1, q2 ); qd = sub( q1, q2 ); - a = W_shr( a, s_max( qd, 0 ) ); - pm = W_shr( pm, negate( s_min( qd, 0 ) ) ); - Word32 d0 = L_add( a, pm ); - Word32 d1 = L_max( L_sub( a, pm ), 0 ); + ea = L_shr( ea, s_max( qd, 0 ) ); + pm = L_shr( pm, negate( s_min( qd, 0 ) ) ); + Word32 d0 = L_add( ea, pm ); + Word32 d1 = L_max( L_sub( ea, pm ), 0 ); // check( d0, qm, D_fx[0], *q_D, 1 << 16 ); // check( d1, qm, D_fx[1], *q_D, 1 << 16 ); -- GitLab From 236a187258b5cbf78dfcf68e5e1d5a5f35c717af Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 7 Nov 2025 10:34:34 +0000 Subject: [PATCH 023/750] Optimize eig2x2_fx part 2. --- .../ivas_dirac_dec_binaural_functions_fx.c | 94 +++++++++++++++++-- 1 file changed, 85 insertions(+), 9 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index b79a62c26..5f939ae4c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3518,7 +3518,7 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( return; } -#if 0 +#if 1 static void check( Word32 computed_fx, Word16 computed_q, @@ -3557,7 +3557,7 @@ static void eig2x2_fx( Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/ Word16 *q_D ) { -#if 0 + // #if 0 Word16 chA, chB, ch; Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx; Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im; @@ -3698,7 +3698,8 @@ static void eig2x2_fx( *q_D = sub( q_tmp2, 1 ); move16(); } -#else +// #else +#if 0 Word16 chA, chB, ch; FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -3710,6 +3711,7 @@ static void eig2x2_fx( move32(); } } +#endif // =================================================================================================== /*crossSquare_fx = (c_re * c_re) + (c_im * c_im) @@ -3747,13 +3749,16 @@ static void eig2x2_fx( move16(); } +#if 0 Word32 crossSquare_fx = (Word32) ( cs >> 32 ); // FIXME Word16 q_crossSquare = 2 * q_C + lshift - 32; // FIXME +#endif + Word16 csq = 2 * q_C + lshift; // FIXME // a = max(0, (e1 - e2)^2 + 4 * crossSquare_fx) qm = s_min( q1, q2 ); qd = sub( q1, q2 ); - Word64 a = W_max( W_add( W_shr( es2, s_max( qd, 0 ) ), W_shr( cs, negate( s_min( qd, 0 ) ) ) ), 0 ); + Word64 a = W_max( W_add( W_shr( es2, s_max( qd, 0 ) ), W_shl( cs, s_min( qd, 0 ) ) ), 0 ); // pm = 0.5f * sqrtf(a) // a = 0.5f * ( E1 + E2 ); @@ -3762,29 +3767,32 @@ static void eig2x2_fx( Word16 e = sub( sub( 63, lshift ), qm ); pm = L_shr( Sqrt32( pm, &e ), 1 ); q2 = sub( 31, e ); - // check( pm, q2, pm_fx, q_tmp2, 1 << 16 ); + check( pm, q2, pm_fx, q_tmp2, 1 << 16 ); Word32 ea = L_add( E1_fx, E2_fx ); lshift = sub( norm_l( ea ), 1 ); ea = L_shl( ea, lshift ); q1 = add( add( q_E, 1 ), lshift ); - // check( ea, q1, add_fx, q_tmp1, 1 << 16 ); + check( ea, q1, add_fx, q_tmp1, 1 << 16 ); +#if 0 Word32 add_fx = ea; // FIXME Word16 q_tmp1 = q1; // FIXME Word32 pm_fx = pm; // FIXME Word16 q_tmp2 = q2; // FIXME +#endif // D[0] = add + pm; // D[1] = max( 0.0f, add - pm ); qm = s_min( q1, q2 ); qd = sub( q1, q2 ); ea = L_shr( ea, s_max( qd, 0 ) ); - pm = L_shr( pm, negate( s_min( qd, 0 ) ) ); + pm = L_shl( pm, s_min( qd, 0 ) ); Word32 d0 = L_add( ea, pm ); Word32 d1 = L_max( L_sub( ea, pm ), 0 ); - // check( d0, qm, D_fx[0], *q_D, 1 << 16 ); - // check( d1, qm, D_fx[1], *q_D, 1 << 16 ); + check( d0, qm, D_fx[0], *q_D, 1 << 16 ); + check( d1, qm, D_fx[1], *q_D, 1 << 16 ); +#if 0 D_fx[0] = d0; // FIXME D_fx[1] = d1; // FIXME *q_D = qm; // FIXME @@ -3804,6 +3812,8 @@ static void eig2x2_fx( e2 = L_shl( E2_fx, exp ); // FIXME q_e = add( q_E, exp ); // FIXME #endif + // #endif + /* Numeric case, when input is practically zeros */ // IF( D_fx[0] < EPSILON_FX ) @@ -3875,6 +3885,64 @@ static void eig2x2_fx( move16(); } + // D[ch] - E1 + // D[ch] - E2 + + Word32 arg0, arg1, arg2; + Word32 z1, z2, ad, s; + + qm = s_min( *q_D, q_e ); + qd = sub( *q_D, q_e ); + + arg0 = L_shr( D_fx[ch], s_max( qd, 0 ) ); + arg1 = L_shl( e1, s_min( qd, 0 ) ); + arg2 = L_shl( e2, s_min( qd, 0 ) ); + z1 = L_sub( arg0, arg1 ); + z2 = L_sub( arg0, arg2 ); + + check( z1, qm, tmp1, q_tmp1, 1 << 1 ); + check( z2, qm, tmp2, q_tmp1, 1 << 1 ); + + ad = L_sub( L_abs( z2 ), L_abs( z1 ) ); + if ( ad > 0 ) + { + s = z2; + } + if ( ad <= 0 ) + { + s = z1; + } + + Word64 epsm = ( (Word64) 1180591621 ) << 32; // FIXME + Word16 epsq = 63 - epsilon_exp; // FIXME + + Word16 sq = qm; + Word16 s2q = L_shl( sq, 1 ); + qm = s_min( s2q, csq ); + qm = s_min( qm, epsq ); + + Word64 nval64m; + Word64 nval32m; + Word16 nvalq, nvale; + nval64m = W_shr( W_mult0_32_32( s, s ), L_sub( s2q, qm ) ); + nval64m = W_add( nval64m, W_shr( cs, L_sub( csq, qm ) ) ); + nval64m = W_add( nval64m, W_shr( epsm, L_sub( epsq, qm ) ) ); + lshift = W_norm( nval64m ); + nval64m = W_shl( nval64m, lshift ); + nvalq = add( qm, lshift ); + + Word32 test0m = W_extract_h( nval64m ); // FIXME + Word32 test0q = nvalq; // FIXME + + nval32m = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m ), &nvale ); + nvale = sub( nvale, sub( Q30, nvalq - 32 ) ); + nval32m = Sqrt32( nval32m, &nvale ); + nvalq = sub( 31, nvale ); + + Word32 test1m = nval32m; // FIXME + Word32 test1q = nvalq; // FIXME + + IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) ) { s_fx = tmp2; @@ -3888,11 +3956,15 @@ static void eig2x2_fx( tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + check( test0m, test0q, tmp3, 31 - exp_tmp3, 1 << 18 ); // TODO: remove + tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); + check( test1m, test1q, normVal_fx, q_tmp2, 1 << 18 ); // TODO: remove + q_diff = sub( q_c, q_tmp1 ); IF( q_diff > 0 ) { @@ -3959,11 +4031,15 @@ static void eig2x2_fx( tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + check( test0m, test0q, tmp3, 31 - exp_tmp3, 1 << 18 ); // TODO: remove + tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); + check( test1m, test1q, normVal_fx, q_tmp2, 1 << 18 ); // TODO: remove + q_diff = sub( q_c, q_tmp1 ); IF( q_diff > 0 ) { -- GitLab From c551423d14fc113e75e55bcb92f4c6289747a480 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 10 Nov 2025 10:42:08 +0000 Subject: [PATCH 024/750] Address Thomas Dettbarn's comments. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 416a8a71c..351f59453 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4035,16 +4035,16 @@ static void matrixTransp1Mul_fx( tmp64 = W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ); tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bre_fx[1][chB] ); tmp64 = W_mac_32_32( tmp64, Aim_fx[0][chA], Bim_fx[0][chB] ); - tmp_outRe_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bim_fx[1][chB] ); + tmp_outRe_fx[chA][chB] = W_mac_32_32( tmp64, Aim_fx[1][chA], Bim_fx[1][chB] ); move64(); - common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); + common_lsh = s_min( common_lsh, W_norm( tmp_outRe_fx[chA][chB] ) ); tmp64 = W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ); tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bre_fx[1][chB] ); tmp64 = W_mac_32_32( W_neg( tmp64 ), Are_fx[0][chA], Bim_fx[0][chB] ); - tmp_outIm_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); + tmp_outIm_fx[chA][chB] = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); move64(); - common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); + common_lsh = s_min( common_lsh, W_norm( tmp_outIm_fx[chA][chB] ) ); } } FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) -- GitLab From 6fadb2b497f0910a4dfc72b8bfca1d1c9c32ab8f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 10 Nov 2025 10:53:10 +0000 Subject: [PATCH 025/750] Address Thomas Dettbarn's comments. --- .../ivas_dirac_dec_binaural_functions_fx.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 19c12a3ec..7a7ad9292 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2300,7 +2300,8 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( #ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); matrixTransp2Mul_fx( - tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, + tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, + Mre_fx, Mim_fx, &q_M, resultMtxRe_fx, resultMtxIm_fx, &q_res ); #else matrixTransp2Mul_fx( @@ -3964,7 +3965,7 @@ static void matrixScale_fx( Word16 *q_A ) { Word16 shift; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); scale_sig32( Are_fx[0], size, shift ); scale_sig32( Aim_fx[0], size, shift ); @@ -3986,7 +3987,7 @@ static void matrixMul_fx( { #ifdef OPT_2182_MATRIX_SCALE_OPS Word16 chA, chB; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; #else Word16 chA, chB; Word16 min_q_shift1, min_q_shift2; @@ -4874,8 +4875,10 @@ static void formulate2x2MixingMatrix_fx( } #ifdef OPT_2182_MATRIX_SCALE_OPS - matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, - Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ + matrixTransp2Mul_fx( + tmpRe_fx, tmpIm_fx, &q_temp, + Ure_fx, Uim_fx, &q_U, + Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ #else matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, 0 /*int Ascale*/, @@ -5019,8 +5022,10 @@ static void formulate2x2MixingMatrix_fx( matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp ); #ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); - matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, - Mre_fx, Mim_fx, q_M ); + matrixTransp2Mul_fx( + tmpRe_fx, tmpIm_fx, &q_temp, + Uxre_fx, Uxim_fx, &q_Ux, + Mre_fx, Mim_fx, q_M ); #else matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, 1 /*int Ascale*/, -- GitLab From 890cd054d1bfd87de7fc961a5762c9d44857f863 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 10 Nov 2025 10:11:42 +0000 Subject: [PATCH 026/750] Optimize eig2x2_fx part 3. --- .../ivas_dirac_dec_binaural_functions_fx.c | 612 +++++++++++++----- 1 file changed, 433 insertions(+), 179 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 5f939ae4c..77b7b67c6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3537,13 +3537,366 @@ static void check( Word32 cf = computed_fx >> +max( qd, 0 ); Word32 ef = expected_fx >> -min( qd, 0 ); Word32 abs_error = abs( cf - ef ); - if ( abs_error >= max_abs_err ) + if ( abs_error > max_abs_err ) { assert( false ); } } #endif +Word32 __pm_fx; +Word16 __pm_q; +Word32 __add_fx; +Word16 __add_q; + +Word32 __as[BINAURAL_CHANNELS]; + +Word32 __s_fx[BINAURAL_CHANNELS]; +Word16 __s_q[BINAURAL_CHANNELS]; + +Word32 __nval_fx[BINAURAL_CHANNELS]; +Word16 __nval_q[BINAURAL_CHANNELS]; + +Word32 __Ure_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +Word32 __Uim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +Word16 __U_q; + +Word32 __D_fx[BINAURAL_CHANNELS]; +Word16 __D_q; + +Word32 __diff_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +Word16 __diff_q; + +static void eig2x2_opt( + const Word32 E1_fx, /*q_E*/ + const Word32 E2_fx, /*q_E*/ + Word16 q_E, + const Word32 Cre_fx, /*q_C*/ + const Word32 Cim_fx, /*q_C*/ + Word16 q_C ) +{ + Word32 s_fx[BINAURAL_CHANNELS]; + Word32 pm_fx, add_fx; + Word32 tmp1, tmp2, e1, e2, c_re, c_im, c0_im, c1_im; + Word64 crossSquare_fx, tmp3, tmp4; + Word16 q_crossSquare, q_min, q_diff, q_tmp1, q_tmp2, exp, q_e, q_c; + Word32 i01, i00, i11, i10; + Word64 eps_fx = ( (Word64) EPSILON_MANT ) << 32; + Word16 eps_q = 63 - EPSILON_EXP; + move32(); + move16(); + + set32_fx( (Word32 *) __Ure_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); + set32_fx( (Word32 *) __Uim_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); + __Ure_fx[0][0] = ONE_IN_Q30; + move32(); + __Ure_fx[1][1] = ONE_IN_Q30; + move32(); + __U_q = Q30; + move16(); + + exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); + c_re = L_shl( Cre_fx, exp ); + c_im = L_shl( Cim_fx, exp ); + q_c = add( q_C, exp ); + + exp = sub( get_min_scalefactor( E1_fx, E2_fx ), 2 ); + e1 = L_shl( E1_fx, exp ); + e2 = L_shl( E2_fx, exp ); + q_e = add( q_E, exp ); + + // crossSquare_fx = (c_re * c_re) + (c_im * c_im) + // a_fx = (e1 + e2) * (e1 + e2) - 4.0f * ((e1 * e2) - crossSquare_fx) = (e1 - e2)^2 + 4 * crossSquare_fx + // pm_fx = 0.5f * sqrtf(max(0.0f, a_fx)) + // add_fx = 0.5f * (e1 + e2) + + tmp1 = L_sub( e1, e2 ); + tmp3 = W_mult_32_32( tmp1, tmp1 ); + q_tmp1 = add( add( q_e, q_e ), 1 ); + if ( !tmp3 ) + { + q_tmp1 = 63; + move16(); + } + + crossSquare_fx = W_mac_32_32( W_mult_32_32( c_re, c_re ), c_im, c_im ); + q_crossSquare = add( add( q_c, q_c ), 1 ); + if ( !crossSquare_fx ) + { + q_crossSquare = 63; + move16(); + } + + tmp4 = crossSquare_fx; + move64(); + q_tmp2 = sub( q_crossSquare, 2 ); + if ( !tmp4 ) + { + q_tmp2 = 63; + move16(); + } + + q_diff = sub( q_tmp1, q_tmp2 ); + q_tmp1 = s_min( q_tmp1, q_tmp2 ); + if ( q_diff > 0 ) + { + tmp3 = W_shr( tmp3, q_diff ); + } + if ( q_diff < 0 ) + { + tmp4 = W_shl( tmp4, q_diff ); + } + tmp3 = W_add( tmp3, tmp4 ); + q_diff = W_norm( tmp3 ); + tmp3 = W_shl( tmp3, q_diff ); + q_tmp1 = add( q_tmp1, q_diff ); + + // pm_fx = 0.5f * sqrtf(max(0.0f, a_fx)) + exp = sub( 63, q_tmp1 ); + pm_fx = Sqrt32( L_max( 0, W_extract_h( tmp3 ) ), &exp ); + pm_fx = L_shr( pm_fx, 1 ); + q_tmp2 = sub( 31, exp ); + + // add_fx = 0.5 * (e1 + e2) + add_fx = L_shr( L_add( e1, e2 ), 1 ); + q_tmp1 = q_e; + move16(); + + __pm_fx = pm_fx; // FIXME + __pm_q = q_tmp2; // FIXME + __add_fx = add_fx; // FIXME + __add_q = q_tmp1; // FIXME + + // D[0] = add + pm; + // D[1] = max( 0.0f, add - pm ); + + q_diff = sub( q_tmp1, q_tmp2 ); + + tmp1 = add_fx; + move32(); + if ( q_diff > 0 ) + { + tmp1 = L_shr( tmp1, q_diff ); + } + + tmp2 = pm_fx; + move32(); + if ( q_diff < 0 ) + { + tmp2 = L_shl( tmp2, q_diff ); + } + + __D_fx[0] = L_add( tmp1, tmp2 ); + move32(); + __D_fx[1] = L_max( L_sub( tmp1, tmp2 ), 0 ); + move32(); + __D_q = s_min( q_tmp1, q_tmp2 ); + move32(); + + // Numeric case, when input is practically zeros + // if ( __D_fx[0] < EPSILON_FX ) + + if ( LT_32( L_shl_sat( __D_fx[0], sub( 31 - EPSILON_EXP, __D_q ) ), EPSILON_MANT ) ) + { + return; + } + + // Numeric case, when input is near an identity matrix with a gain + tmp1 = Mpy_32_32( INV_1000_Q31, add_fx ); + if ( q_diff > 0 ) + { + tmp1 = L_shr( tmp1, q_diff ); + } + + if ( LT_32( tmp2, tmp1 ) ) + { + return; + } + + // Eigenvectors + + q_diff = sub( q_e, __D_q ); + q_tmp1 = s_min( q_e, __D_q ); + + tmp1 = __D_fx[0]; + move32(); + if ( q_diff > 0 ) + { + tmp1 = L_shr( tmp1, q_diff ); + } + + tmp2 = __D_fx[1]; + move32(); + if ( q_diff > 0 ) + { + tmp2 = L_shr( tmp2, q_diff ); + } + + if ( q_diff < 0 ) + { + e1 = L_shl( e1, q_diff ); + } + + if ( q_diff < 0 ) + { + e2 = L_shl( e2, q_diff ); + } + + s_fx[0] = L_sub( tmp1, e1 ); // __D_fx[0] - e1 + tmp1 = L_sub( tmp1, e2 ); // __D_fx[0] - e2 + s_fx[1] = L_sub( tmp2, e1 ); // __D_fx[1] - e1 + tmp2 = L_sub( tmp2, e2 ); // __D_fx[1] - e2 + + __diff_fx[0][0] = s_fx[0]; + __diff_fx[0][1] = tmp1; + __diff_fx[1][0] = s_fx[1]; + __diff_fx[1][1] = tmp2; + + __diff_q = q_tmp1; + + i01 = GT_32( L_abs( tmp1 ), L_abs( s_fx[0] ) ); // fabsf( __D_fx[0] - e2 ) > fabsf( __D_fx[0] - e1 ) + i11 = GT_32( L_abs( tmp2 ), L_abs( s_fx[1] ) ); // fabsf( __D_fx[1] - e2 ) > fabsf( __D_fx[1] - e1 ) + + __as[0] = i01; + __as[1] = i11; + + if ( i01 ) + { + s_fx[0] = tmp1; + move32(); + } + + if ( i11 ) + { + s_fx[1] = tmp2; + move32(); + } + + __s_fx[0] = s_fx[0]; + __s_fx[1] = s_fx[1]; + __s_q[0] = q_tmp1; + __s_q[1] = q_tmp1; + + // normVal = sqrtf( 1.0f / ( 1e-12f + crossSquare + s * s ) ); + + Word32 nvalm[BINAURAL_CHANNELS]; + Word16 nvalq[BINAURAL_CHANNELS]; + + q_tmp2 = L_shl( q_tmp1, 1 ); + q_min = s_min( q_tmp2, q_crossSquare ); + q_min = s_min( q_min, eps_q ); + + Word64 nval64m[BINAURAL_CHANNELS]; + + q_diff = L_sub( q_tmp2, q_min ); + nval64m[0] = W_shr( W_mult0_32_32( s_fx[0], s_fx[0] ), q_diff ); + nval64m[1] = W_shr( W_mult0_32_32( s_fx[1], s_fx[1] ), q_diff ); + + q_diff = L_sub( q_crossSquare, q_min ); + crossSquare_fx = W_shr( crossSquare_fx, q_diff ); + nval64m[0] = W_add( nval64m[0], crossSquare_fx ); + nval64m[1] = W_add( nval64m[1], crossSquare_fx ); + + q_diff = L_sub( eps_q, q_min ); + eps_fx = W_shr( eps_fx, q_diff ); + nval64m[0] = W_add( nval64m[0], eps_fx ); + nval64m[1] = W_add( nval64m[1], eps_fx ); + + q_diff = W_norm( nval64m[0] ); + nval64m[0] = W_shl( nval64m[0], q_diff ); + nvalq[0] = add( q_min, q_diff ); + + q_diff = W_norm( nval64m[1] ); + nval64m[1] = W_shl( nval64m[1], q_diff ); + nvalq[1] = add( q_min, q_diff ); + + nvalm[0] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ), &exp ); + exp = sub( exp, sub( 62, nvalq[0] ) ); + nvalm[0] = Sqrt32( nvalm[0], &exp ); + nvalq[0] = sub( 31, exp ); + + nvalm[1] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ), &exp ); + exp = sub( exp, sub( 62, nvalq[1] ) ); + nvalm[1] = Sqrt32( nvalm[1], &exp ); + nvalq[1] = sub( 31, exp ); + + __nval_fx[0] = nvalm[0]; + __nval_q[0] = nvalq[0]; + __nval_fx[1] = nvalm[1]; + __nval_q[1] = nvalq[1]; + + q_diff = sub( q_c, q_tmp1 ); + q_tmp1 = s_min( q_tmp1, q_c ); + + if ( q_diff > 0 ) + { + c_re = L_shr( c_re, q_diff ); + } + + if ( q_diff > 0 ) + { + c_im = L_shr( c_im, q_diff ); + } + + if ( q_diff < 0 ) + { + s_fx[0] = L_shl( s_fx[0], q_diff ); + } + + if ( q_diff < 0 ) + { + s_fx[1] = L_shl( s_fx[1], q_diff ); + } + + q_diff = sub( nvalq[0], nvalq[1] ); + q_tmp2 = s_min( nvalq[0], nvalq[1] ); + + if ( q_diff > 0 ) + { + nvalm[0] = L_shr( nvalm[0], q_diff ); + } + + if ( q_diff < 0 ) + { + nvalm[1] = L_shl( nvalm[1], q_diff ); + } + + __U_q = sub( add( q_tmp1, q_tmp2 ), 31 ); + + i00 = L_sub( 1, i01 ); + i10 = L_sub( 1, i11 ); + + c0_im = c_im; + move32(); + if ( i00 > 0 ) + { + c0_im = L_negate( c0_im ); + } + + c1_im = c_im; + move32(); + if ( i10 > 0 ) + { + c1_im = L_negate( c1_im ); + } + + __Ure_fx[i00][0] = Mpy_32_32( s_fx[0], nvalm[0] ); + move32(); + __Ure_fx[i01][0] = Mpy_32_32( c_re, nvalm[0] ); + move32(); + __Uim_fx[i01][0] = Mpy_32_32( c0_im, nvalm[0] ); + move32(); + + __Ure_fx[i10][1] = Mpy_32_32( s_fx[1], nvalm[1] ); + move32(); + __Ure_fx[i11][1] = Mpy_32_32( c_re, nvalm[1] ); + move32(); + __Uim_fx[i11][1] = Mpy_32_32( c1_im, nvalm[1] ); + move32(); + + return; +} + static void eig2x2_fx( const Word32 E1_fx, /*q_E*/ const Word32 E2_fx, /*q_E*/ @@ -3557,7 +3910,23 @@ static void eig2x2_fx( Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/ Word16 *q_D ) { - // #if 0 +#if 0 + eig2x2_opt( E1_fx, E2_fx, q_E, Cre_fx, Cim_fx, q_C ); + Ure_fx[0][0] = __Ure_fx[0][0]; + Ure_fx[0][1] = __Ure_fx[0][1]; + Ure_fx[1][0] = __Ure_fx[1][0]; + Ure_fx[1][1] = __Ure_fx[1][1]; + Uim_fx[0][0] = __Uim_fx[0][0]; + Uim_fx[0][1] = __Uim_fx[0][1]; + Uim_fx[1][0] = __Uim_fx[1][0]; + Uim_fx[1][1] = __Uim_fx[1][1]; + *q_U = __U_q; + D_fx[0] = __D_fx[0]; + D_fx[1] = __D_fx[1]; + *q_D = __D_q; +#else + eig2x2_opt( E1_fx, E2_fx, q_E, Cre_fx, Cim_fx, q_C ); + Word16 chA, chB, ch; Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx; Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im; @@ -3680,6 +4049,9 @@ static void eig2x2_fx( q_tmp1 = q_e; move16(); + check( __pm_fx, __pm_q, pm_fx, q_tmp2, 1 << 26 ); + check( __add_fx, __add_q, add_fx, q_tmp1, 1 << 26 ); + IF( LT_16( q_tmp1, q_tmp2 ) ) { D_fx[0] = L_add( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ); @@ -3698,121 +4070,9 @@ static void eig2x2_fx( *q_D = sub( q_tmp2, 1 ); move16(); } -// #else -#if 0 - Word16 chA, chB, ch; - FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) - { - FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) - { - Ure_fx[chA][chB] = 0; - move32(); - Uim_fx[chA][chB] = 0; - move32(); - } - } -#endif - // =================================================================================================== - /*crossSquare_fx = (c_re * c_re) + (c_im * c_im) - a_fx = (e1 + e2) * (e1 + e2) - 4.0f * ((e1 * e2) - crossSquare_fx) = (e1 - e2)^2 + 4 * crossSquare_fx - pm_fx = 0.5f * sqrtf(max(0.0f, a_fx)) - add_fx = 0.5f * (e1 + e2)*/ - - Word16 q1, q2, qm, qd, lshift; - - // (e1 - e2)^2 -> Q: 2 * q_E - q1 = shl( q_E, 1 ); - // 4 * ((c_re * c_re) + (c_im * c_im)) -> Q: 2 * q_C - 2 - q2 = sub( shl( q_C, 1 ), 2 ); - - // (e1 - e2)^2 - Word32 es = L_sub( E1_fx, E2_fx ); - Word64 es2 = W_mult0_32_32( es, es ); - lshift = sub( W_norm( es2 ), 1 ); - es2 = W_shl( es2, lshift ); - q1 = add( q1, lshift ); - if ( !es2 ) - { - q1 = 63; - move16(); - } - - // 4 * ((c_re * c_re) + (c_im * c_im)) - Word64 cs = W_add( W_mult0_32_32( Cre_fx, Cre_fx ), W_mult0_32_32( Cim_fx, Cim_fx ) ); // 2*q_C-2 - lshift = sub( W_norm( cs ), 1 ); - cs = W_shl( cs, lshift ); - q2 = add( q2, lshift ); - if ( !cs ) - { - q2 = 63; - move16(); - } - -#if 0 - Word32 crossSquare_fx = (Word32) ( cs >> 32 ); // FIXME - Word16 q_crossSquare = 2 * q_C + lshift - 32; // FIXME -#endif - Word16 csq = 2 * q_C + lshift; // FIXME - - // a = max(0, (e1 - e2)^2 + 4 * crossSquare_fx) - qm = s_min( q1, q2 ); - qd = sub( q1, q2 ); - Word64 a = W_max( W_add( W_shr( es2, s_max( qd, 0 ) ), W_shl( cs, s_min( qd, 0 ) ) ), 0 ); - - // pm = 0.5f * sqrtf(a) - // a = 0.5f * ( E1 + E2 ); - lshift = W_norm( a ); - Word32 pm = W_extract_h( W_shl( a, lshift ) ); - Word16 e = sub( sub( 63, lshift ), qm ); - pm = L_shr( Sqrt32( pm, &e ), 1 ); - q2 = sub( 31, e ); - check( pm, q2, pm_fx, q_tmp2, 1 << 16 ); - Word32 ea = L_add( E1_fx, E2_fx ); - lshift = sub( norm_l( ea ), 1 ); - ea = L_shl( ea, lshift ); - q1 = add( add( q_E, 1 ), lshift ); - check( ea, q1, add_fx, q_tmp1, 1 << 16 ); - -#if 0 - Word32 add_fx = ea; // FIXME - Word16 q_tmp1 = q1; // FIXME - Word32 pm_fx = pm; // FIXME - Word16 q_tmp2 = q2; // FIXME -#endif - - // D[0] = add + pm; - // D[1] = max( 0.0f, add - pm ); - qm = s_min( q1, q2 ); - qd = sub( q1, q2 ); - ea = L_shr( ea, s_max( qd, 0 ) ); - pm = L_shl( pm, s_min( qd, 0 ) ); - Word32 d0 = L_add( ea, pm ); - Word32 d1 = L_max( L_sub( ea, pm ), 0 ); - check( d0, qm, D_fx[0], *q_D, 1 << 16 ); - check( d1, qm, D_fx[1], *q_D, 1 << 16 ); - -#if 0 - D_fx[0] = d0; // FIXME - D_fx[1] = d1; // FIXME - *q_D = qm; // FIXME - - Word32 tmp1, tmp2, tmp3, e1, e2, s_fx, normVal_fx, c_re, c_im; // FIXME - Word16 q_U_1, q_U_2, q_c, q_e, exp, exp_tmp3; // FIXME - Word32 epsilon_mant = 1180591621; // FIXME - Word16 epsilon_exp = -39; // FIXME - - exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); // FIXME - c_re = L_shl( Cre_fx, exp ); // FIXME - c_im = L_shl( Cim_fx, exp ); // FIXME - q_c = add( q_C, exp ); // FIXME - - exp = sub( get_min_scalefactor( E1_fx, E2_fx ), 2 ); // FIXME - e1 = L_shl( E1_fx, exp ); // FIXME - e2 = L_shl( E2_fx, exp ); // FIXME - q_e = add( q_E, exp ); // FIXME -#endif - // #endif + check( __D_fx[0], __D_q, D_fx[0], *q_D, 1 << 26 ); + check( __D_fx[1], __D_q, D_fx[1], *q_D, 1 << 26 ); /* Numeric case, when input is practically zeros */ // IF( D_fx[0] < EPSILON_FX ) @@ -3826,6 +4086,15 @@ static void eig2x2_fx( *q_U = Q31; move16(); + for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) + { + for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) + { + check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 2 ); + check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 2 ); + } + } + return; } @@ -3843,6 +4112,15 @@ static void eig2x2_fx( *q_U = Q30; move16(); + for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) + { + for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) + { + check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 2 ); + check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 2 ); + } + } + return; } } @@ -3857,6 +4135,15 @@ static void eig2x2_fx( *q_U = Q30; move16(); + for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) + { + for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) + { + check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 2 ); + check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 2 ); + } + } + return; } } @@ -3885,68 +4172,18 @@ static void eig2x2_fx( move16(); } - // D[ch] - E1 - // D[ch] - E2 - - Word32 arg0, arg1, arg2; - Word32 z1, z2, ad, s; - - qm = s_min( *q_D, q_e ); - qd = sub( *q_D, q_e ); - - arg0 = L_shr( D_fx[ch], s_max( qd, 0 ) ); - arg1 = L_shl( e1, s_min( qd, 0 ) ); - arg2 = L_shl( e2, s_min( qd, 0 ) ); - z1 = L_sub( arg0, arg1 ); - z2 = L_sub( arg0, arg2 ); - - check( z1, qm, tmp1, q_tmp1, 1 << 1 ); - check( z2, qm, tmp2, q_tmp1, 1 << 1 ); - - ad = L_sub( L_abs( z2 ), L_abs( z1 ) ); - if ( ad > 0 ) - { - s = z2; - } - if ( ad <= 0 ) - { - s = z1; - } - - Word64 epsm = ( (Word64) 1180591621 ) << 32; // FIXME - Word16 epsq = 63 - epsilon_exp; // FIXME - - Word16 sq = qm; - Word16 s2q = L_shl( sq, 1 ); - qm = s_min( s2q, csq ); - qm = s_min( qm, epsq ); - - Word64 nval64m; - Word64 nval32m; - Word16 nvalq, nvale; - nval64m = W_shr( W_mult0_32_32( s, s ), L_sub( s2q, qm ) ); - nval64m = W_add( nval64m, W_shr( cs, L_sub( csq, qm ) ) ); - nval64m = W_add( nval64m, W_shr( epsm, L_sub( epsq, qm ) ) ); - lshift = W_norm( nval64m ); - nval64m = W_shl( nval64m, lshift ); - nvalq = add( qm, lshift ); - - Word32 test0m = W_extract_h( nval64m ); // FIXME - Word32 test0q = nvalq; // FIXME - - nval32m = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m ), &nvale ); - nvale = sub( nvale, sub( Q30, nvalq - 32 ) ); - nval32m = Sqrt32( nval32m, &nvale ); - nvalq = sub( 31, nvale ); - - Word32 test1m = nval32m; // FIXME - Word32 test1q = nvalq; // FIXME - + check( __diff_fx[ch][0], __diff_q, tmp1, q_tmp1, 1 << 26 ); + check( __diff_fx[ch][1], __diff_q, tmp2, q_tmp1, 1 << 26 ); IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) ) { + check( __as[ch], 0, 1, 0, 0 ); + s_fx = tmp2; move32(); + + check( __s_fx[ch], __s_q[ch], s_fx, q_tmp1, 1 << 26 ); + exp = sub( norm_l( s_fx ), 1 ); tmp2 = Mpy_32_32( s_fx, s_fx ); q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); @@ -3956,14 +4193,12 @@ static void eig2x2_fx( tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - check( test0m, test0q, tmp3, 31 - exp_tmp3, 1 << 18 ); // TODO: remove - tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); - check( test1m, test1q, normVal_fx, q_tmp2, 1 << 18 ); // TODO: remove + check( __nval_fx[ch], __nval_q[ch], normVal_fx, q_tmp2, 1 << 26 ); q_diff = sub( q_c, q_tmp1 ); IF( q_diff > 0 ) @@ -3988,6 +4223,10 @@ static void eig2x2_fx( move32(); q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); + check( __Ure_fx[0][ch], __U_q, Ure_fx[0][ch], q_U_1, 1 << 26 ); + check( __Ure_fx[1][ch], __U_q, Ure_fx[1][ch], q_U_1, 1 << 26 ); + check( __Uim_fx[1][ch], __U_q, Uim_fx[1][ch], q_U_1, 1 << 26 ); + IF( q_U_2 != 0 ) { q_diff = sub( q_U_2, q_U_1 ); @@ -4019,9 +4258,13 @@ static void eig2x2_fx( } ELSE { + check( __as[ch], 0, 0, 0, 0 ); + s_fx = tmp1; move32(); + check( __s_fx[ch], __s_q[ch], s_fx, q_tmp1, 1 << 26 ); + exp = sub( norm_l( s_fx ), 1 ); tmp2 = Mpy_32_32( s_fx, s_fx ); q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); @@ -4031,14 +4274,12 @@ static void eig2x2_fx( tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - check( test0m, test0q, tmp3, 31 - exp_tmp3, 1 << 18 ); // TODO: remove - tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); - check( test1m, test1q, normVal_fx, q_tmp2, 1 << 18 ); // TODO: remove + check( __nval_fx[ch], __nval_q[ch], normVal_fx, q_tmp2, 1 << 26 ); q_diff = sub( q_c, q_tmp1 ); IF( q_diff > 0 ) @@ -4063,6 +4304,10 @@ static void eig2x2_fx( move32(); q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); + check( __Ure_fx[1][ch], __U_q, Ure_fx[1][ch], q_U_2, 1 << 26 ); + check( __Ure_fx[0][ch], __U_q, Ure_fx[0][ch], q_U_2, 1 << 26 ); + check( __Uim_fx[0][ch], __U_q, Uim_fx[0][ch], q_U_2, 1 << 26 ); + IF( q_U_1 != 0 ) { q_diff = sub( q_U_2, q_U_1 ); @@ -4106,6 +4351,15 @@ static void eig2x2_fx( move16(); } + for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) + { + for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) + { + check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 26 ); + check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 26 ); + } + } +#endif return; } -- GitLab From 76fc3d302e735243d59e521717db453dba125d41 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 12 Nov 2025 09:36:34 +0000 Subject: [PATCH 027/750] Finalize optimization. --- lib_basop/enh64.h | 102 -------- lib_com/options.h | 6 + lib_debug/wmc_auto.c | 2 +- lib_debug/wmc_auto.h | 2 - .../ivas_dirac_dec_binaural_functions_fx.c | 237 +++--------------- 5 files changed, 42 insertions(+), 307 deletions(-) diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index ab21d5b0c..c3896bb0d 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -21,108 +21,6 @@ * *****************************************************************************/ #ifdef ENH_64_BIT_OPERATOR - - -/*______________________________________________________________________________ -| | -| Function Name : W_min | -| | -| Purpose : | -| | -| Compares L64_var1 and L64_var2 and returns the minimum value. | -| | -| Complexity weight : 1 | -| | -| Inputs : | -| | -| L64_var1 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | -| | -| L64_var2 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | -| | -| Outputs : | -| | -| none | -| | -| Return Value : | -| | -| L64_var_out | -| 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | -|______________________________________________________________________________| -*/ -static __inline Word64 W_min( Word64 L64_var1, Word64 L64_var2 ) -{ - Word64 L64_var_out; - - if ( L64_var1 <= L64_var2 ) - { - L64_var_out = L64_var1; - } - else - { - L64_var_out = L64_var2; - } - -#ifdef WMOPS - multiCounter[currCounter].W_min++; -#endif /* ifdef WMOPS */ - - return ( L64_var_out ); -} - - -/*______________________________________________________________________________ -| | -| Function Name : W_max | -| | -| Purpose : | -| | -| Compares L64_var1 and L64_var2 and returns the maximum value. | -| | -| Complexity weight : 1 | -| | -| Inputs : | -| | -| L64_var1 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | -| | -| L64_var2 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var2 <= 0x7fffffff ffffffffLL. | -| | -| Outputs : | -| | -| none | -| | -| Return Value : | -| | -| L64_var_out | -| 64 bit long signed integer (Word64) whose value falls in the | -| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | -|______________________________________________________________________________| -*/ -static __inline Word64 W_max( Word64 L64_var1, Word64 L64_var2 ) -{ - Word64 L64_var_out; - - if ( L64_var1 >= L64_var2 ) - { - L64_var_out = L64_var1; - } - else - { - L64_var_out = L64_var2; - } - -#ifdef WMOPS - multiCounter[currCounter].W_max++; -#endif /* ifdef WMOPS */ - - return ( L64_var_out ); -} - - Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_shl( Word64 L64_var1, Word16 var2 ); diff --git a/lib_com/options.h b/lib_com/options.h index 10ea208a2..eb655ce24 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -159,4 +159,10 @@ /* #################### End BASOP porting switches ############################ */ +/* #################### Start BASOP optimization switches ############################ */ + +#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ + +/* #################### End BASOP optimization switches ############################ */ + #endif diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 9d4d573f0..5afd9de16 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -133,7 +133,7 @@ static BASIC_OP op_weight = { #ifdef ENH_64_BIT_OPERATOR /* Weights of new 64 bit basops */ , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 6dff36f50..64e2c751a 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -877,8 +877,6 @@ typedef struct /* New 64 bit basops */ #ifdef ENH_64_BIT_OPERATOR unsigned int move64; /* Complexity Weight of 1 */ - unsigned int W_min; /* Complexity Weight of 1 */ - unsigned int W_max; /* Complexity Weight of 1 */ unsigned int W_add_nosat; /* Complexity Weight of 1 */ unsigned int W_sub_nosat; /* Complexity Weight of 1 */ unsigned int W_shl; /* Complexity Weight of 1 */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 77b7b67c6..6bbb57349 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3518,63 +3518,20 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( return; } -#if 1 -static void check( - Word32 computed_fx, - Word16 computed_q, - Word32 expected_fx, - Word16 expected_q, - Word32 max_abs_err ); - -static void check( - Word32 computed_fx, - Word16 computed_q, - Word32 expected_fx, - Word16 expected_q, - Word32 max_abs_err ) -{ - Word16 qd = computed_q - expected_q; - Word32 cf = computed_fx >> +max( qd, 0 ); - Word32 ef = expected_fx >> -min( qd, 0 ); - Word32 abs_error = abs( cf - ef ); - if ( abs_error > max_abs_err ) - { - assert( false ); - } -} -#endif - -Word32 __pm_fx; -Word16 __pm_q; -Word32 __add_fx; -Word16 __add_q; - -Word32 __as[BINAURAL_CHANNELS]; - -Word32 __s_fx[BINAURAL_CHANNELS]; -Word16 __s_q[BINAURAL_CHANNELS]; - -Word32 __nval_fx[BINAURAL_CHANNELS]; -Word16 __nval_q[BINAURAL_CHANNELS]; - -Word32 __Ure_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -Word32 __Uim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -Word16 __U_q; - -Word32 __D_fx[BINAURAL_CHANNELS]; -Word16 __D_q; - -Word32 __diff_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -Word16 __diff_q; - -static void eig2x2_opt( +static void eig2x2_fx( const Word32 E1_fx, /*q_E*/ const Word32 E2_fx, /*q_E*/ Word16 q_E, const Word32 Cre_fx, /*q_C*/ const Word32 Cim_fx, /*q_C*/ - Word16 q_C ) + Word16 q_C, + Word32 Ure_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_U*/ + Word32 Uim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_U*/ + Word16 *q_U, + Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/ + Word16 *q_D ) { +#ifdef NONBE_OPT_2193_EIG2X2 Word32 s_fx[BINAURAL_CHANNELS]; Word32 pm_fx, add_fx; Word32 tmp1, tmp2, e1, e2, c_re, c_im, c0_im, c1_im; @@ -3586,13 +3543,13 @@ static void eig2x2_opt( move32(); move16(); - set32_fx( (Word32 *) __Ure_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); - set32_fx( (Word32 *) __Uim_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); - __Ure_fx[0][0] = ONE_IN_Q30; + set32_fx( (Word32 *) Ure_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); + set32_fx( (Word32 *) Uim_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); + Ure_fx[0][0] = ONE_IN_Q30; move32(); - __Ure_fx[1][1] = ONE_IN_Q30; + Ure_fx[1][1] = ONE_IN_Q30; move32(); - __U_q = Q30; + *q_U = Q30; move16(); exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); @@ -3662,11 +3619,6 @@ static void eig2x2_opt( q_tmp1 = q_e; move16(); - __pm_fx = pm_fx; // FIXME - __pm_q = q_tmp2; // FIXME - __add_fx = add_fx; // FIXME - __add_q = q_tmp1; // FIXME - // D[0] = add + pm; // D[1] = max( 0.0f, add - pm ); @@ -3686,17 +3638,17 @@ static void eig2x2_opt( tmp2 = L_shl( tmp2, q_diff ); } - __D_fx[0] = L_add( tmp1, tmp2 ); + D_fx[0] = L_add( tmp1, tmp2 ); move32(); - __D_fx[1] = L_max( L_sub( tmp1, tmp2 ), 0 ); + D_fx[1] = L_max( L_sub( tmp1, tmp2 ), 0 ); move32(); - __D_q = s_min( q_tmp1, q_tmp2 ); + *q_D = s_min( q_tmp1, q_tmp2 ); move32(); // Numeric case, when input is practically zeros - // if ( __D_fx[0] < EPSILON_FX ) + // if ( D_fx[0] < EPSILON_FX ) - if ( LT_32( L_shl_sat( __D_fx[0], sub( 31 - EPSILON_EXP, __D_q ) ), EPSILON_MANT ) ) + if ( LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ) ) { return; } @@ -3715,17 +3667,17 @@ static void eig2x2_opt( // Eigenvectors - q_diff = sub( q_e, __D_q ); - q_tmp1 = s_min( q_e, __D_q ); + q_diff = sub( q_e, *q_D ); + q_tmp1 = s_min( q_e, *q_D ); - tmp1 = __D_fx[0]; + tmp1 = D_fx[0]; move32(); if ( q_diff > 0 ) { tmp1 = L_shr( tmp1, q_diff ); } - tmp2 = __D_fx[1]; + tmp2 = D_fx[1]; move32(); if ( q_diff > 0 ) { @@ -3742,23 +3694,13 @@ static void eig2x2_opt( e2 = L_shl( e2, q_diff ); } - s_fx[0] = L_sub( tmp1, e1 ); // __D_fx[0] - e1 - tmp1 = L_sub( tmp1, e2 ); // __D_fx[0] - e2 - s_fx[1] = L_sub( tmp2, e1 ); // __D_fx[1] - e1 - tmp2 = L_sub( tmp2, e2 ); // __D_fx[1] - e2 - - __diff_fx[0][0] = s_fx[0]; - __diff_fx[0][1] = tmp1; - __diff_fx[1][0] = s_fx[1]; - __diff_fx[1][1] = tmp2; - - __diff_q = q_tmp1; - - i01 = GT_32( L_abs( tmp1 ), L_abs( s_fx[0] ) ); // fabsf( __D_fx[0] - e2 ) > fabsf( __D_fx[0] - e1 ) - i11 = GT_32( L_abs( tmp2 ), L_abs( s_fx[1] ) ); // fabsf( __D_fx[1] - e2 ) > fabsf( __D_fx[1] - e1 ) + s_fx[0] = L_sub( tmp1, e1 ); // D_fx[0] - e1 + tmp1 = L_sub( tmp1, e2 ); // D_fx[0] - e2 + s_fx[1] = L_sub( tmp2, e1 ); // D_fx[1] - e1 + tmp2 = L_sub( tmp2, e2 ); // D_fx[1] - e2 - __as[0] = i01; - __as[1] = i11; + i01 = GT_32( L_abs( tmp1 ), L_abs( s_fx[0] ) ); // fabsf( D_fx[0] - e2 ) > fabsf( D_fx[0] - e1 ) + i11 = GT_32( L_abs( tmp2 ), L_abs( s_fx[1] ) ); // fabsf( D_fx[1] - e2 ) > fabsf( D_fx[1] - e1 ) if ( i01 ) { @@ -3772,11 +3714,6 @@ static void eig2x2_opt( move32(); } - __s_fx[0] = s_fx[0]; - __s_fx[1] = s_fx[1]; - __s_q[0] = q_tmp1; - __s_q[1] = q_tmp1; - // normVal = sqrtf( 1.0f / ( 1e-12f + crossSquare + s * s ) ); Word32 nvalm[BINAURAL_CHANNELS]; @@ -3820,11 +3757,6 @@ static void eig2x2_opt( nvalm[1] = Sqrt32( nvalm[1], &exp ); nvalq[1] = sub( 31, exp ); - __nval_fx[0] = nvalm[0]; - __nval_q[0] = nvalq[0]; - __nval_fx[1] = nvalm[1]; - __nval_q[1] = nvalq[1]; - q_diff = sub( q_c, q_tmp1 ); q_tmp1 = s_min( q_tmp1, q_c ); @@ -3861,7 +3793,7 @@ static void eig2x2_opt( nvalm[1] = L_shl( nvalm[1], q_diff ); } - __U_q = sub( add( q_tmp1, q_tmp2 ), 31 ); + *q_U = sub( add( q_tmp1, q_tmp2 ), 31 ); i00 = L_sub( 1, i01 ); i10 = L_sub( 1, i11 ); @@ -3880,53 +3812,20 @@ static void eig2x2_opt( c1_im = L_negate( c1_im ); } - __Ure_fx[i00][0] = Mpy_32_32( s_fx[0], nvalm[0] ); + Ure_fx[i00][0] = Mpy_32_32( s_fx[0], nvalm[0] ); move32(); - __Ure_fx[i01][0] = Mpy_32_32( c_re, nvalm[0] ); + Ure_fx[i01][0] = Mpy_32_32( c_re, nvalm[0] ); move32(); - __Uim_fx[i01][0] = Mpy_32_32( c0_im, nvalm[0] ); + Uim_fx[i01][0] = Mpy_32_32( c0_im, nvalm[0] ); move32(); - __Ure_fx[i10][1] = Mpy_32_32( s_fx[1], nvalm[1] ); + Ure_fx[i10][1] = Mpy_32_32( s_fx[1], nvalm[1] ); move32(); - __Ure_fx[i11][1] = Mpy_32_32( c_re, nvalm[1] ); + Ure_fx[i11][1] = Mpy_32_32( c_re, nvalm[1] ); move32(); - __Uim_fx[i11][1] = Mpy_32_32( c1_im, nvalm[1] ); + Uim_fx[i11][1] = Mpy_32_32( c1_im, nvalm[1] ); move32(); - - return; -} - -static void eig2x2_fx( - const Word32 E1_fx, /*q_E*/ - const Word32 E2_fx, /*q_E*/ - Word16 q_E, - const Word32 Cre_fx, /*q_C*/ - const Word32 Cim_fx, /*q_C*/ - Word16 q_C, - Word32 Ure_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_U*/ - Word32 Uim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_U*/ - Word16 *q_U, - Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/ - Word16 *q_D ) -{ -#if 0 - eig2x2_opt( E1_fx, E2_fx, q_E, Cre_fx, Cim_fx, q_C ); - Ure_fx[0][0] = __Ure_fx[0][0]; - Ure_fx[0][1] = __Ure_fx[0][1]; - Ure_fx[1][0] = __Ure_fx[1][0]; - Ure_fx[1][1] = __Ure_fx[1][1]; - Uim_fx[0][0] = __Uim_fx[0][0]; - Uim_fx[0][1] = __Uim_fx[0][1]; - Uim_fx[1][0] = __Uim_fx[1][0]; - Uim_fx[1][1] = __Uim_fx[1][1]; - *q_U = __U_q; - D_fx[0] = __D_fx[0]; - D_fx[1] = __D_fx[1]; - *q_D = __D_q; #else - eig2x2_opt( E1_fx, E2_fx, q_E, Cre_fx, Cim_fx, q_C ); - Word16 chA, chB, ch; Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx; Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im; @@ -4049,9 +3948,6 @@ static void eig2x2_fx( q_tmp1 = q_e; move16(); - check( __pm_fx, __pm_q, pm_fx, q_tmp2, 1 << 26 ); - check( __add_fx, __add_q, add_fx, q_tmp1, 1 << 26 ); - IF( LT_16( q_tmp1, q_tmp2 ) ) { D_fx[0] = L_add( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ); @@ -4071,9 +3967,6 @@ static void eig2x2_fx( move16(); } - check( __D_fx[0], __D_q, D_fx[0], *q_D, 1 << 26 ); - check( __D_fx[1], __D_q, D_fx[1], *q_D, 1 << 26 ); - /* Numeric case, when input is practically zeros */ // IF( D_fx[0] < EPSILON_FX ) @@ -4086,15 +3979,6 @@ static void eig2x2_fx( *q_U = Q31; move16(); - for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) - { - for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) - { - check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 2 ); - check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 2 ); - } - } - return; } @@ -4112,15 +3996,6 @@ static void eig2x2_fx( *q_U = Q30; move16(); - for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) - { - for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) - { - check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 2 ); - check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 2 ); - } - } - return; } } @@ -4135,15 +4010,6 @@ static void eig2x2_fx( *q_U = Q30; move16(); - for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) - { - for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) - { - check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 2 ); - check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 2 ); - } - } - return; } } @@ -4172,18 +4038,10 @@ static void eig2x2_fx( move16(); } - check( __diff_fx[ch][0], __diff_q, tmp1, q_tmp1, 1 << 26 ); - check( __diff_fx[ch][1], __diff_q, tmp2, q_tmp1, 1 << 26 ); - IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) ) { - check( __as[ch], 0, 1, 0, 0 ); - s_fx = tmp2; move32(); - - check( __s_fx[ch], __s_q[ch], s_fx, q_tmp1, 1 << 26 ); - exp = sub( norm_l( s_fx ), 1 ); tmp2 = Mpy_32_32( s_fx, s_fx ); q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); @@ -4198,8 +4056,6 @@ static void eig2x2_fx( normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); - check( __nval_fx[ch], __nval_q[ch], normVal_fx, q_tmp2, 1 << 26 ); - q_diff = sub( q_c, q_tmp1 ); IF( q_diff > 0 ) { @@ -4223,10 +4079,6 @@ static void eig2x2_fx( move32(); q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); - check( __Ure_fx[0][ch], __U_q, Ure_fx[0][ch], q_U_1, 1 << 26 ); - check( __Ure_fx[1][ch], __U_q, Ure_fx[1][ch], q_U_1, 1 << 26 ); - check( __Uim_fx[1][ch], __U_q, Uim_fx[1][ch], q_U_1, 1 << 26 ); - IF( q_U_2 != 0 ) { q_diff = sub( q_U_2, q_U_1 ); @@ -4258,13 +4110,9 @@ static void eig2x2_fx( } ELSE { - check( __as[ch], 0, 0, 0, 0 ); - s_fx = tmp1; move32(); - check( __s_fx[ch], __s_q[ch], s_fx, q_tmp1, 1 << 26 ); - exp = sub( norm_l( s_fx ), 1 ); tmp2 = Mpy_32_32( s_fx, s_fx ); q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); @@ -4279,8 +4127,6 @@ static void eig2x2_fx( normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); - check( __nval_fx[ch], __nval_q[ch], normVal_fx, q_tmp2, 1 << 26 ); - q_diff = sub( q_c, q_tmp1 ); IF( q_diff > 0 ) { @@ -4304,10 +4150,6 @@ static void eig2x2_fx( move32(); q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); - check( __Ure_fx[1][ch], __U_q, Ure_fx[1][ch], q_U_2, 1 << 26 ); - check( __Ure_fx[0][ch], __U_q, Ure_fx[0][ch], q_U_2, 1 << 26 ); - check( __Uim_fx[0][ch], __U_q, Uim_fx[0][ch], q_U_2, 1 << 26 ); - IF( q_U_1 != 0 ) { q_diff = sub( q_U_2, q_U_1 ); @@ -4350,15 +4192,6 @@ static void eig2x2_fx( *q_U = q_U_2; move16(); } - - for ( int i = 0; i < BINAURAL_CHANNELS; ++i ) - { - for ( int j = 0; j < BINAURAL_CHANNELS; ++j ) - { - check( __Ure_fx[i][j], __U_q, Ure_fx[i][j], *q_U, 1 << 26 ); - check( __Uim_fx[i][j], __U_q, Uim_fx[i][j], *q_U, 1 << 26 ); - } - } #endif return; } -- GitLab From 6411b45e18ac83411315d8e710045df023bb3455 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 12 Nov 2025 10:28:35 +0000 Subject: [PATCH 028/750] Apply clang format. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 6bbb57349..e3b64440b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3592,7 +3592,7 @@ static void eig2x2_fx( q_tmp2 = 63; move16(); } - + q_diff = sub( q_tmp1, q_tmp2 ); q_tmp1 = s_min( q_tmp1, q_tmp2 ); if ( q_diff > 0 ) -- GitLab From 8d0b26d53a9cca5326201d60d1aac217d166f779 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 12 Nov 2025 10:45:35 +0000 Subject: [PATCH 029/750] Fix MSVC build failure. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index e3b64440b..61cbb2308 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3719,22 +3719,22 @@ static void eig2x2_fx( Word32 nvalm[BINAURAL_CHANNELS]; Word16 nvalq[BINAURAL_CHANNELS]; - q_tmp2 = L_shl( q_tmp1, 1 ); + q_tmp2 = shl( q_tmp1, 1 ); q_min = s_min( q_tmp2, q_crossSquare ); q_min = s_min( q_min, eps_q ); Word64 nval64m[BINAURAL_CHANNELS]; - q_diff = L_sub( q_tmp2, q_min ); + q_diff = sub( q_tmp2, q_min ); nval64m[0] = W_shr( W_mult0_32_32( s_fx[0], s_fx[0] ), q_diff ); nval64m[1] = W_shr( W_mult0_32_32( s_fx[1], s_fx[1] ), q_diff ); - q_diff = L_sub( q_crossSquare, q_min ); + q_diff = sub( q_crossSquare, q_min ); crossSquare_fx = W_shr( crossSquare_fx, q_diff ); nval64m[0] = W_add( nval64m[0], crossSquare_fx ); nval64m[1] = W_add( nval64m[1], crossSquare_fx ); - q_diff = L_sub( eps_q, q_min ); + q_diff = sub( eps_q, q_min ); eps_fx = W_shr( eps_fx, q_diff ); nval64m[0] = W_add( nval64m[0], eps_fx ); nval64m[1] = W_add( nval64m[1], eps_fx ); -- GitLab From 7008e8f9e1d8f778c5ccd3355ad2a78f1837dba6 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 13 Nov 2025 17:03:23 +0100 Subject: [PATCH 030/750] Using rounding in multiplication to improve precision in cngNoiseLevel[] --- lib_com/options.h | 2 +- lib_dec/fd_cng_dec_fx.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index eb172a83c..c277431c3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,7 +112,7 @@ #define NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES /* FhG: Adjust scaleFactor according to st->cldfbSyn->cldfb_state_fx too to avoid overflow in cldfbSynthesis_ivas_fx() */ - +#define FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES /* FhG: Using rounding in multiplication to improve precision in cngNoiseLevel[] */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index abdac9076..45b5fc6b5 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1092,7 +1092,11 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { - cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES + cngNoiseLevel[j] = L_shl( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#else + cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#endif move32(); } } @@ -1182,7 +1186,11 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { - cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES + cngNoiseLevel[j] = L_shl( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#else + cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#endif move32(); } } @@ -1793,7 +1801,11 @@ void perform_noise_estimation_dec_ivas_fx( FOR( p = 0; p < npart; p++ ) { temp = L_shl( msPeriodog[p], q_shift ); - msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ +#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES + msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ +#else + msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ +#endif move32(); } } @@ -1871,7 +1883,11 @@ void perform_noise_estimation_dec_ivas_fx( L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) ); IF( LT_32( L_tmp, msNoiseEst[p] ) ) { +#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES + msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/ +#else msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/ +#endif move32(); temp_q_msNoiseEst[p] = sub( add( hFdCngDec->msNoiseEst_exp, scale ), 15 ); move16(); @@ -1894,7 +1910,11 @@ void perform_noise_estimation_dec_ivas_fx( L_tmp = L_shr_sat( hFdCngDec->msPeriodog_ST_fx[p], sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_ST_exp ) ); /*Q31 - hFdCngDec->msPeriodog_ST_exp*/ IF( LT_32( L_tmp, msNoiseEst[p] ) ) { - msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ +#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES + msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ +#else + msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ +#endif move32(); } } @@ -2931,7 +2951,7 @@ void generate_comfort_noise_dec_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c1 = Sqrt16( hFdCngCom->coherence_fx[0], &temp ); /*Q15 - temp*/ #else - c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ + c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ #endif c1 = shl( c1, temp ); /*Q15*/ temp = 0; @@ -2939,7 +2959,7 @@ void generate_comfort_noise_dec_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx[0] ), &temp ); /*Q15 - temp*/ #else - c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx ), &temp ); /*Q15 - temp*/ + c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx ), &temp ); /*Q15 - temp*/ #endif c2 = shl( c2, temp ); /*Q15*/ -- GitLab From fbfafd9e912b51f84feebb83d6dca1123a82f7bb Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 14 Nov 2025 08:55:19 +0100 Subject: [PATCH 031/750] Fix EVS non-bit-exactness --- lib_dec/fd_cng_dec_fx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 45b5fc6b5..eb5daaf62 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1092,11 +1092,7 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { -#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES - cngNoiseLevel[j] = L_shl( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#endif move32(); } } -- GitLab From d0f1ab8b4e8fb2c25c9d1b68574b02b65a769895 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 14 Nov 2025 08:58:39 +0100 Subject: [PATCH 032/750] Apply clang formatting --- lib_dec/fd_cng_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index eb5daaf62..0c2f5125b 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1092,7 +1092,7 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { - cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ + cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ move32(); } } -- GitLab From 75000e057627d63309b9809518e4a408e43cb0b8 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 14 Nov 2025 12:13:24 +0100 Subject: [PATCH 033/750] Use rounding during the scaling of cngNoiseLevel[]. --- lib_dec/fd_cng_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 0c2f5125b..946e210e5 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1183,7 +1183,7 @@ Word16 ApplyFdCng_fx( FOR( ; j <= hFdCngCom->part[k]; j++ ) { #ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES - cngNoiseLevel[j] = L_shl( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ + cngNoiseLevel[j] = L_shl_r( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ #else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ #endif -- GitLab From e0a9b1d43da56d045ed97162eaa551c72f4dbd40 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 14 Nov 2025 15:46:02 +0100 Subject: [PATCH 034/750] fix MSVC Release mode build --- Workspace_msvc/lib_dec.vcxproj | 2 +- apps/encoder.c | 8 +- apps/encoder_fmtsw.c | 8 +- lib_com/common_api_types.h | 490 ++++++++++++++++++++++++++++++++ lib_dec/lib_dec.h | 6 +- lib_dec/lib_dec_fx.c | 5 +- lib_util/ivas_rtp_file.c | 22 +- lib_util/ivas_rtp_file.h | 6 +- lib_util/ivas_rtp_payload.c | 4 +- lib_util/ivas_rtp_pi_data.c | 2 +- lib_util/ivas_rtp_pi_data.h | 491 --------------------------------- 11 files changed, 518 insertions(+), 526 deletions(-) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index e93fc6c7c..9d98513e8 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_basop;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;..\lib_util;.%(AdditionalIncludeDirectories) + ..\lib_basop;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/apps/encoder.c b/apps/encoder.c index 551eee9af..fd03e990d 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -864,10 +864,10 @@ int main( /* scene orientation */ if ( sceneOrientationFileReader ) { - PIDATA_TS *piDataTs = &ivasRtp.piData[ivasRtp.nWrittenPiData++]; + IVAS_PIDATA_TS *piDataTs = &ivasRtp.piData[ivasRtp.nWrittenPiData++]; IVAS_PIDATA_ORIENTATION *scene = &piDataTs->data.scene; - memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + memset( piDataTs, 0, sizeof( IVAS_PIDATA_TS ) ); scene->size = sizeof( IVAS_PIDATA_ORIENTATION ); scene->piDataType = IVAS_PI_SCENE_ORIENTATION; @@ -881,10 +881,10 @@ int main( /* device orientation */ if ( deviceOrientationFileReader ) { - PIDATA_TS *piDataTs = &ivasRtp.piData[ivasRtp.nWrittenPiData++]; + IVAS_PIDATA_TS *piDataTs = &ivasRtp.piData[ivasRtp.nWrittenPiData++]; IVAS_PIDATA_ORIENTATION *device = &piDataTs->data.deviceUnCompensated; - memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + memset( piDataTs, 0, sizeof( IVAS_PIDATA_TS ) ); device->size = sizeof( IVAS_PIDATA_ORIENTATION ); device->piDataType = IVAS_PI_DEVICE_ORIENTATION_COMPENSATED; diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 10d81fc2f..688716e58 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -987,10 +987,10 @@ int encoder_main( /* scene orientation */ if ( sceneOrientationFileReader ) { - PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; + IVAS_PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; IVAS_PIDATA_ORIENTATION *scene = &piDataTs->data.scene; - memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + memset( piDataTs, 0, sizeof( IVAS_PIDATA_TS ) ); scene->size = sizeof( IVAS_PIDATA_ORIENTATION ); scene->piDataType = IVAS_PI_SCENE_ORIENTATION; @@ -1004,10 +1004,10 @@ int encoder_main( /* device orientation */ if ( deviceOrientationFileReader ) { - PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; + IVAS_PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; IVAS_PIDATA_ORIENTATION *device = &piDataTs->data.deviceUnCompensated; - memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + memset( piDataTs, 0, sizeof( IVAS_PIDATA_TS ) ); device->size = sizeof( IVAS_PIDATA_ORIENTATION ); device->piDataType = IVAS_PI_DEVICE_ORIENTATION_COMPENSATED; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 27290eb18..1230dccc8 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -394,4 +394,494 @@ typedef struct } IVAS_REND_AudioBuffer; +#ifdef IVAS_RTPDUMP +/*----------------------------------------------------------------------------------* + * RTP API structures and enums + *----------------------------------------------------------------------------------*/ + +/* IVAS PI Data Types */ +typedef enum +{ + /* Forward direction PI types */ + IVAS_PI_SCENE_ORIENTATION, /* orientation of audio scene in unit quaternions */ + IVAS_PI_DEVICE_ORIENTATION_COMPENSATED, /* orientation of device in unit quaternions (compensated) */ + IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED, /* orientation of device in unit quaternions (un-compensated) */ + IVAS_PI_ACOUSTIC_ENVIRONMENT, /* describe the acoustic environment */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_PI_AUDIO_DESCRIPTION, /* audio content description (voice/music/ambiance) */ + IVAS_PI_ISM_NUM, /* Number of objects */ + IVAS_PI_ISM_ID, /* id of each object */ + IVAS_PI_ISM_GAIN, /* gain of each object */ + IVAS_PI_ISM_ORIENTATION, /* orientation of each object */ + IVAS_PI_ISM_POSITION, /* position of each object */ + IVAS_PI_ISM_DISTANCE_ATTENUATION, /* distance attenuation for each object */ + IVAS_PI_ISM_DIRECTIVITY, /* directivity of each object */ + IVAS_PI_DIEGETIC_TYPE, /* digetic audio indication */ + IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION, /* audio suppression indication */ + IVAS_PI_AUDIO_FOCUS_INDICATION, /* audio focus indication (direction in Quaternions and/or level) */ + IVAS_PI_RESERVED15, /* reserved */ + + /* Reverse direction PI types */ + IVAS_PI_PLAYBACK_DEVICE_ORIENTATION, /* orientation of the playback device in quaternions */ + IVAS_PI_HEAD_ORIENTATION, /* head orientation of the listener in Quaternions */ + IVAS_PI_LISTENER_POSITION, /* position of the listener in 3D space */ + IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST, /* receiver’s preference with respect to audio suppression */ + IVAS_PI_AUDIO_FOCUS_REQUEST, /* direction of interest for the listener in Quaternions and/or audio focus level */ + IVAS_PI_PI_LATENCY, /* round-trip latency for PI frames */ + IVAS_PI_R_ISM_ID, /* id of an object for editing */ + IVAS_PI_R_ISM_GAIN, /* editing request for gain factor for received object */ + IVAS_PI_R_ISM_ORIENTATION, /* editing request for orientation for received object */ + IVAS_PI_R_ISM_POSITION, /* editing request for position for received object */ + IVAS_PI_R_ISM_DIRECTION, /* editing request for direction for received object */ + IVAS_PI_RESERVED27, /* reserved */ + IVAS_PI_RESERVED28, /* reserved */ + IVAS_PI_RESERVED29, /* reserved */ + IVAS_PI_RESERVED30, /* reserved */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_PI_NO_DATA = 31, /* Indicates an empty PI data frame */ + IVAS_PI_MAX_ID /* Max number of PI data IDs supprted */ +} IVAS_PI_TYPE; + +/* orientation data corresponding to any of the following pi data types :- + * - IVAS_PI_SCENE_ORIENTATION + * - IVAS_PI_DEVICE_ORIENTATION_COMPENSATED + * - IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED + * - IVAS_PI_PLAYBACK_DEVICE_ORIENTATION + * - IVAS_PI_HEAD_ORIENTATION + * - IVAS_PI_R_ISM_ORIENTATION + * + * piDataType is used to identify the correct pi data type contained here + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_SCENE_ORIENTATION) */ + uint32_t piDataType; /* one of supported orientation data types */ + IVAS_QUATERNION orientation; /* orientation data expressed as quartenions */ +} IVAS_PIDATA_ORIENTATION; + +/* Acoustic environment corresponding to IVAS_PI_ACOUSTIC_ENVIRONMENT + * + * acoustic environment ID + * late reverb parameters + * - RT60 – indicating the time that it takes for the reflections to reduce 60 dB in energy level, per frequency band + * - DSR – diffuse to source signal energy ratio, per frequency band + * - Pre-delay – delay at which the computation of DSR values was performed + * early reflections + * - 3D rectangular virtual room dimensions + * - Broadband energy absorption coefficient per wall surface + */ +typedef enum +{ + IVAS_PI_AE_LOW, /* center frequency 25 Hz */ + IVAS_PI_AE_MID, /* center frequency 250 Hz */ + IVAS_PI_AE_HIGH, /* center frequency 2.5 kHz */ + IVAS_PI_AE_NUM_BANDS /* number of ae bands */ +} IVAS_PI_AE_BANDS; + +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +typedef enum +{ + IVAS_PI_AE_LOW_FREQ = 25, + IVAS_PI_AE_MID_FREQ = 250, + IVAS_PI_AE_HIGH_FREQ = 2500 +} IVAS_PI_AE_BANDS_FREQ; +#endif + +typedef enum +{ + IVAS_PI_AE_FRONT, + IVAS_PI_AE_BACK, + IVAS_PI_AE_LEFT, + IVAS_PI_AE_RIGHT, + IVAS_PI_AE_CEILING, + IVAS_PI_AE_FLOOR, + IVAS_PI_AE_NUM_SURFACE +} IVAS_PI_AE_SURFACE; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ACOUSTIC_ENV) */ + uint32_t piDataType; /* IVAS_PI_ACOUSTIC_ENVIRONMENT */ + bool availLateReverb; /* AE contains only late reverb parameters */ + bool availEarlyReflections; /* AE containing late reverb and simplified early reflections */ + uint8_t aeid; /* seven-bit acoustic environment identifier */ + + /* only valid if availLateReverb==true or availEarlyReflections==true */ + float rt60[IVAS_PI_AE_NUM_BANDS]; /* time for the reflections to reduce 60 dB per band in seconds */ + float dsr[IVAS_PI_AE_NUM_BANDS]; /* diffuse to source signal energy ratio per band in dB */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + Word32 rt60_fx[IVAS_PI_AE_NUM_BANDS]; /* Q26: time for the reflections to reduce 60 dB per band in seconds */ + Word32 dsr_fx[IVAS_PI_AE_NUM_BANDS]; /* Q30: diffuse to source signal energy ratio per band in dB */ +#endif + + /* only valid if availEarlyReflections==true */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + IVAS_VECTOR3 roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ +#else + IVAS_COORDINATE roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ +#endif + float absorbCoeffs[IVAS_PI_AE_NUM_SURFACE]; /* absorption coefficients for all surfaces */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + Word32 absorbCoeffs_fx[IVAS_PI_AE_NUM_SURFACE]; /* Q30: absorption coefficients for all surfaces */ +#endif +} IVAS_PIDATA_ACOUSTIC_ENV; + +#ifdef RTP_S4_251135_CR26253_0016_REV1 +/* Audio Description corresponding to IVAS_PI_AUDIO_DESCRIPTION + * Describe the following audio decriptors per object/type :- + * - audio content type is speech/music/ambiance + * - if audio rendering is editable + * - if stereo audio is binaural + * + * number of valid entries decide on basis of audio format:- + * - Stereo/SBA/MASA = 1 entry + * - MultiChannel = 2 entries (1 for center channel + 1 for all other channels) + * - ISM = Number of Object entries ( 1 per object ) + * - OMASA/OSBA = 1 + Num Discrete Coded Objects + * + */ +typedef struct +{ + bool speech; /* audio has voice/speech */ + bool music; /* audio has music */ + bool ambiance; /* audio has background ambiance */ + bool editable; /* rendering audio metadata is editable */ + bool binaural; /* stereo stream is binaural */ +} IVAS_AUDIO_ID; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_AUDIO_DESC) */ + uint32_t piDataType; /* IVAS_PI_AUDIO_DESCRIPTION */ + uint32_t nValidEntries; /* Number of valid audio IDs */ + IVAS_AUDIO_ID audioId[1 + IVAS_MAX_NUM_OBJECTS]; /* audio id as per format */ +} IVAS_PIDATA_AUDIO_DESC; + +/* ISM specific PI data related to PI types : - + * + * - IVAS_PI_ISM_NUM + * - IVAS_PI_ISM_ID + * - IVAS_PI_ISM_GAIN + * - IVAS_PI_ISM_ORIENTATION + * - IVAS_PI_ISM_POSITION + * - IVAS_PI_ISM_DISTANCE_ATTENUATION + * - IVAS_PI_ISM_DIRECTIVITY + */ + +/* Number of ISMs */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_NUM) */ + uint32_t piDataType; /* IVAS_PI_ISM_NUM */ + uint32_t numObjects; /* Number of ISM */ +} IVAS_PIDATA_ISM_NUM; + +/* ISM ID */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ + uint32_t piDataType; /* IVAS_PI_ISM_ID */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif + uint8_t id[IVAS_MAX_NUM_OBJECTS]; /* 8-bit ISM id of object */ +} IVAS_PIDATA_ISM_ID; + +/* ISM gain */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ + uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif + int8_t dB[IVAS_MAX_NUM_OBJECTS]; /* ISM gain in dB per object [-96, +3] */ +} IVAS_PIDATA_ISM_GAIN; + +/* ISM orientation */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ + uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif + IVAS_QUATERNION orientation[IVAS_MAX_NUM_OBJECTS]; /* Orientation of audio objects in ISM(s) */ +} IVAS_PIDATA_ISM_ORIENTATION; + +/* ISM position */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ + uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif + IVAS_VECTOR3 position[IVAS_MAX_NUM_OBJECTS]; /* Position of audio objects in ISM(s) */ +} IVAS_PIDATA_ISM_POSITION; + +/* ISM distance attenuation comprising of following gains per ISM + * - reference distance + * - maximum distance + * - roll-off factor + */ +typedef struct +{ + float ref_dist; /* reference distance in meters */ + float max_dist; /* maximum distance in meters */ + float roll; /* roll-off factor values */ +} IVAS_DIST_ATTEN; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ + uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif + IVAS_DIST_ATTEN distAtten[IVAS_MAX_NUM_OBJECTS]; /* Distance attenuation of audio objects */ +} IVAS_PIDATA_ISM_ATTENUATION; + +/* ISM Directivity comprising of following per ISM :- + * - inner cone angle determines the size of the main cone directed to the front of the object + * - outer cone angle determines the size of the outer (back) cone + * - outer attenuation gain determines the attenuation outside the outer cone + */ +typedef struct +{ + uint16_t innerConeAngle; /* inner cone angle in degrees (0 - 360) */ + uint16_t outerConeAngle; /* outer cone angle in degrees (0 - 360) */ + float outerAttenuationdB; /* attenuation outside the outer cone in dB */ +} IVAS_ISM_DIRECTIVITY; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ + uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif + IVAS_ISM_DIRECTIVITY directivity[IVAS_MAX_NUM_OBJECTS]; /* Directivity of audio objects */ +} IVAS_PIDATA_ISM_DIRECTIVITY; + +/* Diegetic and non-diegetic indication flag as per audio format + * + * number of valid entries decided on basis of audio format:- + * - Stereo/SBA/MASA/MultiChannel = 1 entry + * - ISM = Number of Object entries ( 1 per object ) + * - OMASA/OSBA = 1 (last) + Num Discrete Coded Objects + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_DIEGETIC) */ + uint32_t piDataType; /* IVAS_PI_DIEGETIC_TYPE */ + bool isDiegetic[1 + IVAS_MAX_NUM_OBJECTS]; /* diegetic indication as per audio format */ +} IVAS_PIDATA_DIEGETIC; + +/* Audio focus direction indicates a direction of interest. + * The audio focus level indicates the amount of suppression applied to the + * directions other than the audio focus direction. + */ +typedef enum +{ + IVAS_FLVL_NO_AUDIO_FOCUS = 0, /* Apply no audio focus */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_1, /* Audio focus level 1 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_2, /* Audio focus level 2 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_3, /* Audio focus level 3 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_4, /* Audio focus level 4 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_5, /* Audio focus level 5 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_6, /* Audio focus level 6 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_7, /* Audio focus level 7 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_8, /* Audio focus level 8 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_9, /* Audio focus level 9 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_10, /* Audio focus level 10 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_11, /* Audio focus level 11 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_12, /* Audio focus level 12 */ + IVAS_FLVL_MAX_AUDIO_FOCUS, /* Apply max audio focus */ + IVAS_FLVL_DEFAULT_AUDIO_FOCUS, /* Default audio focus */ + IVAS_FLVL_NO_PREFERENCE, /* No preference / No indication */ +} IVAS_FLVL; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_AUDIO_FOCUS) */ + uint32_t piDataType; /* IVAS_PI_AUDIO_FOCUS_INDCATION or IVAS_PI_AUDIO_FOCUS_REQUEST */ + bool availDirection; /* audio focus contains direction */ + bool availLevel; /* audio focus contains level */ + IVAS_QUATERNION direction; /* direction data expressed as quarternions */ + IVAS_FLVL flvl; /* audio focus level */ +} IVAS_PIDATA_AUDIO_FOCUS; + +#ifdef REVERSE_ISM_PI_DATA +/* Position data corresponding to any of the following pi data types :- + * - IVAS_PI_LISTENER_POSITION + * - IVAS_PI_R_ISM_POSITION + * + * piDataType is used to identify the correct pi data type contained here + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_POSITION) */ + uint32_t piDataType; /* one of supported position data types */ + IVAS_VECTOR3 position; /* Position data */ +} IVAS_PIDATA_POSITION; +#else +/* Listener position */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_LISTENER_POSITION) */ + uint32_t piDataType; /* IVAS_PI_LISTENER_POSITION */ + IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ +} IVAS_PIDATA_LISTENER_POSITION; +#endif + + +/* Dynamic Audio Suppression describes receiver’s preference with respect to the + * type of audio content that should be enhanced and the amount of suppression to + * be applied to the background noise + */ +typedef enum +{ + IVAS_SLI_MIN_SUPPRESSION = 0, /* Apply min suppression */ + IVAS_SLI_SUPPRESSION_LEVEL_1, /* Suppression level 1 */ + IVAS_SLI_SUPPRESSION_LEVEL_2, /* Suppression level 2 */ + IVAS_SLI_SUPPRESSION_LEVEL_3, /* Suppression level 3 */ + IVAS_SLI_SUPPRESSION_LEVEL_4, /* Suppression level 4 */ + IVAS_SLI_SUPPRESSION_LEVEL_5, /* Suppression level 5 */ + IVAS_SLI_SUPPRESSION_LEVEL_6, /* Suppression level 6 */ + IVAS_SLI_SUPPRESSION_LEVEL_7, /* Suppression level 7 */ + IVAS_SLI_SUPPRESSION_LEVEL_8, /* Suppression level 8 */ + IVAS_SLI_SUPPRESSION_LEVEL_9, /* Suppression level 9 */ + IVAS_SLI_SUPPRESSION_LEVEL_10, /* Suppression level 10 */ + IVAS_SLI_SUPPRESSION_LEVEL_11, /* Suppression level 11 */ + IVAS_SLI_MAX_SUPPRESSION, /* Apply max suppression */ + IVAS_SLI_NO_SUPPRESSION, /* Apply no suppression */ + IVAS_SLI_DEFAULT_SUPPRESSION, /* Apply default suppression */ + IVAS_SLI_NO_PREFERENCE, /* No preference / No indication */ +} IVAS_SLI; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_DYNAMIC_SUPPRESSION) */ + uint32_t piDataType; /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST or IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION */ + bool speech; /* receiver's preference is voice/speech */ + bool music; /* receiver's preference is music */ + bool ambiance; /* receiver's preference is background ambiance */ + IVAS_SLI sli; /* suppression level indicator [0, 15] */ +} IVAS_PIDATA_DYNAMIC_SUPPRESSION; + +/* Reverse PI latency calculated as the elapsed time between the sent reverse PI data + * and received forward PI data. It is based on the receiving device experiencing the + * result of its sent data by receiving the corresponding data in forward direction as + * forward PI data + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_REVERSE_PI_LATENCY) */ + uint32_t piDataType; /* IVAS_PI_PI_LATENCY */ + IVAS_PI_TYPE type; /* Reverse PI used for computation of Latency */ + int32_t latency; /* Latency as 27-bit int on RTP Clock @ 16KHz */ +} IVAS_PIDATA_REVERSE_PI_LATENCY; + +/* ISM specific PI data editing requests */ + +/* ISM ID in editing requests */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_ID) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_ID */ + uint8_t id; /* 8-bit ISM id of object to edit */ +} IVAS_PIDATA_ISM_EDIT_ID; + +/* Editing request for ISM gain */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_GAIN) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_GAIN */ + int8_t dB; /* Preferred ISM gain in dB [-96, +3] */ +} IVAS_PIDATA_ISM_EDIT_GAIN; + +/* Editing request for ISM orientation */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_ORIENTATION) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_ORIENTATION */ + IVAS_QUATERNION orientation; /* orientation editing request for received ISM */ +} IVAS_PIDATA_ISM_EDIT_ORIENTATION; + +#ifndef REVERSE_ISM_PI_DATA +/* Editing request for ISM position */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_POSITION) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_POSITION */ + IVAS_COORDINATE position; /* Positional editing request for received ISM */ +} IVAS_PIDATA_ISM_EDIT_POSITION; +#endif + +/* Editing request for ISM direction */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_DIRECTION) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_DIRECTION */ + float azimuth; /* azimuth angle in degrees [-180, 180] */ + float elevation; /* elevation angle in degrees [-90°, 90°] */ +} IVAS_PIDATA_ISM_EDIT_DIRECTION; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_NO_DATA) */ + uint32_t piDataType; /* IVAS_PI_NO_DATA */ +} IVAS_PIDATA_NO_DATA; + +typedef union +{ + IVAS_PIDATA_ORIENTATION scene; + IVAS_PIDATA_ORIENTATION deviceCompensated; + IVAS_PIDATA_ORIENTATION deviceUnCompensated; + IVAS_PIDATA_ACOUSTIC_ENV acousticEnv; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_PIDATA_AUDIO_DESC audioDesc; + IVAS_PIDATA_ISM_NUM ismNum; + IVAS_PIDATA_ISM_ID ismId; + IVAS_PIDATA_ISM_GAIN ismGain; + IVAS_PIDATA_ISM_ORIENTATION ismOrientation; + IVAS_PIDATA_ISM_POSITION ismPosition; + IVAS_PIDATA_ISM_ATTENUATION ismAttenuation; + IVAS_PIDATA_ISM_DIRECTIVITY ismDirectivity; + IVAS_PIDATA_DIEGETIC digeticIndicator; + IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionIndication; + IVAS_PIDATA_AUDIO_FOCUS focusIndication; + + IVAS_PIDATA_ORIENTATION playbackOrientation; + IVAS_PIDATA_ORIENTATION headOrientation; +#ifdef REVERSE_ISM_PI_DATA + IVAS_PIDATA_POSITION listnerPosition; +#else + IVAS_PIDATA_LISTENER_POSITION listnerPosition; +#endif + IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionRequest; + IVAS_PIDATA_AUDIO_FOCUS focusRequest; + IVAS_PIDATA_REVERSE_PI_LATENCY piLatency; + IVAS_PIDATA_ISM_EDIT_ID ismEditId; + IVAS_PIDATA_ISM_EDIT_GAIN ismEditGain; + IVAS_PIDATA_ISM_EDIT_ORIENTATION ismEditOrientation; +#ifdef REVERSE_ISM_PI_DATA + IVAS_PIDATA_POSITION ismEditPosition; +#else + IVAS_PIDATA_ISM_EDIT_POSITION ismEditPosition; +#endif + IVAS_PIDATA_ISM_EDIT_DIRECTION ismEditDirection; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_PIDATA_NO_DATA noPiData; +} IVAS_PIDATA; + +typedef struct +{ + IVAS_PIDATA data; + uint32_t timestamp; +} IVAS_PIDATA_TS; + +#endif /* IVAS_RTPDUMP */ #endif /* COMMON_API_TYPES_H */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 698ca55a6..0310cb043 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -36,9 +36,6 @@ #include "common_api_types.h" #include #include "typedef.h" -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "ivas_rtp_pi_data.h" -#endif /*---------------------------------------------------------------------* @@ -90,7 +87,6 @@ typedef enum _IVAS_DEC_BS_FORMAT } IVAS_DEC_BS_FORMAT; typedef struct IVAS_DEC *IVAS_DEC_HANDLE; -typedef struct pidata_ts_struct *hPiDataTs; #ifdef SUPPORT_JBM_TRACEFILE /* Callback function for JBM tracefile writing */ @@ -530,7 +526,7 @@ ivas_error IVAS_DEC_GetJbmData( #ifdef IVAS_RTPDUMP ivas_error IVAS_DEC_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - hPiDataTs piData, /* i : PI data received in rtp packet */ + IVAS_PIDATA_TS *piData, /* i : PI data received in rtp packet */ UWord32 numPiData /* i : number of PI data received in rtp packet */ ); #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8ac73cb85..121e6fe3b 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -41,9 +41,6 @@ #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_fifo.h" -#ifdef IVAS_RTPDUMP -#include "ivas_rtp_pi_data.h" -#endif #include #include #ifdef DEBUGGING @@ -7018,7 +7015,7 @@ static void setDiegeticInputPI( ivas_error IVAS_DEC_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - hPiDataTs piData, /* i : PI data received in rtp packet */ + IVAS_PIDATA_TS *piData, /* i : PI data received in rtp packet */ UWord32 numPiData /* i : number of PI data received in rtp packet */ ) { diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 6ded4e78e..83f0a6391 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -153,9 +153,9 @@ static const char *const PiDataNames[IVAS_PI_MAX_ID] = { }; void IVAS_RTP_LogPiData( - FILE *f_piDataOut, /* i/o : Output json file handle to dump PI data for debug/test */ - const PIDATA_TS *piData, /* i : PI Data + Timestamp array containing all PI data in current packet */ - uint32_t nPiDataPresent /* i : Number of valid elements in the piData array */ + FILE *f_piDataOut, /* i/o : Output json file handle to dump PI data for debug/test */ + const IVAS_PIDATA_TS *piData, /* i : PI Data + Timestamp array containing all PI data in current packet */ + uint32_t nPiDataPresent /* i : Number of valid elements in the piData array */ ) { #ifdef ISM_PI_DATA @@ -182,7 +182,7 @@ void IVAS_RTP_LogPiData( while ( nPiDataPresent-- > 0 ) { - const PIDATA_TS *cur = piData++; + const IVAS_PIDATA_TS *cur = piData++; if ( timestamp != ( ~0u ) && timestamp != cur->timestamp ) { @@ -529,10 +529,10 @@ void IVAS_RTP_LogPiData( } void IVAS_RTP_WriteExtPiData( - FILE *f_piDataOut, /* i/o : Output csv file handle to dump PI data for external output */ - const PIDATA_TS *piData, /* i : PI Data + Timestamp array containing all PI data in current packet */ - uint32_t nPiDataPresent, /* i : Number of valid elements in the piData array */ - uint16_t numObj /* i : Number of objects */ + FILE *f_piDataOut, /* i/o : Output csv file handle to dump PI data for external output */ + const IVAS_PIDATA_TS *piData, /* i : PI Data + Timestamp array containing all PI data in current packet */ + uint32_t nPiDataPresent, /* i : Number of valid elements in the piData array */ + uint16_t numObj /* i : Number of objects */ ) { if ( f_piDataOut == NULL || piData == NULL || nPiDataPresent == 0 ) @@ -544,7 +544,7 @@ void IVAS_RTP_WriteExtPiData( while ( nPiDataPresent-- > 0 ) { - const PIDATA_TS *cur = piData++; + const IVAS_PIDATA_TS *cur = piData++; /* The writing follows the pattern of: timestamp, PI DATA TYPE, PI DATA */ @@ -1023,7 +1023,7 @@ ivas_error IVAS_RTP_WriteNextFrame( while ( rtp->nWrittenPiData > 0 ) { - PIDATA_TS *piDataTs = &rtp->piData[nProcPiData++]; + IVAS_PIDATA_TS *piDataTs = &rtp->piData[nProcPiData++]; if ( ( error = IVAS_RTP_PACK_PushPiData( rtp->hPack, (const IVAS_PIDATA_GENERIC *) &piDataTs->data ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError %s while pushing scene orientation\n", ivas_error_to_string( error ) ); @@ -1096,7 +1096,7 @@ ivas_error IVAS_RTP_ReadNextFrame( /* Pre-read all PI data */ while ( rtp->numPiDataInPacket != 0 ) { - PIDATA_TS *piData = &rtp->piData[rtp->nReadPiData]; + IVAS_PIDATA_TS *piData = &rtp->piData[rtp->nReadPiData]; if ( ( error = IVAS_RTP_UNPACK_PullNextPiData( rtp->hUnpack, (IVAS_PIDATA_GENERIC *) &piData->data, sizeof( piData->data ), &piData->timestamp ) ) != IVAS_ERR_OK ) { fprintf( stderr, "failed to pull PI Data, error = %s\n", ivas_error_to_string( error ) ); diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index fc92a4d02..1ffea87be 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -42,7 +42,7 @@ typedef struct IVAS_RTP_FILE *IVAS_RTP_FILE_HANDLE; typedef struct { uint8_t packet[NOMINAL_BUFFER_SIZE( IVAS_MAX_FRAMES_PER_RTP_PACKET )]; - PIDATA_TS piData[IVAS_PI_MAX_ID * IVAS_MAX_FRAMES_PER_RTP_PACKET]; + IVAS_PIDATA_TS piData[IVAS_PI_MAX_ID * IVAS_MAX_FRAMES_PER_RTP_PACKET]; IVAS_RTP_FILE_HANDLE hRtpFile; FILE *f_piDataOut; @@ -91,8 +91,8 @@ ivas_error IVAS_RTP_ReadNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t *auSizeBi ivas_error IVAS_RTP_WriteNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t auSizeBits, bool isMono, bool forcePacket ); ivas_error IVAS_RTP_ReadNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t *auSizeBits, uint32_t *rtpTimeStamp, uint16_t *rtpSequenceNumber, uint32_t *nextPacketRcvTime_ms, bool *qBit ); #endif -void IVAS_RTP_LogPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent ); -void IVAS_RTP_WriteExtPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent, uint16_t numObj ); +void IVAS_RTP_LogPiData( FILE *f_piDataOut, const IVAS_PIDATA_TS *piData, uint32_t nPiDataPresent ); +void IVAS_RTP_WriteExtPiData( FILE *f_piDataOut, const IVAS_PIDATA_TS *piData, uint32_t nPiDataPresent, uint16_t numObj ); const char *IVAS_RTP_GetExtPiFilePath( IVAS_RTP *rtp ); uint16_t IVAS_RTP_OwnRandom( uint16_t *seed ); diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 2f8d3aca9..79e0a3594 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -140,7 +140,7 @@ typedef struct typedef struct PIDATA_NODE { struct PIDATA_NODE *next; /* next node is first element */ - PIDATA data; /* unpacked pi data per frame */ + IVAS_PIDATA data; /* unpacked pi data per frame */ uint32_t timestamp; /* rtp timestamp of this frame */ } PIDATA_NODE; @@ -1018,7 +1018,7 @@ ivas_error IVAS_RTP_PACK_PushPiData( if ( data == NULL || data->piDataType >= IVAS_PI_NO_DATA || /* NO_PI_DATA cannot be provided by user, it is generated in packing */ - data->size > sizeof( PIDATA ) ) + data->size > sizeof( IVAS_PIDATA ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Wrong PI Data provided" ); } diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 0a23a6d7b..d4aa2f2a8 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -1711,7 +1711,7 @@ ivas_error PI_UnPackData( uint8_t piDataType, uint32_t piSize, const uint8_t *pi return IVAS_ERR_OK; } -/* PIDATA Tables */ +/* IVAS_PIDATA Tables */ const float mapRT60[1u << NBITS_RT60] = { 0.01f, 0.0126f, 0.0159f, 0.02f, 0.0252f, 0.0317f, 0.04f, 0.0504f, 0.0635f, 0.08f, 0.1008f, 0.1270f, 0.16f, 0.2016f, 0.2540f, 0.32f, diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index 2bce92fa7..e81d27cfb 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -46,497 +46,6 @@ #define REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV 0.7055555556f #endif -/* IVAS PI Data Types */ -typedef enum -{ - /* Forward direction PI types */ - IVAS_PI_SCENE_ORIENTATION, /* orientation of audio scene in unit quaternions */ - IVAS_PI_DEVICE_ORIENTATION_COMPENSATED, /* orientation of device in unit quaternions (compensated) */ - IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED, /* orientation of device in unit quaternions (un-compensated) */ - IVAS_PI_ACOUSTIC_ENVIRONMENT, /* describe the acoustic environment */ -#ifdef RTP_S4_251135_CR26253_0016_REV1 - IVAS_PI_AUDIO_DESCRIPTION, /* audio content description (voice/music/ambiance) */ - IVAS_PI_ISM_NUM, /* Number of objects */ - IVAS_PI_ISM_ID, /* id of each object */ - IVAS_PI_ISM_GAIN, /* gain of each object */ - IVAS_PI_ISM_ORIENTATION, /* orientation of each object */ - IVAS_PI_ISM_POSITION, /* position of each object */ - IVAS_PI_ISM_DISTANCE_ATTENUATION, /* distance attenuation for each object */ - IVAS_PI_ISM_DIRECTIVITY, /* directivity of each object */ - IVAS_PI_DIEGETIC_TYPE, /* digetic audio indication */ - IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION, /* audio suppression indication */ - IVAS_PI_AUDIO_FOCUS_INDICATION, /* audio focus indication (direction in Quaternions and/or level) */ - IVAS_PI_RESERVED15, /* reserved */ - - /* Reverse direction PI types */ - IVAS_PI_PLAYBACK_DEVICE_ORIENTATION, /* orientation of the playback device in quaternions */ - IVAS_PI_HEAD_ORIENTATION, /* head orientation of the listener in Quaternions */ - IVAS_PI_LISTENER_POSITION, /* position of the listener in 3D space */ - IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST, /* receiver’s preference with respect to audio suppression */ - IVAS_PI_AUDIO_FOCUS_REQUEST, /* direction of interest for the listener in Quaternions and/or audio focus level */ - IVAS_PI_PI_LATENCY, /* round-trip latency for PI frames */ - IVAS_PI_R_ISM_ID, /* id of an object for editing */ - IVAS_PI_R_ISM_GAIN, /* editing request for gain factor for received object */ - IVAS_PI_R_ISM_ORIENTATION, /* editing request for orientation for received object */ - IVAS_PI_R_ISM_POSITION, /* editing request for position for received object */ - IVAS_PI_R_ISM_DIRECTION, /* editing request for direction for received object */ - IVAS_PI_RESERVED27, /* reserved */ - IVAS_PI_RESERVED28, /* reserved */ - IVAS_PI_RESERVED29, /* reserved */ - IVAS_PI_RESERVED30, /* reserved */ -#endif /* RTP_S4_251135_CR26253_0016_REV1 */ - IVAS_PI_NO_DATA = 31, /* Indicates an empty PI data frame */ - IVAS_PI_MAX_ID /* Max number of PI data IDs supprted */ -} IVAS_PI_TYPE; - -/* cartesian coordinates (X,Y,Z) in 3D space */ -typedef struct -{ - float x, y, z; -} IVAS_COORDINATE; - -/* orientation data corresponding to any of the following pi data types :- - * - IVAS_PI_SCENE_ORIENTATION - * - IVAS_PI_DEVICE_ORIENTATION_COMPENSATED - * - IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED - * - IVAS_PI_PLAYBACK_DEVICE_ORIENTATION - * - IVAS_PI_HEAD_ORIENTATION - * - IVAS_PI_R_ISM_ORIENTATION - * - * piDataType is used to identify the correct pi data type contained here - */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_SCENE_ORIENTATION) */ - uint32_t piDataType; /* one of supported orientation data types */ - IVAS_QUATERNION orientation; /* orientation data expressed as quartenions */ -} IVAS_PIDATA_ORIENTATION; - -/* Acoustic environment corresponding to IVAS_PI_ACOUSTIC_ENVIRONMENT - * - * acoustic environment ID - * late reverb parameters - * - RT60 – indicating the time that it takes for the reflections to reduce 60 dB in energy level, per frequency band - * - DSR – diffuse to source signal energy ratio, per frequency band - * - Pre-delay – delay at which the computation of DSR values was performed - * early reflections - * - 3D rectangular virtual room dimensions - * - Broadband energy absorption coefficient per wall surface - */ -typedef enum -{ - IVAS_PI_AE_LOW, /* center frequency 25 Hz */ - IVAS_PI_AE_MID, /* center frequency 250 Hz */ - IVAS_PI_AE_HIGH, /* center frequency 2.5 kHz */ - IVAS_PI_AE_NUM_BANDS /* number of ae bands */ -} IVAS_PI_AE_BANDS; - -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -typedef enum -{ - IVAS_PI_AE_LOW_FREQ = 25, - IVAS_PI_AE_MID_FREQ = 250, - IVAS_PI_AE_HIGH_FREQ = 2500 -} IVAS_PI_AE_BANDS_FREQ; -#endif - -typedef enum -{ - IVAS_PI_AE_FRONT, - IVAS_PI_AE_BACK, - IVAS_PI_AE_LEFT, - IVAS_PI_AE_RIGHT, - IVAS_PI_AE_CEILING, - IVAS_PI_AE_FLOOR, - IVAS_PI_AE_NUM_SURFACE -} IVAS_PI_AE_SURFACE; - -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ACOUSTIC_ENV) */ - uint32_t piDataType; /* IVAS_PI_ACOUSTIC_ENVIRONMENT */ - bool availLateReverb; /* AE contains only late reverb parameters */ - bool availEarlyReflections; /* AE containing late reverb and simplified early reflections */ - uint8_t aeid; /* seven-bit acoustic environment identifier */ - - /* only valid if availLateReverb==true or availEarlyReflections==true */ - float rt60[IVAS_PI_AE_NUM_BANDS]; /* time for the reflections to reduce 60 dB per band in seconds */ - float dsr[IVAS_PI_AE_NUM_BANDS]; /* diffuse to source signal energy ratio per band in dB */ -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - Word32 rt60_fx[IVAS_PI_AE_NUM_BANDS]; /* Q26: time for the reflections to reduce 60 dB per band in seconds */ - Word32 dsr_fx[IVAS_PI_AE_NUM_BANDS]; /* Q30: diffuse to source signal energy ratio per band in dB */ -#endif - - /* only valid if availEarlyReflections==true */ -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - IVAS_VECTOR3 roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ -#else - IVAS_COORDINATE roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ -#endif - float absorbCoeffs[IVAS_PI_AE_NUM_SURFACE]; /* absorption coefficients for all surfaces */ -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - Word32 absorbCoeffs_fx[IVAS_PI_AE_NUM_SURFACE]; /* Q30: absorption coefficients for all surfaces */ -#endif -} IVAS_PIDATA_ACOUSTIC_ENV; - -#ifdef RTP_S4_251135_CR26253_0016_REV1 -/* Audio Description corresponding to IVAS_PI_AUDIO_DESCRIPTION - * Describe the following audio decriptors per object/type :- - * - audio content type is speech/music/ambiance - * - if audio rendering is editable - * - if stereo audio is binaural - * - * number of valid entries decide on basis of audio format:- - * - Stereo/SBA/MASA = 1 entry - * - MultiChannel = 2 entries (1 for center channel + 1 for all other channels) - * - ISM = Number of Object entries ( 1 per object ) - * - OMASA/OSBA = 1 + Num Discrete Coded Objects - * - */ -typedef struct -{ - bool speech; /* audio has voice/speech */ - bool music; /* audio has music */ - bool ambiance; /* audio has background ambiance */ - bool editable; /* rendering audio metadata is editable */ - bool binaural; /* stereo stream is binaural */ -} IVAS_AUDIO_ID; - -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_AUDIO_DESC) */ - uint32_t piDataType; /* IVAS_PI_AUDIO_DESCRIPTION */ - uint32_t nValidEntries; /* Number of valid audio IDs */ - IVAS_AUDIO_ID audioId[1 + IVAS_MAX_NUM_OBJECTS]; /* audio id as per format */ -} IVAS_PIDATA_AUDIO_DESC; - -/* ISM specific PI data related to PI types : - - * - * - IVAS_PI_ISM_NUM - * - IVAS_PI_ISM_ID - * - IVAS_PI_ISM_GAIN - * - IVAS_PI_ISM_ORIENTATION - * - IVAS_PI_ISM_POSITION - * - IVAS_PI_ISM_DISTANCE_ATTENUATION - * - IVAS_PI_ISM_DIRECTIVITY - */ - -/* Number of ISMs */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_NUM) */ - uint32_t piDataType; /* IVAS_PI_ISM_NUM */ - uint32_t numObjects; /* Number of ISM */ -} IVAS_PIDATA_ISM_NUM; - -/* ISM ID */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ - uint32_t piDataType; /* IVAS_PI_ISM_ID */ -#ifdef ISM_PI_DATA - uint16_t numObjects; /* number of objects */ -#endif - uint8_t id[IVAS_MAX_NUM_OBJECTS]; /* 8-bit ISM id of object */ -} IVAS_PIDATA_ISM_ID; - -/* ISM gain */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ - uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ -#ifdef ISM_PI_DATA - uint16_t numObjects; /* number of objects */ -#endif - int8_t dB[IVAS_MAX_NUM_OBJECTS]; /* ISM gain in dB per object [-96, +3] */ -} IVAS_PIDATA_ISM_GAIN; - -/* ISM orientation */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ - uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ -#ifdef ISM_PI_DATA - uint16_t numObjects; /* number of objects */ -#endif - IVAS_QUATERNION orientation[IVAS_MAX_NUM_OBJECTS]; /* Orientation of audio objects in ISM(s) */ -} IVAS_PIDATA_ISM_ORIENTATION; - -/* ISM position */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ - uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ -#ifdef ISM_PI_DATA - uint16_t numObjects; /* number of objects */ -#endif - IVAS_COORDINATE position[IVAS_MAX_NUM_OBJECTS]; /* Position of audio objects in ISM(s) */ -} IVAS_PIDATA_ISM_POSITION; - -/* ISM distance attenuation comprising of following gains per ISM - * - reference distance - * - maximum distance - * - roll-off factor - */ -typedef struct -{ - float ref_dist; /* reference distance in meters */ - float max_dist; /* maximum distance in meters */ - float roll; /* roll-off factor values */ -} IVAS_DIST_ATTEN; - -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ - uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ -#ifdef ISM_PI_DATA - uint16_t numObjects; /* number of objects */ -#endif - IVAS_DIST_ATTEN distAtten[IVAS_MAX_NUM_OBJECTS]; /* Distance attenuation of audio objects */ -} IVAS_PIDATA_ISM_ATTENUATION; - -/* ISM Directivity comprising of following per ISM :- - * - inner cone angle determines the size of the main cone directed to the front of the object - * - outer cone angle determines the size of the outer (back) cone - * - outer attenuation gain determines the attenuation outside the outer cone - */ -typedef struct -{ - uint16_t innerConeAngle; /* inner cone angle in degrees (0 - 360) */ - uint16_t outerConeAngle; /* outer cone angle in degrees (0 - 360) */ - float outerAttenuationdB; /* attenuation outside the outer cone in dB */ -} IVAS_ISM_DIRECTIVITY; - -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ - uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ -#ifdef ISM_PI_DATA - uint16_t numObjects; /* number of objects */ -#endif - IVAS_ISM_DIRECTIVITY directivity[IVAS_MAX_NUM_OBJECTS]; /* Directivity of audio objects */ -} IVAS_PIDATA_ISM_DIRECTIVITY; - -/* Diegetic and non-diegetic indication flag as per audio format - * - * number of valid entries decided on basis of audio format:- - * - Stereo/SBA/MASA/MultiChannel = 1 entry - * - ISM = Number of Object entries ( 1 per object ) - * - OMASA/OSBA = 1 (last) + Num Discrete Coded Objects - */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_DIEGETIC) */ - uint32_t piDataType; /* IVAS_PI_DIEGETIC_TYPE */ - bool isDiegetic[1 + IVAS_MAX_NUM_OBJECTS]; /* diegetic indication as per audio format */ -} IVAS_PIDATA_DIEGETIC; - -/* Audio focus direction indicates a direction of interest. - * The audio focus level indicates the amount of suppression applied to the - * directions other than the audio focus direction. - */ -typedef enum -{ - IVAS_FLVL_NO_AUDIO_FOCUS = 0, /* Apply no audio focus */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_1, /* Audio focus level 1 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_2, /* Audio focus level 2 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_3, /* Audio focus level 3 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_4, /* Audio focus level 4 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_5, /* Audio focus level 5 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_6, /* Audio focus level 6 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_7, /* Audio focus level 7 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_8, /* Audio focus level 8 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_9, /* Audio focus level 9 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_10, /* Audio focus level 10 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_11, /* Audio focus level 11 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_12, /* Audio focus level 12 */ - IVAS_FLVL_MAX_AUDIO_FOCUS, /* Apply max audio focus */ - IVAS_FLVL_DEFAULT_AUDIO_FOCUS, /* Default audio focus */ - IVAS_FLVL_NO_PREFERENCE, /* No preference / No indication */ -} IVAS_FLVL; - -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_AUDIO_FOCUS) */ - uint32_t piDataType; /* IVAS_PI_AUDIO_FOCUS_INDCATION or IVAS_PI_AUDIO_FOCUS_REQUEST */ - bool availDirection; /* audio focus contains direction */ - bool availLevel; /* audio focus contains level */ - IVAS_QUATERNION direction; /* direction data expressed as quarternions */ - IVAS_FLVL flvl; /* audio focus level */ -} IVAS_PIDATA_AUDIO_FOCUS; - -#ifdef REVERSE_ISM_PI_DATA -/* Position data corresponding to any of the following pi data types :- - * - IVAS_PI_LISTENER_POSITION - * - IVAS_PI_R_ISM_POSITION - * - * piDataType is used to identify the correct pi data type contained here - */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_POSITION) */ - uint32_t piDataType; /* one of supported position data types */ - IVAS_COORDINATE position; /* Position data */ -} IVAS_PIDATA_POSITION; -#else -/* Listener position */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_LISTENER_POSITION) */ - uint32_t piDataType; /* IVAS_PI_LISTENER_POSITION */ - IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ -} IVAS_PIDATA_LISTENER_POSITION; -#endif - - -/* Dynamic Audio Suppression describes receiver’s preference with respect to the - * type of audio content that should be enhanced and the amount of suppression to - * be applied to the background noise - */ -typedef enum -{ - IVAS_SLI_MIN_SUPPRESSION = 0, /* Apply min suppression */ - IVAS_SLI_SUPPRESSION_LEVEL_1, /* Suppression level 1 */ - IVAS_SLI_SUPPRESSION_LEVEL_2, /* Suppression level 2 */ - IVAS_SLI_SUPPRESSION_LEVEL_3, /* Suppression level 3 */ - IVAS_SLI_SUPPRESSION_LEVEL_4, /* Suppression level 4 */ - IVAS_SLI_SUPPRESSION_LEVEL_5, /* Suppression level 5 */ - IVAS_SLI_SUPPRESSION_LEVEL_6, /* Suppression level 6 */ - IVAS_SLI_SUPPRESSION_LEVEL_7, /* Suppression level 7 */ - IVAS_SLI_SUPPRESSION_LEVEL_8, /* Suppression level 8 */ - IVAS_SLI_SUPPRESSION_LEVEL_9, /* Suppression level 9 */ - IVAS_SLI_SUPPRESSION_LEVEL_10, /* Suppression level 10 */ - IVAS_SLI_SUPPRESSION_LEVEL_11, /* Suppression level 11 */ - IVAS_SLI_MAX_SUPPRESSION, /* Apply max suppression */ - IVAS_SLI_NO_SUPPRESSION, /* Apply no suppression */ - IVAS_SLI_DEFAULT_SUPPRESSION, /* Apply default suppression */ - IVAS_SLI_NO_PREFERENCE, /* No preference / No indication */ -} IVAS_SLI; - -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_DYNAMIC_SUPPRESSION) */ - uint32_t piDataType; /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST or IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION */ - bool speech; /* receiver's preference is voice/speech */ - bool music; /* receiver's preference is music */ - bool ambiance; /* receiver's preference is background ambiance */ - IVAS_SLI sli; /* suppression level indicator [0, 15] */ -} IVAS_PIDATA_DYNAMIC_SUPPRESSION; - -/* Reverse PI latency calculated as the elapsed time between the sent reverse PI data - * and received forward PI data. It is based on the receiving device experiencing the - * result of its sent data by receiving the corresponding data in forward direction as - * forward PI data - */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_REVERSE_PI_LATENCY) */ - uint32_t piDataType; /* IVAS_PI_PI_LATENCY */ - IVAS_PI_TYPE type; /* Reverse PI used for computation of Latency */ - int32_t latency; /* Latency as 27-bit int on RTP Clock @ 16KHz */ -} IVAS_PIDATA_REVERSE_PI_LATENCY; - -/* ISM specific PI data editing requests */ - -/* ISM ID in editing requests */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_ID) */ - uint32_t piDataType; /* IVAS_PI_R_ISM_ID */ - uint8_t id; /* 8-bit ISM id of object to edit */ -} IVAS_PIDATA_ISM_EDIT_ID; - -/* Editing request for ISM gain */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_GAIN) */ - uint32_t piDataType; /* IVAS_PI_R_ISM_GAIN */ - int8_t dB; /* Preferred ISM gain in dB [-96, +3] */ -} IVAS_PIDATA_ISM_EDIT_GAIN; - -/* Editing request for ISM orientation */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_ORIENTATION) */ - uint32_t piDataType; /* IVAS_PI_R_ISM_ORIENTATION */ - IVAS_QUATERNION orientation; /* orientation editing request for received ISM */ -} IVAS_PIDATA_ISM_EDIT_ORIENTATION; - -#ifndef REVERSE_ISM_PI_DATA -/* Editing request for ISM position */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_POSITION) */ - uint32_t piDataType; /* IVAS_PI_R_ISM_POSITION */ - IVAS_COORDINATE position; /* Positional editing request for received ISM */ -} IVAS_PIDATA_ISM_EDIT_POSITION; -#endif - -/* Editing request for ISM direction */ -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_DIRECTION) */ - uint32_t piDataType; /* IVAS_PI_R_ISM_DIRECTION */ - float azimuth; /* azimuth angle in degrees [-180, 180] */ - float elevation; /* elevation angle in degrees [-90°, 90°] */ -} IVAS_PIDATA_ISM_EDIT_DIRECTION; -#endif /* RTP_S4_251135_CR26253_0016_REV1 */ - -typedef struct -{ - size_t size; /* sizeof(IVAS_PIDATA_NO_DATA) */ - uint32_t piDataType; /* IVAS_PI_NO_DATA */ -} IVAS_PIDATA_NO_DATA; - - -typedef union -{ - IVAS_PIDATA_ORIENTATION scene; - IVAS_PIDATA_ORIENTATION deviceCompensated; - IVAS_PIDATA_ORIENTATION deviceUnCompensated; - IVAS_PIDATA_ACOUSTIC_ENV acousticEnv; -#ifdef RTP_S4_251135_CR26253_0016_REV1 - IVAS_PIDATA_AUDIO_DESC audioDesc; - IVAS_PIDATA_ISM_NUM ismNum; - IVAS_PIDATA_ISM_ID ismId; - IVAS_PIDATA_ISM_GAIN ismGain; - IVAS_PIDATA_ISM_ORIENTATION ismOrientation; - IVAS_PIDATA_ISM_POSITION ismPosition; - IVAS_PIDATA_ISM_ATTENUATION ismAttenuation; - IVAS_PIDATA_ISM_DIRECTIVITY ismDirectivity; - IVAS_PIDATA_DIEGETIC digeticIndicator; - IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionIndication; - IVAS_PIDATA_AUDIO_FOCUS focusIndication; - - IVAS_PIDATA_ORIENTATION playbackOrientation; - IVAS_PIDATA_ORIENTATION headOrientation; -#ifdef REVERSE_ISM_PI_DATA - IVAS_PIDATA_POSITION listnerPosition; -#else - IVAS_PIDATA_LISTENER_POSITION listnerPosition; -#endif - IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionRequest; - IVAS_PIDATA_AUDIO_FOCUS focusRequest; - IVAS_PIDATA_REVERSE_PI_LATENCY piLatency; - IVAS_PIDATA_ISM_EDIT_ID ismEditId; - IVAS_PIDATA_ISM_EDIT_GAIN ismEditGain; - IVAS_PIDATA_ISM_EDIT_ORIENTATION ismEditOrientation; -#ifdef REVERSE_ISM_PI_DATA - IVAS_PIDATA_POSITION ismEditPosition; -#else - IVAS_PIDATA_ISM_EDIT_POSITION ismEditPosition; -#endif - IVAS_PIDATA_ISM_EDIT_DIRECTION ismEditDirection; -#endif /* RTP_S4_251135_CR26253_0016_REV1 */ - IVAS_PIDATA_NO_DATA noPiData; -} PIDATA; - -typedef struct pidata_ts_struct -{ - PIDATA data; - uint32_t timestamp; -} PIDATA_TS; - #endif /* IVAS_RTPDUMP */ #endif /* IVAS_RTP_PI_DATA_H */ -- GitLab From 48ec177e64497ae49ce20df230f2f76e1083d6bf Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 14 Nov 2025 15:51:26 +0100 Subject: [PATCH 035/750] clang-format --- lib_com/common_api_types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 1230dccc8..dd9b29297 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -721,9 +721,9 @@ typedef struct */ typedef struct { - size_t size; /* sizeof(IVAS_PIDATA_POSITION) */ - uint32_t piDataType; /* one of supported position data types */ - IVAS_VECTOR3 position; /* Position data */ + size_t size; /* sizeof(IVAS_PIDATA_POSITION) */ + uint32_t piDataType; /* one of supported position data types */ + IVAS_VECTOR3 position; /* Position data */ } IVAS_PIDATA_POSITION; #else /* Listener position */ -- GitLab From 49860cd71d6f2aebadb7fcf801b01ef993066901 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 14 Nov 2025 16:12:48 +0000 Subject: [PATCH 036/750] Optimize ivas_filter_process_fx part 1. --- lib_com/ivas_filters_fx.c | 97 +++++++++++++++++++++++++++++ lib_com/ivas_prot_fx.h | 7 +++ lib_com/ivas_stat_com.h | 4 ++ lib_com/ivas_transient_det_fx.c | 77 ++++++++++++++++++++++- lib_com/ivas_transient_det_fx.py | 98 ++++++++++++++++++++++++++++++ lib_com/options.h | 6 ++ lib_dec/ivas_ism_metadata_dec_fx.c | 2 +- 7 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 lib_com/ivas_transient_det_fx.py diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 02e7b272a..e3920d649 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -43,6 +43,7 @@ *------------------------------------------------------------------------------------------*/ static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); +static void ivas_iir_2_filter_fixed_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); /*-----------------------------------------------------------------------------------------* @@ -145,6 +146,10 @@ void ivas_filters_init_fx( move16(); } +#ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->q_diff = 0; +#endif + return; } @@ -285,3 +290,95 @@ static void ivas_iir_2_filter_fx( return; } + +void ivas_filter_process_fixed_fx( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ + const Word16 length, /* i : filter order */ + Word16 *q_in_out ) +{ + SWITCH( filter_state->order ) + { + case IVAS_FILTER_ORDER_1: + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_in_out ); + /* Scale pIn_Out_fx back to input Q */ + BREAK; + case IVAS_FILTER_ORDER_4: + /* biquad-1 */ + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_in_out ); + /* biquad-2 */ + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q_in_out ); + /* Scale pIn_Out_fx back to input Q */ + BREAK; + default: + BREAK; + } + + return; +} + +static void ivas_iir_2_filter_fixed_fx( + ivas_filters_process_state_t *filter_state, + Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) + const Word16 length, + const Word16 stage, + Word16 *q_in_out ) +{ + Word16 i, j; + + Word32 *pIn_fx = pIn_Out_fx; + Word32 *pOut_fx = pIn_Out_fx; + Word32 tmp_pIn_buf_i_fx; + Word16 tmp_pIn_buf_i_e; + + Word32 L_tmp_prod, L_tmp; + Word16 L_prod_e, L_tmp_e; + + Word16 exp; + Word16 q_in = *q_in_out; + Word16 q_out = add( filter_state->q_diff, q_in ); + *q_in_out = q_out; + + FOR( i = 0; i < length; i++ ) + { + tmp_pIn_buf_i_fx = pIn_fx[i]; + move32(); + tmp_pIn_buf_i_e = q_in; + move16(); + + L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(q_in+ filter_state->num_e[stage][0]) + L_prod_e = add( q_in, filter_state->num_e[stage][0] ); + + pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &exp ); // Q31 - pIn_Out_e[i] + move32(); + + FOR( j = 1; j < filter_state->filt_len; j++ ) + { + L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e + L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e ); + + L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e + + L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] ) + L_prod_e = add( exp, filter_state->den_e[stage][j] ); + + filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1] + move32(); + /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/ + IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) ) + { + filter_state->state_fx[stage][j - 1] = 0; + move32(); + filter_state->state_e[stage][j - 1] = 0; + move16(); + } + } + + + Word16 shift = ( 31 - exp ) - q_out; + pOut_fx[i] = L_shr_r_sat( pOut_fx[i], shift ); + move32(); + } + + return; +} diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b75b38137..07f738592 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3817,6 +3817,13 @@ void ivas_filter_process_exp_fx( Word16 *pIn_Out_e ); +void ivas_filter_process_fixed_fx( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ + const Word16 length, /* i : filter order */ + Word16 *q_in_out +); + ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 65a081c9c..117325fff 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -661,6 +661,10 @@ typedef struct ivas_filters_process_state_t Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; +#ifdef OPT_2239_IVAS_FILTER_PROCESS + Word16 q_diff; // q_diff = q_out - q_in -> q_out = q_diff + q_in +#endif + } ivas_filters_process_state_t; diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 39dee9314..4239c7c1b 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -382,7 +382,6 @@ void ivas_td_decorr_get_ducking_gains_fx( { Word16 i; Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; - Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k]; Word32 in_duck_gain = hTranDet->in_duck_gain; /*Q30*/ move32(); Word32 out_duck_gain = hTranDet->out_duck_gain; /*Q30*/ @@ -396,6 +395,80 @@ void ivas_td_decorr_get_ducking_gains_fx( Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ + +#ifdef OPT_2239_IVAS_FILTER_PROCESS + /* env hpf */ + Word16 q_fast = Q11; + + ivas_filter_process_fixed_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, &q_fast ); + + Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; + Word16 env_eps_q = Q31; + + Word16 q_diff = sub( q_fast, env_eps_q ); + q_fast = s_min( q_fast, env_eps_q ); + + if ( q_diff >= 0 ) + { + for ( i = 0; i < frame_len; i++ ) + { + e_fast_fx[i] = L_add( L_abs( L_shr( e_fast_fx[i], q_diff ) ), env_eps_fx ); + move32(); + e_slow_fx[i] = e_fast_fx[i]; + move32(); + } + } + else + { + env_eps_fx = L_shl( env_eps_fx, q_diff ); + for ( i = 0; i < frame_len; i++ ) + { + e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), env_eps_fx ); + move32(); + e_slow_fx[i] = e_fast_fx[i]; + move32(); + } + } + + Word16 q_slow = q_fast; + + /* env fast*/ + ivas_filter_process_fixed_fx( &hTranDet->env_fast, e_fast_fx, frame_len, &q_fast ); + + /* env slow */ + ivas_filter_process_fixed_fx( &hTranDet->env_slow, e_slow_fx, frame_len, &q_slow ); + + + IF( tdet_flag ) + { + FOR( i = 0; i < frame_len; i++ ) + { + in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], 31 - q_slow, e_fast_fx[i], 31 - q_fast, duck_mult_fac ); /*Q30*/ + pIn_duck_gains[i] = in_duck_gain; /*Q30*/ + move32(); + } + hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ + move32(); + } + ELSE + { + FOR( i = 0; i < frame_len; i++ ) + { + in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], 31 - q_slow, e_fast_fx[i], 31 - q_fast, duck_mult_fac ); /*Q30*/ + pIn_duck_gains[i] = in_duck_gain; /*Q30*/ + move32(); + out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], 31 - q_fast, e_slow_fx[i], 31 - q_slow, duck_mult_fac ); /*Q30*/ + pOut_duck_gains[i] = out_duck_gain; /*Q30*/ + move32(); + } + hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ + move32(); + hTranDet->out_duck_gain = out_duck_gain; /*Q30*/ + move32(); + } +#else + Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k]; + set16_fx( e_fast_e, 31 - Q11, L_FRAME48k ); /* env hpf */ @@ -446,6 +519,8 @@ void ivas_td_decorr_get_ducking_gains_fx( hTranDet->out_duck_gain = out_duck_gain; /*Q30*/ move32(); } +#endif + return; } diff --git a/lib_com/ivas_transient_det_fx.py b/lib_com/ivas_transient_det_fx.py new file mode 100644 index 000000000..e5b298998 --- /dev/null +++ b/lib_com/ivas_transient_det_fx.py @@ -0,0 +1,98 @@ +import numpy as np +from scipy import signal +import matplotlib.pyplot as plt + +def generate_biquad_butterworth_coeffs(cutoff_freq, fs, order=2, ftype='lowpass', output='ba'): + Wn = cutoff_freq + if output == 'sos': + sos_coeffs = signal.butter(order, Wn, btype=ftype, analog=False, output='sos', fs=fs) + return sos_coeffs + elif output == 'ba': + b_coeffs, a_coeffs = signal.butter(order, Wn, btype=ftype, analog=False, output='ba', fs=fs) + return b_coeffs, a_coeffs + else: + raise ValueError("Output format must be 'sos' or 'ba'") + +def plot_biquad_frequency_response(b, a, fs): + w, h = signal.freqz(b, a, fs=fs) + magnitude_db = 20 * np.log10(np.abs(h)) + phase_degrees = np.unwrap(np.angle(h)) * 180 / np.pi + + fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True, tight_layout=True) + + ax1.plot(w, magnitude_db, 'b') + ax1.set_ylabel('Magnitude (dB)', color='b') + ax1.set_xlabel('Frequency (Hz)') + ax1.grid() + + ax2.plot(w, phase_degrees, 'g') + ax2.set_ylabel('Phase (degrees)', color='g') + ax2.set_xlabel('Frequency (Hz)') + ax2.grid() + + plt.show() + +def max_abs_output_biquad(b, a, n_samples=10000): + if a[0] != 1.0: + b = np.array(b) / a[0] + a = np.array(a) / a[0] + a[0] = 1.0 + + impulse_input = np.zeros(n_samples) + impulse_input[0] = 1.0 + + impulse_response = signal.lfilter(b, a, impulse_input) + + max_gain = np.sum(np.abs(impulse_response)) + + return max_gain + +# sampling_rate = 44100.0 # Hz +# cutoff_frequency = 5000.0 # Hz +# b_coeffs,a_coeffs = generate_biquad_butterworth_coeffs(cutoff_frequency, sampling_rate) +# plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) + +# # Calculate the maximum gain +# gain = max_abs_output_biquad(b_coeffs, a_coeffs) +# print(f"Numerator coefficients (b): {b_coeffs}") +# print(f"Denominator coefficients (a): {a_coeffs}") +# print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") + + +IVAS_C_HPF_48k = 0.675231906655777 +IVAS_C_HPF_32k = 0.554854910159853 +IVAS_C_HPF_16k = 0.307863971328499 + +IVAS_C_FAST_48k = 0.995842001845110 +IVAS_C_FAST_32k = 0.993769490623395 +IVAS_C_FAST_16k = 0.987577800493881 + +IVAS_C_SLOW_48k = 0.999739617238810 +IVAS_C_SLOW_32k = 0.999609451284012 +IVAS_C_SLOW_16k = 0.999219055096324 + +#env_hpf +sampling_rate = 48000.0 # Hz +b_coeffs = [ +IVAS_C_HPF_48k, -IVAS_C_HPF_48k, 0.0 ] +a_coeffs = [ 1.0, -IVAS_C_HPF_48k, 0.0 ] +plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) +gain = max_abs_output_biquad(b_coeffs, a_coeffs) +print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") + +#env_fast +sampling_rate = 48000.0 # Hz +b_coeffs = [ 1.0 - IVAS_C_FAST_48k, 0.0, 0.0 ] +a_coeffs = [ 1.0, -IVAS_C_FAST_48k, 0.0 ] +plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) +gain = max_abs_output_biquad(b_coeffs, a_coeffs) +print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") + +#env_slow +sampling_rate = 48000.0 # Hz +b_coeffs = [ 1.0 - IVAS_C_SLOW_48k, 0.0, 0.0 ] +a_coeffs = [ 1.0, -IVAS_C_SLOW_48k, 0.0 ] +plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) +gain = max_abs_output_biquad(b_coeffs, a_coeffs) +print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") + + diff --git a/lib_com/options.h b/lib_com/options.h index b1d98931d..0b6813e1e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -167,4 +167,10 @@ /* #################### End BASOP porting switches ############################ */ +/* #################### Start BASOP optimization switches ############################ */ + +#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ + +/* #################### End BASOP optimization switches ############################ */ + #endif diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 54cc5da15..4d3c06b9c 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -40,6 +39,7 @@ #include "ivas_stat_enc.h" #include #include "wmc_auto.h" +#include "move.h" #include "ivas_prot_fx.h" -- GitLab From 2cf229bed52c15b143f6807d6db4950898d39012 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 17 Nov 2025 16:34:09 +0000 Subject: [PATCH 037/750] Optimize ivas_filter_process_fx part 2. --- lib_com/ivas_filters_fx.c | 133 ++++++++++++++++++++++++-------- lib_com/ivas_prot_fx.h | 8 +- lib_com/ivas_stat_com.h | 4 + lib_com/ivas_transient_det_fx.c | 39 ++++++++++ 4 files changed, 148 insertions(+), 36 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index e3920d649..7768de77f 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -93,6 +93,10 @@ void ivas_filters_init_fx( move16(); move16(); move16(); + + filter_state->state64_fx[0][0] = 0; + filter_state->state64_fx[0][1] = 0; + filter_state->state64_fx[0][2] = 0; } ELSE { @@ -144,6 +148,13 @@ void ivas_filters_init_fx( move16(); move16(); move16(); + + filter_state->state64_fx[0][0] = 0; + filter_state->state64_fx[0][1] = 0; + filter_state->state64_fx[0][2] = 0; + filter_state->state64_fx[1][0] = 0; + filter_state->state64_fx[1][1] = 0; + filter_state->state64_fx[1][2] = 0; } #ifdef OPT_2239_IVAS_FILTER_PROCESS @@ -293,22 +304,18 @@ static void ivas_iir_2_filter_fx( void ivas_filter_process_fixed_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ const Word16 length, /* i : filter order */ - Word16 *q_in_out ) + Word16 *q_factor ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_in_out ); - /* Scale pIn_Out_fx back to input Q */ + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_factor ); BREAK; case IVAS_FILTER_ORDER_4: - /* biquad-1 */ - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_in_out ); - /* biquad-2 */ - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q_in_out ); - /* Scale pIn_Out_fx back to input Q */ + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_factor ); + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q_factor ); BREAK; default: BREAK; @@ -317,66 +324,128 @@ void ivas_filter_process_fixed_fx( return; } +#if 0 +static void __check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ); + +static void __check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ) +{ + Word16 cq, eq, shift, q_diff; + Word64 cfx, efx; + + shift = W_norm( computed_fx ); + cfx = W_shl( computed_fx, shift ); + cq = add( computed_q, shift ); + + shift = W_norm( expected_fx ); + efx = W_shl( expected_fx, shift ); + eq = add( expected_q, shift ); + + q_diff = cq - eq; + shift = abs( q_diff ); + if ( q_diff >= 0 ) + { + cfx = shift < 64 ? W_shr( cfx, shift ) : 0; + } + else + { + efx = shift < 64 ? W_shr( efx, shift ) : 0; + } + Word64 error = llabs( cfx - efx ); + if ( error > ( ( (Word64) 1 ) << 60 ) ) + { + assert( false ); + } +} + +Word64 __to_state64( Word16 q, Word32 state_fx, Word16 state_e ) +{ + Word16 q_diff = q - ( 31 - state_e ); + Word64 state; + if ( q_diff <= -32 ) + state = 0; + else + state = W_shl( (Word64) state_fx, q_diff ); + // __check( state, q, state_fx, 31 - state_e ); + return state; +} +#endif + static void ivas_iir_2_filter_fixed_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) const Word16 length, const Word16 stage, - Word16 *q_in_out ) + Word16 *q_factor ) { Word16 i, j; Word32 *pIn_fx = pIn_Out_fx; Word32 *pOut_fx = pIn_Out_fx; Word32 tmp_pIn_buf_i_fx; - Word16 tmp_pIn_buf_i_e; Word32 L_tmp_prod, L_tmp; Word16 L_prod_e, L_tmp_e; - Word16 exp; - Word16 q_in = *q_in_out; - Word16 q_out = add( filter_state->q_diff, q_in ); - *q_in_out = q_out; + Word16 q_in, q_out; + Word16 e_in, e_out; + q_in = *q_factor; + *q_factor = q_out = q_in + filter_state->q_diff; + + // Word64 shift, tmp_prod, tmp, out64; FOR( i = 0; i < length; i++ ) { tmp_pIn_buf_i_fx = pIn_fx[i]; move32(); - tmp_pIn_buf_i_e = q_in; + e_in = 31 - q_in; move16(); - L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(q_in+ filter_state->num_e[stage][0]) - L_prod_e = add( q_in, filter_state->num_e[stage][0] ); + L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(pIn_Out_e[i]+ filter_state->num_e[stage][0]) + L_prod_e = add( 31 - q_in, filter_state->num_e[stage][0] ); + + // shift = 31 - filter_state->num_e[stage][0] + q_in - ( q_out + 32 ); + // tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ), shift ); + // __check( tmp_prod, q_out + 32, L_tmp_prod, 31 - L_prod_e ); - pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &exp ); // Q31 - pIn_Out_e[i] + e_out = 31 - q_in; + pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &e_out ); // Q31 - pIn_Out_e[i] move32(); + // out64 = W_add( filter_state->state64_fx[stage][0], tmp_prod ); + // __check( out64, q_out + 32, pOut_fx[i], 31 - e_out ); + // pOut_fx[i] = (Word32)(out64 >> 32); + FOR( j = 1; j < filter_state->filt_len; j++ ) { L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e - L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e ); + L_prod_e = add( filter_state->num_e[stage][j], e_in ); + + // shift = 31 - filter_state->num_e[stage][j] + q_in - ( q_out + 32 ); + // tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ), shift ); + // __check( tmp_prod, q_out + 32, L_tmp_prod, 31 - L_prod_e ); L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e + // tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); + // __check( tmp, q_out + 32, L_tmp, 31 - L_tmp_e ); + L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] ) - L_prod_e = add( exp, filter_state->den_e[stage][j] ); + L_prod_e = add( e_out, filter_state->den_e[stage][j] ); + + // shift = 31 - filter_state->den_e[stage][j] + q_out - ( q_out + 32 ); + // tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ), shift ); + // __check( tmp_prod, q_out + 32, L_tmp_prod, 31 - L_prod_e ); filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1] move32(); - /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/ - IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) ) - { - filter_state->state_fx[stage][j - 1] = 0; - move32(); - filter_state->state_e[stage][j - 1] = 0; - move16(); - } - } + // filter_state->state64_fx[stage][j - 1] = W_add( tmp, tmp_prod ); + // __check( filter_state->state64_fx[stage][j - 1], q_out + 32, filter_state->state_fx[stage][j - 1], 31 - filter_state->state_e[stage][j - 1] ); + + // filter_state->state64_fx[stage][j - 1] = __to_state64( q_out + 32, filter_state->state_fx[stage][j - 1], filter_state->state_e[stage][j - 1] ); + } - Word16 shift = ( 31 - exp ) - q_out; - pOut_fx[i] = L_shr_r_sat( pOut_fx[i], shift ); + pOut_fx[i] = L_shr_r_sat( pOut_fx[i], sub( sub( 31, q_out ), e_out ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor) move32(); } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 07f738592..9f91e6c9b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3818,10 +3818,10 @@ void ivas_filter_process_exp_fx( ); void ivas_filter_process_fixed_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ - const Word16 length, /* i : filter order */ - Word16 *q_in_out + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word32 *pIn_Out_fx, /* i : signal subject to filtering */ + const Word16 length, /* i : filter order */ + Word16 *q_factor ); ivas_error ivas_osba_enc_open_fx( diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 117325fff..4f7f2bb66 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -663,6 +663,7 @@ typedef struct ivas_filters_process_state_t #ifdef OPT_2239_IVAS_FILTER_PROCESS Word16 q_diff; // q_diff = q_out - q_in -> q_out = q_diff + q_in + Word32 state64_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #endif } ivas_filters_process_state_t; @@ -677,6 +678,9 @@ typedef struct ivas_trans_det_state_t ivas_filters_process_state_t env_hpf; ivas_filters_process_state_t env_fast; ivas_filters_process_state_t env_slow; + ivas_filters_process_state_t test_env_hpf; + ivas_filters_process_state_t test_env_fast; + ivas_filters_process_state_t test_env_slow; Word32 in_duck_coeff; Word32 out_duck_coeff; Word32 in_duck_gain; diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 4239c7c1b..c81f3d3f6 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -225,6 +225,9 @@ static void ivas_transient_det_init( ivas_filters_init_fx( &hTranDet->env_hpf, (const Word32 *) filt_coeff_arr_fx[0], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); ivas_filters_init_fx( &hTranDet->env_fast, (const Word32 *) filt_coeff_arr_fx[1], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); ivas_filters_init_fx( &hTranDet->env_slow, (const Word32 *) filt_coeff_arr_fx[2], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); + ivas_filters_init_fx( &hTranDet->test_env_hpf, (const Word32 *) filt_coeff_arr_fx[0], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); + ivas_filters_init_fx( &hTranDet->test_env_fast, (const Word32 *) filt_coeff_arr_fx[1], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); + ivas_filters_init_fx( &hTranDet->test_env_slow, (const Word32 *) filt_coeff_arr_fx[2], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); hTranDet->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC; /*Q29*/ move32(); @@ -372,6 +375,31 @@ static Word32 ivas_calc_duck_gain_fx( * Calculate in/out ducking gains *-----------------------------------------------------------------------------------------*/ +#ifndef OPT_2239_IVAS_FILTER_PROCESS +static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ); + +static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ) +{ + Word32 cfx, efx; + Word16 q_diff = computed_q - expected_q; + if ( q_diff >= 0 ) + { + cfx = L_shr( computed_fx, +q_diff ); + efx = expected_fx; + } + else + { + cfx = computed_fx; + efx = L_shr( expected_fx, -q_diff ); + } + Word32 error = abs( cfx - efx ); + if ( error >= ( 1 << 22 ) ) + { + assert( false ); + } +} +#endif + void ivas_td_decorr_get_ducking_gains_fx( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ Word32 *pIn_pcm, /*Q11*/ @@ -475,6 +503,17 @@ void ivas_td_decorr_get_ducking_gains_fx( ivas_filter_process_exp_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, e_fast_e ); + // Word32 test_e_fast_fx[L_FRAME48k]; + // Word16 q_fast = Q11; + // Copy32( pIn_pcm, test_e_fast_fx, frame_len ); /*Q11*/ + // ivas_filter_process_fixed_fx( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, &q_fast ); + + // for ( i = 0; i < frame_len; i++ ) + // { + // check(test_e_fast_fx[i],q_fast,e_fast_fx[i],31-e_fast_e[i]); + // } + + FOR( i = 0; i < frame_len; i++ ) { // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ -- GitLab From 43a92380470d8539d72a70a7465d37499c2ba92e Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 18 Nov 2025 07:53:39 +0000 Subject: [PATCH 038/750] Optimize ivas_filter_process_fx part 3. --- lib_com/ivas_filters_fx.c | 188 ++++++++++++-------------------- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_stat_com.h | 6 +- lib_com/ivas_transient_det_fx.c | 94 ++++++++++++---- 4 files changed, 151 insertions(+), 139 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 7768de77f..cdbb937cc 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -43,7 +43,7 @@ *------------------------------------------------------------------------------------------*/ static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); -static void ivas_iir_2_filter_fixed_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); +static void ivas_iir_2_filter_fixed_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); /*-----------------------------------------------------------------------------------------* @@ -79,6 +79,12 @@ void ivas_filters_init_fx( move32(); move16(); move16(); +#ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->num_q[IVAS_FILTER_STAGE_0][i] = Q30; + filter_state->den_q[IVAS_FILTER_STAGE_0][i] = Q30; + move16(); + move16(); +#endif } filter_state->state_fx[0][0] = 0; @@ -94,15 +100,27 @@ void ivas_filters_init_fx( move16(); move16(); - filter_state->state64_fx[0][0] = 0; - filter_state->state64_fx[0][1] = 0; - filter_state->state64_fx[0][2] = 0; +#ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; + move64(); + move64(); + move64(); + filter_state->state64_q[IVAS_FILTER_STAGE_0] = Q30; + move16(); +#endif } ELSE { filter_state->filt_len = IVAS_BIQUAD_FILT_LEN; move16(); +#ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->state64_q[IVAS_FILTER_STAGE_0] = 63; + filter_state->state64_q[IVAS_FILTER_STAGE_1] = 63; +#endif + FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ ) { @@ -122,6 +140,24 @@ void ivas_filters_init_fx( move16(); move16(); move16(); +#ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->num_q[IVAS_FILTER_STAGE_0][i] = sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ); + filter_state->den_q[IVAS_FILTER_STAGE_0][i] = sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ); + filter_state->num_q[IVAS_FILTER_STAGE_1][i] = sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ); + filter_state->den_q[IVAS_FILTER_STAGE_1][i] = sub( 31, filt_coeff_e[i + 3 * IVAS_BIQUAD_FILT_LEN] ); + move16(); + move16(); + move16(); + move16(); + filter_state->state64_q[IVAS_FILTER_STAGE_0] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_0], filter_state->num_q[IVAS_FILTER_STAGE_0][i] ); + filter_state->state64_q[IVAS_FILTER_STAGE_0] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_0], filter_state->den_q[IVAS_FILTER_STAGE_0][i] ); + filter_state->state64_q[IVAS_FILTER_STAGE_1] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_1], filter_state->num_q[IVAS_FILTER_STAGE_1][i] ); + filter_state->state64_q[IVAS_FILTER_STAGE_1] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_1], filter_state->den_q[IVAS_FILTER_STAGE_1][i] ); + move16(); + move16(); + move16(); + move16(); +#endif } filter_state->state_fx[0][0] = 0; @@ -149,17 +185,21 @@ void ivas_filters_init_fx( move16(); move16(); - filter_state->state64_fx[0][0] = 0; - filter_state->state64_fx[0][1] = 0; - filter_state->state64_fx[0][2] = 0; - filter_state->state64_fx[1][0] = 0; - filter_state->state64_fx[1][1] = 0; - filter_state->state64_fx[1][2] = 0; - } - #ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->q_diff = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][2] = 0; + move64(); + move64(); + move64(); + move64(); + move64(); + move64(); #endif + } return; } @@ -306,16 +346,16 @@ void ivas_filter_process_fixed_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ const Word16 length, /* i : filter order */ - Word16 *q_factor ) + Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_factor ); + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_factor ); - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q_factor ); + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; @@ -324,129 +364,43 @@ void ivas_filter_process_fixed_fx( return; } -#if 0 -static void __check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ); - -static void __check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ) -{ - Word16 cq, eq, shift, q_diff; - Word64 cfx, efx; - - shift = W_norm( computed_fx ); - cfx = W_shl( computed_fx, shift ); - cq = add( computed_q, shift ); - - shift = W_norm( expected_fx ); - efx = W_shl( expected_fx, shift ); - eq = add( expected_q, shift ); - - q_diff = cq - eq; - shift = abs( q_diff ); - if ( q_diff >= 0 ) - { - cfx = shift < 64 ? W_shr( cfx, shift ) : 0; - } - else - { - efx = shift < 64 ? W_shr( efx, shift ) : 0; - } - Word64 error = llabs( cfx - efx ); - if ( error > ( ( (Word64) 1 ) << 60 ) ) - { - assert( false ); - } -} - -Word64 __to_state64( Word16 q, Word32 state_fx, Word16 state_e ) -{ - Word16 q_diff = q - ( 31 - state_e ); - Word64 state; - if ( q_diff <= -32 ) - state = 0; - else - state = W_shl( (Word64) state_fx, q_diff ); - // __check( state, q, state_fx, 31 - state_e ); - return state; -} -#endif - static void ivas_iir_2_filter_fixed_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) const Word16 length, const Word16 stage, - Word16 *q_factor ) + Word16 q ) { Word16 i, j; - Word32 *pIn_fx = pIn_Out_fx; - Word32 *pOut_fx = pIn_Out_fx; - Word32 tmp_pIn_buf_i_fx; - - Word32 L_tmp_prod, L_tmp; - Word16 L_prod_e, L_tmp_e; - - Word16 q_in, q_out; - Word16 e_in, e_out; - q_in = *q_factor; - *q_factor = q_out = q_in + filter_state->q_diff; - - // Word64 shift, tmp_prod, tmp, out64; + Word64 shift, tmp_prod, tmp; + Word32 in, out; FOR( i = 0; i < length; i++ ) { - tmp_pIn_buf_i_fx = pIn_fx[i]; + in = pIn_Out_fx[i]; move32(); - e_in = 31 - q_in; - move16(); - - L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(pIn_Out_e[i]+ filter_state->num_e[stage][0]) - L_prod_e = add( 31 - q_in, filter_state->num_e[stage][0] ); - // shift = 31 - filter_state->num_e[stage][0] + q_in - ( q_out + 32 ); - // tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ), shift ); - // __check( tmp_prod, q_out + 32, L_tmp_prod, 31 - L_prod_e ); + shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; + tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); - e_out = 31 - q_in; - pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &e_out ); // Q31 - pIn_Out_e[i] + shift = sub( filter_state->state64_q[stage], q ); + pIn_Out_fx[i] = out = W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ); move32(); - // out64 = W_add( filter_state->state64_fx[stage][0], tmp_prod ); - // __check( out64, q_out + 32, pOut_fx[i], 31 - e_out ); - // pOut_fx[i] = (Word32)(out64 >> 32); - FOR( j = 1; j < filter_state->filt_len; j++ ) { - L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e - L_prod_e = add( filter_state->num_e[stage][j], e_in ); - - // shift = 31 - filter_state->num_e[stage][j] + q_in - ( q_out + 32 ); - // tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ), shift ); - // __check( tmp_prod, q_out + 32, L_tmp_prod, 31 - L_prod_e ); - - L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e - - // tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - // __check( tmp, q_out + 32, L_tmp, 31 - L_tmp_e ); + shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; + tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); - L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] ) - L_prod_e = add( e_out, filter_state->den_e[stage][j] ); + tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - // shift = 31 - filter_state->den_e[stage][j] + q_out - ( q_out + 32 ); - // tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ), shift ); - // __check( tmp_prod, q_out + 32, L_tmp_prod, 31 - L_prod_e ); + shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; + tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); - filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1] + filter_state->state64_fx[stage][j - 1] = W_add( tmp, W_neg( tmp_prod ) ); move32(); - - // filter_state->state64_fx[stage][j - 1] = W_add( tmp, tmp_prod ); - // __check( filter_state->state64_fx[stage][j - 1], q_out + 32, filter_state->state_fx[stage][j - 1], 31 - filter_state->state_e[stage][j - 1] ); - - // filter_state->state64_fx[stage][j - 1] = __to_state64( q_out + 32, filter_state->state_fx[stage][j - 1], filter_state->state_e[stage][j - 1] ); } - - pOut_fx[i] = L_shr_r_sat( pOut_fx[i], sub( sub( 31, q_out ), e_out ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor) - move32(); } return; diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 9f91e6c9b..ddcb33fef 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3821,7 +3821,7 @@ void ivas_filter_process_fixed_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ - Word16 *q_factor + Word16 q ); ivas_error ivas_osba_enc_open_fx( diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 4f7f2bb66..97a4f58a8 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -662,8 +662,10 @@ typedef struct ivas_filters_process_state_t Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #ifdef OPT_2239_IVAS_FILTER_PROCESS - Word16 q_diff; // q_diff = q_out - q_in -> q_out = q_diff + q_in - Word32 state64_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word64 state64_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 num_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 den_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 state64_q[IVAS_FILTER_MAX_STAGES]; #endif } ivas_filters_process_state_t; diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index c81f3d3f6..b287701e1 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -375,7 +375,6 @@ static Word32 ivas_calc_duck_gain_fx( * Calculate in/out ducking gains *-----------------------------------------------------------------------------------------*/ -#ifndef OPT_2239_IVAS_FILTER_PROCESS static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ); static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ) @@ -393,12 +392,11 @@ static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Wo efx = L_shr( expected_fx, -q_diff ); } Word32 error = abs( cfx - efx ); - if ( error >= ( 1 << 22 ) ) + if ( error > ( 1 << 16 ) ) { assert( false ); } } -#endif void ivas_td_decorr_get_ducking_gains_fx( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ @@ -424,11 +422,11 @@ void ivas_td_decorr_get_ducking_gains_fx( Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#if 0 // def OPT_2239_IVAS_FILTER_PROCESS /* env hpf */ Word16 q_fast = Q11; - ivas_filter_process_fixed_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, &q_fast ); + ivas_filter_process_fixed_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, q_fast ); Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; Word16 env_eps_q = Q31; @@ -436,9 +434,9 @@ void ivas_td_decorr_get_ducking_gains_fx( Word16 q_diff = sub( q_fast, env_eps_q ); q_fast = s_min( q_fast, env_eps_q ); - if ( q_diff >= 0 ) + IF( q_diff >= 0 ) { - for ( i = 0; i < frame_len; i++ ) + FOR( i = 0; i < frame_len; i++ ) { e_fast_fx[i] = L_add( L_abs( L_shr( e_fast_fx[i], q_diff ) ), env_eps_fx ); move32(); @@ -446,10 +444,10 @@ void ivas_td_decorr_get_ducking_gains_fx( move32(); } } - else + ELSE { env_eps_fx = L_shl( env_eps_fx, q_diff ); - for ( i = 0; i < frame_len; i++ ) + FOR( i = 0; i < frame_len; i++ ) { e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), env_eps_fx ); move32(); @@ -461,10 +459,10 @@ void ivas_td_decorr_get_ducking_gains_fx( Word16 q_slow = q_fast; /* env fast*/ - ivas_filter_process_fixed_fx( &hTranDet->env_fast, e_fast_fx, frame_len, &q_fast ); + ivas_filter_process_fixed_fx( &hTranDet->env_fast, e_fast_fx, frame_len, q_fast ); /* env slow */ - ivas_filter_process_fixed_fx( &hTranDet->env_slow, e_slow_fx, frame_len, &q_slow ); + ivas_filter_process_fixed_fx( &hTranDet->env_slow, e_slow_fx, frame_len, q_slow ); IF( tdet_flag ) @@ -503,15 +501,17 @@ void ivas_td_decorr_get_ducking_gains_fx( ivas_filter_process_exp_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, e_fast_e ); - // Word32 test_e_fast_fx[L_FRAME48k]; - // Word16 q_fast = Q11; - // Copy32( pIn_pcm, test_e_fast_fx, frame_len ); /*Q11*/ - // ivas_filter_process_fixed_fx( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, &q_fast ); + // ==================================================================================================== + Word32 test_e_fast_fx[L_FRAME48k]; + Word16 q_fast = Q11; + Copy32( pIn_pcm, test_e_fast_fx, frame_len ); /*Q11*/ + ivas_filter_process_fixed_fx( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, q_fast ); - // for ( i = 0; i < frame_len; i++ ) - // { - // check(test_e_fast_fx[i],q_fast,e_fast_fx[i],31-e_fast_e[i]); - // } + for ( i = 0; i < frame_len; i++ ) + { + check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); + } + // ==================================================================================================== FOR( i = 0; i < frame_len; i++ ) @@ -525,12 +525,68 @@ void ivas_td_decorr_get_ducking_gains_fx( move16(); } + // ==================================================================================================== + Word32 test_e_slow_fx[L_FRAME48k]; + Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; + Word16 env_eps_q = Q31; + + Word16 q_diff = sub( q_fast, env_eps_q ); + q_fast = s_min( q_fast, env_eps_q ); + + if ( q_diff >= 0 ) + { + for ( i = 0; i < frame_len; i++ ) + { + test_e_fast_fx[i] = L_add( L_abs( L_shr( test_e_fast_fx[i], q_diff ) ), env_eps_fx ); + move32(); + test_e_slow_fx[i] = test_e_fast_fx[i]; + move32(); + } + } + else + { + env_eps_fx = L_shl( env_eps_fx, q_diff ); + for ( i = 0; i < frame_len; i++ ) + { + test_e_fast_fx[i] = L_add( L_abs( test_e_fast_fx[i] ), env_eps_fx ); + move32(); + test_e_slow_fx[i] = test_e_fast_fx[i]; + move32(); + } + } + + Word16 q_slow = q_fast; + + for ( i = 0; i < frame_len; i++ ) + { + check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); + } + // ==================================================================================================== + /* env fast*/ ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e ); + // ==================================================================================================== + ivas_filter_process_fixed_fx( &hTranDet->test_env_fast, test_e_fast_fx, frame_len, q_fast ); + + for ( i = 0; i < frame_len; i++ ) + { + check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); + } + // ==================================================================================================== + /* env slow */ ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e ); + // ==================================================================================================== + ivas_filter_process_fixed_fx( &hTranDet->test_env_slow, test_e_slow_fx, frame_len, q_slow ); + + for ( i = 0; i < frame_len; i++ ) + { + check( test_e_slow_fx[i], q_slow, e_slow_fx[i], 31 - e_slow_e[i] ); + } + // ==================================================================================================== + IF( tdet_flag ) { FOR( i = 0; i < frame_len; i++ ) -- GitLab From b71eba63d77a8a60d25d61f0c7da02b132999922 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 18 Nov 2025 12:16:27 +0000 Subject: [PATCH 039/750] Fix MSVC build failure. --- lib_com/ivas_filters_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index cdbb937cc..3f1bc8b54 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -371,9 +371,9 @@ static void ivas_iir_2_filter_fixed_fx( const Word16 stage, Word16 q ) { - Word16 i, j; + Word16 i, j, shift; - Word64 shift, tmp_prod, tmp; + Word64 tmp_prod, tmp; Word32 in, out; FOR( i = 0; i < length; i++ ) -- GitLab From 596469bc5e3be33594a953e1ec09eae792042660 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 18 Nov 2025 12:45:41 +0000 Subject: [PATCH 040/750] Fix MSVC build failure. --- lib_com/ivas_filters_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 3f1bc8b54..ab1b4ce96 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -385,7 +385,7 @@ static void ivas_iir_2_filter_fixed_fx( tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); shift = sub( filter_state->state64_q[stage], q ); - pIn_Out_fx[i] = out = W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ); + pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) -- GitLab From 4e772bc17205d7b722ab3789bb6cf65dac1da028 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 18 Nov 2025 13:36:02 +0000 Subject: [PATCH 041/750] Switch to optimized version. --- lib_com/ivas_transient_det_fx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index b287701e1..2bcb1b7cb 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -375,6 +375,7 @@ static Word32 ivas_calc_duck_gain_fx( * Calculate in/out ducking gains *-----------------------------------------------------------------------------------------*/ +#if 0 static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ); static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ) @@ -397,6 +398,7 @@ static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Wo assert( false ); } } +#endif void ivas_td_decorr_get_ducking_gains_fx( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ @@ -422,7 +424,7 @@ void ivas_td_decorr_get_ducking_gains_fx( Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ -#if 0 // def OPT_2239_IVAS_FILTER_PROCESS +#ifdef OPT_2239_IVAS_FILTER_PROCESS /* env hpf */ Word16 q_fast = Q11; -- GitLab From f7c6386563d9bf50976039562df983e9deb4e4d3 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 18 Nov 2025 13:38:59 +0000 Subject: [PATCH 042/750] Remove ivas_transient_det_fx.py. --- lib_com/ivas_transient_det_fx.py | 98 -------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 lib_com/ivas_transient_det_fx.py diff --git a/lib_com/ivas_transient_det_fx.py b/lib_com/ivas_transient_det_fx.py deleted file mode 100644 index e5b298998..000000000 --- a/lib_com/ivas_transient_det_fx.py +++ /dev/null @@ -1,98 +0,0 @@ -import numpy as np -from scipy import signal -import matplotlib.pyplot as plt - -def generate_biquad_butterworth_coeffs(cutoff_freq, fs, order=2, ftype='lowpass', output='ba'): - Wn = cutoff_freq - if output == 'sos': - sos_coeffs = signal.butter(order, Wn, btype=ftype, analog=False, output='sos', fs=fs) - return sos_coeffs - elif output == 'ba': - b_coeffs, a_coeffs = signal.butter(order, Wn, btype=ftype, analog=False, output='ba', fs=fs) - return b_coeffs, a_coeffs - else: - raise ValueError("Output format must be 'sos' or 'ba'") - -def plot_biquad_frequency_response(b, a, fs): - w, h = signal.freqz(b, a, fs=fs) - magnitude_db = 20 * np.log10(np.abs(h)) - phase_degrees = np.unwrap(np.angle(h)) * 180 / np.pi - - fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True, tight_layout=True) - - ax1.plot(w, magnitude_db, 'b') - ax1.set_ylabel('Magnitude (dB)', color='b') - ax1.set_xlabel('Frequency (Hz)') - ax1.grid() - - ax2.plot(w, phase_degrees, 'g') - ax2.set_ylabel('Phase (degrees)', color='g') - ax2.set_xlabel('Frequency (Hz)') - ax2.grid() - - plt.show() - -def max_abs_output_biquad(b, a, n_samples=10000): - if a[0] != 1.0: - b = np.array(b) / a[0] - a = np.array(a) / a[0] - a[0] = 1.0 - - impulse_input = np.zeros(n_samples) - impulse_input[0] = 1.0 - - impulse_response = signal.lfilter(b, a, impulse_input) - - max_gain = np.sum(np.abs(impulse_response)) - - return max_gain - -# sampling_rate = 44100.0 # Hz -# cutoff_frequency = 5000.0 # Hz -# b_coeffs,a_coeffs = generate_biquad_butterworth_coeffs(cutoff_frequency, sampling_rate) -# plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) - -# # Calculate the maximum gain -# gain = max_abs_output_biquad(b_coeffs, a_coeffs) -# print(f"Numerator coefficients (b): {b_coeffs}") -# print(f"Denominator coefficients (a): {a_coeffs}") -# print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") - - -IVAS_C_HPF_48k = 0.675231906655777 -IVAS_C_HPF_32k = 0.554854910159853 -IVAS_C_HPF_16k = 0.307863971328499 - -IVAS_C_FAST_48k = 0.995842001845110 -IVAS_C_FAST_32k = 0.993769490623395 -IVAS_C_FAST_16k = 0.987577800493881 - -IVAS_C_SLOW_48k = 0.999739617238810 -IVAS_C_SLOW_32k = 0.999609451284012 -IVAS_C_SLOW_16k = 0.999219055096324 - -#env_hpf -sampling_rate = 48000.0 # Hz -b_coeffs = [ +IVAS_C_HPF_48k, -IVAS_C_HPF_48k, 0.0 ] -a_coeffs = [ 1.0, -IVAS_C_HPF_48k, 0.0 ] -plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) -gain = max_abs_output_biquad(b_coeffs, a_coeffs) -print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") - -#env_fast -sampling_rate = 48000.0 # Hz -b_coeffs = [ 1.0 - IVAS_C_FAST_48k, 0.0, 0.0 ] -a_coeffs = [ 1.0, -IVAS_C_FAST_48k, 0.0 ] -plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) -gain = max_abs_output_biquad(b_coeffs, a_coeffs) -print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") - -#env_slow -sampling_rate = 48000.0 # Hz -b_coeffs = [ 1.0 - IVAS_C_SLOW_48k, 0.0, 0.0 ] -a_coeffs = [ 1.0, -IVAS_C_SLOW_48k, 0.0 ] -plot_biquad_frequency_response(b_coeffs, a_coeffs, sampling_rate) -gain = max_abs_output_biquad(b_coeffs, a_coeffs) -print(f"Maximum possible time-domain gain (L1 norm): {gain:.4f}") - - -- GitLab From a9eb284cd8ef43adb00b3a641124e3ffafac1938 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 19 Nov 2025 09:57:45 +0000 Subject: [PATCH 043/750] Address Markus' comments. --- lib_com/basop_util.c | 1 - lib_com/basop_util.h | 2 ++ .../ivas_dirac_dec_binaural_functions_fx.c | 24 +++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index bd55e59b6..6f4e00f45 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1041,7 +1041,6 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) } #endif -Word32 div_w_newton( Word32 num, Word32 den ); /* Table of 256 precalculated estimates to be used by the "div_w_newton" function using the Newton/Raphson method. diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index bfafdfacb..947c16922 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -334,6 +334,8 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ #endif +Word32 div_w_newton( Word32 num, /*!< i : Numerator*/ + Word32 den ); /*!< i : Denominator*/ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 61cbb2308..1849e318a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3747,13 +3747,29 @@ static void eig2x2_fx( nval64m[1] = W_shl( nval64m[1], q_diff ); nvalq[1] = add( q_min, q_diff ); - nvalm[0] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ), &exp ); - exp = sub( exp, sub( 62, nvalq[0] ) ); + // nvalm[0] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ), &exp ); + // exp = sub( exp, sub( 62, nvalq[0] ) ); + // + // is equivalent to: + // + // nvalm[0] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ) ); + // exp = sub( nvalq[0], 61 ); + + nvalm[0] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ) ); + exp = sub( nvalq[0], 61 ); nvalm[0] = Sqrt32( nvalm[0], &exp ); nvalq[0] = sub( 31, exp ); - nvalm[1] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ), &exp ); - exp = sub( exp, sub( 62, nvalq[1] ) ); + // nvalm[1] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ), &exp ); + // exp = sub( exp, sub( 62, nvalq[1] ) ); + // + // is equivalent to: + // + // nvalm[1] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ) ); + // exp = sub( nvalq[1], 61 ); + + nvalm[1] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ) ); + exp = sub( nvalq[1], 61 ); nvalm[1] = Sqrt32( nvalm[1], &exp ); nvalq[1] = sub( 31, exp ); -- GitLab From a6323fe09ab29184ae9a3a0ab14fe140d4d819dd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 11:07:39 +0100 Subject: [PATCH 044/750] addov --- lib_enc/ivas_mcmasa_enc_fx.c | 112 ++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 280da9456..3ac57ff83 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -42,7 +42,7 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" - +// #define compute_cov_mtx_fx_ADDCOV /*------------------------------------------------------------------------- * Local constants @@ -72,6 +72,17 @@ static void ivas_mcmasa_dmx_fx( const Word16 nchan_transport, const Word16 nchan_inp ); +#ifdef compute_cov_mtx_fx_ADDCOV +/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ +static void compute_cov_mtx_fx( + Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ + Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] (inp_exp) */ + Word16 num_freq_bands, + const Word16 N, /* i : Number of channels */ + CovarianceMatrix pCOVls[MASA_FREQUENCY_BANDS], /* o : Output matrix, contains upper part of cov mtx */ + Word16 inp_exp, /*Stores exponent for temp*/ + Word16 *band_grouping ); +#else static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] */ Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] */ @@ -80,6 +91,7 @@ static void compute_cov_mtx_fx( CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */ Word16 inp_exp /*Stores exponent for temp*/ ); +#endif static void computeIntensityVector_enc_fx( const Word16 *band_grouping, @@ -919,7 +931,11 @@ void ivas_mcmasa_param_est_enc_fx( Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; +#ifdef compute_cov_mtx_fx_ADDCOV + Word16 mrange[2]; +#else Word16 mrange[2], brange[2]; +#endif Word16 numSubFramesForRatio; CovarianceMatrix COVls[MASA_FREQUENCY_BANDS]; Word32 absCOVls_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; @@ -1064,6 +1080,20 @@ void ivas_mcmasa_param_est_enc_fx( } inp_q = add( inp_q, sf ); +#ifdef compute_cov_mtx_fx_ADDCOV + /* Compute covariance matrix */ + compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); + + FOR( i = 0; i < num_freq_bands; i++ ) + { + /* Store energies for guiding metadata encoding */ + FOR( j = 0; j < numAnalysisChannels; j++ ) + { + move32(); + hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] ); + } + } +#else /* Compute covariance matrix */ FOR( i = 0; i < num_freq_bands; i++ ) { @@ -1076,6 +1106,7 @@ void ivas_mcmasa_param_est_enc_fx( compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, j, numAnalysisChannels, &( COVls[i] ), sub( 31, inp_q ) ); } + /* Store energies for guiding metadata encoding */ FOR( j = 0; j < numAnalysisChannels; j++ ) { @@ -1083,6 +1114,7 @@ void ivas_mcmasa_param_est_enc_fx( hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] ); } } +#endif IF( !hMcMasa->separateChannelEnabled ) { @@ -2087,6 +2119,83 @@ static void ivas_mcmasa_dmx_fx( return; } + +#ifdef compute_cov_mtx_fx_ADDCOV + +/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ +static void compute_cov_mtx_fx( + Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ + Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] (inp_exp) */ + Word16 num_freq_bands, + const Word16 N, /* i : Number of channels */ + CovarianceMatrix pCOVls[MASA_FREQUENCY_BANDS], /* o : Output matrix, contains upper part of cov mtx */ + Word16 inp_exp, /*Stores exponent for temp*/ + Word16 *band_grouping ) +{ + Word16 brange[2]; + Word16 freq; + int k; + int i, j; + Word16 max_exp_r, max_exp_i; + Word64 temp64_1_r_acc, temp64_1_i_acc; + Word64 temp64_1; + Word16 tmp_16; + Word16 temp_exp = shl( inp_exp, 1 ); + + + FOR( i = 0; i < N; i++ ) + { + FOR( j = i; j < N; j++ ) + { + FOR( k = 0; k < num_freq_bands; k++ ) + { + brange[0] = band_grouping[k]; + move16(); + brange[1] = band_grouping[k + 1]; + move16(); + CovarianceMatrix *COVls = &( pCOVls[k] ); + + temp64_1_r_acc = W_deposit32_h( COVls->xr_fx[i][j] ); + max_exp_r = s_max( COVls->xr_e[i][j], temp_exp ); + temp64_1_r_acc = W_shl( temp64_1_r_acc, sub( COVls->xr_e[i][j], max_exp_r ) ); // exp:max_exp_r + + temp64_1_i_acc = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j] + max_exp_i = s_max( COVls->xi_e[i][j], temp_exp ); + temp64_1_i_acc = W_shl( temp64_1_i_acc, sub( COVls->xi_e[i][j], max_exp_i ) ); // exp:max_exp_i + + FOR( freq = brange[0]; freq < brange[1]; freq++ ) + { + temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r + temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r + + temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i + temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i + } + + tmp_16 = W_norm( temp64_1_r_acc ); + + COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1_r_acc, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xr_e[i][j] = sub( max_exp_r, tmp_16 ); + move32(); + move16(); + + tmp_16 = W_norm( temp64_1_i_acc ); + + COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1_i_acc, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xi_e[i][j] = sub( max_exp_i, tmp_16 ); + move32(); + move16(); + + } + } + } + return; +} + + +#else /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ @@ -2133,6 +2242,7 @@ static void compute_cov_mtx_fx( } return; } +#endif static void computeIntensityVector_enc_fx( const Word16 *band_grouping, -- GitLab From e8387d0dfa7eee0f96e5f2bbcb1c2370d676f95c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 11:15:29 +0100 Subject: [PATCH 045/750] clang patch --- lib_enc/ivas_mcmasa_enc_fx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 3ac57ff83..9e8c92dc3 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2166,12 +2166,12 @@ static void compute_cov_mtx_fx( FOR( freq = brange[0]; freq < brange[1]; freq++ ) { temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r - temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r + temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i - temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i + temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i } tmp_16 = W_norm( temp64_1_r_acc ); @@ -2187,7 +2187,6 @@ static void compute_cov_mtx_fx( COVls->xi_e[i][j] = sub( max_exp_i, tmp_16 ); move32(); move16(); - } } } -- GitLab From 16d926147e9103126fe331bf58e66cf8802701c3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 11:30:15 +0100 Subject: [PATCH 046/750] activate addcov --- lib_enc/ivas_mcmasa_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 9e8c92dc3..6e4cf18f2 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -42,7 +42,7 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -// #define compute_cov_mtx_fx_ADDCOV +#define compute_cov_mtx_fx_ADDCOV /*------------------------------------------------------------------------- * Local constants -- GitLab From 3339c98f19d7525f7609c32d570e7e0ff7df8340 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 19 Nov 2025 11:15:30 +0000 Subject: [PATCH 047/750] Fix div_w_newton when denominator is 0x40000000. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 867677dd0..58099faca 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3492,6 +3492,19 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( return; } +#ifdef NONBE_OPT_2193_EIG2X2 +static Word32 eig2x2_div_fx( Word32 num, Word32 den ); + +static Word32 eig2x2_div_fx( Word32 num, Word32 den ) +{ + if ( EQ_32( den, 0x40000000 ) ) + { + return num; + } + return div_w_newton( num, den ); +} +#endif + static void eig2x2_fx( const Word32 E1_fx, /*q_E*/ const Word32 E2_fx, /*q_E*/ @@ -3729,7 +3742,7 @@ static void eig2x2_fx( // nvalm[0] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ) ); // exp = sub( nvalq[0], 61 ); - nvalm[0] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ) ); + nvalm[0] = eig2x2_div_fx( ONE_IN_Q30, W_extract_h( nval64m[0] ) ); exp = sub( nvalq[0], 61 ); nvalm[0] = Sqrt32( nvalm[0], &exp ); nvalq[0] = sub( 31, exp ); @@ -3742,7 +3755,7 @@ static void eig2x2_fx( // nvalm[1] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ) ); // exp = sub( nvalq[1], 61 ); - nvalm[1] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ) ); + nvalm[1] = eig2x2_div_fx( ONE_IN_Q30, W_extract_h( nval64m[1] ) ); exp = sub( nvalq[1], 61 ); nvalm[1] = Sqrt32( nvalm[1], &exp ); nvalq[1] = sub( 31, exp ); -- GitLab From 173c88ccfb4d95cabf30775041201c458622fd50 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 13:59:20 +0100 Subject: [PATCH 048/750] put macro to options.h --- lib_com/options.h | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 744952c84..1ab9bb21d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,7 @@ #define NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS /* Nokia: fix basop issue 2233: Fix differing rtpdump streams */ #define NONBE_FIX_2237_ZERO_CURR_NOISE_PROBLEM /* FhG: Modify sum of hTonalMDCTConc->curr_noise_nrg to avoid inaccurate zero */ - +#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: SPeeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 6e4cf18f2..f88c7d4db 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -42,7 +42,6 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#define compute_cov_mtx_fx_ADDCOV /*------------------------------------------------------------------------- * Local constants @@ -72,7 +71,7 @@ static void ivas_mcmasa_dmx_fx( const Word16 nchan_transport, const Word16 nchan_inp ); -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ @@ -931,7 +930,7 @@ void ivas_mcmasa_param_est_enc_fx( Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST Word16 mrange[2]; #else Word16 mrange[2], brange[2]; @@ -1080,7 +1079,7 @@ void ivas_mcmasa_param_est_enc_fx( } inp_q = add( inp_q, sf ); -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix */ compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); @@ -2120,7 +2119,7 @@ static void ivas_mcmasa_dmx_fx( return; } -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( -- GitLab From 167f8cf4fa9db13775eba8fe6a4f17ccc365ebca Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 19 Nov 2025 13:32:50 +0000 Subject: [PATCH 049/750] Address Tommy's comments. --- .../ivas_dirac_dec_binaural_functions_fx.c | 112 +++++++++--------- 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 58099faca..ced1f13ed 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3519,11 +3519,12 @@ static void eig2x2_fx( Word16 *q_D ) { #ifdef NONBE_OPT_2193_EIG2X2 - Word32 s_fx[BINAURAL_CHANNELS]; Word32 pm_fx, add_fx; Word32 tmp1, tmp2, e1, e2, c_re, c_im, c0_im, c1_im; + Word32 condition, s0_fx, s1_fx, nval0_fx, nval1_fx; Word64 crossSquare_fx, tmp3, tmp4; Word16 q_crossSquare, q_min, q_diff, q_tmp1, q_tmp2, exp, q_e, q_c; + Word16 nval0_q, nval1_q; Word32 i01, i00, i11, i10; Word64 eps_fx = ( (Word64) EPSILON_MANT ) << 32; Word16 eps_q = 63 - EPSILON_EXP; @@ -3634,8 +3635,8 @@ static void eig2x2_fx( // Numeric case, when input is practically zeros // if ( D_fx[0] < EPSILON_FX ) - - if ( LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ) ) + condition = LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ); + if ( condition != 0 ) { return; } @@ -3646,8 +3647,8 @@ static void eig2x2_fx( { tmp1 = L_shr( tmp1, q_diff ); } - - if ( LT_32( tmp2, tmp1 ) ) + condition = LT_32( tmp2, tmp1 ); + if ( condition != 0 ) { return; } @@ -3681,84 +3682,79 @@ static void eig2x2_fx( e2 = L_shl( e2, q_diff ); } - s_fx[0] = L_sub( tmp1, e1 ); // D_fx[0] - e1 - tmp1 = L_sub( tmp1, e2 ); // D_fx[0] - e2 - s_fx[1] = L_sub( tmp2, e1 ); // D_fx[1] - e1 - tmp2 = L_sub( tmp2, e2 ); // D_fx[1] - e2 + s0_fx = L_sub( tmp1, e1 ); // D_fx[0] - e1 + tmp1 = L_sub( tmp1, e2 ); // D_fx[0] - e2 + s1_fx = L_sub( tmp2, e1 ); // D_fx[1] - e1 + tmp2 = L_sub( tmp2, e2 ); // D_fx[1] - e2 - i01 = GT_32( L_abs( tmp1 ), L_abs( s_fx[0] ) ); // fabsf( D_fx[0] - e2 ) > fabsf( D_fx[0] - e1 ) - i11 = GT_32( L_abs( tmp2 ), L_abs( s_fx[1] ) ); // fabsf( D_fx[1] - e2 ) > fabsf( D_fx[1] - e1 ) + i01 = GT_32( L_abs( tmp1 ), L_abs( s0_fx ) ); // fabsf( D_fx[0] - e2 ) > fabsf( D_fx[0] - e1 ) + i11 = GT_32( L_abs( tmp2 ), L_abs( s1_fx ) ); // fabsf( D_fx[1] - e2 ) > fabsf( D_fx[1] - e1 ) if ( i01 ) { - s_fx[0] = tmp1; + s0_fx = tmp1; move32(); } if ( i11 ) { - s_fx[1] = tmp2; + s1_fx = tmp2; move32(); } // normVal = sqrtf( 1.0f / ( 1e-12f + crossSquare + s * s ) ); - Word32 nvalm[BINAURAL_CHANNELS]; - Word16 nvalq[BINAURAL_CHANNELS]; - q_tmp2 = shl( q_tmp1, 1 ); q_min = s_min( q_tmp2, q_crossSquare ); q_min = s_min( q_min, eps_q ); - Word64 nval64m[BINAURAL_CHANNELS]; - q_diff = sub( q_tmp2, q_min ); - nval64m[0] = W_shr( W_mult0_32_32( s_fx[0], s_fx[0] ), q_diff ); - nval64m[1] = W_shr( W_mult0_32_32( s_fx[1], s_fx[1] ), q_diff ); + tmp3 = W_shr( W_mult0_32_32( s0_fx, s0_fx ), q_diff ); + tmp4 = W_shr( W_mult0_32_32( s1_fx, s1_fx ), q_diff ); q_diff = sub( q_crossSquare, q_min ); crossSquare_fx = W_shr( crossSquare_fx, q_diff ); - nval64m[0] = W_add( nval64m[0], crossSquare_fx ); - nval64m[1] = W_add( nval64m[1], crossSquare_fx ); + tmp3 = W_add( tmp3, crossSquare_fx ); + tmp4 = W_add( tmp4, crossSquare_fx ); q_diff = sub( eps_q, q_min ); eps_fx = W_shr( eps_fx, q_diff ); - nval64m[0] = W_add( nval64m[0], eps_fx ); - nval64m[1] = W_add( nval64m[1], eps_fx ); + tmp3 = W_add( tmp3, eps_fx ); + tmp4 = W_add( tmp4, eps_fx ); - q_diff = W_norm( nval64m[0] ); - nval64m[0] = W_shl( nval64m[0], q_diff ); - nvalq[0] = add( q_min, q_diff ); + q_diff = W_norm( tmp3 ); + tmp3 = W_shl( tmp3, q_diff ); + nval0_q = add( q_min, q_diff ); - q_diff = W_norm( nval64m[1] ); - nval64m[1] = W_shl( nval64m[1], q_diff ); - nvalq[1] = add( q_min, q_diff ); + q_diff = W_norm( tmp4 ); + tmp4 = W_shl( tmp4, q_diff ); + nval1_q = add( q_min, q_diff ); - // nvalm[0] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ), &exp ); - // exp = sub( exp, sub( 62, nvalq[0] ) ); + // nval0_fx = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( tmp3 ), &exp ); + // exp = sub( exp, sub( 62, nval0_q ) ); // // is equivalent to: // - // nvalm[0] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[0] ) ); - // exp = sub( nvalq[0], 61 ); + // nval0_fx = div_w_newton( ONE_IN_Q30, W_extract_h( tmp3 ) ); + // exp = sub( nval0_q, 61 ); - nvalm[0] = eig2x2_div_fx( ONE_IN_Q30, W_extract_h( nval64m[0] ) ); - exp = sub( nvalq[0], 61 ); - nvalm[0] = Sqrt32( nvalm[0], &exp ); - nvalq[0] = sub( 31, exp ); + nval0_fx = eig2x2_div_fx( ONE_IN_Q30, W_extract_h( tmp3 ) ); + exp = sub( nval0_q, 61 ); + nval0_fx = Sqrt32( nval0_fx, &exp ); + nval0_q = sub( 31, exp ); - // nvalm[1] = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ), &exp ); - // exp = sub( exp, sub( 62, nvalq[1] ) ); + // nval1_fx = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, W_extract_h( tmp4 ), &exp ); + // exp = sub( exp, sub( 62, nval1_q ) ); // // is equivalent to: // - // nvalm[1] = div_w_newton( ONE_IN_Q30, W_extract_h( nval64m[1] ) ); - // exp = sub( nvalq[1], 61 ); + // nval1_fx = div_w_newton( ONE_IN_Q30, W_extract_h( tmp4 ) ); + // exp = sub( nval1_q, 61 ); - nvalm[1] = eig2x2_div_fx( ONE_IN_Q30, W_extract_h( nval64m[1] ) ); - exp = sub( nvalq[1], 61 ); - nvalm[1] = Sqrt32( nvalm[1], &exp ); - nvalq[1] = sub( 31, exp ); + nval1_fx = eig2x2_div_fx( ONE_IN_Q30, W_extract_h( tmp4 ) ); + exp = sub( nval1_q, 61 ); + nval1_fx = Sqrt32( nval1_fx, &exp ); + nval1_q = sub( 31, exp ); q_diff = sub( q_c, q_tmp1 ); q_tmp1 = s_min( q_tmp1, q_c ); @@ -3775,25 +3771,25 @@ static void eig2x2_fx( if ( q_diff < 0 ) { - s_fx[0] = L_shl( s_fx[0], q_diff ); + s0_fx = L_shl( s0_fx, q_diff ); } if ( q_diff < 0 ) { - s_fx[1] = L_shl( s_fx[1], q_diff ); + s1_fx = L_shl( s1_fx, q_diff ); } - q_diff = sub( nvalq[0], nvalq[1] ); - q_tmp2 = s_min( nvalq[0], nvalq[1] ); + q_diff = sub( nval0_q, nval1_q ); + q_tmp2 = s_min( nval0_q, nval1_q ); if ( q_diff > 0 ) { - nvalm[0] = L_shr( nvalm[0], q_diff ); + nval0_fx = L_shr( nval0_fx, q_diff ); } if ( q_diff < 0 ) { - nvalm[1] = L_shl( nvalm[1], q_diff ); + nval1_fx = L_shl( nval1_fx, q_diff ); } *q_U = sub( add( q_tmp1, q_tmp2 ), 31 ); @@ -3815,18 +3811,18 @@ static void eig2x2_fx( c1_im = L_negate( c1_im ); } - Ure_fx[i00][0] = Mpy_32_32( s_fx[0], nvalm[0] ); + Ure_fx[i00][0] = Mpy_32_32( s0_fx, nval0_fx ); move32(); - Ure_fx[i01][0] = Mpy_32_32( c_re, nvalm[0] ); + Ure_fx[i01][0] = Mpy_32_32( c_re, nval0_fx ); move32(); - Uim_fx[i01][0] = Mpy_32_32( c0_im, nvalm[0] ); + Uim_fx[i01][0] = Mpy_32_32( c0_im, nval0_fx ); move32(); - Ure_fx[i10][1] = Mpy_32_32( s_fx[1], nvalm[1] ); + Ure_fx[i10][1] = Mpy_32_32( s1_fx, nval1_fx ); move32(); - Ure_fx[i11][1] = Mpy_32_32( c_re, nvalm[1] ); + Ure_fx[i11][1] = Mpy_32_32( c_re, nval1_fx ); move32(); - Uim_fx[i11][1] = Mpy_32_32( c1_im, nvalm[1] ); + Uim_fx[i11][1] = Mpy_32_32( c1_im, nval1_fx ); move32(); #else Word16 chA, chB, ch; -- GitLab From c902c9dd26617b6171a70fc724a27efc4b58428d Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Nov 2025 14:36:45 +0100 Subject: [PATCH 050/750] revision of constants and includes --- apps/renderer.c | 2 + lib_com/cnst.h | 1506 +++++++---------- lib_com/ivas_agc_com_fx.c | 4 +- lib_com/ivas_cnst.h | 132 +- lib_com/ivas_cov_smooth_fx.c | 2 +- lib_com/ivas_dirac_com_fx.c | 2 - lib_com/ivas_entropy_coder_common_fx.c | 1 - lib_com/ivas_fb_mixer_fx.c | 2 - lib_com/ivas_ism_com_fx.c | 2 - lib_com/ivas_lfe_com_fx.c | 4 +- lib_com/ivas_limiter_fx.c | 9 +- lib_com/ivas_masa_com_fx.c | 1 - lib_com/ivas_mc_com_fx.c | 1 - lib_com/ivas_mc_param_com_fx.c | 1 - lib_com/ivas_mdft_imdft_fx.c | 8 +- lib_com/ivas_omasa_com_fx.c | 2 +- lib_com/ivas_osba_com_fx.c | 2 - lib_com/ivas_qmetadata_com_fx.c | 2 - lib_com/ivas_qspherical_com_fx.c | 2 - lib_com/ivas_rom_com.h | 1 - lib_com/ivas_rom_com_fx.c | 1 - lib_com/ivas_rotation_com_fx.c | 10 +- lib_com/ivas_sba_config_fx.c | 3 - lib_com/ivas_sns_com_fx.c | 4 +- lib_com/ivas_spar_com_fx.c | 4 +- lib_com/ivas_spar_com_quant_util_fx.c | 1 - lib_com/ivas_stat_com.h | 1 - lib_com/ivas_stereo_dft_com_fx.c | 1 - lib_com/ivas_stereo_eclvq_com_fx.c | 2 +- lib_com/ivas_stereo_ica_com_fx.c | 4 +- lib_com/ivas_stereo_td_bit_alloc_fx.c | 1 - lib_com/ivas_tools_fx.c | 6 +- lib_com/ivas_transient_det_fx.c | 2 +- lib_debug/debug.h | 3 + lib_debug/sba_debug.c | 1 + lib_dec/ivas_agc_dec_fx.c | 2 - lib_dec/ivas_binRenderer_internal_fx.c | 4 +- lib_dec/ivas_core_dec_fx.c | 3 +- lib_dec/ivas_cpe_dec_fx.c | 3 - lib_dec/ivas_dirac_dec_fx.c | 2 - lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 5 - lib_dec/ivas_init_dec_fx.c | 4 +- lib_dec/ivas_ism_dtx_dec_fx.c | 1 - lib_dec/ivas_ism_metadata_dec_fx.c | 2 - lib_dec/ivas_ism_param_dec_fx.c | 5 +- lib_dec/ivas_ism_renderer_fx.c | 2 - lib_dec/ivas_jbm_dec_fx.c | 4 - lib_dec/ivas_lfe_dec_fx.c | 1 - lib_dec/ivas_lfe_plc_fx.c | 1 - lib_dec/ivas_masa_dec_fx.c | 5 +- lib_dec/ivas_mc_param_dec_fx.c | 9 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 4 - lib_dec/ivas_mct_core_dec_fx.c | 7 +- lib_dec/ivas_mct_dec_fx.c | 3 - lib_dec/ivas_mdct_core_dec_fx.c | 7 +- lib_dec/ivas_mono_dmx_renderer_fx.c | 4 - lib_dec/ivas_objectRenderer_internal_fx.c | 3 +- lib_dec/ivas_omasa_dec_fx.c | 2 - lib_dec/ivas_out_setup_conversion_fx.c | 6 +- lib_dec/ivas_pca_dec_fx.c | 2 +- lib_dec/ivas_post_proc_fx.c | 2 - lib_dec/ivas_qmetadata_dec_fx.c | 1 - lib_dec/ivas_range_uni_dec_fx.c | 2 - lib_dec/ivas_rom_dec_fx.c | 3 - lib_dec/ivas_sba_dec_fx.c | 6 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 12 +- lib_dec/ivas_sba_rendering_internal_fx.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 2 - lib_dec/ivas_sns_dec_fx.c | 3 +- lib_dec/ivas_spar_decoder_fx.c | 4 - lib_dec/ivas_spar_md_dec_fx.c | 2 +- lib_dec/ivas_stereo_cng_dec_fx.c | 2 - lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 2 - lib_dec/ivas_stereo_dft_dec_fx.c | 4 - lib_dec/ivas_stereo_dft_plc_fx.c | 3 +- lib_dec/ivas_stereo_ica_dec_fx.c | 3 - lib_dec/ivas_stereo_icbwe_dec_fx.c | 2 - lib_dec/ivas_stereo_mdct_core_dec_fx.c | 4 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 2 - lib_dec/ivas_stereo_switching_dec_fx.c | 5 +- lib_dec/ivas_stereo_td_dec_fx.c | 3 - lib_dec/ivas_svd_dec_fx.c | 5 +- lib_dec/ivas_tcx_core_dec_fx.c | 6 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 - lib_dec/lib_dec_fx.c | 1 - lib_enc/enc_acelp_fx.c | 2 +- lib_enc/igf_enc_fx.c | 2 +- lib_enc/ivas_agc_enc_fx.c | 3 - lib_enc/ivas_core_enc_fx.c | 4 - lib_enc/ivas_core_pre_proc_front_fx.c | 6 - lib_enc/ivas_core_pre_proc_fx.c | 3 - lib_enc/ivas_corecoder_enc_reconfig_fx.c | 5 +- lib_enc/ivas_cpe_enc_fx.c | 4 - lib_enc/ivas_decision_matrix_enc_fx.c | 6 +- lib_enc/ivas_dirac_enc_fx.c | 2 - lib_enc/ivas_enc_fx.c | 4 +- lib_enc/ivas_entropy_coder_fx.c | 2 +- lib_enc/ivas_front_vad_fx.c | 5 - lib_enc/ivas_ism_dtx_enc_fx.c | 1 - lib_enc/ivas_ism_metadata_enc_fx.c | 1 - lib_enc/ivas_ism_param_enc_fx.c | 2 - lib_enc/ivas_lfe_enc_fx.c | 2 +- lib_enc/ivas_masa_enc_fx.c | 1 - lib_enc/ivas_mc_param_enc_fx.c | 6 +- lib_enc/ivas_mc_paramupmix_enc_fx.c | 5 +- lib_enc/ivas_mct_core_enc_fx.c | 4 +- lib_enc/ivas_mct_enc_fx.c | 3 - lib_enc/ivas_mct_enc_mct_fx.c | 1 - lib_enc/ivas_mdct_core_enc_fx.c | 5 +- lib_enc/ivas_omasa_enc_fx.c | 1 - lib_enc/ivas_osba_enc_fx.c | 1 - lib_enc/ivas_pca_enc_fx.c | 2 - lib_enc/ivas_qmetadata_enc_fx.c | 1 - lib_enc/ivas_qspherical_enc_fx.c | 1 - lib_enc/ivas_range_uni_enc_fx.c | 2 - lib_enc/ivas_rom_enc_fx.c | 1 - lib_enc/ivas_sba_enc_fx.c | 4 - lib_enc/ivas_sce_enc_fx.c | 3 - lib_enc/ivas_sns_enc_fx.c | 3 - lib_enc/ivas_spar_encoder_fx.c | 1 - lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/ivas_stereo_adapt_GR_enc_fx.c | 3 +- lib_enc/ivas_stereo_classifier_fx.c | 35 +- lib_enc/ivas_stereo_cng_enc_fx.c | 3 - lib_enc/ivas_stereo_dft_enc_fx.c | 8 +- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 21 +- lib_enc/ivas_stereo_dft_td_itd_fx.c | 3 - lib_enc/ivas_stereo_dmx_evs_fx.c | 4 - lib_enc/ivas_stereo_eclvq_enc_fx.c | 1 - lib_enc/ivas_stereo_ica_enc_fx.c | 3 - lib_enc/ivas_stereo_icbwe_enc_fx.c | 2 - lib_enc/ivas_stereo_mdct_core_enc_fx.c | 6 +- lib_enc/ivas_stereo_mdct_igf_enc_fx.c | 5 +- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 3 - lib_enc/ivas_stereo_switching_enc_fx.c | 3 +- lib_enc/ivas_stereo_td_analysis_fx.c | 3 - lib_enc/ivas_stereo_td_enc_fx.c | 4 +- lib_enc/ivas_tcx_core_enc_fx.c | 5 +- lib_enc/ivas_td_low_rate_enc_fx.c | 2 - lib_enc/lib_enc_fx.c | 2 +- lib_enc/lp_exc_e_fx.c | 2 +- lib_isar/isar_cnst.h | 2 + lib_isar/isar_rom_post_rend.c | 2 +- lib_rend/ivas_allrad_dec_fx.c | 1 - lib_rend/ivas_cldfb_ring_buffer.c | 2 +- lib_rend/ivas_crend_fx.c | 2 - .../ivas_dirac_dec_binaural_functions_fx.c | 5 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 9 +- lib_rend/ivas_dirac_onsets_dec_fx.c | 1 - lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 - lib_rend/ivas_dirac_rend_fx.c | 2 - lib_rend/ivas_efap_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 3 +- lib_rend/ivas_mcmasa_ana_fx.c | 7 +- lib_rend/ivas_objectRenderer_fx.c | 3 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 2 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 6 - lib_rend/ivas_objectRenderer_sources_fx.c | 1 - lib_rend/ivas_objectRenderer_vec_fx.c | 1 - lib_rend/ivas_omasa_ana_fx.c | 3 +- lib_rend/ivas_orient_trk_fx.c | 2 +- lib_rend/ivas_reflections_fx.c | 4 +- lib_rend/ivas_reverb_delay_line_fx.c | 4 + lib_rend/ivas_reverb_fft_filter_fx.c | 4 +- lib_rend/ivas_reverb_filter_design_fx.c | 1 - lib_rend/ivas_reverb_fx.c | 4 +- lib_rend/ivas_reverb_iir_filter_fx.c | 5 + lib_rend/ivas_reverb_utils_fx.c | 1 - lib_rend/ivas_rom_TdBinauralRenderer.h | 1 - lib_rend/ivas_rom_TdBinauralRenderer_fx.c | 1 - lib_rend/ivas_rom_binauralRenderer.h | 1 - lib_rend/ivas_rom_binauralRenderer_fx.c | 1 - lib_rend/ivas_rotation_fx.c | 9 +- lib_rend/ivas_sba_rendering_fx.c | 3 +- lib_rend/ivas_shoebox_fx.c | 1 - lib_rend/ivas_stat_rend.h | 2 - lib_rend/ivas_td_decorr_fx.c | 49 +- lib_rend/ivas_vbap_fx.c | 2 +- lib_rend/lib_rend.h | 1 - lib_rend/lib_rend_fx.c | 14 +- lib_util/ambi_convert.c | 5 +- lib_util/ambi_convert.h | 5 +- lib_util/ivas_rtp_pi_data.c | 11 +- 183 files changed, 911 insertions(+), 1399 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 8256f1e46..404c1bbcf 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -99,6 +99,8 @@ static * Local structures *------------------------------------------------------------------------------------------*/ +typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][RENDERER_MAX_OUTPUT_CHANNELS]; + typedef struct { uint32_t frameCounter; diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 8aecbedaf..26ade8800 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -42,113 +42,11 @@ #include "stl.h" /* clang-format off */ -#define MATRIX_CONSTANT (759250113) -#define NUM_SAMPLES_960 (960) -#define NUM_SAMPLES_720 (720) -#define NUM_SAMPLES_640 (640) -#define NUM_SAMPLES_320 (320) -#define NUM_SAMPLES_160 (160) -#define L_SUBFRAME_48k (240) -#define L_SUBFRAME_32k (160) -#define L_SUBFRAME_16k (80) -#define L_SUBFRAME_8k (40) -#define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */ -#define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */ -#define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */ -#define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */ -#define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */ -#define Q31_BY_SUB_FRAME_240 ( 8985287 ) /* 1/239 in Q31 */ -#define Q31_BY_SUB_FRAME_180 ( 11997115 ) /* 1/179 in Q31 */ -#define Q31_BY_SUB_FRAME_80 ( 27183337 ) /* 1/79 in Q31 */ -#define Q31_BY_SUB_FRAME_40 ( 55063683 ) /* 1/39 in Q31 */ - -/*----------------------------------------------------------------------------------* - *Q values - *----------------------------------------------------------------------------------*/ - -#define Q1 1 -#define Q2 2 -#define Q3 3 -#define Q4 4 -#define Q5 5 -#define Q6 6 -#define Q7 7 -#define Q8 8 -#define Q9 9 -#define Q10 10 -#define Q11 11 -#define Q12 12 -#define Q13 13 -#define Q14 14 -#define Q15 15 -#define Q16 16 -#define Q17 17 -#define Q18 18 -#define Q19 19 -#define Q20 20 -#define Q21 21 -#define Q22 22 -#define Q23 23 -#define Q24 24 -#define Q25 25 -#define Q26 26 -#define Q27 27 -#define Q28 28 -#define Q29 29 -#define Q30 30 -#define Q31 31 - -/*----------------------------------------------------------------------------------* - * one in Q - *----------------------------------------------------------------------------------*/ - -#define ONE_IN_Q1 2 -#define ONE_IN_Q2 4 -#define ONE_IN_Q3 8 -#define ONE_IN_Q4 16 -#define ONE_IN_Q5 32 -#define ONE_IN_Q6 64 -#define ONE_IN_Q7 128 -#define ONE_IN_Q8 256 -#define ONE_IN_Q9 512 -#define ONE_IN_Q10 1024 -#define ONE_IN_Q11 2048 -#define ONE_IN_Q12 4096 -#define ONE_IN_Q13 8192 -#define ONE_IN_Q14 16384 -#define ONE_IN_Q15 32768 -#define ONE_IN_Q16 65536 -#define ONE_IN_Q17 131072 -#define ONE_IN_Q18 262144 -#define ONE_IN_Q19 524288 -#define ONE_IN_Q20 1048576 -#define ONE_IN_Q21 2097152 -#define ONE_IN_Q22 4194304 -#define ONE_IN_Q23 8388608 -#define ONE_IN_Q24 16777216 -#define ONE_IN_Q25 33554432 -#define ONE_IN_Q26 67108864 -#define ONE_IN_Q27 134217728 -#define ONE_IN_Q28 268435456 -#define ONE_IN_Q29 536870912 -#define ONE_IN_Q30 1073741824 -#define ONE_IN_Q31 0x7fffffff -#define MINUS_ONE_IN_Q31 (-2147483647 - 1) -#define TWO_IN_Q29 1073741824 -#define FOUR_IN_Q28 1073741824 - -#define MAX_WORD16 32767 -#define ONE_IN_Q45 (Word64)0x200000000000 -#define ONE_IN_Q62 (Word64)0x4000000000000000 /*----------------------------------------------------------------------------------* * General constants *----------------------------------------------------------------------------------*/ -#define DEGREE_90_Q_22 377487360 -#define DEGREE_180_Q_22 754974720 -#define DEGREE_360_Q_22 1509949440 - #define MODE1 1 #define MODE2 2 @@ -156,28 +54,18 @@ #define PI2 ( 2 * EVS_PI ) #define RANDOM_INITSEED 21845 /* Seed for random generators */ -#ifndef FLT_MIN -#define FLT_MIN ( 1.175494351e-38F ) -#define FLT_MIN_10_EXP (-37) // min decimal exponent -#define FLT_MIN_EXP (-125) // min binary exponent -#endif -#ifndef FLT_MAX -#define FLT_MAX ( 3.402823466e+38F ) -#endif +//#define FLT_MIN ( 1.175494351e-38F ) +//#define FLT_MAX ( 3.402823466e+38F ) #define TRUE 1 #define FALSE 0 #define MAX16B 32767 #define MIN16B ( -32768 ) -#define MAX16B_FLT 32767.0f -#define MIN16B_FLT ( -32768.0f ) -#define MIN16B_FLT_FX -32768 //Q0 -#define MIN16B_FLT_FX_IN_Q11 -67108864//Q11 -#define MIN16B_FLT_FX_IN_Q15 -1073741824//Q15 -#define PCM16_TO_FLT_FAC 32768.0f -#define PCM16_TO_FLT_FAC_FX 32768 //Q0 -#define PCM16_TO_FLT_FAC_FX_Q15 1073741824L //16Q15 -#define MDFT_NORM_SCALING ( 1.0f / PCM16_TO_FLT_FAC ) +#define MIN16B_FLT_FX -32768 //Q0 +#define MIN16B_FLT_FX_IN_Q11 -67108864//Q11 +#define MIN16B_FLT_FX_IN_Q15 -1073741824//Q15 +#define PCM16_TO_FLT_FAC_FX 32768 //Q0 +#define PCM16_TO_FLT_FAC_FX_Q15 1073741824L //16Q15 #define MDFT_NORM_SCALING_FX 65536 //Q31 #define LOG2_MDFT_NORM_SCALING_FX -503316448 //Q25 #define MAX_FRAME_COUNTER 200 @@ -626,7 +514,7 @@ enum #define N_WS2N_FRAMES 40 /* number of frames for attenuation during the band-width switching */ #define N_NS2W_FRAMES 20 /* number of frames for attenuation during the band-width switching */ -#define ONE_BY_N_NS2W_FRAMES_Q15 ( 1638 ) +#define ONE_BY_N_NS2W_FRAMES_Q15 ( 1638 ) /*----------------------------------------------------------------------------------* * Coder types (only for ACELP core when not running in AMR-WB IO mode) @@ -708,14 +596,14 @@ enum #define AUTO_REGRESSIVE 2 #define INT_FS_12k8 12800 /* internal sampling frequency */ -#define ONE_BY_INT_FS_12k8_Q42 343597384 /* internal sampling frequency */ +#define ONE_BY_INT_FS_12k8_Q42 343597384 /* internal sampling frequency */ #define M 16 /* order of the LP filter @ 12.8kHz */ #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ #define L_SUBFR ( L_FRAME / NB_SUBFR ) /* subframe size */ #define L_SUBFR_LOG2 6 /* To be used for shift operation instead of division */ -#define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ -#define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */ +#define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ +#define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */ #define L_INP_MEM ( L_LOOK_16k + ( ( L_LP_16k - ( NS2SA( INT_FS_16k, ACELP_LOOK_NS ) + L_SUBFR16k / 2 ) ) - 3 * L_SUBFR16k / 2 ) ) /*=240 samples length of memory of input signal, given by the Look-Ahead + the past memory (max needed for the LP window at 16 kHz) */ #define L_INP_12k8 ( L_INP_MEM + L_FRAME ) /* length of input signal buffer @12.8kHz */ @@ -736,8 +624,7 @@ enum #define OLD_SYNTH_SIZE_ENC L_FRAME32k + L_FRAME32k / 4 /* encoder synth memory */ #define OLD_EXC_SIZE_DEC ( 3 * L_FRAME_MAX / 2 + 2 * L_FIR_FER2 ) /*old excitation needed for decoder for PLC*/ -#define TILT_CODE_FLT 0.3f /* ACELP code preemphasis factor */ -#define TILT_CODE 9830 /* ACELP code preemphasis factor ~=0.3f (0Q15) (=0.299987792968750) */ +#define TILT_CODE 9830 /* ACELP code preemphasis factor ~=0.3f (0Q15) (=0.299987792968750) */ #define L_SUBFR16k ( L_FRAME16k / NB_SUBFR ) /* subframe size at 16kHz */ #define L_HALFR16k ( 2 * L_SUBFR16k ) /* half-frame size at 16kHz */ @@ -745,34 +632,27 @@ enum #define MAX_LP_FILTER_ORDER 20 /* Max order of an LP filter */ #define L_INTERPOL2 16 /* Length of filter for interpolation */ #define L_INTERPOL ( L_INTERPOL2 + 1 ) /* Length of filter for interpolation */ -#define TILT_FAC 0.68f /* tilt factor (denominator) */ -#define TILT_FAC_FX 22282 /* tilt factor (denominator) fixed-point*/ +#define TILT_FAC_FX 22282 /* tilt factor (denominator) fixed-point, 0.68f */ #define M16k 20 /* order of the LP filter @ 16kHz */ -#define PIT_SHARP 0.85f /* pitch sharpening factor */ -#define PIT_SHARP_fx 27853 /* pitch sharpening factor */ +#define PIT_SHARP_fx 27853 /* pitch sharpening factor, 0.85f */ #define PIT_UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ -#define UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ +#define UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ #define PIT_L_INTERPOL2 16 #define PIT_FIR_SIZE2 ( PIT_UP_SAMP * PIT_L_INTERPOL2 + 1 ) #define PIT_UP_SAMP6 6 #define PIT_L_INTERPOL6_2 17 #define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 ) -#define E_MIN 0.0035f /* minimum allowable energy */ -#define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/ -#define E_MIN_Q27_FX 469762 /* minimum allowable energy in Q27*/ -#define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */ -#define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */ -#define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ -#define E_MIN_FX 1 /* QSCALE (Q7)*/ -#define E_MIN_IVAS_FX 1835 /* (Q19) (E12) */ -#define E_MIN_IVAS_FX_Q31 7516193 /* (Q31) (0.0035f) */ - -#define STEP_DELTA_FX 11 -#define FORMANT_SHARPENING_NOISE_THRESHOLD_FX 5376 /* 21 (!8)lp_noise level above which formant sharpening is deactivated - at this level most of 20 dB SNR office noisy speech still uses sharpening */ - -#define LP_NOISE_THRESH_FLT 20.f -#define LP_NOISE_THRESH 167772160l/*20.f Q23*/ -#define LFAC 160 /* FAC maximum frame length */ +#define E_MIN_Q11_FX 7 /* minimum allowable energy, 0.0035f in Q11 */ +#define E_MIN_Q27_FX 469762 /* minimum allowable energy, 0.0035f in Q27 */ +#define E_MIN_FX 1 /* QSCALE (Q7)*/ +#define E_MIN_IVAS_FX 1835 /* (Q19) (E12) */ +#define E_MIN_IVAS_FX_Q31 7516193 /* (Q31) (0.0035f) */ + +#define STEP_DELTA_FX 11 /* quantization step for tilt compensation of gaussian cb. excitation, 0.0625f */ +#define FORMANT_SHARPENING_NOISE_THRESHOLD_FX 5376 /* 21.f (!8)lp_noise level above which formant sharpening is deactivated - at this level most of 20 dB SNR office noisy speech still uses sharpening */ + +#define LP_NOISE_THRESH 167772160l /* 20.f Q23 */ +#define LFAC 160 /* FAC maximum frame length */ #define L_FILT_UP8k 24 /* Resampling - delay of filter for 8 kHz output signals (at 12.8 kHz sampling rate) */ #define LEN_WIN_SSS 120 @@ -818,36 +698,22 @@ typedef enum } CLDFB_PROTOTYPE; /* pre-calculated scale values for the cldfb filter prototypes - values are calculated like this: sqrt( 6400 / no_cldfb_channels * sum(filter[k]**2)) */ -#define CLDFB80_10_SCALE 88.293854f -#define CLDFB80_16_SCALE 88.299622f -#define CLDFB80_20_SCALE 88.300926f -#define CLDFB80_30_SCALE 88.234489f -#define CLDFB80_32_SCALE 88.303848f -#define CLDFB80_40_SCALE 88.304726f -#define CLDFB80_60_SCALE 88.028412f -#define CLDFB80_10_SCALE_FX_Q8 ( 22603 ) -#define CLDFB80_16_SCALE_FX_Q8 ( 22605 ) -#define CLDFB80_20_SCALE_FX_Q8 ( 22605 ) -#define CLDFB80_30_SCALE_FX_Q8 ( 22588 ) -#define CLDFB80_32_SCALE_FX_Q8 ( 22606 ) -#define CLDFB80_40_SCALE_FX_Q8 ( 22606 ) -#define CLDFB80_60_SCALE_FX_Q8 ( 22535 ) - -#define LDQMF_10_SCALE 84.567841f -#define LDQMF_16_SCALE 84.567932f -#define LDQMF_20_SCALE 84.567963f -#define LDQMF_30_SCALE 84.501907f -#define LDQMF_32_SCALE 84.568001f -#define LDQMF_40_SCALE 84.567986f -#define LDQMF_60_SCALE 84.303284f -#define LDQMF_10_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_16_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_20_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_30_SCALE_FX_Q8 ( 21632 ) -#define LDQMF_32_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_40_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_60_SCALE_FX_Q8 ( 21582 ) + values are calculated like this: sqrt( 6400 / no_cldfb_channels * sum(filter[k]**2)) */ +#define CLDFB80_10_SCALE_FX_Q8 ( 22603 ) /* 88.293854f */ +#define CLDFB80_16_SCALE_FX_Q8 ( 22605 ) /* 88.299622f */ +#define CLDFB80_20_SCALE_FX_Q8 ( 22605 ) /* 88.300926f */ +#define CLDFB80_30_SCALE_FX_Q8 ( 22588 ) /* 88.234489f */ +#define CLDFB80_32_SCALE_FX_Q8 ( 22606 ) /* 88.303848f */ +#define CLDFB80_40_SCALE_FX_Q8 ( 22606 ) /* 88.304726f */ +#define CLDFB80_60_SCALE_FX_Q8 ( 22535 ) /* 88.028412f */ + +#define LDQMF_10_SCALE_FX_Q8 ( 21649 ) /* 84.567841f */ +#define LDQMF_16_SCALE_FX_Q8 ( 21649 ) /* 84.567932f */ +#define LDQMF_20_SCALE_FX_Q8 ( 21649 ) /* 84.567963f */ +#define LDQMF_30_SCALE_FX_Q8 ( 21632 ) /* 84.501907f */ +#define LDQMF_32_SCALE_FX_Q8 ( 21649 ) /* 84.568001f */ +#define LDQMF_40_SCALE_FX_Q8 ( 21649 ) /* 84.567986f */ +#define LDQMF_60_SCALE_FX_Q8 ( 21582 ) /* 84.303284f */ #define L_FFT 256 /* Spectral analysis - length of the FFT */ #define LOG2_L_FFT 8 /* Spectral analysis - log2 of L_FFT */ @@ -860,16 +726,14 @@ typedef enum #define VOIC_BAND_8k 17 /* Spectral analysis - number of critical bands considered as voiced in NB (related to VOIC_BINS_8k) */ #define N_SPEC (L_FFT/2) /* number of spectral bins */ -#define M_ALPHA 0.9f /* Multi-harm analysis - forgetting factor of LT correlation map */ -#define M_GAMMA 0.99f /* Multi-harm analysis - forgetting factor of active speech decision predictor */ #define THR_CORR 56 /* Multi-harm analysis - starting threshold of multi-harm. correlation */ -#define M_GAMMA_FX 32440 /* Q15 - forgetting factor of active speech decision predictor */ -#define M_ALPHA_FX 29491 /* Q15 - forgetting factor of LT correlation map */ -#define ONE_MINUS_M_ALPHA 3277 /* Q15 - one minus forgetting factor of LT correlation map */ -#define THR_CORR_INIT_FX (56<<9 ) /* Q9 - starting threshold of multi-harm. correlation */ -#define THR_NCHAR_WB_FX 2048 /* Q11 threshold for noise character (WB) */ -#define THR_NCHAR_NB_FX 2048 /* Q11 threshold for noise character (NB) */ +#define M_GAMMA_FX 32440 /* 0.99f in Q15 - forgetting factor of active speech decision predictor */ +#define M_ALPHA_FX 29491 /* 0.9f in Q15 - forgetting factor of LT correlation map */ +#define ONE_MINUS_M_ALPHA 3277 /* Q15 - one minus forgetting factor of LT correlation map */ +#define THR_CORR_INIT_FX (56<<9 ) /* Q9 - starting threshold of multi-harm. correlation */ +#define THR_NCHAR_WB_FX 2048 /* Q11 threshold for noise character (WB) */ +#define THR_NCHAR_NB_FX 2048 /* Q11 threshold for noise character (NB) */ #define L_LP 320 /* LP analysis - LP window size */ @@ -877,7 +741,7 @@ typedef enum #define L_LP_AMR_WB 384 /* LP analysis - windows size (only for AMR-WB IO mode) */ #define GRID50_POINTS 51 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ #define GRID40_POINTS 41 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ -#define GRID80_POINTS 80 /* LP analysis - number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ +#define GRID80_POINTS 80 /* LP analysis - number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ #define GRID100_POINTS 100 /* LP analysis - number of points to evaluate Chebyshev polynomials */ #define PIT_MIN 34 /* OL pitch analysis - Minimum pitch lag */ @@ -910,7 +774,7 @@ typedef enum #define PIT_MAX_32k 577 #define PIT_FR1_8b_32k 75 #define PIT_MAX_MAX PIT_MAX_32k -#define PIT_MAX_16k 289 +#define PIT_MAX_16k 289 #define PIT_FR1_8b 92 /* Pitch encoding - Minimum pitch lag with resolution 1 */ #define PIT_FR2_9b 128 /* Pitch encoding - Minimum pitch lag with resolution 1/2 */ @@ -942,25 +806,20 @@ typedef enum #define DTX_THR 5 /* DTX - lp_noise threshold for DTX at higher bitrates */ #define DTX_HIST_SIZE 8 /* CNG & DTX - number of last signal frames used for CNG averaging */ -#define CNG_ISF_FACT 0.9f /* CNG & DTX - CNG spectral envelope smoothing factor */ -#define STEP_AMR_WB_SID 2.625f /* CNG & DTX - CNG energy quantization step */ -#define CNG_ISF_FACT_FX 29491 /* Q15(0.9), CNG & DTX - CNG spectral envelope smoothing factor*/ -#define STEP_AMR_WB_SID_FX 10752 /* Q12 */ +#define CNG_ISF_FACT_FX 29491 /* Q15 (0.9f), CNG & DTX - CNG spectral envelope smoothing factor*/ +#define STEP_AMR_WB_SID_FX 10752 /* Q12 (2.625f), CNG & DTX - CNG energy quantization step */ #define HO_HIST_SIZE 8 /* CNG & DTX - maximal number of hangover frames used for averaging */ #define NUM_ENV_CNG 20 -#define BUF_L_NRG 0.7f /* CNG & DTX - lower threshold factor for hangover updates */ -#define BUF_H_NRG 1.03f /* CNG & DTX - higher threshold factor for hangover updates */ #define CNG_TYPE_HO 20 /* CNG & DTX - hangover for switching between CNG types */ -#define BUF_L_NRG_FX 22938 /* Q15(0.7), CNG & DTX - lower threshold offset for hangover updates */ -#define ONE_OVER_BUF_H_NRG_FX 31814 /* Q15(1/1.03), CNG & DTX - inverse of higher threshold offset for hangover updates */ -#define HO_ATT_FAC_FX 3277 /* Q15(0.1), CNG & DTX - Hangover frame attenuation rate factor */ +#define BUF_L_NRG_FX 22938 /* Q15(0.7), CNG & DTX - lower threshold offset for hangover updates */ +#define ONE_OVER_BUF_H_NRG_FX 31814 /* Q15(1/1.03), CNG & DTX - inverse of higher threshold offset for hangover updates */ +#define HO_ATT_FAC_FX 3277 /* Q15(0.1), CNG & DTX - Hangover frame attenuation rate factor */ #define BUF_DEC_RATE 25 /* CNG & DTX - buffer size decrease rate for active frames */ -#define STEP_SID 5.25f /* CNG & DTX - CNG energy quantization step */ -#define STEP_SID_FX 21504 /* Q12 */ -#define ISTEP_SID_FX 6242 /* Inverse of CNG & DTX - CNG energy quantization step in Q15(1/5.25 in Q15)*/ -#define ISTEP_AMR_WB_SID_FX 12483 /* Q15(1/2.625) Inverse of CNG & DTX - CNG energy quantization step */ +#define STEP_SID_FX 21504 /* CNG & DTX - CNG energy quantization step, 5.25f in Q12 */ +#define ISTEP_SID_FX 6242 /* Inverse of CNG & DTX - CNG energy quantization step in Q15(1/5.25 in Q15)*/ +#define ISTEP_AMR_WB_SID_FX 12483 /* Q15(1/2.625) Inverse of CNG & DTX - CNG energy quantization step */ #define MIN_ACT_CNG_UPD 20 /* DTX - Minimum number of consecutive active frames for CNG mode update */ @@ -968,11 +827,10 @@ typedef enum #define TOTALNOISE_HIST_SIZE 4 -#define SUBFFT_QIN 10 -#define DATAFFT_Q 5 -#define SUBFFT_QOUT SUBFFT_QIN-DATAFFT_Q -#define SPECAMP_Q SUBFFT_QIN - +#define SUBFFT_QIN 10 +#define DATAFFT_Q 5 +#define SUBFFT_QOUT SUBFFT_QIN-DATAFFT_Q +#define SPECAMP_Q SUBFFT_QIN #define UNKNOWN_NOISE 0 /* unknown noisy type */ #define SILENCE 1 /* speech with high SNR */ @@ -985,10 +843,8 @@ typedef enum #define PRE_SNR_NUM 32 /* number of snr to calculate average SNR of all sub-bands */ #define POWER_NUM 56 /* number of energy of several frames*/ #define PRE_SPEC_DIF_NUM 56 /* number of energy of several frames*/ -#define CLDFBVAD_VAD_ON 1 -#define COM_VAD_ON 2 - - +#define CLDFBVAD_VAD_ON 1 +#define COM_VAD_ON 2 #define MAX_SUBBAND_NUM 12 /* max number of sub-band divided non-uniformly*/ #define BG_ENG_NUM MAX_SUBBAND_NUM /* number of energy of sub-band divided non-uniformly*/ @@ -998,19 +854,17 @@ typedef enum #define STABLE_NUM 4 /* number of time-domain stable rate*/ #define SFM_NUM 3 /* number of spectral flatness */ -#define MAX_CORR_SHIFT_FX 16384 /* corrshift limit, 0.5 in Q15 */ - +#define MAX_CORR_SHIFT_FX 16384 /* corrshift limit, 0.5 in Q15 */ #define START_NG 5 /* Stationary noise UV modification */ #define FULL_NG 10 /* Stationary noise UV modification */ -#define ISP_SMOOTHING_QUANT_A1 0.9f /* Stationary noise UV modification */ -#define ISP_SMOOTHING_QUANT_A1_FX 29491 /* 0.9f in Q15 */ /* Stationary noise UV modification */ +#define ISP_SMOOTHING_QUANT_A1_FX 29491 /* Stationary noise UV modification, 0.9f in Q15 */ -#define KP559016994_FX 18318 /* EDCT & EMDCT constants */ -#define KP951056516_FX 31164 /* EDCT & EMDCT constants */ -#define KP587785252_FX 19261 /* EDCT & EMDCT constants */ -#define KP866025403_FX 28378 /* EDCT & EMDCT constants */ -#define KP250000000_FX 8192 /* EDCT & EMDCT constants */ +#define KP559016994_FX 18318 /* EDCT & EMDCT constants */ +#define KP951056516_FX 31164 /* EDCT & EMDCT constants */ +#define KP587785252_FX 19261 /* EDCT & EMDCT constants */ +#define KP866025403_FX 28378 /* EDCT & EMDCT constants */ +#define KP250000000_FX 8192 /* EDCT & EMDCT constants */ #define FEC_BITS_CLS 2 /* FEC - number of bits for clas information */ #define FEC_BITS_ENR 5 /* FEC - number of bits for energy information */ @@ -1032,34 +886,23 @@ typedef enum #define BWS_TRAN_PERIOD 5 /* BWS - number of frames for transition period */ #define ONE_BY_BWS_TRAN_PERIOD_Q15 6554 -#define PREEMPH_FAC_FLT 0.68f /* preemphasis factor at 12.8kHz */ -#define PREEMPH_FAC_16k_FLT 0.72f -#define PREEMPH_FAC_SWB_FLT 0.9f /* preemphasis factor for super wide band */ -#define GAMMA1_FLT 0.92f /* weighting factor (numerator) default:0.92 */ -#define GAMMA16k_FLT 0.94f - -#define FORMANT_SHARPENING_G1_FLT 0.75f /* Formant sharpening numerator weighting at 12.8kHz */ -#define FORMANT_SHARPENING_G2_FLT 0.9f /* Formant sharpening denominator weighting at 12.8kHz */ -#define FORMANT_SHARPENING_G1_16k_FLT 0.8f /* Formant sharpening numerator weighting at 16kHz */ -#define FORMANT_SHARPENING_G2_16k_FLT 0.92f /* Formant sharpening denominator weighting at 16kHz */ - -#define PREEMPH_FAC 22282 /* preemphasis factor at 12.8kHz (0.68f in 0Q15) */ -#define PREEMPH_FAC_16k 23593 /* preemphasis factor at 16kHz (0.72f in 0Q15) */ -#define PREEMPH_FAC_SWB 29491 /* preemphasis factor for super wide band (0.9f in 0Q15) */ -#define GAMMA1 30147 /* weighting factor (numerator) default:0.92 (0Q15format) */ -#define GAMMA1_INV 17809 /* weighting factor (numerator) default:0.92 (1Q14format) */ -#define GAMMA16k 30802 /* weighting factor (numerator) default:0.94 (0Q15format) */ -#define GAMMA16k_INV 17430 /* weighting factor (numerator) default:0.94 (1Q14format) */ - -#define FORMANT_SHARPENING_G1 24576 /* Formant sharpening numerator weighting at 12.8kHz (0.75f) */ -#define FORMANT_SHARPENING_G2 29491 /* Formant sharpening denominator weighting at 12.8kHz (0.9f) */ -#define FORMANT_SHARPENING_G1_16k 26214 /* Formant sharpening numerator weighting at 16kHz (0.8f) */ -#define FORMANT_SHARPENING_G2_16k 30147 /* Formant sharpening denominator weighting at 16kHz (0.92f) */ - -#define LD_FSCALE_DENOM 9 +#define PREEMPH_FAC 22282 /* preemphasis factor at 12.8kHz (0.68f in 0Q15) */ +#define PREEMPH_FAC_16k 23593 /* preemphasis factor at 16kHz (0.72f in 0Q15) */ +#define PREEMPH_FAC_SWB 29491 /* preemphasis factor for super wide band (0.9f in 0Q15) */ +#define GAMMA1 30147 /* weighting factor (numerator) default:0.92 (0Q15format) */ +#define GAMMA1_INV 17809 /* weighting factor (numerator) default:0.92 (1Q14format) */ +#define GAMMA16k 30802 /* weighting factor (numerator) default:0.94 (0Q15format) */ +#define GAMMA16k_INV 17430 /* weighting factor (numerator) default:0.94 (1Q14format) */ + +#define FORMANT_SHARPENING_G1 24576 /* Formant sharpening numerator weighting at 12.8kHz (0.75f) */ +#define FORMANT_SHARPENING_G2 29491 /* Formant sharpening denominator weighting at 12.8kHz (0.9f) */ +#define FORMANT_SHARPENING_G1_16k 26214 /* Formant sharpening numerator weighting at 16kHz (0.8f) */ +#define FORMANT_SHARPENING_G2_16k 30147 /* Formant sharpening denominator weighting at 16kHz (0.92f) */ + +#define LD_FSCALE_DENOM 9 #define FSCALE_DENOM (1 << LD_FSCALE_DENOM) -#define FSCALE_DENOM_HALF FSCALE_DENOM/2 -#define FSCALE_E 2 +#define FSCALE_DENOM_HALF FSCALE_DENOM/2 +#define FSCALE_E 2 #define ACELP_FIXED_CDK_NB 41 #define ACELP_FIXED_CDK_BITS( n ) PulseConfTable[n].bits @@ -1103,69 +946,43 @@ enum #define PIT16k_FR2_EXTEND_10b 264 /* Minimum 10 bit pitch lag with resolution 1/2 of extended range @16kHz */ #define WIDTH_BAND 8 /* sub-band width in AVQ coding */ -#define G_AVQ_MIN 0.80f /* lower limit for gain Q in higher-rate ACELP contribution */ -#define G_AVQ_MAX 96.0f /* upper limit for gain Q in higher-rate ACELP contribution */ -#define FAC_PRE_AVQ 0.3f /* preemhasis factor in ACELP pre-quantizer */ -#define G_AVQ_MIN_FX 6554 /* Q13 */ -#define G_AVQ_MIN_DIV10_FX 655 /* Q13 */ -#define G_AVQ_MAX_FX 6144 /* Q6 */ -#define FAC_PRE_AVQ_FX 9830 /* preemhasis factor in ACELP pre-quantizer (0.3 in Q15) */ - - - -#define G_AVQ_MIN_INACT 0.70f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments */ -#define G_AVQ_MAX_INACT 4.1f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments */ -#define G_AVQ_MIN_INACT_48k 0.35f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbps */ -#define G_AVQ_MAX_INACT_48k 2.8f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbps */ -#define G_AVQ_MIN_INACT_64k 0.25f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbps */ -#define G_AVQ_MAX_INACT_64k 1.5f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbps */ -#define G_AVQ_MIN_INACT_Q12 2867 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments (0.7 in Q12) */ -#define G_AVQ_MIN_INACT_48k_Q12 1434 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbit/s (0.35 in Q12) */ -#define G_AVQ_MIN_INACT_64k_Q12 1024 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbit/s (0.25 in Q12 )*/ -#define G_AVQ_DELTA_INACT_Q12 221 /* (4.1 - 0.7) / ((1 << G_AVQ_BITS) - 1) in Q12 */ -#define G_AVQ_DELTA_INACT_48k_Q12 159 /* (2.8 - 0.35) / ((1 << G_AVQ_BITS) - 1) */ -#define G_AVQ_DELTA_INACT_64k_Q12 81 /*(1.5 - 0.25) / ((1 << G_AVQ_BITS) - 1) */ -#define G_AVQ_DELTA_INACT_48k ( G_AVQ_MAX_INACT_48k - G_AVQ_MIN_INACT_48k ) / ( ( 1 << G_AVQ_BITS ) - 1 ) -#define G_AVQ_DELTA_INACT_64k ( G_AVQ_MAX_INACT_64k - G_AVQ_MIN_INACT_64k ) / ( ( 1 << G_AVQ_BITS ) - 1 ) +#define G_AVQ_MIN_FX 6554 /* lower limit for gain Q in higher-rate ACELP contribution, 0.80f in Q13 */ +#define G_AVQ_MIN_DIV10_FX 655 /* Q13 */ +#define G_AVQ_MAX_FX 6144 /* upper limit for gain Q in higher-rate ACELP contribution, 96.0f in Q6 */ +#define FAC_PRE_AVQ_FX 9830 /* preemhasis factor in ACELP pre-quantizer (0.3 in Q15) */ + +#define G_AVQ_MIN_INACT_Q12 2867 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments (0.7 in Q12) */ +#define G_AVQ_MIN_INACT_48k_Q12 1434 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbit/s (0.35 in Q12) */ +#define G_AVQ_MIN_INACT_64k_Q12 1024 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbit/s (0.25 in Q12 )*/ +#define G_AVQ_DELTA_INACT_Q12 221 /* (4.1 - 0.7) / ((1 << G_AVQ_BITS) - 1) in Q12 */ +#define G_AVQ_DELTA_INACT_48k_Q12 159 /* (2.8 - 0.35) / ((1 << G_AVQ_BITS) - 1) */ +#define G_AVQ_DELTA_INACT_64k_Q12 81 /*(1.5 - 0.25) / ((1 << G_AVQ_BITS) - 1) */ #define G_AVQ_BITS 6 /* number of bits to quantize the AVQ gain in higher-rate ACELP contribtuion */ -#define G_AVQ_DELTA ( G_AVQ_MAX - G_AVQ_MIN ) / ( ( 1 << G_AVQ_BITS ) - 1 ) -#define G_AVQ_DELTA_INACT ( G_AVQ_MAX_INACT - G_AVQ_MIN_INACT ) / ( ( 1 << G_AVQ_BITS ) - 1 ) - -#define G_PITCH_MIN 0.00f /* SQ of gains: pitch gain lower limit */ -#define G_PITCH_MAX 1.22f /* SQ of gains: pitch gain upper limit */ -#define G_CODE_MIN 0.02f /* SQ of gains: code gain lower limit */ -#define G_CODE_MAX 5.00f /* SQ of gains: code gain upper limit */ -#define G_PITCH_MIN_TC192 0.1f -#define G_PITCH_MAX_TC192 0.95f -#define G_CODE_MIN_TC192 0.6f -#define G_CODE_MAX_TC192 41.0f +#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit */ +#define G_PITCH_MAX_Q13 9994 /* SQ of gains: pitch gain upper limit, 1.22 */ +#define G_PITCH_MAX_Q14 19988 /* SQ of gains: pitch gain upper limit, 1.22 in Q14 */ +#define G_CODE_MIN_FX 164 /* SQ of gains: code gain lower limit, 0.02f in Q13 */ +#define G_CODE_MAX_FX 320 /* SQ of gains: code gain upper limit, 5.0f in Q6 */ -#define G_PITCH_MIN_Q14 0 -#define G_PITCH_MAX_Q13 9994/*1.22 */ -#define G_PITCH_MAX_Q14 19988 /* 1.22 in Q14 */ - -#define G_CODE_MIN_FX 164 /* Q13 */ -#define G_CODE_MAX_FX 320 /* Q6 */ - -#define G_PITCH_MIN_TC192_Q14 1638 -#define G_PITCH_MAX_TC192_Q14 15565 /* 0.95 in Q14 */ -#define G_PITCH_MAX_MINUS_MIN_TC192_Q13 6963/*(G_PITCH_MAX_TC192 - G_PITCH_MIN_TC192) */ -#define G_CODE_MIN_TC192_Q15 19661 -#define G_CODE_MIN_TC192_FX 4915 /* Q13 */ -#define G_CODE_MAX_TC192_Q0 41 +#define G_PITCH_MIN_TC192_Q14 1638 /* 0.1f in Q14 */ +#define G_PITCH_MAX_TC192_Q14 15565 /* 0.95 in Q14 */ +#define G_PITCH_MAX_MINUS_MIN_TC192_Q13 6963 /*(G_PITCH_MAX_TC192 - G_PITCH_MIN_TC192) */ +#define G_CODE_MIN_TC192_Q15 19661 /* 0.6f in Q15 */ +#define G_CODE_MIN_TC192_FX 4915 /* 41 in Q13 */ +#define G_CODE_MAX_TC192_Q0 41 #define BIT_SAVING_LOW_THR 10 #define BIT_SAVING_HIGH_THR 80 + /*--------------------------------------------------------------* * ACELP constants *---------------------------------------------------------------*/ -#define MODE_MAX 15 - -#define NB_PULSES_MAX 15 -#define ACELP_GAINS_CONST 0.8f /* ACELP - adaptive codebook gain constraint */ +#define MODE_MAX 15 +#define NB_PULSES_MAX 15 +#define ACELP_GAINS_CONST_Q31 1717986944l /* ACELP - adaptive codebook gain constraint, 0.8f in Q31 */ /*--------------------------------------------------------------* * TCX constants @@ -1195,7 +1012,7 @@ enum #define N_MAX_ARI 800 #define N_LTP_GAIN_MEMS 4 -#define SPEC_EXP_DEC 20 /* initial decoder spectrum exponent */ +#define SPEC_EXP_DEC 20 /* initial decoder spectrum exponent */ #define N_TCX_STARTLINE_NOISE_WB 11 @@ -1238,41 +1055,31 @@ enum #define NC16k ( M16k / 2 ) #define NO_ITER 4 /* number of iterations for tracking the root */ -#define SPC 0.0234952f -#define SPC_plus SPC * 1.001f -#define ALPHA_SQ ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) -#define ALPHA_SQ_Q30 (6799549) /* ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) in Q30 */ +#define ALPHA_SQ_Q30 (6799549) /* ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) in Q30 */ #define NC M / 2 -#define LSF_GAP 50.0f -#define SPC_FX 770 /* q15 */ -#define SPC_PLUS_FX 771 +#define SPC_FX 770 /* 0.0234952f in q15 */ +#define SPC_PLUS_FX 771 /* SPC * 1.001f */ -#define LSF_GAP_FX 128 /*50.0f x 2.56*/ -#define MODE1_LSF_GAP_FX 179 /* MODE1_LSF_GAP*2.56 */ /* Minimum LSF separation for end-frame ISFs */ -#define FREQ_MAX 16384 /*6400Hz in 14Q1*1.28 */ -#define FREQ_DIV 800 /*400.0f in 14Q1 */ +#define LSF_GAP_FX 128 /*50.0f x 2.56*/ +#define MODE1_LSF_GAP_FX 179 /* MODE1_LSF_GAP*2.56 */ /* Minimum LSF separation for end-frame ISFs */ +#define FREQ_MAX 16384 /*6400Hz in 14Q1*1.28 */ +#define FREQ_DIV 800 /*400.0f in 14Q1 */ #define LSF_BITS_CNG 29 #define MU_MA ( 1.0f / 3.0f ) /* original prediction factor (only for AMR-WB IO mode) */ #define ISF_GAP 50 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */ -#define LSF_GAP_MID 80.0f /* Minimum LSF separation for mid-frame LSFs */ -#define MODE1_LSF_GAP 70.0f /* Minimum LSF separation for end-frame ISFs */ -#define PREFERSFNET 1.05 -#define ISF_GAP_FX 128 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */ -#define LSF_GAP_MID_FX 205 /* 80.0 * 2.56 */ /* Minimum LSF separation for mid-frame LSFs */ -#define PREFERSFNET_FX 1638 /* 0.05 in Q16*/ - -#define SFNETLOWLIMIT_WB_FLT 35000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ -#define SFNETLOWLIMIT_NB_FLT 38000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ -#define SFNETLOWLIMIT_WB 3670016 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ -#define SFNETLOWLIMIT_NB 3984589 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ +#define ISF_GAP_FX 128 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */ +#define LSF_GAP_MID_FX 205 /* 80.0 * 2.56 */ /* Minimum LSF separation for mid-frame LSFs */ +#define PREFERSFNET_FX 1638 /* 1.05 in Q16*/ + +#define SFNETLOWLIMIT_WB 3670016 /* 35000*2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ +#define SFNETLOWLIMIT_NB 3984589 /* 38000*2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ #define LSFMBEST 2 /* number of survivors from one stage to another */ #define STREAKLEN 3 /* Allow this many predictive frames, before starting limiting */ -#define STREAKMULT 0.8f /* Exponential limiting multiplier */ -#define STREAKMULT_FX 26214 /* Exponential limiting multiplier */ +#define STREAKMULT_FX 26214 /* Exponential limiting multiplier, 0.8f */ #define LSFMBEST_MAX 16 @@ -1280,14 +1087,12 @@ enum #define TCXLPC_NUMBITS 13 #define TCXLPC_IND_NUMSTAGES 1 #define TCXLPC_IND_NUMBITS 2 -#define TCXLPC_LSF_GAP_FLT 80.0f -#define TCXLPC_LSF_GAP 204 /* 80 in 14Q1*1.28 */ -#define kMaxC 8 - +#define TCXLPC_LSF_GAP 204 /* 80 in 14Q1*1.28 */ +#define kMaxC 8 #define MAX_VQ_STAGES 4 -#define MAX_VQ_STAGES_USED 9 /* this is the maximum number of stages currently used and changing this will affect the memory allocated \ - MAX_VQ_STAGES is also used as offset for addressing some arrays, so this should NOT be changed*/ +#define MAX_VQ_STAGES_USED 9 /* this is the maximum number of stages currently used and changing this will affect the memory allocated \ + MAX_VQ_STAGES is also used as offset for addressing some arrays, so this should NOT be changed*/ #define MIDLSF_NBITS 5 #define ENDLSF_NBITS 31 @@ -1299,11 +1104,11 @@ enum #define MAX_NO_VALS 4 #define WB_LIMIT_LSF 6350 #define CNG_LVQ_MODES 16 -#define MAX_NO_MODES_IVAS 169 +#define MAX_NO_MODES_IVAS 169 #define MAX_NO_MODES 128 -#define START_CNG_IVAS MAX_NO_MODES_IVAS - CNG_LVQ_MODES +#define START_CNG_IVAS MAX_NO_MODES_IVAS - CNG_LVQ_MODES #define START_CNG 112 -#define MAX_NO_MODES_p_IVAS 237 +#define MAX_NO_MODES_p_IVAS 237 #define MAX_NO_MODES_p 145 #define NO_CODING_MODES 6 #define LVQ_COD_MODES 18 @@ -1315,8 +1120,7 @@ enum #define N_STAGE_VQ 8 #define N_DIM 2 #define NUM_SUBSET 8 -#define OP_LOOP_THR_HVO_FLT 3784536.3f /* 80% : Open-loop Threshold */ -#define OP_LOOP_THR_HVO 1550146 /* 80% : Open-loop Threshold 2.56*2.56/16 */ +#define OP_LOOP_THR_HVO 1550146 /* 80% : Open-loop Threshold 3784536.3f*2.56*2.56/16 */ #define NUM_STATE 16 /* BC-TCQ - Number of state of the Trellis */ #define N_STAGE 16 /* BC-TCQ - Smaple number in a frame */ @@ -1344,10 +1148,10 @@ enum #define MAX_TD_DELAY 2 * NSUBBLOCKS /* Maximum allowed delay (in number of subblocks) of the transient detection, affects required memory */ #define NSUBBLOCKS_SHIFT 3 /* Number of subblocks which are shifter betwen TD dectector and TCX-LTP */ -#define NO_TCX 0 -#define TCX_20 1 -#define TCX_10 2 -#define TCX_5 3 +#define NO_TCX 0 +#define TCX_20 1 +#define TCX_10 2 +#define TCX_5 3 #define TRANSITION_OVERLAP ( -2 ) #define RECTANGULAR_OVERLAP ( -1 ) @@ -1356,12 +1160,12 @@ enum #define MIN_OVERLAP 2 #define HALF_OVERLAP 3 #define ALDO_WINDOW 4 -#define WINDECAY48 1230 -#define WINDECAY48_256 656 -#define WINDECAY16 410 -#define N16_CORE_SW 90 -#define N_ZERO_8 45 -#define N_ZERO_BY_FS 9216 /* == N_ZERO_MDCT_NS / FRAME_SIZE_NS in Q15 */ +#define WINDECAY48 1230 +#define WINDECAY48_256 656 +#define WINDECAY16 410 +#define N16_CORE_SW 90 +#define N_ZERO_8 45 +#define N_ZERO_BY_FS 9216 /* == N_ZERO_MDCT_NS / FRAME_SIZE_NS in Q15 */ #define SWITCH_OVERLAP_8k 15 /* == NS2SA(8000, SWITCH_GAP_LENGTH_NS) - NS2SA(8000, 10000000.0f - N_ZERO_MDCT_NS) */ #define SWITCH_GAP_LENGTH_8k 50 @@ -1388,35 +1192,25 @@ enum #define INACTIVE_CLAS 6 /* Inactive frame (used only in decoder) */ #define AUDIO_CLAS 7 /* Audio frame (used only in AMR-WB IO mode) */ -#define BETA_FEC 0.75f /* FEC - weighting factor for LSF estimation in FER */ -#define STAB_FAC_LIMIT 0.25f /* FEC - limit at which safety net is forced for next frame */ -#define BETA_FEC_FX 24576 /* FEC - weighting factor for LSF estimation in FER */ -#define STAB_FAC_LIMIT_FX 8192 /* FEC - limit at which safety net is forced for next frame */ +#define BETA_FEC_FX 24576 /* FEC - weighting factor for LSF estimation in FER, 0.75f */ +#define STAB_FAC_LIMIT_FX 8192 /* FEC - limit at which safety net is forced for next frame, 0.25f */ #define MODE1_L_FIR_FER 5 /* FEC - impulse response length for low- and high-pass filters in FEC */ #define L_FIR_FER 3 /* impulse response length for low- & high-pass filters in FER concealment */ #define L_FIR_FER2 11 /* new filter tuning: 11*/ #define MAX_UPD_CNT 5 /* FEC - maximum number of frames since last pitch update */ -#define ALPHA_S 0.6f /* FEC - damping factor for SIN_ONSET frames */ -#define ALPHA_V 1.0f /* FEC - damping factor for VOICED_CLAS frames */ -#define ALPHA_VT 0.4f /* FEC - damping factor for VOICED_TRANSITION frames */ -#define ALPHA_UT 0.8f /* FEC - damping factor for UNVOICED_TRANSITION frames */ -#define ALPHA_U 0.4f /* FEC - damping factor for UNVOICED_CLAS frames */ -#define ALPHA_UU 1.0f /* FEC - damping factor for UNVOICED_CLAS frames */ - /* attenuation strategy in case of FER */ -#define _ALPHA_S_FX 19661 -#define _ALPHA_V_FX 32767 -#define _ALPHA_VT_FX 13107 -#define _ALPHA_UT_FX 26214 -#define _ALPHA_U_FX 13107 -#define _ALPHA_U_FX_X_2 26214 -#define _ALPHA_UU_FX 32767 +#define _ALPHA_S_FX 19661 /* FEC - damping factor for SIN_ONSET frames, 0.6f */ +#define _ALPHA_V_FX 32767 /* FEC - damping factor for VOICED_CLAS frames, 1.0f */ +#define _ALPHA_VT_FX 13107 /* FEC - damping factor for VOICED_TRANSITION frames, 0.4f */ +#define _ALPHA_UT_FX 26214 /* FEC - damping factor for UNVOICED_TRANSITION frames, 0.8f */ +#define _ALPHA_U_FX 13107 /* FEC - damping factor for UNVOICED_CLAS frames, 0.4f */ +#define _ALPHA_U_FX_X_2 26214 /* FEC - damping factor for UNVOICED_CLAS frames, 1.0f */ +#define _ALPHA_UU_FX 32767 #define AGC 0.98f -#define PLC_MIN_CNG_LEV_FLT 0.01f /* minimum background level */ -#define PLC_MIN_CNG_LEV 328/*0.01f Q15*/ -#define PLC_MIN_CNG_LEV_Q21 20992/*0.01f Q21*/ +#define PLC_MIN_CNG_LEV 328 /* minimum background level, 0.01f Q15*/ +#define PLC_MIN_CNG_LEV_Q21 20992 /* minimum background level, 0.01f Q21*/ #define PLC_MIN_STAT_BUFF_SIZE 50 /* buffer size for minimum statistics */ #define G_LPC_RECOVERY_BITS 1 @@ -1429,9 +1223,9 @@ enum #define TC_SUBFR2IDX_16KHZ( x ) ( x == 0 ? 0 : x == 64 ? 1 : x == 128 ? 2 : x == 192 ? 3 : x == 256 ? 4 : 0 ) -#define TC_SUBFR2IDX_16KHZ_fx(x) mac_r(1024L, (x), 512) /* -1 => 0, 0 => 0, 64 => 1, 128 => 2, 192 => 3, 256 => 4 */ +#define TC_SUBFR2IDX_16KHZ_fx(x) mac_r(1024L, (x), 512) /* -1 => 0, 0 => 0, 64 => 1, 128 => 2, 192 => 3, 256 => 4 */ -#define TC_SUBFR2IDX_fx(x) add(s_min(3, s_max(0, sub((x), 1))), TC_SUBFR2IDX_16KHZ_fx(x)) +#define TC_SUBFR2IDX_fx(x) add(s_min(3, s_max(0, sub((x), 1))), TC_SUBFR2IDX_16KHZ_fx(x)) #define L_IMPULSE 17 /* TC - length of one prototype impulse */ @@ -1487,10 +1281,10 @@ enum * TCQ constants *----------------------------------------------------------------------------------*/ -#define MAX_PULSES 560 -#define MAX_POS 320 -#define MAX_LEN MAX_PULSES -#define NUM_ENG_PACKED_WORDS 20 /* Storage for variable rate quantizer bits */ +#define MAX_PULSES 560 +#define MAX_POS 320 +#define MAX_LEN MAX_PULSES +#define NUM_ENG_PACKED_WORDS 20 /* Storage for variable rate quantizer bits */ #define NORMAL_HQ_CORE 0 /* Signal use of Normal HQ core */ #define LOW_RATE_HQ_CORE 1 /* Signal use of Low Rate MDCT core */ @@ -1543,7 +1337,6 @@ enum #define LPC_SHB_ORDER 10 #define LPC_WHTN_ORDER 4 /* Order of whitening filter for SHB excitation */ #define SHB_OVERLAP_LEN ( L_FRAME16k - L_SHB_LAHEAD ) / ( NUM_SHB_SUBFR - 1 ) -#define QUANT_DIST_INIT ( 10000000000.0f ) /* Quantiser search distance initialisation */ #define HIBND_ACB_L_FAC 5 / 2 /* SHB Interpolation Factor */ #define HIBND_ACB_L_FAC_Q1 ( 5 ) /* SHB Interpolation Factor Q1 */ #define NUM_HILBERTS 2 @@ -1558,8 +1351,7 @@ enum #define NUM_BITS_SHB_FrameGain 6 #define NUM_BITS_SHB_FrameGain_LBR_WB 4 -#define RECIP_ROOT_EIGHT 0.3535534f /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ -#define RECIP_ROOT_EIGHT_FX 11585 /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ +#define RECIP_ROOT_EIGHT_FX 11585 /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ #define LPC_SHB_ORDER_WB 6 #define LPC_WHTN_ORDER_WB 2 /* Order of whitening filter for WB excitation */ @@ -1578,88 +1370,65 @@ enum #define NUM_BITS_SHB_RES_GS 3 #define NUM_BITS_SHB_VF 3 #define NUM_BITS_SHB_SUBGAINS_RF 5 /* Number of bits for subframe gains for SWB in RF */ -#define SHB_GAIN_QLOW -1.0f /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA 0.15f /* SHB gain scalar quantizer stepsize */ -#define SHB_GAIN_QLOW_1k75 0.0f /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA_1k75 0.08f /* SHB gain scalar quantizer stepsize */ -#define SHB_GAIN_QLOW_1k75_FX 0 /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA_1k75_FX 10486 /* SHB gain scalar quantizer stepsize Q17 */ -#define SHB_GAIN_QDELTA_1k75_FX_15 2622 /* SHB gain scalar quantizer stepsize */ -#define SHB_GAIN_QLOW_FX -262144 /* Q18*/ /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QLOW_FX_16 -65536 /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA_FX_15 4915 /* SHB gain scalar quantizer step size */ -#define SHB_GAIN_QDELTA_FX_16 9830 -#define SHB_GAIN_QDELTA_FX 19661 /* 0.15 in Q17*/ +#define SHB_GAIN_QLOW_1k75_FX 0 /* SHB gain lowest scalar quantizer value */ +#define SHB_GAIN_QDELTA_1k75_FX 10486 /* SHB gain scalar quantizer stepsize, 0.08f Q17 */ +#define SHB_GAIN_QDELTA_1k75_FX_15 2622 /* SHB gain scalar quantizer stepsize, 0.08f */ +#define SHB_GAIN_QLOW_FX -262144 /* -SHB gain lowest scalar quantizer value, 1.0f in Q18 */ +#define SHB_GAIN_QLOW_FX_16 -65536 /* SHB gain lowest scalar quantizer value */ +#define SHB_GAIN_QDELTA_FX_15 4915 /* SHB gain scalar quantizer step size, 0.15f */ +#define SHB_GAIN_QDELTA_FX_16 9830 /* 0.15f in Q16 */ +#define SHB_GAIN_QDELTA_FX 19661 /* 0.15 in Q17 */ #define NUM_Q_LSF 5 /* Number of quantized LSFs */ #define MIRROR_POINT_BITS 2 /* Number of bits used to quantize mirror point */ #define MIRROR_POINT_Q_CB_SIZE 4 /* Size of codebook used to quantize mirror point */ -#define MAX_LSF 0.5f /* Maximum value of the LSFs */ -#define MAX_LSF_FX_2 8192 /* Maximum value of the LSFs */ -#define MAX_LSF_FX 16384 /* Maximum value of the LSFs */ -#define MAX_LSF_FX_BY_2 8192 /* Maximum value of the LSFs */ +#define MAX_LSF_FX_2 8192 /* Maximum value of the LSFs */ +#define MAX_LSF_FX 16384 /* Maximum value of the LSFs, 0.5f */ +#define MAX_LSF_FX_BY_2 8192 /* Maximum value of the LSFs */ #define NUM_MAP_LSF 5 /* Number of mapped LSFs */ #define NUM_LSF_GRIDS 4 /* Number of LSF grids */ #define NUM_LSF_GRID_BITS 2 /* Number of bits used for the LSF grids */ #define NUM_BITS_SHB_MSLVQ 20 /* Number of bits for the MSLVQ quantizer */ -#define VF_0th_PARAM 0.34f -#define VF_1st_PARAM 0.5f -#define VF_2nd_PARAM ( VF_1st_PARAM - VF_0th_PARAM ) -#define VF_0th_PARAM_FX 11141 /*.34*/ -#define VF_1st_PARAM_FX 16384 /*.5*/ -#define VF_2nd_PARAM_FX (VF_1st_PARAM_FX - VF_0th_PARAM_FX) - - -#define GAMMA0 0.65f /* Mean value of gamma1/gamma2 for formant PF */ -#define GAMMA_SHARP 0.15f /* Largest sharpening for gamma1/gamma2 (0.83/0.67)*/ -#define SWB_NOISE_MIX_FAC 0.15f /* Noise mixing adjustment factor for active PF */ -#define SWB_TILT_LOW 1.0f /* Lower threshold for PF tilt adaptation */ -#define SWB_TILT_HIGH 2.0f /* Higher threshold for PF tilt adaptation */ -#define SWB_TILT_DELTA ( 1.0f / ( SWB_TILT_HIGH - SWB_TILT_LOW ) ) /* Inclination between thresholds */ -#define GAMMA3_PLUS_WB 0.65f /* WB post-filter */ -#define GAMMA3_MINUS_WB 0.85f /* WB post-filter */ -#define AGC_FAC_WB 0.85f /* WB post-filter - gain adjustment factor */ -#define AGC_FAC1_WB ( 1.0f - AGC_FAC_WB ) /* WB post-filter - gain adjustment factor complement */ - -#define GAMMA0_FX 21299 /* Mean value of gamma1/gamma2 for formant PF */ -#define GAMMA_SHARP_FX 4915 /* Largest sharpening for gamma1/gamma2 (0.83/0.67)*/ -#define SWB_NOISE_MIX_FAC_FX 4915 /* 0.15f in Q15 */ -#define SWB_TILT_LOW_FX 4096 /* Q12 1.0f Lower threshold for PF tilt adaptation */ -#define SWB_TILT_HIGH_FX 8192 /* Q12 2.0f Higher threshold for PF tilt adaptation */ -#define SWB_TILT_DELTA_FX 32767 /* Q15 (1.0f/(SWB_TILT_HIGH-SWB_TILT_LOW)) Inclination between thresholds */ -#define HALF_POINT_FX (16384) -#define GAMMA3_PLUS_FX 6554 /* NB post-filter - tilt weighting factor when k1>0 */ -#define GAMMA3_MINUS_FX 29491 /* NB post-filter - tilt weighting factor when k1<0 */ -#define GAMMA3_PLUS_WB_FX 21299 /* WB post-filter */ -#define GAMMA3_MINUS_WB_FX 27853 /* WB post-filter */ -#define AGC_FAC_WB_FX 27853 /* WB post-filter - gain adjustment factor */ -#define AGC_FAC1_WB_FX (Word16)(32768L-AGC_FAC_WB_FX) /* WB post-filter - gain adjustment factor complement */ +#define VF_0th_PARAM_FX 11141 /*.34*/ +#define VF_1st_PARAM_FX 16384 /*.5*/ +#define VF_2nd_PARAM_FX (VF_1st_PARAM_FX - VF_0th_PARAM_FX) + +#define GAMMA0_FX 21299 /* Mean value of gamma1/gamma2 for formant PF, 0.65f */ +#define GAMMA_SHARP_FX 4915 /* Largest sharpening for gamma1/gamma2 (0.83/0.67=0.15f)*/ +#define SWB_NOISE_MIX_FAC_FX 4915 /* 0.15f in Q15 */ +#define SWB_TILT_LOW_FX 4096 /* Q12 1.0f Lower threshold for PF tilt adaptation */ +#define SWB_TILT_HIGH_FX 8192 /* Q12 2.0f Higher threshold for PF tilt adaptation */ +#define SWB_TILT_DELTA_FX 32767 /* Q15 (1.0f/(SWB_TILT_HIGH-SWB_TILT_LOW)) Inclination between thresholds */ +#define HALF_POINT_FX (16384) +#define GAMMA3_PLUS_FX 6554 /* NB post-filter - tilt weighting factor when k1>0 */ +#define GAMMA3_MINUS_FX 29491 /* NB post-filter - tilt weighting factor when k1<0 */ +#define GAMMA3_PLUS_WB_FX 21299 /* WB post-filter, 0.65f */ +#define GAMMA3_MINUS_WB_FX 27853 /* WB post-filter, 0.85f */ +#define AGC_FAC_WB_FX 27853 /* WB post-filter - gain adjustment factor, 0.85f */ +#define AGC_FAC1_WB_FX (Word16)(32768L-AGC_FAC_WB_FX) /* WB post-filter - gain adjustment factor complement */ #define MAX_LEN_MA_FILTER 20 /* maximum length of the MA filter for SHB TD envelope calculation */ #define TABLE_CUMSUM_MAX_N 320 /* maximum length of cumsum(i) and cumsum(i*i) tables */ #define NUM_BITS_FB_FRAMEGAIN_TBE 4 /* Number of bits for framegain for FB TBE */ -/* SWB TBE, FX only constants */ -#define NOISE_QFAC 6 -#define NOISE_QADJ (15-NOISE_QFAC) + + /* SWB TBE, FX only constants */ +#define NOISE_QFAC 6 +#define NOISE_QADJ (15-NOISE_QFAC) /*----------------------------------------------------------------------------------* * SWB BWE constants *----------------------------------------------------------------------------------*/ -#define INV_L_SUBFR16k 0.0125f -#define INV_L_SUBFR16k_FX 410 /*Q15 */ +#define INV_L_SUBFR16k_FX 410 /* 0.0125f in Q15 */ #define SWB_L_SUBFR 160 #define FB_L_SUBFR 240 #define SWB_FENV 14 -#define FB_GAIN_QLOW 0.0f -#define FB_GAIN_QDELTA 0.03125f -#define FB_GAIN_QLOW_FX 0 -#define FB_GAIN_QDELTA_FX 512 /*Q14 */ -#define FB_MAX_GAIN_VAR 0.5f +#define FB_GAIN_QLOW_FX 0 +#define FB_GAIN_QDELTA_FX 512 /* 0.03125f in Q14 */ #define NUM_BITS_FB_FRAMEGAIN 4 /* Number of bits for framegain for FB BWE */ @@ -1728,19 +1497,13 @@ enum #define NBITS_THRESH_BWE_HR 400 /* BWE HR number of bits threshold */ #define NBITS_HF_GAIN_BWE_HR 2 /* number of bits for HF (noncoded) energy estimation */ -#define BWE_HR_TRANS_EN_LIMIT1 0.1f /* HF (noncoded) energy equalization limit 1, transient frames */ -#define BWE_HR_TRANS_EN_LIMIT2 0.3f /* HF (noncoded) energy equalization limit 2, transient frames */ -#define BWE_HR_TRANS_EN_LIMIT3 0.5f /* HF (noncoded) energy equalization limit 3, transient frames */ -#define BWE_HR_NONTRANS_EN_LIMIT1 0.5f /* HF (noncoded) energy equalization limit 1, non-transient frames */ -#define BWE_HR_NONTRANS_EN_LIMIT2 1.2f /* HF (noncoded) energy equalization limit 2, non-transient frames */ -#define BWE_HR_NONTRANS_EN_LIMIT3 0.8f /* HF (noncoded) energy equalization limit 3, non-transient frames */ -#define BWE_HR_TRANS_EN_LIMIT1_FX_Q16 6554 -#define BWE_HR_TRANS_EN_LIMIT2_FX_Q16 19661 -#define BWE_HR_TRANS_EN_LIMIT3_FX_Q16 32767 -#define BWE_HR_NONTRANS_EN_LIMIT1_FX_Q15 16384 /* 0.5 */ -#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q14 19661 /* 1.2 */ -#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q15 16384 -#define BWE_HR_NONTRANS_EN_LIMIT3_FX_Q15 26214 /* 0.8 */ +#define BWE_HR_TRANS_EN_LIMIT1_FX_Q16 6554 /* 0.1, HF (noncoded) energy equalization limit 1, transient frames */ +#define BWE_HR_TRANS_EN_LIMIT2_FX_Q16 19661 /* 0.3, HF (noncoded) energy equalization limit 2, transient frames */ +#define BWE_HR_TRANS_EN_LIMIT3_FX_Q16 32767 /* 0.5, HF (noncoded) energy equalization limit 3, transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT1_FX_Q15 16384 /* 0.5, HF (noncoded) energy equalization limit 1, non-transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q14 19661 /* 1.2, HF (noncoded) energy equalization limit 2, non-transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q15 16384 /* 1.2, HF (noncoded) energy equalization limit 2, non-transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT3_FX_Q15 26214 /* 0.8, HF (noncoded) energy equalization limit 3, non-transient frames */ /*----------------------------------------------------------------------------------* * FD CNG @@ -1759,21 +1522,14 @@ enum #define FD_CNG_stages_37bits 6 #define FD_CNG_JOINT_stages_25bits 4 -#define OUTMAX_INV 0.000030517578125f /* 1/2^15 */ -#define OUTMAX_INV_FX 65536 /* 1/2^15 (Q31) */ #define ONE_BY_NS2A_8K_ST_DFT32MS_OVL_NS (Word16)(0x051E) -#define OUTMAX_INV_FX_16 (Word16)(0x0001) /* 1/2^15 */ -#define OUTMAX_SQ 1073741824.f /* 2^30 */ -#define OUTMAX_SQ_INV 0.00000000093132257461547852f /* 1/2^30 */ -#define DELTA ( 1e-20f ) -#define DELTA_FX ( 1 ) -#define DELTA_MANTISSA_W16 0x5e73 -#define DELTA_MANTISSA_W32 0x5e728433 -#define DELTA_EXPONENT (-66) +#define DELTA_FX ( 1 ) +#define DELTA_MANTISSA_W16 0x5e73 +#define DELTA_MANTISSA_W32 0x5e728433 +#define DELTA_EXPONENT (-66) -#define CLDFB_SCALING_FLT ( 1.5f ) -#define CLDFB_SCALING 24576/*1.5 Q14*/ /* Q 2.14 */ +#define CLDFB_SCALING 24576 /*1.5 Q14*/ /* Q 2.14 */ #define FFTLEN 640 #define FFTLEN2 ( FFTLEN / 2 ) @@ -1785,13 +1541,13 @@ enum #define NPARTCLDFB 10 #define NPART_SHAPING 62 -#define FDCNG_VQ_MAX_LEN FD_CNG_maxN_37bits -#define FDCNG_VQ_DCT_NSEGM 4 -#define FDCNG_VQ_DCT_MINTRUNC 8 -#define FDCNG_VQ_DCT_MAXTRUNC 18 -#define FDCNG_VQ_MAX_LEN_WB 21 +#define FDCNG_VQ_MAX_LEN FD_CNG_maxN_37bits +#define FDCNG_VQ_DCT_NSEGM 4 +#define FDCNG_VQ_DCT_MINTRUNC 8 +#define FDCNG_VQ_DCT_MAXTRUNC 18 +#define FDCNG_VQ_MAX_LEN_WB 21 -#define FDCNG_VQ_DCT_NPOST 8 +#define FDCNG_VQ_DCT_NPOST 8 typedef enum _DCTTYPE { @@ -1806,59 +1562,44 @@ typedef enum _DCTTYPE #define MSNUMSUBFR 6 #define MSBUFLEN 5 -#define NOISE_HEADROOM 5 /* headroom of noise in generate_masking_noise_fx */ - -#define MSALPHACORALPHA_FLT 0.7f -#define MSALPHACORMAX_FLT 0.3f -#define MSALPHAMAX_FLT 0.96f -#define MSALPHAHATMIN_FLT 0.05f /* It is used for all bands except the first one to get a stable bass */ -#define MSQEQINVMAX_FLT ( 1.f / 5.f ) -#define MSAV_FLT 2.12f -#define MSBETAMAX_FLT 0.8f -#define MSSNREXP_FLT ( -0.02f / 0.064f ) -#define MSALPHACORALPHA 22938/*0.7f Q15*/ -#define MSALPHACORALPHA2 9830/*0.3f Q15*/ -#define MSALPHACORMAX 9830/*0.3f Q15*/ -#define MSALPHAMAX 31457/*0.96f Q15*/ -#define MSALPHAHATMIN 107374184l/*0.05f Q31*/ -#define MSQEQINVMAX 6554/*1.f/5.f Q15*/ -#define MSAV 17367/*2.12f Q13*/ -#define MSAV_EXP 2 -#define MSBETAMAX 1717986944l/*0.8f Q31*/ -#define MSBETAMAX_SQRT 1920767767l/*0.894427191 Q31*/ /* sqrt(MSBETAMAX) */ -#define MSSNREXP -10240/*-0.02f/0.064f Q15*/ - -#define NB_LAST_BAND_SCALE_FLT 0.8f -#define SWB_13k2_LAST_BAND_SCALE_FLT 0.8f -#define NB_LAST_BAND_SCALE 26214/*0.8f Q15*/ -#define SWB_13k2_LAST_BAND_SCALE 26214/*0.8f Q15*/ - -#define CNG_LOG_SCALING 512.f /*2^9*/ +#define NOISE_HEADROOM 5 /* headroom of noise in generate_masking_noise_fx */ + +#define MSALPHACORALPHA 22938 /*0.7f Q15*/ +#define MSALPHACORALPHA2 9830 /*0.3f Q15*/ +#define MSALPHACORMAX 9830 /*0.3f Q15*/ +#define MSALPHAMAX 31457 /*0.96f Q15*/ +#define MSALPHAHATMIN 107374184l /*0.05f Q31*/ +#define MSQEQINVMAX 6554 /*1.f/5.f Q15*/ +#define MSAV 17367 /*2.12f Q13*/ +#define MSAV_EXP 2 +#define MSBETAMAX 1717986944l /*0.8f Q31*/ +#define MSBETAMAX_SQRT 1920767767l /*0.894427191 Q31*/ /* sqrt(MSBETAMAX) */ +#define MSSNREXP -10240 /*-0.02f/0.064f Q15*/ + +#define NB_LAST_BAND_SCALE 26214 /*0.8f Q15*/ +#define SWB_13k2_LAST_BAND_SCALE 26214 /*0.8f Q15*/ #define M_MAX 32 -#define NSTAGES_MAX 9 -#define MBEST_MAX 8 +#define NSTAGES_MAX 9 +#define MBEST_MAX 8 #define N_GAIN_MIN 4 #define N_GAIN_MAX 17 -#define numSlots_inv_EXP (-3) -#define PREEMPH_COMPENSATION_EXP 4 +#define PREEMPH_COMPENSATION_EXP 4 #define CHEAP_NORM_SIZE 161 -#define CLDFBscalingFactor_EXP (-15) -#define CLDFBinvScalingFactor_EXP ( 16) +#define CLDFBscalingFactor_EXP (-15) +#define CLDFBinvScalingFactor_EXP ( 16) -#define CNG_NORM_RECIPROCAL_RANGE_SHIFT 2 -#define CNG_RAND_GAUSS_SHIFT 2 +#define CNG_NORM_RECIPROCAL_RANGE_SHIFT 2 +#define CNG_RAND_GAUSS_SHIFT 2 #define CNA_MAX_BRATE ACELP_13k20 #define CNA_INIT_NBANDS 6 -#define GAIN_Q_OFFSET_EVS 60.f -#define GAIN_Q_OFFSET_EVS_FX_Q0 60 -#define GAIN_Q_OFFSET_IVAS 45.f -#define GAIN_Q_OFFSET_IVAS_FX_Q0 45 +#define GAIN_Q_OFFSET_EVS_FX_Q0 60 +#define GAIN_Q_OFFSET_IVAS_FX_Q0 45 /*----------------------------------------------------------------------------------* * Bass post-filter constants @@ -1871,30 +1612,20 @@ typedef enum _DCTTYPE * NB post-filter constants *----------------------------------------------------------------------------------*/ -#define THRESCRIT 0.5f /* NB post-filter - threshold LT pst switch off */ -#define AGC_FAC 0.9875f /* NB post-filter - gain adjustment factor */ -#define AGC_FAC1 ( 1.0f - AGC_FAC ) /* NB post-filter - gain adjustment factor complement */ #define LONG_H_ST 20 /* NB post-filter - impulse response length */ -#define POST_G1 0.75f /* NB post-filter - denominator weighting factor 12kbps */ -#define POST_G2 0.7f /* NB post-filter - numerator weighting factor 12kbps */ -#define GAMMA1_PST12K_FX 24576 /* denominator weighting factor 12K (0.75 in Q15) */ -#define GAMMA2_PST12K_FX 22938 /* numerator weighting factor 12K (0.7 in Q15) */ -#define POST_G1_FX GAMMA1_PST12K_FX /* 12 kbps default */ -#define POST_G2_FX GAMMA2_PST12K_FX /* 12 kbps default */ - -#define GAMMA1_PST 0.7f /* denominator weighting factor */ -#define GAMMA2_PST 0.55f /* numerator weighting factor */ -#define GAMMA3_PLUS 0.2f /* NB post-filter - tilt weighting factor when k1>0 */ -#define GAMMA3_MINUS 0.9f /* NB post-filter - tilt weighting factor when k1<0 */ -#define GAMMA1_PST12K_MIN_FX 21299 /* 0.65 in Q15 */ -#define GAMMA2_PST12K_MIN_FX 18022 /* 0.55 in Q15 */ -#define GAMMA1_PST12K_NOIS_FX 4915 /* 0.15 in Q15 */ -#define GAMMA2_PST12K_NOIS_FX 3277 /* 0.10 in Q15 */ +#define GAMMA1_PST12K_FX 24576 /* denominator weighting factor 12K (0.75 in Q15) */ +#define GAMMA2_PST12K_FX 22938 /* numerator weighting factor 12K (0.7 in Q15) */ +#define POST_G1_FX GAMMA1_PST12K_FX /* 12 kbps default */ +#define POST_G2_FX GAMMA2_PST12K_FX /* 12 kbps default */ + +#define GAMMA1_PST12K_MIN_FX 21299 /* 0.65 in Q15 */ +#define GAMMA2_PST12K_MIN_FX 18022 /* 0.55 in Q15 */ +#define GAMMA1_PST12K_NOIS_FX 4915 /* 0.15 in Q15 */ +#define GAMMA2_PST12K_NOIS_FX 3277 /* 0.10 in Q15 */ #define F_UP_PST 8 /* NB post-filter - resolution for fractionnal delay */ #define LH2_S 4 /* NB post-filter - length of INT16 interp. subfilters */ #define LH2_L 16 /* NB post-filter - length of long interp. subfilters */ -#define MIN_GPLT ( 1.0f / 1.5f ) /* NB post-filter - LT gain minimum */ #define LH_UP_S ( LH2_S / 2 ) #define LH_UP_L ( LH2_L / 2 ) #define LH2_L_P1 ( LH2_L + 1 ) @@ -1903,24 +1634,13 @@ typedef enum _DCTTYPE #define SIZ_Y_UP ( ( F_UP_PST - 1 ) * ( L_SUBFR + 1 ) ) #define SIZ_TAB_HUP_L ( ( F_UP_PST - 1 ) * LH2_L ) #define SIZ_TAB_HUP_S ( ( F_UP_PST - 1 ) * LH2_S ) -#define POST_G1_MIN 0.65f -#define POST_G2_MIN 0.55f -#define POST_G1_NOIS 0.15f -#define POST_G2_NOIS 0.10f -#define BG1 ( -0.01f ) -#define BG2 ( -0.05f ) -#define CG1 0.9f -#define CG2 1.45f -#define C_LP_NOISE ( 0.1f / 4.0f ) -#define K_LP_NOISE 15.0f -#define LP_NOISE_THR 25.0f -#define BG1_FX -328 /* -0.01 in Q15 */ -#define BG2_FX -1638 /* -0.05 in Q15 */ -#define CG1_FX 29491 /* 0.9 in Q15 */ -#define CG2_FX 47514L /* 1.45 in Q15 */ -#define C_LP_NOISE_FX 819 /* 0.1/4.0 in Q15 */ -#define CK_LP_NOISE_FX 6291456L /* 15.0 * 0.1/4 in Q8 * 65536 */ -#define LP_NOISE_THR_FX 6400 /* 25.0 in Q8 */ +#define BG1_FX -328 /* -0.01 in Q15 */ +#define BG2_FX -1638 /* -0.05 in Q15 */ +#define CG1_FX 29491 /* 0.9 in Q15 */ +#define CG2_FX 47514L /* 1.45 in Q15 */ +#define C_LP_NOISE_FX 819 /* 0.1/4.0 in Q15 */ +#define CK_LP_NOISE_FX 6291456L /* 15.0 * 0.1/4 in Q8 * 65536 */ +#define LP_NOISE_THR_FX 6400 /* 25.0 in Q8 */ /*----------------------------------------------------------------------------------* * Stability estimation @@ -1928,16 +1648,11 @@ typedef enum _DCTTYPE #define NB_BFI_THR 2 /* threshold for counter of last bad frames */ #define MAX_LT 40 -#define INV_MAX_LT ( 1.0f / MAX_LT ) -#define TH_0_MIN 2.5f -#define TH_1_MIN 1.875f -#define TH_2_MIN 1.5625f -#define TH_3_MIN 1.3125f -#define TH_0_MIN_FX 5120 /* 2.5f in Q11 */ -#define TH_1_MIN_FX 3840 /* 1.875f in Q11 */ -#define TH_2_MIN_FX 3200 /* 1.5625f in Q11 */ -#define TH_3_MIN_FX 2688 /* 1.3125f in Q11 */ +#define TH_0_MIN_FX 5120 /* 2.5f in Q11 */ +#define TH_1_MIN_FX 3840 /* 1.875f in Q11 */ +#define TH_2_MIN_FX 3200 /* 1.5625f in Q11 */ +#define TH_3_MIN_FX 2688 /* 1.3125f in Q11 */ /*----------------------------------------------------------------------------------* * Speech/music classifier constants @@ -1956,12 +1671,12 @@ typedef enum _DCTTYPE #define N_SMC_MIXTURES 6 /* number of mixtures */ #define N_PCA_COEF 12 /* number of PCA components */ #define HALF_N_PCA_COEF_LOG_P12_Q18 2890731 //Q18 of (0.5f * N_PCA_COEF *logf( PI2 )) -#define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */ +#define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */ #define M_LSP_SPMUS 6 /* number of LSPs used in speech/music classifier */ #define NB_BANDS_SPMUS 15 #define START_BAND_SPMUS 2 -#define N_OLD_BIN_E 42 /* == (L_FFT/2-2)/3 */ +#define N_OLD_BIN_E 42 /* == (L_FFT/2-2)/3 */ #define LOWEST_FBIN 3 /* lowest frequency bin for feature vector preparation */ #define HIGHEST_FBIN 70 /* highest frequency bin for feature vector preparation */ @@ -1970,18 +1685,14 @@ typedef enum _DCTTYPE #define BUF_LEN 60 #define L_OVR 8 -#define N_FEATURES_2 3 /* number of features */ +#define N_FEATURES_2 3 /* number of features */ #define ATT_NSEG 32 /* strong attack detection - number of time blocks */ #define TOD_NSPEC 80 /* number of spectral bins of the tonal detector */ #define TOD_NSPEC_INV_Q31 26843546 /* inverse of number of spectral bins of the tonal detector */ -#define TOD_THR_MASS 0.86f /* initial value for the adaptive threshold of the tonal detector */ -#define TOD_THR_MASS_FX_Q22 3607101 /* initial value for the adaptive threshold of the tonal detector */ -#define P2A_FACT 0.9f /* long-term averaging factor for peak-to-average ratio */ -#define P2A_FACT_FX_Q15 29491 /* long-term averaging factor for peak-to-average ratio */ -#define THR_P2A_HIGH 95.0f /* higher threshold to detect strongly peaky signals at low bitrates*/ -#define THR_P2A 80.0f /* lower threshold to detect strongly peaky signals at higher bitrates */ +#define TOD_THR_MASS_FX_Q22 3607101 /* initial value for the adaptive threshold of the tonal detector, 0.86f in Q22 */ +#define P2A_FACT_FX_Q15 29491 /* long-term averaging factor for peak-to-average ratio, 0.9f in Q15 */ #define THR_P2A_HIGH_FX 95 /* Q0, higher threshold to detect strongly peaky signals at low bitrates*/ #define THR_P2A_FX 80 /* Q0, lower threshold to detect strongly peaky signals at higher bitrates */ @@ -2031,11 +1742,8 @@ typedef enum _DCTTYPE #define MBANDS_GN 16 /* Number of band for gain coding in GSC */ #define MBANDS_GN_BITALLOC16k 20 /* Number of band for gain coding in GSC */ #define BAND1k2 3 -#define DSR_NB_PULSE ( 4.5f ) -#define DSR_NB_PULSE_Q18 ( 1179648 ) -#define MAX_EQ_LF 1.0f +#define DSR_NB_PULSE_Q18 ( 1179648 ) /* 4.5f*/ #define MBANDS_LOC ( MBANDS_GN - 1 ) -#define BIN_SIZE 25.0f #define SWNB_SUBFR 1 #define MIN_RATE_4SBFR ACELP_16k40 @@ -2070,16 +1778,14 @@ typedef enum _DCTTYPE #define HQ_GEN_FB 5 #define PREECHO_SMOOTH_LEN 20 -#define INV_PREECHO_SMOOTH_LENP1 ( 1 / ( PREECHO_SMOOTH_LEN + 1.0 ) ); -#define EPSILON 0.000000000000001f +//#define EPSILON 0.000000000000001f #define EPSILON_FX_SMALL 1 #define EPSILON_FIX (1) #define EPSILON_FX (Word32)1 #define EPSILON_FX_M 1208925819 #define EPSILON_FX_E -49 - #define MAX_SEGMENT_LENGTH 480 #define NUM_TIME_SWITCHING_BLOCKS 4 #define NUM_MAP_BANDS 20 @@ -2118,7 +1824,7 @@ typedef enum _DCTTYPE #define HVQ_PVQ_BUF_LEN ( HVQ_PVQ_COEFS * ( MAX_PVQ_BANDS - 1 ) + HQ_MAX_BAND_LEN ) /* 24*7+96 = 216 */ #define QBIT_MAX2 9 -#define Q_PVQ_OUT 10 +#define Q_PVQ_OUT 10 #define FLAGN_BITS 1 #define GAIN0_BITS 5 @@ -2140,15 +1846,12 @@ typedef enum _DCTTYPE #define HUFF_THR 10 #define NOSUPERPOSITION 40 -#define MAXVALUEOFFIRSTGAIN 2.5f -#define MINVALUEOFFIRSTGAIN -2.5f -#define MAXVALUEOFFIRSTGAIN_FX 20480 /*2.5f in Q13 */ -#define MINVALUEOFFIRSTGAIN_FX -20480 +#define MAXVALUEOFFIRSTGAIN_FX 20480 /* 2.5f in Q13 */ +#define MINVALUEOFFIRSTGAIN_FX -20480 /* -2.5f in Q13 */ #define NOOFGAINBITS1 6 #define AUDIODELAYBITS 6 -#define DELTAOFFIRSTGAIN (float) ( MAXVALUEOFFIRSTGAIN - MINVALUEOFFIRSTGAIN ) / (float) ( ( 1 << NOOFGAINBITS1 ) - 1 ) -#define DELTAOFFIRSTGAIN_FX 2601 /*Q15 */ +#define DELTAOFFIRSTGAIN_FX 2601 /*Q15 */ #define MAX_D1M_16k ( ( L_FRAME16k >> 1 ) - NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) - 16 ) #define MAX_D1M_12k8 ( ( L_FRAME16k >> 1 ) - NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) - 20 ) @@ -2160,30 +1863,23 @@ typedef enum _DCTTYPE #define ENV_ADJ_START 6 /* Number of consecutive bands for which the attenuation is maximum */ #define ENV_ADJ_INCL 5 /* Inclination for mapping between attenuation region width and attenuation limit */ -#define ENV_SMOOTH_FAC 0.1f /* Smoothing factor for envelope stability measure */ -#define ENV_SMOOTH_FAC_FX ((Word16)0x0CCD) +#define ENV_SMOOTH_FAC_FX ((Word16)0x0CCD) /* Smoothing factor for envelope stability measure, 0.1f */ #define L_STAB_TBL 10 /* Number of elements in stability transition table */ -#define LUMPED_ENV_SMOOTH_FAC_FX ((Word16)10089) /* Q19 (no typo error), 0.1/sqrt(27) */ -#define CMPLMNT_ENV_SMOOTH_FAC_FX ((Word16)29491) /* Q15 0.9 */ +#define LUMPED_ENV_SMOOTH_FAC_FX ((Word16)10089) /* Q19 (no typo error), 0.1/sqrt(27) */ +#define CMPLMNT_ENV_SMOOTH_FAC_FX ((Word16)29491) /* Q15 0.9 */ #define M_STAB_TBL_FX ( (Word16) 21068 ) /* Q13, 2.571756 */ #define D_STAB_TBL_FX ( (Word16) 845 ) /* Q13 0.1013138 */ #define HALF_D_STAB_TBL_FX ( (Word16) 422 ) /* Q13 0.1013138/2.0 */ #define NUM_ENV_STAB_PLC_STATES 2 /* Number of states of markov model */ -#define INV_NUM_ENV_STAB_PLC_STATES 16384 /* Q15 */ -#define INV_STAB_TRANS_FX 16497 /* Q14. Equal to 1.0f/(1-2*stab_trans_fx[L_STAB_TBL-1]) */ - -#define ENV_STAB_EST1 2.93f /* env_stab estimation coefficient 1 */ -#define ENV_STAB_EST2 (-2.20f) /* env_stab estimation coefficient 2 */ -#define ENV_STAB_EST3 0.741f /* env_stab estimation coefficient 3 */ -#define ENV_STAB_EST1_FX 12001 /* env_stab estimation coefficient 1 *//*Q-12*/ -#define ENV_STAB_EST2_FX (-9011) /* env_stab estimation coefficient 2 *//*Q-12*/ -#define ENV_STAB_EST3_FX 3035 /* env_stab estimation coefficient 3 *//*Q-12*/ -#define STAB_FAC_EST1 1.093f /* stab_fac HQ estimation coefficient 1 */ -#define STAB_FAC_EST2 (-5.84e-05f) /* stab_fac HQ estimation coefficient 2, including Q12 scaling */ -#define STAB_FAC_EST3 0.125f /* stab_fac HQ estimation coefficient 3 */ -#define STAB_FAC_EST1_FX ((Word32)0x45F3B646) /* stab_fac HQ estimation coefficient 1 */ -#define STAB_FAC_EST2_FX ((Word32)0xFFFF0B0D) /* stab_fac HQ estimation coefficient 2, including Q12 scaling */ -#define STAB_FAC_EST3_FX ((Word32)0x10000000) /* stab_fac HQ estimation coefficient 3 */ +#define INV_NUM_ENV_STAB_PLC_STATES 16384 /* Q15 */ +#define INV_STAB_TRANS_FX 16497 /* Q14. Equal to 1.0f/(1-2*stab_trans_fx[L_STAB_TBL-1]) */ + +#define ENV_STAB_EST1_FX 12001 /* env_stab estimation coefficient 1, 2.93f *//*Q-12*/ +#define ENV_STAB_EST2_FX (-9011) /* env_stab estimation coefficient 2, -2.20f *//*Q-12*/ +#define ENV_STAB_EST3_FX 3035 /* env_stab estimation coefficient 3, 0.741f *//*Q-12*/ +#define STAB_FAC_EST1_FX ((Word32)0x45F3B646) /* stab_fac HQ estimation coefficient 1, 1.093f */ +#define STAB_FAC_EST2_FX ((Word32)0xFFFF0B0D) /* stab_fac HQ estimation coefficient 2, (-5.84e-05f), including Q12 scaling */ +#define STAB_FAC_EST3_FX ((Word32)0x10000000) /* stab_fac HQ estimation coefficient 3, 0.125f */ #define ATT_LIM_HANGOVER 150 /* Number of hangover frames for disabling stability dependent attenuation */ #define DELTA_TH 5.0f /* Delta energy threshold for transient detection for envelope stability */ @@ -2216,8 +1912,6 @@ typedef enum _DCTTYPE #define HQ_GENERIC_EXC1 1 #define HQ_GENERIC_SP_EXC 2 -#define LF_EMP_FAC 1.2f - #define DIM_FB 3 #define HQ_FB_FENV SWB_FENV + DIM_FB #define N_CB_FB 32 @@ -2255,52 +1949,37 @@ typedef enum _DCTTYPE #define HVQ_NEW_BAND_BIT_THR 30 #define HVQ_NF_GROUPS 2 -#define HVQ_NF_WEIGHT1 0.9578f /* HVQ Classifier - Noise floor estimate weight 1 */ -#define HVQ_NF_WEIGHT2 0.6472f /* HVQ Classifier - Noise floor estimate weight 2 */ -#define HVQ_PE_WEIGHT1 0.42237f /* HVQ Classifier - Peak envelope estimate weight 1 */ -#define HVQ_PE_WEIGHT2 0.80285f /* HVQ Classifier - Peak envelope estimate weight 2 */ -#define HVQ_THR_POW 0.88f /* HVQ Classifier power factor for threshold calc */ #define HVQ_SHARP_THRES 9 /* HVQ Classifier - Sharpness threshold */ -#define HVQ_NF_WEIGHT1_FX 31385 /* Q15 0.9578 - HVQ Classifier - Noise floor estimate weight 1 */ -#define HVQ_NF_WEIGHT1B 1383 /* Q15, 1 - HVQ_NF_WEIGHT1_FX */ -#define HVQ_NF_WEIGHT2_FX 21207 /* Q15 0.6472 - HVQ Classifier - Noise floor estimate weight 2 */ -#define HVQ_NF_WEIGHT2B 11561 /* Q15 1 - HVQ_NF_WEIGHT2_FX */ -#define HVQ_PE_WEIGHT1_FX 13840 /* Q15 0.42237 - HVQ Classifier - Peak envelope estimate weight 1 */ -#define HVQ_PE_WEIGHT1B 18928 /* Q15, 1 - HVQ_PE_WEIGHT1_FX */ -#define HVQ_PE_WEIGHT2_FX 26308 /* Q15 0.80285 - HVQ Classifier - Peak envelope estimate weight 2 */ -#define HVQ_PE_WEIGHT2B 6460 /* Q15, 1 - HVQ_PE_WEIGHT2_FX */ -#define HVQ_SHARP_THRES_FX 576 /*9 in Q6 */ - -#define HVQ_PA_FAC 0.7071f /* HVQ Classifier peak allocation factor */ -#define HVQ_PA_FAC_FX 23170 /* Q15 0.7071 - HVQ Classifier peak allocation factor */ +#define HVQ_NF_WEIGHT1_FX 31385 /* Q15 0.9578 - HVQ Classifier - Noise floor estimate weight 1 */ +#define HVQ_NF_WEIGHT1B 1383 /* Q15, 1 - HVQ_NF_WEIGHT1_FX */ +#define HVQ_NF_WEIGHT2_FX 21207 /* Q15 0.6472 - HVQ Classifier - Noise floor estimate weight 2 */ +#define HVQ_NF_WEIGHT2B 11561 /* Q15 1 - HVQ_NF_WEIGHT2_FX */ +#define HVQ_PE_WEIGHT1_FX 13840 /* Q15 0.42237 - HVQ Classifier - Peak envelope estimate weight 1 */ +#define HVQ_PE_WEIGHT1B 18928 /* Q15, 1 - HVQ_PE_WEIGHT1_FX */ +#define HVQ_PE_WEIGHT2_FX 26308 /* Q15 0.80285 - HVQ Classifier - Peak envelope estimate weight 2 */ +#define HVQ_PE_WEIGHT2B 6460 /* Q15, 1 - HVQ_PE_WEIGHT2_FX */ +#define HVQ_SHARP_THRES_FX 576 /* 9 in Q6 */ + +#define HVQ_PA_FAC_FX 23170 /* Q15 0.7071 - HVQ Classifier peak allocation factor */ #define HVQ_PA_PEAKS_SHARP1 9 /* HVQ Classifier - Maximum number of peaks for band with high sharpness */ #define HVQ_PA_PEAKS_SHARP2 3 /* HVQ Classifier - Maximum number of peaks for band with medium sharpness */ #define HVQ_PA_PEAKS_SHARP3 2 /* HVQ Classifier - Maximum number of peaks for band with low sharpness */ -#define HVQ_PA_SHARP_THRES2 16.0f /* HVQ Classifier - Sharpness threshold for band with medium sharpness */ -#define HVQ_PA_SHARP_THRES3 12.0f /* HVQ Classifier - Sharpness threshold for band with low sharpness */ -#define HVQ_PA_SHARP_THRES2_FX 1024 /* Q6 16.0 - HVQ Classifier - Sharpness threshold for band with medium sharpness */ -#define HVQ_PA_SHARP_THRES3_FX 768 /* Q6 12.0 - HVQ Classifier - Sharpness threshold for band with low sharpness */ +#define HVQ_PA_SHARP_THRES2_FX 1024 /* Q6 16.0 - HVQ Classifier - Sharpness threshold for band with medium sharpness */ +#define HVQ_PA_SHARP_THRES3_FX 768 /* Q6 12.0 - HVQ Classifier - Sharpness threshold for band with low sharpness */ #define HVQ_BW 32 /* HVQ Classifier subband bandwidth */ #define HVQ_NSUB_32k 10 #define HVQ_NSUB_24k 7 /* HVQ Classifier number of subbands */ -#define HQ_CREST_THRESHOLD 7.0f /* HQ harmonic high band classifier, crest threshold */ -#define HQ_CREST_THRESHOLD_FX 1879048192 //7.0f in Q28 /* HQ harmonic high band classifier, crest threshold */ -#define HQ_CREST_MOD_THRESHOLD 2.128f /* HQ harmonic high band classifier, modified crest threshold */ -#define HQ_CREST_MOD_THRESHOLD_FX 1142461301 //2.128f in Q29 /* HQ harmonic high band classifier, modified crest threshold */ -#define HQ_CREST_FAC_SM 0.97f /* HQ harmonic high band classifier, smoothing factor */ -#define HQ_CREST_FAC_SM_FX 2083059139 //0.97f in Q31 /* HQ harmonic high band classifier, smoothing factor */ +#define HQ_CREST_THRESHOLD_FX 1879048192 /* HQ harmonic high band classifier, crest threshold, 7.0f in Q28 */ +#define HQ_CREST_MOD_THRESHOLD_FX 1142461301 /* HQ harmonic high band classifier, modified crest threshold, 2.128f in Q29 */ +#define HQ_CREST_FAC_SM_FX 2083059139 /* HQ harmonic high band classifier, smoothing factor, 0.97f in Q31 */ #define HVQ_BWE_NOISE_BANDS 2 /* Number of BWE noise bands */ -#define HVQ_BWE_WEIGHT1 0.95f -#define HVQ_BWE_WEIGHT2 0.2f -#define HVQ_NFPE_FACTOR 6.4f -#define HVQ_LB_NFPE_FACTOR 3.2f -#define HVQ_BWE_WEIGHT1_FX ((Word16)31130) /* 0.95 in Q15 */ -#define HVQ_BWE_WEIGHT2_FX ((Word16)6554) /* 0.2 in Q15 */ -#define HVQ_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 6.4^3 in Q6 */ -#define HVQ_LB_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 3.2^3 in Q9 */ +#define HVQ_BWE_WEIGHT1_FX ((Word16)31130) /* 0.95 in Q15 */ +#define HVQ_BWE_WEIGHT2_FX ((Word16)6554) /* 0.2 in Q15 */ +#define HVQ_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 6.4^3 in Q6 */ +#define HVQ_LB_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 3.2^3 in Q9 */ #define HVQ_VQ_DIM 5 /* HVQ peak VQ dimension */ #define HVQ_PVQ_GAIN_BITS 5 /* Number of bits to encode PVQ gains in HVQ */ @@ -2344,9 +2023,9 @@ enum QuantaMode #define KMAX 512 #define KMAX_NON_DIRECT 96 /* max K for non-direct indexing recursion rows */ #define ODD_DIV_SIZE 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ -#define KMAX_FX 512 -#define KMAX_NON_DIRECT_FX 96 /* max K for non-direct indexing recursion rows is 1+KMAX_NON_DIRECT +1 */ -#define ODD_DIV_SIZE_FX 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ +#define KMAX_FX 512 +#define KMAX_NON_DIRECT_FX 96 /* max K for non-direct indexing recursion rows is 1+KMAX_NON_DIRECT +1 */ +#define ODD_DIV_SIZE_FX 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ /* TCQ */ #define TCQ_MAX_BAND_SIZE 120 /* Maxiumum supported band size for TCQ+USQ search */ @@ -2503,8 +2182,7 @@ enum QuantaMode #define MAX_PLOCS L_PROT48k / 4 + 1 /* maximum number of spectral peaks to be searched */ #define QUOT_LPR_LTR 4 #define LGW_MAX 9 /* maximum number frequency group widths */ -#define BETA_MUTE_FAC_INI_FLT 0.5f /* initial noise attenuation factor */ -#define BETA_MUTE_FAC_INI 16384 /* Q15, initial noise attenuation factor */ +#define BETA_MUTE_FAC_INI 16384 /* 0.5f in Q15, initial noise attenuation factor */ #define L_TRANA32k ( L_PROT32k / QUOT_LPR_LTR ) /* transient analysis frame length */ #define L_TRANA16k ( L_TRANA32k / 2 ) #define L_TRANA8k ( L_TRANA32k / 4 ) @@ -2520,16 +2198,11 @@ enum QuantaMode #define OFF_FRAMES_LIMIT 30 /* HQ phase ECU, burst length for muting to zero */ #define PH_ECU_MUTE_START 15 /* HQ phase ECU, burst length to start steep muting */ -#define SCALE_DOWN_3dB 0.7071f -#define MAX_TILT 0.f -#define ED_THRES 1.0f +//#define SCALE_DOWN_3dB 0.7071f -#define ED_THRES_12P 0.032209f -#define ED_THRES_50P 0.159063f -#define ED_THRES_90P 0.532669 -#define ED_THRES_12P_fx 66 -#define ED_THRES_50P_fx 326 -#define ED_THRES_90P_fx 1091 +#define ED_THRES_12P_fx 66 /* 0.032209f */ +#define ED_THRES_50P_fx 326 /* 0.159063f */ +#define ED_THRES_90P_fx 1091 /* 0.532669f */ #define MAXDELAY_FEC 224 @@ -2547,26 +2220,19 @@ enum QuantaMode #define GROUP_LENGTH 7 #define MAX_PEAKS_FROM_PITCH 10 #define LAST_HARMONIC_POS_TO_CHECK 128 /* 128 because we check harmonics only up to 3.2 kHz */ -#define ALLOWED_SIDE_LOBE_FLUCTUATION_FLT 3.0f /* 4.8 dB */ -#define ALLOWED_SIDE_LOBE_FLUCTUATION 24576/*3.0f Q13*/ /* 4.8 dB */ -#define ALLOWED_SIDE_LOBE_FLUCTUATION_EXP 2 -#define LEVEL_ABOVE_ENVELOPE_FLT 7.59f /* 8.8 dB */ -#define UNREACHABLE_THRESHOLD_FLT 16.0f /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT so that the threshold is not reached */ -#define SMALL_THRESHOLD_FLT 1.10f /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT for the peak detection at a definitive peak in the estimated spectrum */ -#define BIG_THRESHOLD_FLT 1.5f /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT for the peak detection at a probable peak in the estimated spectrum */ -#define LEVEL_ABOVE_ENVELOPE 7.59f /* 8.8 dB */ -#define UNREACHABLE_THRESHOLD 16384/*16.0f Q10*/ /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE so that the threshold is not reached */ -#define SMALL_THRESHOLD 1126/*1.10f Q10*/ /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a definitive peak in the estimated spectrum */ -#define BIG_THRESHOLD 1536/*1.5f Q10*/ /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a probable peak in the estimated spectrum */ - -#define kSmallerLagsTargetBitsThreshold 150 -#define kCtxHmOlRSThr_FLT 2.6f -#define kLtpHmGainThr_FLT 0.46f /* Use the LTP pitch lag in the harmonic model? */ -#define kLtpHmGainThr 0x3AE1 /* 0.46f */ -#define kCtxHmOlRSThr 0x5333 /* 2.6f (2Q13) */ - -#define kTcxHmSnrOffsetGc 8/*0.03125f Q8*/ -#define kTcxHmSnrOffsetVc 0 +#define ALLOWED_SIDE_LOBE_FLUCTUATION 24576 /*3.0f Q13*/ /* 4.8 dB */ +#define ALLOWED_SIDE_LOBE_FLUCTUATION_EXP 2 +#define LEVEL_ABOVE_ENVELOPE 7.59f /* 8.8 dB */ +#define UNREACHABLE_THRESHOLD 16384 /* 16.0f Q10*/ /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE so that the threshold is not reached */ +#define SMALL_THRESHOLD 1126 /* 1.10f Q10*/ /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a definitive peak in the estimated spectrum */ +#define BIG_THRESHOLD 1536 /* 1.5f Q10*/ /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a probable peak in the estimated spectrum */ + +#define kSmallerLagsTargetBitsThreshold 150 +#define kLtpHmGainThr 0x3AE1 /* 0.46f, Use the LTP pitch lag in the harmonic model? */ +#define kCtxHmOlRSThr 0x5333 /* 2.6f (2Q13) */ + +#define kTcxHmSnrOffsetGc 8 /* 0.03125f Q8 */ +#define kTcxHmSnrOffsetVc 0 #define kTcxHmNumGainBits 2 /* Number of bits for the gain index */ #define kTcxHmParabolaHalfWidth 4 /* Parabola half width */ @@ -2673,13 +2339,9 @@ enum #define CUTFREE_ABS_RANGE 6 #define CUTFREE_REL_RANGE 0.25 -#define VBR_ADR_MAX_TARGET 6.15f /* max target ADR for VBR. This rate is used in the closed loop rate control */ +#define PPP_LAG_THRLD_Q6 180*64 #define PPP_LAG_THRLD 180 /* max lag allowed for PPP coding */ - -#define PPP_LAG_THRLD_Q6 180*64 -#define PPP_LAG_THRLD 180 -#define SNR_THLD_FX_Q8 17152 /* Threshold is upscaled to Q8 to compared with st->vadsnr*/ - +#define SNR_THLD_FX_Q8 17152 /* Threshold is upscaled to Q8 to compared with st->vadsnr*/ #define MAXLAG_WI ( PPP_LAG_THRLD / 2 + 12 ) /* Maximum lag used in waveform interpolation */ #define MAX_LAG_PIT ( PPP_LAG_THRLD + 21 ) /* Max possible pitch lag after adding delta lag */ @@ -2690,21 +2352,21 @@ enum #define Q_SCALE 7 -#define CONST_1_16_Q14 19005 /* 1.16*16384 */ -#define CONST_1_37_Q14 22446 /* 1.37*16384 */ -#define SCALE_DOWN_ERAS_Q15 26214 /* 0.8*32768 */ -#define SHAPE1_COEF_QF 15 /* shape1 num and den coeffcient Q format */ -#define SHAPE2_COEF_QF 15 /* shape2 num and den coeffcient Q format */ -#define SHAPE3_COEF_QF 15 /* shape3 num and den coeffcient Q format */ -#define BP1_COEF_WB_QF 14 /* wb num and den coeffcient Q format */ -#define BP1_COEF_NB_QF_ORDER7 13 /* nb num and den coeffcient Q format */ +#define CONST_1_16_Q14 19005 /* 1.16*16384 */ +#define CONST_1_37_Q14 22446 /* 1.37*16384 */ +#define SCALE_DOWN_ERAS_Q15 26214 /* 0.8*32768 */ +#define SHAPE1_COEF_QF 15 /* shape1 num and den coeffcient Q format */ +#define SHAPE2_COEF_QF 15 /* shape2 num and den coeffcient Q format */ +#define SHAPE3_COEF_QF 15 /* shape3 num and den coeffcient Q format */ +#define BP1_COEF_WB_QF 14 /* wb num and den coeffcient Q format */ +#define BP1_COEF_NB_QF_ORDER7 13 /* nb num and den coeffcient Q format */ /*----------------------------------------------------------------------------------* * JBM *----------------------------------------------------------------------------------*/ -#define MAX_JBM_SLOTS 100 /* every primary copy and partial copy stored in JBM needs one slot */ -#define MAX_AU_SIZE ( ( MAX_BITS_PER_FRAME + 7 ) / 8 ) /* max frame size in bytes */ +#define MAX_JBM_SLOTS 100 /* every primary copy and partial copy stored in JBM needs one slot */ +#define MAX_AU_SIZE ( ( MAX_BITS_PER_FRAME + 7 ) / 8 ) /* max frame size in bytes */ #define ACTIVE 4 #define BACKGROUND 1 @@ -2718,99 +2380,99 @@ enum /*------------------------------------------------------------------------------------* FEC_clas_estim constants *-------------------------------------------------------------------------------------*/ + #define Q_MAX 12 -#define LG10 24660 /* 10*log10(2) in Q13 */ +#define LG10 24660 /* 10*log10(2) in Q13 */ #define L_Q_MEM 5 #define GE_SHIFT 6 #define LSF_1_OVER_256SQ 5000 #define LSF_1_OVER_256SQSQ 763 -#define G_CODE_MIN_TC_Q15 655 /*0.02 Q15*/ +#define G_CODE_MIN_TC_Q15 655 /*0.02 Q15*/ #define G_CODE_MAX_TC_Q0 5 -#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit (0.0 in Q13) */ -#define G_PITCH_MAX_MINUS_MIN_Q13 9994 /* SQ of gains: pitch gain upper limit (1.22-0 in Q13) */ +#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit (0.0 in Q13) */ +#define G_PITCH_MAX_MINUS_MIN_Q13 9994 /* SQ of gains: pitch gain upper limit (1.22-0 in Q13) */ /* higher ACELP constants */ -#define G_AVQ_MIN_32kbps_Q15 2621 /* lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ -#define G_AVQ_MIN_Q15 26214 /* lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ -#define G_AVQ_MAX_Q0 96 /* upper limit for gain Q in higher-rate ACELP contribtuion */ - -#define LG10_G_AVQ_MIN_32kbps_Q14 (-17972) /* log10(0.08) lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ -#define LG10_G_AVQ_MIN_Q14 (-1588) /* log10(0.8) lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ -#define LG10_G_AVQ_MAX_Q13 16239 /* log10(96) upper limit for gain Q in higher-rate ACELP contribtuion */ -#define LG10_G_CODE_MIN_TC192_Q14 (-3635) /* log10(0.6) */ -#define LG10_G_CODE_MAX_TC192_Q13 13212 /* log10(41) */ -#define LG10_G_CODE_MAX_Q13 5726 /* log10(5) SQ of gains: code gain upper limit */ -#define LG10_G_CODE_MIN_Q14 (-27836) /* log10(0.02) SQ of gains: code gain lower limit */ -#define LG10_G_CODE_MIN_TC_Q14 LG10_G_CODE_MIN_Q14 /* log10(0.02) Q15*/ -#define LG10_G_CODE_MAX_TC_Q13 LG10_G_CODE_MAX_Q13 - -#define LN_2_Q31 (1488521848 ) +#define G_AVQ_MIN_32kbps_Q15 2621 /* lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ +#define G_AVQ_MIN_Q15 26214 /* lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ +#define G_AVQ_MAX_Q0 96 /* upper limit for gain Q in higher-rate ACELP contribtuion */ + +#define LG10_G_AVQ_MIN_32kbps_Q14 (-17972) /* log10(0.08) lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ +#define LG10_G_AVQ_MIN_Q14 (-1588) /* log10(0.8) lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ +#define LG10_G_AVQ_MAX_Q13 16239 /* log10(96) upper limit for gain Q in higher-rate ACELP contribtuion */ +#define LG10_G_CODE_MIN_TC192_Q14 (-3635) /* log10(0.6) */ +#define LG10_G_CODE_MAX_TC192_Q13 13212 /* log10(41) */ +#define LG10_G_CODE_MAX_Q13 5726 /* log10(5) SQ of gains: code gain upper limit */ +#define LG10_G_CODE_MIN_Q14 (-27836) /* log10(0.02) SQ of gains: code gain lower limit */ +#define LG10_G_CODE_MIN_TC_Q14 LG10_G_CODE_MIN_Q14 /* log10(0.02) Q15*/ +#define LG10_G_CODE_MAX_TC_Q13 LG10_G_CODE_MAX_Q13 + +#define LN_2_Q31 (1488521848 ) /* AVQ (RE8) related consatnts */ -#define QR 32768 -#define Q_AVQ_OUT 6 /* AVQ_output scaling currently Q9, but may change */ -#define Q_AVQ_OUT_DEC 10 +#define QR 32768 +#define Q_AVQ_OUT 6 /* AVQ_output scaling currently Q9, but may change */ +#define Q_AVQ_OUT_DEC 10 -#define PIT_DECODE_2XL_SUBFR (2*L_SUBFR) -#define PIT_FR1_8b_MINUS_PIT_MIN_X2 ((PIT_FR1_8b-PIT_MIN)*2) +#define PIT_DECODE_2XL_SUBFR (2*L_SUBFR) +#define PIT_FR1_8b_MINUS_PIT_MIN_X2 ((PIT_FR1_8b-PIT_MIN)*2) #define PIT_FR1_8b_MINUS_PIT_FR1_8b_MINUS_PIT_MIN_X2 (PIT_FR1_8b-PIT_FR1_8b_MINUS_PIT_MIN_X2) -#define PIT_FR2_9b_MINUS_PIT_MIN_X4 ((PIT_FR2_9b-PIT_MIN)*4) -#define PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2 ((PIT_FR1_EXTEND_8b-PIT_MIN_EXTEND)*2) -#define PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 ((PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4) -#define PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2 ((PIT_FR1_EXTEND_9b-PIT_FR2_EXTEND_9b)*2) -#define PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2 ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2 ) -#define PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4 ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 ) - -#define PIT_DECODE_1 ((PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2) -#define PIT_DECODE_2 ((PIT_FR2_9b-PIT_MIN)*4) -#define PIT_DECODE_3 (PIT_FR1_9b - ((PIT_FR2_9b-PIT_MIN)*4) - ((PIT_FR1_9b-PIT_FR2_9b)*2)) -#define PIT_DECODE_7 (PIT_FR1_EXTEND_9b - (PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4) - (PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2)) -#define PIT_DECODE_8 (PIT_FR1_DOUBLEEXTEND_8b - ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2)) -#define PIT_DECODE_9 (( (PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 + (PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) -#define PIT_DECODE_10 (PIT_FR1_DOUBLEEXTEND_9b - ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4) - ((PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) - -#define BIN4_FX 800 -#define TH_COR_FX 19661 /* Q15 Minimum correlation for per bin processing */ -#define TH_D_FX 800 /* 50 (Q4) Difference limit between nearest harmonic and a frequency bin */ -#define TH_PIT_FX 128 /* (Fs / (2.0f * TH_D)) Maximum pitch for per bin processing */ - -#define GUESS_TBL_SZ 256 -#define INT_FS_FX 12800 /* internal sampling frequency */ -#define INT_FS_16k_FX 16000 /* CELP core internal sampling frequency @16kHz */ - -#define WB_LIMIT_LSF_FX 16256 -#define Fs_2 16384 /* lsf max value (Use in reorder_fx.c) */ -#define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */ - -#define LG10 24660 /* 10*log10(2) in Q13 */ -#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ -#define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ -#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ -#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ -#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ +#define PIT_FR2_9b_MINUS_PIT_MIN_X4 ((PIT_FR2_9b-PIT_MIN)*4) +#define PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2 ((PIT_FR1_EXTEND_8b-PIT_MIN_EXTEND)*2) +#define PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 ((PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4) +#define PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2 ((PIT_FR1_EXTEND_9b-PIT_FR2_EXTEND_9b)*2) +#define PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2 ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2 ) +#define PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4 ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 ) + +#define PIT_DECODE_1 ((PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2) +#define PIT_DECODE_2 ((PIT_FR2_9b-PIT_MIN)*4) +#define PIT_DECODE_3 (PIT_FR1_9b - ((PIT_FR2_9b-PIT_MIN)*4) - ((PIT_FR1_9b-PIT_FR2_9b)*2)) +#define PIT_DECODE_7 (PIT_FR1_EXTEND_9b - (PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4) - (PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2)) +#define PIT_DECODE_8 (PIT_FR1_DOUBLEEXTEND_8b - ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2)) +#define PIT_DECODE_9 (( (PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 + (PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) +#define PIT_DECODE_10 (PIT_FR1_DOUBLEEXTEND_9b - ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4) - ((PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) + +#define BIN4_FX 800 +#define TH_COR_FX 19661 /* Q15 Minimum correlation for per bin processing */ +#define TH_D_FX 800 /* 50 (Q4) Difference limit between nearest harmonic and a frequency bin */ +#define TH_PIT_FX 128 /* (Fs / (2.0f * TH_D)) Maximum pitch for per bin processing */ + +#define GUESS_TBL_SZ 256 +#define INT_FS_FX 12800 /* internal sampling frequency */ +#define INT_FS_16k_FX 16000 /* CELP core internal sampling frequency @16kHz */ + +#define WB_LIMIT_LSF_FX 16256 +#define Fs_2 16384 /* lsf max value (Use in reorder_fx.c) */ +#define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */ + +#define LG10 24660 /* 10*log10(2) in Q13 */ +#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ +#define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ +#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ +#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ +#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ #ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA -#define INV_LOG2_10 9864 /* 1/log2(10), Q15*/ +#define INV_LOG2_10 9864 /* 1/log2(10), Q15*/ #endif -#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ +#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ -#define E_MIN_FXQ15 115 /* Q15*/ -#define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/ +#define E_MIN_FXQ15 115 /* Q15*/ +#define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/ -#define MAX_DYNAMIC_FX (82*128) -#define MIN_DYNAMIC_FX (50*128) -#define DYNAMIC_RANGE_FX (MAX_DYNAMIC_FX-MIN_DYNAMIC_FX) -#define MAX_GSC_NF_BITS 3 -//#define GSC_NF_STEPS (1 << MAX_GSC_NF_BITS) -#define GSF_NF_DELTA_FX (DYNAMIC_RANGE_FX/GSC_NF_STEPS) +#define MAX_DYNAMIC_FX (82*128) +#define MIN_DYNAMIC_FX (50*128) +#define DYNAMIC_RANGE_FX (MAX_DYNAMIC_FX-MIN_DYNAMIC_FX) +#define MAX_GSC_NF_BITS 3 +#define GSF_NF_DELTA_FX (DYNAMIC_RANGE_FX/GSC_NF_STEPS) /*----------------------------------------------------------------------------------* * AVQ constants *----------------------------------------------------------------------------------*/ -#define MIN_GLOB_GAIN_BWE_HR_FX 24576 /* Q13 */ -#define MAX_GLOB_GAIN_BWE_HR_FX 32000 /* Q6 */ +#define MIN_GLOB_GAIN_BWE_HR_FX 24576 /* Q13 */ +#define MAX_GLOB_GAIN_BWE_HR_FX 32000 /* Q6 */ #define LG10_MIN_GLOB_GAIN_BWE_HR_Q14 7817 #define LG10_MAX_GLOB_GAIN_BWE_HR_Q13 22110 @@ -2819,186 +2481,187 @@ enum * LD music post-filter constants *----------------------------------------------------------------------------------*/ -#define BIN_16kdct_fx (6400/DCT_L_POST) -#define E_MIN_Q15 14680 /* 0.0035 -> Q22 */ +#define BIN_16kdct_fx (6400/DCT_L_POST) +#define E_MIN_Q15 14680 /* 0.0035 -> Q22 */ -#define QSCALE 7 -#define MODE2_E_MIN 4/*0.03f Q0*/ /* 0.03f in QSCALE */ -#define MODE2_E_MIN_Q15 983/*0.03f Q15*/ /* 0.03f in Q15*/ +#define QSCALE 7 +#define MODE2_E_MIN 4 /*0.03f Q0*/ /* 0.03f in QSCALE */ +#define MODE2_E_MIN_Q15 983 /*0.03f Q15*/ /* 0.03f in Q15*/ /* long term pst parameters : */ -#define L2_LH2_L 4 /* log2(LH2_L) */ -#define MIN_GPLT_FX 21845 /* LT gain minimum 1/1.5 (Q15) */ +#define L2_LH2_L 4 /* log2(LH2_L) */ +#define MIN_GPLT_FX 21845 /* LT gain minimum 1/1.5 (Q15) */ -#define AGC_FAC_FX 32358 /* gain adjustment factor 0.9875 (Q15) */ -#define AGC_FAC1_FX (Word16)(32768L - AGC_FAC_FX) +#define AGC_FAC_FX 32358 /* gain adjustment factor 0.9875 (Q15) */ +#define AGC_FAC1_FX (Word16)(32768L - AGC_FAC_FX) -#define DOWNMIX_12k8_FX 1850 +#define DOWNMIX_12k8_FX 1850 /*----------------------------------------------------------------------------------* * HQ Constants *----------------------------------------------------------------------------------*/ -#define INV2POWHALF 23170 /* Q15, sqrt(2)/2 */ -#define EPSILLON_FX (Word16) 1 -#define MAX_SFM_LEN_FX 96 -#define MAX_P_ATT_FX (Word16) 40 /* Maximum number of pulses for gain attenuation factor */ -#define MAX_PHG_FX (Word16) 10 /* Q0, Maximum number of pulses for which to apply pulse height dependent gain */ -#define PHG_START_FX (Word16) 3277 /* Q15, 0.1f */ -#define PHG_DELTA_FX (Word16) 2621 /* Q15, ((PHG_END-PHG_START)/MAX_PHG) */ -#define ENV_ADJ_START_FX (Word16) 6 /* Q0, Number of consecutive bands for which the attenuation is maximum */ -#define ENV_ADJ_INV_INCL_FX (Word16) 6554 /* Q15, 1/5.0f, Inverse inclination for mapping between attenuation region width and attenuation limit */ - -#define INV_HVQ_THRES_BIN_24k 9362 /* 1/224 in Q21 */ -#define INV_HVQ_THRES_BIN_32k 6554 /* 1/320 in Q21 */ -#define INV_BANDS_PER_SUBFRAMES 14564 /* 1/9 in Q17 */ -#define NUM_SUBFRAMES 4 -#define BANDS_PER_SUBFRAMES 9 -#define ENERGY_TH_NUM_SUBFRAMES 1638400L /* 400 in Q12 */ -#define INV_SFM_N_ENV_STAB 19418 /* 1/27 in Q19 */ -#define ENERGY_TH_FX 819200L /* 100 in Q13 */ -#define ENERGY_LT_BETA_FX 30474 /* 0.93 in Q15 - Smoothing factor for long-term energy measure */ -#define ENERGY_LT_BETA_1_FX 2294 /* 0.07 i Q15 - (1 - ENERGY_LT_BETA_FX) */ -#define INV_DELTA_TH 13107 /* 1/5 in Q16 - Inverse Delta energy threshold for transient detection for envelope stability */ - -#define ONE_OVER_HVQ_BAND_MAX_BITS_24k_FX ((Word16) 410) /* Q15, 1/80 = 0.0125 */ -#define ONE_OVER_HVQ_BAND_MAX_BITS_32k_FX ((Word16) 345) /* Q15, 1/95 = 0.010526315 */ - -#define INV_PREECHO_SMOOTH_LENP1_FX 1560 /*(32768 / (PREECHO_SMOOTH_LEN + 1.0));*/ - -#define INV_HVQ_BW 1024 /* Q15 1/32 */ - -#define ACELP_48k_BITS 960 /* Q0 - ACELP_48k / 50 */ +#define INV2POWHALF 23170 /* Q15, sqrt(2)/2 */ +#define EPSILLON_FX (Word16) 1 +#define MAX_SFM_LEN_FX 96 +#define MAX_P_ATT_FX (Word16) 40 /* Maximum number of pulses for gain attenuation factor */ +#define MAX_PHG_FX (Word16) 10 /* Q0, Maximum number of pulses for which to apply pulse height dependent gain */ +#define PHG_START_FX (Word16) 3277 /* Q15, 0.1f */ +#define PHG_DELTA_FX (Word16) 2621 /* Q15, ((PHG_END-PHG_START)/MAX_PHG) */ +#define ENV_ADJ_START_FX (Word16) 6 /* Q0, Number of consecutive bands for which the attenuation is maximum */ +#define ENV_ADJ_INV_INCL_FX (Word16) 6554 /* Q15, 1/5.0f, Inverse inclination for mapping between attenuation region width and attenuation limit */ + +#define INV_HVQ_THRES_BIN_24k 9362 /* 1/224 in Q21 */ +#define INV_HVQ_THRES_BIN_32k 6554 /* 1/320 in Q21 */ +#define INV_BANDS_PER_SUBFRAMES 14564 /* 1/9 in Q17 */ +#define NUM_SUBFRAMES 4 +#define BANDS_PER_SUBFRAMES 9 +#define ENERGY_TH_NUM_SUBFRAMES 1638400L /* 400 in Q12 */ +#define INV_SFM_N_ENV_STAB 19418 /* 1/27 in Q19 */ +#define ENERGY_TH_FX 819200L /* 100 in Q13 */ +#define ENERGY_LT_BETA_FX 30474 /* 0.93 in Q15 - Smoothing factor for long-term energy measure */ +#define ENERGY_LT_BETA_1_FX 2294 /* 0.07 i Q15 - (1 - ENERGY_LT_BETA_FX) */ +#define INV_DELTA_TH 13107 /* 1/5 in Q16 - Inverse Delta energy threshold for transient detection for envelope stability */ + +#define ONE_OVER_HVQ_BAND_MAX_BITS_24k_FX ((Word16) 410) /* Q15, 1/80 = 0.0125 */ +#define ONE_OVER_HVQ_BAND_MAX_BITS_32k_FX ((Word16) 345) /* Q15, 1/95 = 0.010526315 */ + +#define INV_PREECHO_SMOOTH_LENP1_FX 1560 /*(32768 / (PREECHO_SMOOTH_LEN + 1.0));*/ + +#define INV_HVQ_BW 1024 /* Q15 1/32 */ + +#define ACELP_48k_BITS 960 /* Q0 - ACELP_48k / 50 */ /*----------------------------------------------------------------------------------* * ISF quantizer constants *----------------------------------------------------------------------------------*/ - /*qlpc_avq, lsf_msvq_ma*/ -#define W_MODE0 0x1333 /*60.0f/FREQ_DIV in 0Q15*/ -#define W_MODE1 0x14CD /*65.0f/FREQ_DIV in 0Q15*/ -#define W_MODE2 0x147B /*64.0f/FREQ_DIV in 0Q15*/ -#define W_MODE_ELSE 0x1429 /*60.0f/FREQ_DIV in 0Q15*/ -/* qmc_cng_common.h */ -/* codec side */ -#define SCALE_TABLE_SHIFT_FACTOR (31-23) - -/* parameter_bitmapping.h */ -#define NPARAMS_MAX 10 + +#define W_MODE0 0x1333 /*60.0f/FREQ_DIV in 0Q15*/ +#define W_MODE1 0x14CD /*65.0f/FREQ_DIV in 0Q15*/ +#define W_MODE2 0x147B /*64.0f/FREQ_DIV in 0Q15*/ +#define W_MODE_ELSE 0x1429 /*60.0f/FREQ_DIV in 0Q15*/ +#define SCALE_TABLE_SHIFT_FACTOR (31-23) + +#define NPARAMS_MAX 10 /* Flags for CLDFB intialization */ /* Flag indicating that the states should be kept. */ -#define CLDFB_FLAG_KEEP_STATES 8 +#define CLDFB_FLAG_KEEP_STATES 8 /* Flag indicating 2.5 ms setup */ -#define CLDFB_FLAG_2_5MS_SETUP 128 +#define CLDFB_FLAG_2_5MS_SETUP 128 + typedef enum SIGNAL_CLASSIFER_MODE { CLASSIFIER_ACELP, CLASSIFIER_TCX } SIGNAL_CLASSIFIER_MODE; -#define CNT0P1 1717986918 /* 0.1*2^34 */ -#define CNT0P001 1099511627 /* 0.001*2^40 */ -#define CNT0P0001 1759218604 /* 0.0001*2^44 */ +#define CNT0P1 1717986918 /* 0.1*2^34 */ +#define CNT0P001 1099511627 /* 0.001*2^40 */ +#define CNT0P0001 1759218604 /* 0.0001*2^44 */ -#define CNT0P05 1717986918 /* 0.05*2^35 */ +#define CNT0P05 1717986918 /* 0.05*2^35 */ -#define CNT1DIV28 1227133513 /* (1/28)*2^35 */ -#define CNT1DIV14 1227133513 /* (1/14)*2^34 */ -#define CNT1DIV8 1073741824 /* (1/8)*2^33 */ +#define CNT1DIV28 1227133513 /* (1/28)*2^35 */ +#define CNT1DIV14 1227133513 /* (1/14)*2^34 */ +#define CNT1DIV8 1073741824 /* (1/8)*2^33 */ + +#define SP_CENTER_Q 10 +#define ITD_STABLE_RATE_Q 15 +#define SPEC_AMP_Q 14 +#define SFM_Q 15 +#define TONA_Q 14 +#define lt_bg_highf_eng_Q 16 -#define SP_CENTER_Q 10 -#define ITD_STABLE_RATE_Q 15 -#define SPEC_AMP_Q 14 -#define SFM_Q 15 -#define TONA_Q 14 -#define lt_bg_highf_eng_Q 16 /*----------------------------------------------------------------------------------* * TEC/TFA *----------------------------------------------------------------------------------*/ -#define DELAY_TEMP_ENV_BUFF_TEC 9 -#define EXT_DELAY_HI_TEMP_ENV 2 - - - /************************************************************************/ - /* CLDFB */ - /************************************************************************/ -#define SCALE_MODULATION ( 1 ) - -#define SCALE_GAIN_ANA_10 ( 4 ) -#define SCALE_GAIN_ANA_16 ( 3 ) -#define SCALE_GAIN_ANA_20 ( 3 ) -#define SCALE_GAIN_ANA_32 ( 2 ) -#define SCALE_GAIN_ANA_30 ( 2 ) -#define SCALE_GAIN_ANA_40 ( 2 ) -#define SCALE_GAIN_ANA_60 ( 1 ) - -#define SCALE_GAIN_SYN (-6 ) - -#define SCALE_CLDFB_ANA_10 ( SCALE_MODULATION + SCALE_GAIN_ANA_10 ) -#define SCALE_CLDFB_ANA_16 ( SCALE_MODULATION + SCALE_GAIN_ANA_16 ) -#define SCALE_CLDFB_ANA_20 ( SCALE_MODULATION + SCALE_GAIN_ANA_20 ) -#define SCALE_CLDFB_ANA_32 ( SCALE_MODULATION + SCALE_GAIN_ANA_32 ) -#define SCALE_CLDFB_ANA_40 ( SCALE_MODULATION + SCALE_GAIN_ANA_40 ) -#define SCALE_CLDFB_ANA_60 ( SCALE_MODULATION + SCALE_GAIN_ANA_60 ) -#define SCALE_CLDFB_ANA_30 ( SCALE_MODULATION + SCALE_GAIN_ANA_30 ) - -#define SCALE_CLDFB_SYN_10 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_16 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_20 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_32 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_40 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_60 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_30 ( SCALE_MODULATION + SCALE_GAIN_SYN ) - -/************************************************************************/ -/* FFT */ -/************************************************************************/ -#define SCALEFACTORN2 ( 3) -#define SCALEFACTOR2 ( 2) -#define SCALEFACTOR3 ( 3) -#define SCALEFACTOR4 ( 3) -#define SCALEFACTOR5 ( 4) -#define SCALEFACTOR8 ( 4) -#define SCALEFACTOR10 ( 5) -#define SCALEFACTOR12 ( 5) -#define SCALEFACTOR15 ( 5) -#define SCALEFACTOR16_5 ( 5) -#define SCALEFACTOR20_5 ( 5) -#define SCALEFACTOR24 ( 6) -#define SCALEFACTOR30 ( 6) -#define SCALEFACTOR30_1 ( 5) -#define SCALEFACTOR30_2 ( 1) -#define SCALEFACTOR32 ( 6) -#define SCALEFACTOR32_1 ( 5) -#define SCALEFACTOR32_2 ( 1) -#define SCALEFACTOR40 ( 7) -#define SCALEFACTOR60 ( 7) -#define SCALEFACTOR64 ( 7) -#define SCALEFACTOR80 ( 8) -#define SCALEFACTOR100 (10) -#define SCALEFACTOR120 ( 8) -#define SCALEFACTOR128 ( 8) -#define SCALEFACTOR160 ( 8) -#define SCALEFACTOR192 (10) -#define SCALEFACTOR200 (10) -#define SCALEFACTOR240 ( 9) -#define SCALEFACTOR256 ( 9) -#define SCALEFACTOR320 (10) -#define SCALEFACTOR400 (10) -#define SCALEFACTOR480 (11) -#define SCALEFACTOR600 (10) - -#define BASOP_CFFT_MAX_LENGTH 600 +#define DELAY_TEMP_ENV_BUFF_TEC 9 +#define EXT_DELAY_HI_TEMP_ENV 2 + + +/*----------------------------------------------------------------------------------* + * CLDFB + *----------------------------------------------------------------------------------*/ + +#define SCALE_MODULATION ( 1 ) + +#define SCALE_GAIN_ANA_10 ( 4 ) +#define SCALE_GAIN_ANA_16 ( 3 ) +#define SCALE_GAIN_ANA_20 ( 3 ) +#define SCALE_GAIN_ANA_32 ( 2 ) +#define SCALE_GAIN_ANA_30 ( 2 ) +#define SCALE_GAIN_ANA_40 ( 2 ) +#define SCALE_GAIN_ANA_60 ( 1 ) + +#define SCALE_GAIN_SYN (-6 ) + +#define SCALE_CLDFB_ANA_10 ( SCALE_MODULATION + SCALE_GAIN_ANA_10 ) +#define SCALE_CLDFB_ANA_16 ( SCALE_MODULATION + SCALE_GAIN_ANA_16 ) +#define SCALE_CLDFB_ANA_20 ( SCALE_MODULATION + SCALE_GAIN_ANA_20 ) +#define SCALE_CLDFB_ANA_32 ( SCALE_MODULATION + SCALE_GAIN_ANA_32 ) +#define SCALE_CLDFB_ANA_40 ( SCALE_MODULATION + SCALE_GAIN_ANA_40 ) +#define SCALE_CLDFB_ANA_60 ( SCALE_MODULATION + SCALE_GAIN_ANA_60 ) +#define SCALE_CLDFB_ANA_30 ( SCALE_MODULATION + SCALE_GAIN_ANA_30 ) + +#define SCALE_CLDFB_SYN_10 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_16 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_20 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_32 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_40 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_60 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_30 ( SCALE_MODULATION + SCALE_GAIN_SYN ) + + +/*----------------------------------------------------------------------------------* + * FFT + *----------------------------------------------------------------------------------*/ + +#define SCALEFACTORN2 ( 3) +#define SCALEFACTOR2 ( 2) +#define SCALEFACTOR3 ( 3) +#define SCALEFACTOR4 ( 3) +#define SCALEFACTOR5 ( 4) +#define SCALEFACTOR8 ( 4) +#define SCALEFACTOR10 ( 5) +#define SCALEFACTOR12 ( 5) +#define SCALEFACTOR15 ( 5) +#define SCALEFACTOR16_5 ( 5) +#define SCALEFACTOR20_5 ( 5) +#define SCALEFACTOR24 ( 6) +#define SCALEFACTOR30 ( 6) +#define SCALEFACTOR30_1 ( 5) +#define SCALEFACTOR30_2 ( 1) +#define SCALEFACTOR32 ( 6) +#define SCALEFACTOR32_1 ( 5) +#define SCALEFACTOR32_2 ( 1) +#define SCALEFACTOR40 ( 7) +#define SCALEFACTOR60 ( 7) +#define SCALEFACTOR64 ( 7) +#define SCALEFACTOR80 ( 8) +#define SCALEFACTOR100 (10) +#define SCALEFACTOR120 ( 8) +#define SCALEFACTOR128 ( 8) +#define SCALEFACTOR160 ( 8) +#define SCALEFACTOR192 (10) +#define SCALEFACTOR200 (10) +#define SCALEFACTOR240 ( 9) +#define SCALEFACTOR256 ( 9) +#define SCALEFACTOR320 (10) +#define SCALEFACTOR400 (10) +#define SCALEFACTOR480 (11) +#define SCALEFACTOR600 (10) + +#define BASOP_CFFT_MAX_LENGTH 600 /*----------------------------------------------------------------------------------* * BASOP ROM Tables *----------------------------------------------------------------------------------*/ -#define LD_INT_TAB_LEN 120 -#define INV_TABLE_SIZE 256 -#define SQRT_TABLE_SIZE 256 +#define INV_TABLE_SIZE 256 +#define SQRT_TABLE_SIZE 256 /*----------------------------------------------------------------------------------* @@ -3053,67 +2716,36 @@ enum VOIP_RTPDUMP }; -//EVS macros -#define LT_UV_THR_FX (100*64) /* in Q6 */ -#define INV_MAX_LT_FX (Word16)((1.0f/MAX_LT)*32768) -#define EVS_PI 3.14159265358979323846264338327950288f -#define EVS_PI_FX 25736 /* pi in Q13 */ -#define EVS_2PI_FX 51472 /* 2 * pi in Q13 */ -#define EVS_PI_FX_Q27 421657428 /* pi in Q28 */ -#define EVS_2PI_FX_Q27 843314856 /* 2 * pi in Q28 */ -#define EVS_PI_BY_2_FX (Word16)(0x3244) // Q13 -//#define EVS_PI_FX (Word16)(0x6488) -#define EVS_PI_FX16 (Word16)(0x6488) -#define PI2_FX 1686629713 //Q28 +/*----------------------------------------------------------------------------------* + * EVS macros + *----------------------------------------------------------------------------------*/ -#define LG10 24660 /* 10*log10(2) in Q13 */ +#define LT_UV_THR_FX (100*64) /* in Q6 */ +#define INV_MAX_LT_FX (Word16)((1.0f/MAX_LT)*32768) +#define LG10 24660 /* 10*log10(2) in Q13 */ -#define EVS_LW_MIN (Word32)0x80000000 -#define EVS_LW_MAX (Word32)0x7fffffff +#define EVS_LW_MIN (Word32)0x80000000 +#define EVS_LW_MAX (Word32)0x7fffffff -#define EVS_SW_MAX (Word16)0x7fff /* largest Ram */ +#define EVS_SW_MAX (Word16)0x7fff /* largest Ram */ -#define SYNC_GOOD_FRAME (UWord16) 0x6B21 /* synchronization word of a "good" frame */ -#define SYNC_BAD_FRAME (UWord16) 0x6B20 /* synchronization word of a "bad" frame */ -#define G192_BIN0 (UWord16) 0x007F /* binary "0" according to ITU-T G.192 */ -#define G192_BIN1 (UWord16) 0x0081 /* binary "1" according to ITU-T G.192 */ -#define DEGREE_180 (Word32)(180.0 *ONE_IN_Q22) -#define DEGREE_360 (Word32)(360.0 *ONE_IN_Q22) extern const Word16 Idx2Freq_Tbl[]; - #define chk_fs(fs) /* 'x' is converted to Q6, 'Freq_Tbl'/1000 in Q9 */ /* only works for 'fs' = [8000,12800,16000,25600,32000,48000] (unpredictable otherwise) */ /* 15625 is 1000000.0f/Q6 but we use the calculated value to avoid float point code */ -#define NS2SA_FX2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625))) - -#define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */ -#define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */ -#define L_NEXT_MAX_12k8 112 /* maximum encoder lookahead at 12k8Hz */ -#define L_PAST_MAX_12k8 144 /* maximum encoder past samples at 12k8Hz */ -#define L_DIV 256 /* 20ms frame size (ACELP or short TCX frame) */ -#define L_DIV_MAX 320 - +#define NS2SA_FX2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625))) -//tbs_vase.c -#define PRED_GAIN_E 8 +#define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */ +#define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */ +#define L_NEXT_MAX_12k8 112 /* maximum encoder lookahead at 12k8Hz */ +#define L_PAST_MAX_12k8 144 /* maximum encoder past samples at 12k8Hz */ +#define L_DIV 256 /* 20ms frame size (ACELP or short TCX frame) */ +#define L_DIV_MAX 320 -#define FS_48K_IN_NS_Q31 103079 -#define FS_32K_IN_NS_Q31 68719 -#define FS_16K_IN_NS_Q31 34360 +#define PRED_GAIN_E 8 -#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ -#define ONE_BY_TEN_Q15 3277 /* 1/10.f in Q15 */ -#define THREE_Q21 6291456 -#define SIX_Q21 12582912 - -typedef enum -{ - MCT_CHAN_MODE_REGULAR, - MCT_CHAN_MODE_LFE, - MCT_CHAN_MODE_IGNORE -} MCT_CHAN_MODE; /* clang-format on */ #endif /* CNST_H */ diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index 3f6e181ef..567adeb6b 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -32,13 +32,13 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" -#include #include "wmc_auto.h" #include "prot_fx.h" #include "rom_com.h" + + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b8415b7fd..64225a0f6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -204,8 +204,6 @@ typedef enum #define EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ #endif - - typedef enum { TC_BUFFER_MODE_RENDERER, @@ -646,9 +644,6 @@ typedef enum #define SBA_DIRAC_NRG_SMOOTH_LONG 10 #define SBA_DIRAC_NRG_SMOOTH_SHORT 3 -#define SBA_DIRAC_NRG_SMOOTH_SHORT_BY_LONG_FX ((Word16)0x2667) -#define SBA_DIRAC_NRG_SMOOTH_LONG_BY_LONG_SHORT_FX ((Word32)0x5B6DB6DB) - /* PLC for DFT Stereo residual */ #define STEREO_DFT_RES_N_PEAKS_MAX 15 /*Maximum number of peaks within residual signal in each frame (res_cod_band_max == 6 in 48kHz)*/ @@ -819,7 +814,6 @@ enum fea_names #define STEREO_BITS_ICBWE_DFT ( STEREO_ICBWE_SPBITS_DFT + STEREO_ICBWE_GSBITS_DFT + STEREO_ICBWE_REFBITS ) #define MAX_DELAYREGLEN 12 /* max regression length */ -#define INV_MAX_DELAYREGLEN 0.083333333333333f /* (1/MAX_DELAYREGLEN) */ #define INV_MAX_DELAYREGLEN_FX_Q15 2731 /* (1/MAX_DELAYREGLEN) in Q15 */ #define MAX_INTERPOLATE 11 #define ADDED_MEM_DS 40 @@ -1269,7 +1263,7 @@ enum #define MASA_BIT_REDUCT_PARAM 10 #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 -#define OMASA_TDREND_MATCHING_GAIN_FX 26026 +#define OMASA_TDREND_MATCHING_GAIN_FX 26026 #define OMASA_GAIN_EDIT_THR_Q12 246 /* OMASA gain change threshold, 0.06f in Q12 */ #define OMASA_AZI_EDIT_THR_Q22 ONE_IN_Q22 /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */ @@ -1278,8 +1272,7 @@ enum #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 1453366656l /* 1.353553128183453f in Q30 */ #define MASA_JBM_RINGBUFFER_FRAMES 3 -#define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ -#define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ + typedef enum { MASA_STEREO_NOT_DEFINED, @@ -1366,6 +1359,13 @@ typedef enum #define MCT_NUM_BLOCK_DATA_BITS 4 +typedef enum +{ + MCT_CHAN_MODE_REGULAR, + MCT_CHAN_MODE_LFE, + MCT_CHAN_MODE_IGNORE +} MCT_CHAN_MODE; + /*----------------------------------------------------------------------------------* * MC Param-Upmix Mode Constants @@ -1543,6 +1543,10 @@ typedef enum #define VBAP_NUM_SEARCH_SECTORS 4 +#define DEGREE_90_Q_22 377487360 +#define DEGREE_180_Q_22 754974720 +#define DEGREE_360_Q_22 1509949440 + /*----------------------------------------------------------------------------------* * Binaural Rendering Constants @@ -1600,8 +1604,8 @@ typedef enum #define ONE_BY_360_Q15 ( 91 ) /* Q15 */ #define ONE_BY_180_Q31 ( 11930465 ) /* Q31 */ -#define RESAMPLE_FACTOR_16_48_FX ( 5461 ) // Q14 -#define RESAMPLE_FACTOR_32_48_FX ( 10922 ) // Q14 +#define RESAMPLE_FACTOR_16_48_FX ( 5461 ) // Q14 +#define RESAMPLE_FACTOR_32_48_FX ( 10922 ) // Q14 /* ----- Enums - TD Renderer ----- */ @@ -1852,6 +1856,112 @@ typedef enum } STEREO_DMX_EVS_PRC; + +/*----------------------------------------------------------------------------------* + * Q values + *----------------------------------------------------------------------------------*/ + +#define Q1 1 +#define Q2 2 +#define Q3 3 +#define Q4 4 +#define Q5 5 +#define Q6 6 +#define Q7 7 +#define Q8 8 +#define Q9 9 +#define Q10 10 +#define Q11 11 +#define Q12 12 +#define Q13 13 +#define Q14 14 +#define Q15 15 +#define Q16 16 +#define Q17 17 +#define Q18 18 +#define Q19 19 +#define Q20 20 +#define Q21 21 +#define Q22 22 +#define Q23 23 +#define Q24 24 +#define Q25 25 +#define Q26 26 +#define Q27 27 +#define Q28 28 +#define Q29 29 +#define Q30 30 +#define Q31 31 + +/*----------------------------------------------------------------------------------* + * One (1) in Q + *----------------------------------------------------------------------------------*/ + +#define ONE_IN_Q1 2 +#define ONE_IN_Q2 4 +#define ONE_IN_Q3 8 +#define ONE_IN_Q4 16 +#define ONE_IN_Q5 32 +#define ONE_IN_Q6 64 +#define ONE_IN_Q7 128 +#define ONE_IN_Q8 256 +#define ONE_IN_Q9 512 +#define ONE_IN_Q10 1024 +#define ONE_IN_Q11 2048 +#define ONE_IN_Q12 4096 +#define ONE_IN_Q13 8192 +#define ONE_IN_Q14 16384 +#define ONE_IN_Q15 32768 +#define ONE_IN_Q16 65536 +#define ONE_IN_Q17 131072 +#define ONE_IN_Q18 262144 +#define ONE_IN_Q19 524288 +#define ONE_IN_Q20 1048576 +#define ONE_IN_Q21 2097152 +#define ONE_IN_Q22 4194304 +#define ONE_IN_Q23 8388608 +#define ONE_IN_Q24 16777216 +#define ONE_IN_Q25 33554432 +#define ONE_IN_Q26 67108864 +#define ONE_IN_Q27 134217728 +#define ONE_IN_Q28 268435456 +#define ONE_IN_Q29 536870912 +#define ONE_IN_Q30 1073741824 +#define ONE_IN_Q31 0x7fffffff +#define ONE_IN_Q45 (Word64)0x200000000000 +#define ONE_IN_Q62 (Word64)0x4000000000000000 + +#define MAX_WORD16 32767 + +/*----------------------------------------------------------------------------------* + * General constants + *----------------------------------------------------------------------------------*/ + +#define L_SUBFRAME_48k 240 +#define L_SUBFRAME_32k 160 +#define L_SUBFRAME_16k 80 +#define L_SUBFRAME_8k 40 + +#define Q31_BY_SUB_FRAME_240 8985287 /* 1/239 in Q31 */ +#define Q31_BY_SUB_FRAME_160 13506186 /* 1/159 in Q31 */ +#define Q31_BY_SUB_FRAME_80 27183337 /* 1/79 in Q31 */ +#define Q31_BY_SUB_FRAME_40 55063683 /* 1/39 in Q31 */ + +#define EVS_PI_FX 25736 /* pi in Q13 */ +#define EVS_2PI_FX 51472 /* 2 * pi in Q13 */ +#define EVS_PI_FX_Q27 421657428 /* pi in Q28 */ +#define EVS_2PI_FX_Q27 843314856 /* 2 * pi in Q28 */ +#define EVS_PI_BY_2_FX (Word16)(0x3244)/* Q13 */ + + +#define FS_48K_IN_NS_Q31 103079 +#define FS_32K_IN_NS_Q31 68719 +#define FS_16K_IN_NS_Q31 34360 + +#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ +#define ONE_BY_TEN_Q15 3277 /* 1/10.f in Q15 */ +#define THREE_Q21 6291456 + #endif /* clang-format on */ /* IVAS_CNST_H */ diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index 9a8de3c1f..422717f8e 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index cba992070..35a2cd4aa 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -33,11 +33,9 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index f52d59859..7519e9703 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_rom_com.h" -#include "math.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index c860b354e..2dcd8476b 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -32,10 +32,8 @@ #include #include -#include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index ea276c944..10c1f04b2 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -32,9 +32,7 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c index d515cc5fb..03b92a10f 100644 --- a/lib_com/ivas_lfe_com_fx.c +++ b/lib_com/ivas_lfe_com_fx.c @@ -31,13 +31,11 @@ *******************************************************************************************************/ #include -#include "math.h" #include "options.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" -#include "cnst.h" +#include "ivas_cnst.h" #include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_limiter_fx.c b/lib_com/ivas_limiter_fx.c index a293b629c..fdd1bb97c 100644 --- a/lib_com/ivas_limiter_fx.c +++ b/lib_com/ivas_limiter_fx.c @@ -32,15 +32,17 @@ #include #include "options.h" -#include #include "prot_fx.h" -#include "ivas_prot_rend_fx.h" -#include "ivas_rom_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include #include "ivas_prot_fx.h" + +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + #define RELEASE_CNST_20MS ( 85899345 ) // Q30 #define RELEASE_CNST_2_20MS ( 21474836 ) // Q30 #define RELEASE_CNST_10MS ( 42949672 ) // Q30 @@ -52,6 +54,7 @@ #define ATTACK_CNST_16k ( 2027355264 ) // Q31 #define ATTACK_CNST_8k ( 1913946752 ) // Q31 + /*-------------------------------------------------------------------* * detect_strong_saturations() * diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index 9c706bc74..f55e99153 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c index 8201037a1..c04ded09c 100644 --- a/lib_com/ivas_mc_com_fx.c +++ b/lib_com/ivas_mc_com_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c index e3827c568..7cb186b58 100644 --- a/lib_com/ivas_mc_param_com_fx.c +++ b/lib_com/ivas_mc_param_com_fx.c @@ -32,7 +32,6 @@ #include #include -#include #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index 1d07ab133..d80d8a156 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -29,19 +29,20 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -#include +#include #include #include "options.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" -#include -#include +#ifdef DEBUGGING #include "debug.h" +#endif #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------------------------*/ @@ -52,6 +53,7 @@ #define IVAS_ONE_BY_240_Q37 572662306 #define IVAS_ONE_BY_160_Q37 858993459 #define IVAS_ONE_BY_80_Q37 1717986918 + /*-----------------------------------------------------------------------------------------* * Function ivas_get_mdft_twid_factors() * diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c index 1c1d4bf6c..7bbf287ac 100644 --- a/lib_com/ivas_omasa_com_fx.c +++ b/lib_com/ivas_omasa_com_fx.c @@ -37,7 +37,7 @@ #include "prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" -#include + /*--------------------------------------------------------------- * Local constants diff --git a/lib_com/ivas_osba_com_fx.c b/lib_com/ivas_osba_com_fx.c index 79ce8443a..2f81a9574 100644 --- a/lib_com/ivas_osba_com_fx.c +++ b/lib_com/ivas_osba_com_fx.c @@ -33,8 +33,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" -#include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index 906277f54..f1a0a7609 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -32,12 +32,10 @@ #include #include -#include #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c index 7d7c159b3..6a965850e 100644 --- a/lib_com/ivas_qspherical_com_fx.c +++ b/lib_com/ivas_qspherical_com_fx.c @@ -33,11 +33,9 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 9773d0715..56dbeb50b 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -35,7 +35,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "stat_com.h" #include "ivas_stat_com.h" diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index a5af89655..1d19e657a 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index d399c6a66..199af90d3 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -34,8 +34,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING @@ -46,11 +44,19 @@ #include "enh64.h" +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +#define DEGREE_180 ( Word32 )( 180.0 * ONE_IN_Q22 ) +#define DEGREE_360 ( Word32 )( 360.0 * ONE_IN_Q22 ) + /*------------------------------------------------------------------------- * Euler2Quat() * * Calculate corresponding Quaternion from Euler angles in radians *------------------------------------------------------------------------*/ + void Euler2Quat_fx( const Word32 yaw, /* i : yaw (x) Q22 */ const Word32 pitch, /* i : pitch (y) Q22 */ diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 4caa22da2..7e1fac44b 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -32,11 +32,8 @@ #include #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index 48be0cfd0..57c4cd66e 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -32,15 +32,15 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include #include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*------------------------------------------------------------------- * sns_compute_scf_fx() * diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index afb639ef0..4b70d277a 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -31,14 +31,12 @@ *******************************************************************************************************/ #include -#include "math.h" #include "options.h" #include "basop_util.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" -#include "cnst.h" +#include "ivas_cnst.h" #include #include "wmc_auto.h" #include "basop_util.h" diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 8e84e4e37..7ea6feb05 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "math.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 65a081c9c..9bee290e6 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -36,7 +36,6 @@ #include #include "options.h" #include "typedef.h" -#include "cnst.h" #include "ivas_cnst.h" diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c index 6d63bc6d1..a23b5b700 100644 --- a/lib_com/ivas_stereo_dft_com_fx.c +++ b/lib_com/ivas_stereo_dft_com_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index 958781473..8328e220f 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -32,13 +32,13 @@ #include #include "options.h" -#include #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include #include "prot_fx.h" #include "wmc_auto.h" + /*--------------------------------------------------------------- * ECSQ_init_instance_fx() * diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 11f16d0a5..8b5e15908 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -32,16 +32,14 @@ #include #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" + /*--------------------------------------------------------------- * interpTargetChannel_fx() * diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index fe18e7bad..52933a593 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "cnst.h" #include "stat_enc.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index bc080f2f8..8cf54ec92 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -33,12 +33,16 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" + +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + #define ANGLE_90_DEG_Q22 377487360 #define ANGLE_180_DEG_Q22 754974720 #define ANGLE_360_DEG_Q22 1509949440 diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 39dee9314..f7613a023 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -32,13 +32,13 @@ #include #include "options.h" -#include "math.h" #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "ivas_stat_com.h" + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ diff --git a/lib_debug/debug.h b/lib_debug/debug.h index c79ff6046..f1a40606b 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -70,6 +70,9 @@ char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int #define FORCE_DIR_MAX_LENGTH 255 /* maximum length of the directory for modes/parameters enforcement */ #endif +#define MAX16B_FLT 32767.0f +#define MIN16B_FLT ( -32768.0f ) + /*------------------------------------------------------------------------------------------* * Read/write I/O tool *------------------------------------------------------------------------------------------*/ diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c index c05ae96ef..18892a0d5 100644 --- a/lib_debug/sba_debug.c +++ b/lib_debug/sba_debug.c @@ -38,6 +38,7 @@ #include "options.h" #include "ivas_cnst.h" #include "sba_debug.h" +#include "debug.h" #include #include "wmc_auto.h" #ifdef DEBUG_SBA diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index a196a1abd..eb6f6693f 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 5d4a6d964..0fbaea450 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -32,10 +32,8 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "ivas_rom_dec.h" @@ -43,7 +41,9 @@ #include "ivas_rom_binauralRenderer.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 23f75172a..81740977f 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -33,8 +33,7 @@ #include #include "options.h" #include -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 7a134d59b..8e94de138 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -33,14 +33,11 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 11d80c14f..f2ce9dd3c 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index c53f66138..7d389ec0f 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -37,18 +37,13 @@ #include #include #include -#include #include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "rom_dec.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index b6e7a558e..0713bd8f1 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "prot_fx.h" @@ -112,7 +110,7 @@ ivas_error ivas_dec_get_format_fx( Word16 sba_order, sba_planar, sba_analysis_order; Word32 ivas_total_brate; #ifdef DECODER_FORMAT_SWITCHING - int16_t Opt_tsm; + Word16 Opt_tsm; #endif UWord16 *bit_stream_orig; diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 19d99a0bb..162cc42ed 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 54cc5da15..3ca9f4aac 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -38,7 +37,6 @@ #include "ivas_rom_com.h" #include "prot_fx.h" #include "ivas_stat_enc.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 6af94ea97..e8398c83e 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -32,16 +32,15 @@ #include #include -#include #include "options.h" #include "ivas_prot_rend_fx.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" -#include "ivas_rom_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 2e2a257a1..beee3ee1a 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -38,9 +38,7 @@ #include "ivas_prot_rend_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" -#include "rom_com.h" #include "ivas_rom_dec.h" -#include #include "wmc_auto.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f8664b60b..2aa202738 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -32,16 +32,12 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" -#include #include "wmc_auto.h" -#include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 74d8de662..a4ead6946 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -36,7 +36,6 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" -#include "math.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index ac6da6759..b50fe2120 100755 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "prot_fx.h" #include "ivas_rom_com.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index b41036a5d..fd9eda8fb 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "prot_fx.h" @@ -51,6 +49,9 @@ #define SPAR_META_DELAY_SUBFRAMES 2 /* Number of subframes to delay the SPAR metadata */ #define SPH_IDX_FRONT ( MASA_NO_POINTS_EQUATOR / 2 ) /* Spherical index corresponding to front direction for setting as default value */ +#define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ +#define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ + /*-----------------------------------------------------------------------* * Local function prototypes diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index ca35d80e7..1f33f4875 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -33,25 +33,20 @@ #include #include "options.h" #include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include "math.h" #include "wmc_auto.h" -#include "rom_dec.h" #include "ivas_prot_fx.h" -#define INV_EPSILON_MANT 214748365 - /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ +#define INV_EPSILON_MANT 214748365 + #define PARAM_MC_LOCAL_SZ_LFE_MAP 5 /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index b80a08286..a2afc331a 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -33,17 +33,13 @@ #include #include #include "options.h" -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include "math.h" #include "wmc_auto.h" -#include "rom_dec.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index f96a20126..5f764533a 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -34,15 +34,12 @@ #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "basop_proto_func.h" -#include "stat_com.h" -#include "ivas_stat_dec.h" -#include "ivas_stat_com.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------* * ivas_mct_side_bits() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 49b4edb18..f5cf8364f 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -33,10 +33,7 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index f9d738695..98beb0a5e 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -34,15 +34,10 @@ #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "cnst.h" #include "basop_proto_func.h" -#include "stat_com.h" -#include "ivas_stat_dec.h" -#include "ivas_stat_com.h" -#include #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 6c64eee81..d08105470 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -32,13 +32,9 @@ #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" -#include "ivas_rom_com.h" -#include "ivas_rom_dec.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 069e2c0eb..428c6512e 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -34,11 +34,12 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*---------------------------------------------------------------------* diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0c6c13d19..ca0061785 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -32,14 +32,12 @@ #include "options.h" #include -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 339d6eb4b..01f78da05 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" @@ -40,14 +39,15 @@ #include "ivas_rom_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" - +#ifdef DEBUGGING #include "debug.h" +#endif + /*----------------------------------------------------------------------------------* * Local constants *----------------------------------------------------------------------------------*/ - #define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539 #define LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 2147483647 #define LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 322122547 diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 98611ab7c..fc531c34d 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -36,9 +36,9 @@ #include #include "ivas_cnst.h" #include "wmc_auto.h" -#include "math.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local function definitions *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index f3254c4a5..02be03d21 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index cc98c6ec4..261133d93 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c index 9a49680e8..7b6d428db 100644 --- a/lib_dec/ivas_range_uni_dec_fx.c +++ b/lib_dec/ivas_range_uni_dec_fx.c @@ -33,8 +33,6 @@ #include #include "ivas_cnst.h" #include "ivas_stat_dec.h" -#include "cnst.h" -#include "rom_com.h" #include #include "options.h" #include "prot_fx.h" diff --git a/lib_dec/ivas_rom_dec_fx.c b/lib_dec/ivas_rom_dec_fx.c index 016335004..3209278ed 100644 --- a/lib_dec/ivas_rom_dec_fx.c +++ b/lib_dec/ivas_rom_dec_fx.c @@ -32,11 +32,8 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" -#include "ivas_stat_dec.h" /* clang-format off */ diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index c4a1b0de1..90cca6855 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -34,21 +34,21 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + + /*-------------------------------------------------------------------* * ivas_sba_set_cna_cng_flag() * * Set CNA/CNG flags in IVAS SBA decoder *-------------------------------------------------------------------*/ + void ivas_sba_set_cna_cng_flag( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 42a2524f1..0c380ea5c 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -29,22 +29,28 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + #define SIN_NEG_30_DEGREES_Q15 ( (Word16) 0xC000 ) #define SIN_30_DEGREES_Q15 ( (Word16) 0x4000 ) +#define SBA_DIRAC_NRG_SMOOTH_SHORT_BY_LONG_FX ( (Word16) 0x2667 ) +#define SBA_DIRAC_NRG_SMOOTH_LONG_BY_LONG_SHORT_FX ( (Word32) 0x5B6DB6DB ) + + /*-------------------------------------------------------------------* * ivas_get_sba_dirac_stereo_flag() * diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index d9f7b26be..552b478d2 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -36,13 +36,13 @@ #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif + /*-------------------------------------------------------------------------* * ivas_sba2MC_cldfb() * diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 77c53c5ef..a889c505d 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -33,9 +33,7 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 05bf47cb9..0425cb7ac 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -33,13 +33,12 @@ #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*------------------------------------------------------------------- * sns_1st_dec_fx() * diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 864d05438..7cb1297a7 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -31,18 +31,14 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_stat_dec.h" #include "prot_fx.h" -#include "string.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "ivas_stat_com.h" -#include "stat_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 248518134..64c4375a5 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "math.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include @@ -44,6 +43,7 @@ /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ + #define DEG180_BY_PI_Q24 ( (Word32) 0x394BB835 ) /* 180.0/PI in Q24) */ #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 124f89c5a..2a652a573 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 9b166c41a..32321454c 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index b5e19dad5..33a1eb80b 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -33,17 +33,13 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "rom_com.h" -#include "rom_dec.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" #include "basop_util.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 93588a356..720d43d19 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" -#include "math.h" #include "wmc_auto.h" #include "basop_util.h" + /*--------------------------------------------------------------- * Local constants * ---------------------------------------------------------------*/ diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 96458c4f2..069f42bca 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -33,12 +33,9 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" #include "basop32.h" diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 647ad6e77..8cf565a5e 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 4d5996bb6..d8c1ad18f 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -33,10 +33,8 @@ #include #include #include "options.h" -#include #include "prot_fx.h" -#include "cnst.h" -#include "stat_com.h" +#include "ivas_cnst.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 725211758..d48954e86 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -32,11 +32,9 @@ #include #include -#include #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 76e4d226d..529a46ac9 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -32,15 +32,12 @@ #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "assert.h" #include "wmc_auto.h" -#include -#include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index ec135d7a0..0c91bd3c4 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -32,9 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index d6811d2df..b7a0eaedf 100755 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -29,15 +29,16 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + #include #include "options.h" #include "prot_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ @@ -48,6 +49,8 @@ #define SVD_ZERO_FLUSH_THRESHOLD_FX ( 0 ) #define CONVERGENCE_FACTOR_FX 214748 /* factor for SVD convergence (as per latest float code: 1.0e-04f) */ +#define MINUS_ONE_IN_Q31 ( -2147483647 - 1 ) + /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 01f47c906..dc09cb9b5 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -33,22 +33,20 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "rom_com.h" -#include "stat_dec.h" #include "wmc_auto.h" #include "basop_proto_func.h" -#include "stat_com.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------* * Local prototypes *-------------------------------------------------------------*/ - static void dec_prm_tcx_ivas_fx( Decoder_State *st, Word16 param[], Word16 param_lpc[], Word16 *total_nbbits, const Word16 last_element_mode, Word16 *bitsRead ); static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( Decoder_State *st, const Word16 MCT_flag, const Word16 last_element_mode, Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, Word16 *Q_syn_Overl_TDACFB, Word16 *Q_syn_OverlFB, Word16 *Q_old_out, Word16 *Q_old_outLB, Word16 *Q_old_Aq_12_8 ); + + /*-------------------------------------------------------------* * stereo_tcx_init_dec() * diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 32b5b3f87..8ed51cdab 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include "cnst.h" -#include "stat_enc.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8ac73cb85..cb36de1c1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -44,7 +44,6 @@ #ifdef IVAS_RTPDUMP #include "ivas_rtp_pi_data.h" #endif -#include #include #ifdef DEBUGGING #include "float_to_fix_ops.h" diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index ca4c399b0..54e9893f9 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -615,7 +615,7 @@ Word16 E_ACELP_xy1_corr_fx( /* Note: shl works as shl or shr. */ exp_tmp = sub( exp_tmp, 1 ); BASOP_SATURATE_WARNING_OFF_EVS - tmp = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) ); /*Q14*/ + tmp = round_fx_sat( L_shl_sat( Mpy_32_16_1( ACELP_GAINS_CONST_Q31, tmp ), exp_tmp ) ); /*Q14*/ BASOP_SATURATE_WARNING_ON_EVS gain = s_min( gain, tmp ); /*Q14*/ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index a9c7d768b..30bdf2ffa 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -3320,7 +3320,7 @@ static void IGF_Whitening_ivas_fx( FOR( sb = hGrid->tile[p]; sb < hGrid->tile[p + 1]; sb++ ) { IF( LT_32( powerSpectrum[sb], 1 ) ) - hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP )*/ + hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP=-125 )*/ ELSE hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( powerSpectrum_e[sb], Q25 ) ), Q25 ) ) ); move16(); diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 10d7cb8c7..e5af93e39 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -30,13 +30,10 @@ *******************************************************************************************************/ - #include -#include #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "basop_util.h" diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 96bbca887..2ee800325 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -32,15 +32,11 @@ #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx_enc.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index efa5e9a0a..b5fb1a476 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -32,22 +32,16 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" -#include #ifdef DEBUGGING #include "debug.h" #include "string.h" #endif -#include "prot_fx_enc.h" -#include "ivas_prot_fx.h" /*---------------------------------------------------------------* * Local constants diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 840165824..3d3b9f19b 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -32,10 +32,7 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index a277c965b..2efae00e2 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -37,17 +37,18 @@ #include "prot_fx_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "math.h" #include "wmc_auto.h" #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif + + /*-------------------------------------------------------------------* * ivas_corecoder_enc_reconfig() * * Allocate, initialize, and configure SCE/CPE/MCT handles in case of bitrate switching *-------------------------------------------------------------------*/ -/* Some float operations are still pending */ + ivas_error ivas_corecoder_enc_reconfig_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const Word16 nSCE_old, /* i : number of SCEs in previous frame Q0*/ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 8bd84e031..1396f2e0d 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -33,18 +33,14 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" -#include "prot_fx_enc.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "ivas_rom_enc.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 42e2f446e..17704e9bf 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -32,15 +32,11 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" -#include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" /* Function prototypes */ -#include "ivas_prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ + /*-----------------------------------------------------------------* * ivas_decision_matrix_enc() diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 0264a2199..e9fd93723 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index ffd32570f..7595ef26c 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -31,11 +31,8 @@ *******************************************************************************************************/ #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #ifdef DEBUGGING @@ -44,6 +41,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * ivas_enc() * diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c index 3c8cf92e2..ddd4df2de 100644 --- a/lib_enc/ivas_entropy_coder_fx.c +++ b/lib_enc/ivas_entropy_coder_fx.c @@ -36,13 +36,13 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" -#include "math.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif + /*-----------------------------------------------------------------------------------------* * Function ivas_get_dyn_freq_model_fx() * diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 35400f652..6f1f7f5bf 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -32,15 +32,10 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" -#include "prot_fx_enc.h" #include #include "wmc_auto.h" -#include #include "prot_fx_enc.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 3474b218b..72f362fd7 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index e68556664..65d6452da 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index 47da31a1a..c21098774 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 96959c9dd..6261bb39e 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "math.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" @@ -45,6 +44,7 @@ * * LFE Arithmetic coding block. Writes encoded data to bitstream. *-----------------------------------------------------------------------------------------*/ + static void ivas_lfe_arith_coding_fx( LFE_ENC_HANDLE hLFE, BSTR_ENC_HANDLE hBstr, diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 5613866cc..cb3b6e563 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 67353a279..0c4073fc0 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -45,19 +45,15 @@ y_fx = W_extract_h( W_shl( x_64, norm ) ); \ y_e = sub( sub35gb, norm ); \ } -#include + #include #include "options.h" -#include "cnst.h" -#include "rom_enc.h" #include "ivas_rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" - #include "prot_fx_enc.h" /*------------------------------------------------------------------------- diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index 0e8c845e1..7e9af16a3 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -30,12 +30,8 @@ *******************************************************************************************************/ -#include #include #include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "basop_util.h" @@ -47,6 +43,7 @@ #include "debug.h" #endif + /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 9bbf1260c..d4fd50dbf 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -33,13 +33,11 @@ #include #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include /*----------------------------------------------------------* diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 39735ad03..88e88a865 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -33,14 +33,11 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#include "rom_com.h" /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index d402d834f..de906bde1 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index b4eba6201..81d8757e0 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -30,14 +30,11 @@ *******************************************************************************************************/ -#include "ivas_cnst.h" #include #include #include "options.h" -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 1311181dd..4a620db48 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 3629b8562..5f0ec3319 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include -#include #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 7eb4f18e7..e9fbfac46 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -34,10 +34,8 @@ #include "options.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include #include #include "wmc_auto.h" - #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3f1852774..4753e5276 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c index 3f17a423e..09d61c610 100644 --- a/lib_enc/ivas_qspherical_enc_fx.c +++ b/lib_enc/ivas_qspherical_enc_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c index 6c322a3d9..949625722 100644 --- a/lib_enc/ivas_range_uni_enc_fx.c +++ b/lib_enc/ivas_range_uni_enc_fx.c @@ -34,8 +34,6 @@ #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_stat_enc.h" -#include "cnst.h" -#include "rom_com.h" #include #include "options.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_rom_enc_fx.c b/lib_enc/ivas_rom_enc_fx.c index 1b7bed210..671e20a00 100644 --- a/lib_enc/ivas_rom_enc_fx.c +++ b/lib_enc/ivas_rom_enc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include #include "wmc_auto.h" diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index e630a70d9..574d10f96 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -32,16 +32,12 @@ #include #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index fa58f2674..2457fef6e 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -33,9 +33,7 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" @@ -44,7 +42,6 @@ #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx_enc.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 0e3c0bd40..0beb13759 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -33,11 +33,8 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 2abe06776..884d44d00 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -37,7 +37,6 @@ #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_com.h" -#include "math.h" #include "wmc_auto.h" #include "prot_fx_enc.h" #ifdef DEBUGGING diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index be07b38cb..f5cc2ba80 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -35,11 +35,11 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "math.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" + /*------------------------------------------------------------------------------------------* * PreProcessor *------------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c index 8e79b2288..3e4a5040d 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c @@ -32,9 +32,8 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "stat_enc.h" #include "wmc_auto.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index 2c1bc0317..88469e818 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -31,13 +31,10 @@ *******************************************************************************************************/ #include -#include #include "options.h" #ifdef DEBUGGING #include "debug.h" #endif -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" @@ -45,33 +42,24 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ -#define RC_FACT_UP 0.3f -#define RC_FACT_UP_Q31 644245094 -#define RC_FACT_DOWN 0.7f -#define RC_FACT_DOWN_Q31 1503238554 -#define UNCLR_SCORE_THR 4.0f -#define UNCLR_SCORE_THR_Q28 ( 1073741824 ) -#define XTALK_SCORE_THR_DFT 4.0f -#define XTALK_SCORE_THR_DFT_Q27 ( 1 << 29 ) -#define XTALK_SCORE_THR_TD_UP 3.0f -#define XTALK_SCORE_THR_TD_UP_Q28 ( 805306368 ) +#define RC_FACT_UP_Q31 644245094 /* 0.3f */ +#define RC_FACT_DOWN_Q31 1503238554 /* 0.7f */ +#define UNCLR_SCORE_THR_Q28 ( 1073741824 ) /* 4.0f */ +#define XTALK_SCORE_THR_DFT_Q27 ( 1 << 29 ) /* 4.0f */ +#define XTALK_SCORE_THR_TD_UP_Q28 ( 805306368 ) /* 3.0f */ #define ONE_BY_XTALK_SCORE_THR_TD_UP_Q31 ( 715827882 ) -#define XTALK_SCORE_THR_TD_DN 4.0f -#define XTALK_SCORE_THR_TD_DN_Q28 ( 1073741824 ) +#define XTALK_SCORE_THR_TD_DN_Q28 ( 1073741824 ) /* 4.0f */ #define ONE_BY_XTALK_SCORE_THR_TD_DN_Q31 ( 536870912 ) -#define UNCLR_INTERCEPT_TD 0.780313f -#define UNCLR_INTERCEPT_TD_Q28 ( 209463676 ) -#define UNCLR_INTERCEPT_DFT 1.226513f -#define UNCLR_INTERCEPT_DFT_Q30 1316958306 -#define XTALK_INTERCEPT_TD -1.770983f -#define XTALK_INTERCEPT_TD_Q28 ( -475394629 ) -#define XTALK_INTERCEPT_DFT -0.758556f -#define XTALK_INTERCEPT_DFT_Q31 -1628986606 +#define UNCLR_INTERCEPT_TD_Q28 ( 209463676 ) /* 0.780313f */ +#define UNCLR_INTERCEPT_DFT_Q30 1316958306 /* 1.226513f */ +#define XTALK_INTERCEPT_TD_Q28 ( -475394629 ) /* -1.770983f */ +#define XTALK_INTERCEPT_DFT_Q31 -1628986606 /*-0.758556f */ #define XTALK_INTERCEPT_DFT_Q27 -101811663 #define EDGE_MAX_LEN 30 /* maximum length of buffer for edge detection */ @@ -83,6 +71,7 @@ /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ + static void rc_filter_fx( const Word32 x, Word32 *y, const Word16 order, const Word32 tau ); static void edge_detect_fx( const Word32 *inp, const Word16 len, const Word32 inp_min, const Word32 inp_max, Word16 *edge_str, Word16 *edge_type ); diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c index b73a57f46..929d35b91 100644 --- a/lib_enc/ivas_stereo_cng_enc_fx.c +++ b/lib_enc/ivas_stereo_cng_enc_fx.c @@ -32,9 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index e5522fb37..3a0e19bb4 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -33,9 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" @@ -51,7 +48,7 @@ #define STEREO_DFT_NRG_PAST_MAX_BAND 9 #define STEREO_DFT_NRG_PAST_MAX_BAND_LB 4 -#define STEREO_DFT_DMX_CROSSOVER ( Word16 )( 132 * ( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) + 0.5f ) /* crossover bin between binwise and bandwise DMX */ +#define STEREO_DFT_DMX_CROSSOVER 211 /* crossover bin between binwise and bandwise DMX, ( 132 * ( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) + 0.5f ) */ #define ITD_VAD_E_BAND_N_INIT 200000 #define ITD_SID_PREV_FRAMES 5 @@ -393,8 +390,7 @@ ivas_error stereo_dft_enc_create_fx( stereo_dft_enc_open_fx( hStereoDft_loc, input_Fs, max_bwidth ); - stereo_dft_hybrid_ITD_flag_fx( hStereoDft_loc->hConfig, input_Fs, - hStereoDft_loc->hItd->hybrid_itd_max ); + stereo_dft_hybrid_ITD_flag_fx( hStereoDft_loc->hConfig, input_Fs, hStereoDft_loc->hItd->hybrid_itd_max ); *hStereoDft = hStereoDft_loc; diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index eb23e9d01..09d5f0c91 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -33,9 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" @@ -49,10 +46,8 @@ * Local constants *------------------------------------------------------------------------*/ -#define LP_GCC_PHAT_UP 0.9f /* LP filter coefficient, going up */ -#define LP_GCC_PHAT_UP_Q31 1932735283 /* LP filter coefficient, going up */ -#define LP_GCC_PHAT_DOWN 0.1f /* LP filter coefficient, going down */ -#define LP_GCC_PHAT_DOWN_Q31 214748365 /* LP filter coefficient, going down */ +#define LP_GCC_PHAT_UP_Q31 1932735283 /* LP filter coefficient, going up, 0.9f */ +#define LP_GCC_PHAT_DOWN_Q31 214748365 /* LP filter coefficient, going down, 0.1f */ #define ITD_CNT_MAX 2 /* Minimum number of consecutive ITD estimates for ITD hangover */ #define ITD_HO_GCC_PHAT_MAX 0.6f /* LP GCC PHAT value which gives zero hangover */ #define ITD_HO_GCC_PHAT_MIN 0.3f /* LP GCC PHAT value which gives ITD_HO_MAX ITD hangover frames */ @@ -61,26 +56,20 @@ #define ITD_HO_GCC_PHAT_INCL_Q26 -1118481021 #define ITD_HO_GCC_PHAT_OFFS ( -ITD_HO_GCC_PHAT_INCL * ITD_HO_GCC_PHAT_MAX + 1 ) #define ITD_HO_GCC_PHAT_OFFS_Q26 738197504 -#define SFM_PROD_GRP 4 /*maximum grouping of products for calculating SFM in ITD estimation*/ -#define B_DENOM 0.083333333333333f -#define B_DENOM_Q31 178956971 +#define SFM_PROD_GRP 4 /*maximum grouping of products for calculating SFM in ITD estimation*/ +#define B_DENOM_Q31 178956971 /* 0.083333333333333f */ #define L_SAMPLES 20 #define SUBDIV ( 2 * STEREO_DFT_ITD_MAX_ANA / L_SAMPLES ) #define DENOM 0.05f #define DENOM_Q31 107374182 -#define XSPEC_ALPHA ( 1.f / 32 ) #define XSPEC_ALPHA_Q31 ONE_IN_Q26 -#define CORR_FILT 0.8f -#define CORR_FILT_Q31 1717986918 +#define CORR_FILT_Q31 1717986918 /* 0.8f */ #define CORR_RESET_FRAMES_MAX 20 #define ITD_VAD_NOISE_INIT_FRAMES 30 -#define ITD_VAD_THRSHOLD 0.001f #define ITD_VAD_THRSHOLD_Q31 INV_1000_Q31 -#define ITD_VAD_MS_SNR_UPDATE_THRESH 15.0f #define ITD_VAD_MS_SNR_UPDATE_THRESH_FX 15 -#define HIGHT_SNR_VOICE_TH 10000.0f #define HIGHT_SNR_VOICE_TH_FX 10000 #define MAX_ITD_VAD_HANGOVER 10 diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 2c044625c..94a57b036 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -33,10 +33,7 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 73f7e246c..398fe88fd 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -31,17 +31,13 @@ *******************************************************************************************************/ #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c index a09daffe0..05f9dc80d 100644 --- a/lib_enc/ivas_stereo_eclvq_enc_fx.c +++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 924de4d65..32d70a8b7 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -33,12 +33,9 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index f6bf1a099..2d6c17d9f 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 6bb6af1b3..e764649df 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -33,20 +33,20 @@ #include #include #include "options.h" -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" + /*-------------------------------------------------------------------* * sync_tcx_mode() * * Synchronize under certain conditions the tcx modes and set overlap * windows accordingly *-------------------------------------------------------------------*/ + static void sync_tcx_mode_fx( Encoder_State **st /* i/o: Encoder state */ ) diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index d22e1b885..39f4f4149 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -33,14 +33,13 @@ #include #include #include "options.h" -#include #include "prot_fx.h" -#include "cnst.h" -#include "stat_enc.h" +#include "ivas_cnst.h" #include "ivas_stat_enc.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index d53eb365d..055e22593 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -33,15 +33,12 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "prot_fx_enc.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" -#include "stat_enc.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 0b27de0f6..8440a8263 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -32,8 +32,7 @@ #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "assert.h" diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index ab28f7f7e..1eff3cd9e 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -32,9 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index bad9370b4..029537a4e 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -31,10 +31,8 @@ *******************************************************************************************************/ #include -#include #include "options.h" -#include "cnst.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 7c5972545..ea7a011c5 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -33,15 +33,14 @@ #include #include #include "options.h" -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "rom_com.h" #include "basop_proto_func.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * stereo_tcx_init_enc() diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 21fa71312..8947bfb64 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include "cnst.h" -#include "stat_enc.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 245e5679a..91aeca920 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include #include #include #include @@ -45,6 +44,7 @@ #include "wmc_auto.h" #include "ivas_rom_enc.h" + /*---------------------------------------------------------------------* * Local struct *---------------------------------------------------------------------*/ diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 5ce75c3ac..e9fee4d2e 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -389,7 +389,7 @@ Word16 corr_xy1_fx( /* Note: shl works as shl or shr. */ exp_xx = sub( exp_xx, 1 ); BASOP_SATURATE_WARNING_OFF_EVS - gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_xx ) ); + gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( ACELP_GAINS_CONST_Q31, tmp ), exp_xx ) ); BASOP_SATURATE_WARNING_ON_EVS gain = s_min( gain, gain_p_snr ); // Q14 diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 40d6c3938..f666b453e 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -41,6 +41,8 @@ * Split Binaural Rendering Constants *----------------------------------------------------------------------------------*/ +#define PI2_FX 1686629713 //Q28 + typedef enum { PCM_INT16, diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c index 954d89f63..5591fbb3a 100644 --- a/lib_isar/isar_rom_post_rend.c +++ b/lib_isar/isar_rom_post_rend.c @@ -35,7 +35,7 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include "cnst.h" +#include "ivas_cnst.h" #include "isar_cnst.h" #include #include "wmc_auto.h" diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 5023bee34..a93f3092a 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" -#include #include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 49d88e8f3..98d07346f 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 9c3379527..5084ef138 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" @@ -39,7 +38,6 @@ #include "ivas_rom_rend.h" #include "ivas_rom_binaural_crend_head.h" #include "ivas_stat_rend.h" -#include "lib_rend.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 9683cd743..d81534764 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" @@ -42,15 +41,15 @@ #include "ivas_rom_rend.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" - #include "wmc_auto.h" -Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ +static Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; + #define STEREO_PREPROCESS_IIR_FACTOR_Q15 ( 29491 ) // 0.9f in Q15 /* powf(0.95f, 4.0f) for sub-frame smoothing instead of CLDFB slot */ #define ADAPT_HTPROTO_ROT_LIM_0_FX 429496736 // 0.4f in Q30 diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index acbfb3bd2..a4f703a28 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" @@ -42,6 +40,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ @@ -49,10 +48,8 @@ #define DIRAC_MAX_DECORR_CLDFB_BANDS_AMBI 22 #define DIRAC_MAX_DECORR_CLDFB_BANDS 15 -#define DIRAC_DUCK_ALPHA 0.8f -#define DIRAC_DUCK_GAMMA 1.5f -#define DIRAC_DUCK_GAMMA_FX 1610612736 /* Q30 */ -#define DIRAC_DUCK_ALPHA_FX 1717986944 /* Q31 */ +#define DIRAC_DUCK_GAMMA_FX 1610612736 /* 1.5f in Q30 */ +#define DIRAC_DUCK_ALPHA_FX 1717986944 /* 0.8f in Q31 */ #define ONE_M_DIRAC_DUCK_ALPHA 429496736 /* Q31 */ /* Maximal useful q-format, represents range of 2^-126 (float min) */ diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index 80adebfdd..1e105ba22 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 29184695c..de25c56e5 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index bde35181e..83ce8af45 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 23ffbe0bd..c85d89b85 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include #include #include "options.h" @@ -42,6 +41,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index efffccf84..1e6e13ee4 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -30,9 +30,7 @@ *******************************************************************************************************/ -#include #include "options.h" -#include "lib_rend.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "prot_fx.h" @@ -42,6 +40,7 @@ #endif #include "ivas_prot_fx.h" + #define INV_UINT8_MAX 8421505 /* 1/UINT8_MAX in Q31 */ /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index e31241a53..c402ad1c3 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include #include #include #include "ivas_cnst.h" @@ -47,10 +46,8 @@ * Local constants *------------------------------------------------------------------------*/ -#define NEAR_HORIZONTAL_PLANE_ELEVATION 17.5f -#define NEAR_HORIZONTAL_PLANE_ELEVATION_FX 73400320 /*Q22*/ -#define VERTICAL_ENERGY_RATIO_OFFSET 0.15f -#define VERTICAL_ENERGY_RATIO_OFFSET_FX 4915 /*Q15*/ +#define NEAR_HORIZONTAL_PLANE_ELEVATION_FX 73400320 /* 17.5f in Q22 */ +#define VERTICAL_ENERGY_RATIO_OFFSET_FX 4915 /* 0.15f in Q15 */ /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index dd99c0070..658ff6b0f 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -35,11 +35,12 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index 2a67d7a39..00036a8cd 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -34,12 +34,12 @@ #include #include "options.h" #include "prot_fx.h" -#include #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" #include "wmc_auto.h" + /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index 361cc403d..185cba09e 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -32,18 +32,12 @@ #include #include "options.h" -#include #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "prot_fx.h" #include "wmc_auto.h" -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 33c519c8e..015d227a2 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c index 140861539..ded14eb09 100644 --- a/lib_rend/ivas_objectRenderer_vec_fx.c +++ b/lib_rend/ivas_objectRenderer_vec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 9c209f036..384e8529e 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -32,7 +32,6 @@ #include "options.h" #include -#include #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" #include "ivas_prot_fx.h" @@ -41,11 +40,11 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" + /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ - static void ivas_omasa_dmx_fx( Word32 data_in_f_fx[][L_FRAME48k], Word16 *data_in_q, diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index ee91e7060..201f5a826 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -36,11 +36,11 @@ #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" -#include #include #include "wmc_auto.h" #include "prot_fx.h" + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index 3bf9f7169..c342d5ca2 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -32,16 +32,16 @@ #include "options.h" #include -#include #include "prot_fx.h" #include "rom_dec.h" -#include "lib_rend.h" #include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index d2a6a0c44..5e7b206c8 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -35,7 +35,11 @@ #include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif + + /*-----------------------------------------------------------------------------------------* * Function ivas_rev_delay_line_init() * diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index b7f890ec3..6453b32d7 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -34,10 +34,10 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" - +#endif /*------------------------------------------------------------------------------------------* * Static functions declarations diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index e826596ba..3b896a137 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -35,7 +35,6 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include -#include #include #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 6ab0c7a63..ba4159ba8 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -35,11 +35,12 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" -#include "math.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif /* The reverberator structure implemented here is described in detail in: @@ -86,6 +87,7 @@ static const Word16 default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1 static const Word16 default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 }; static const Word16 default_loop_delay_16k[IVAS_REV_MAX_NR_BRANCHES] = { 769, 619, 509, 421, 353, 307, 269, 239 }; +#define MATRIX_CONSTANT ( 759250113 ) /*------------------------------------------------------------------------------------------* * Local Struct definition diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index 981a40466..f4f0cf516 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -35,9 +35,14 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif + + #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) + /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_iir_filt_init() * diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 6433da819..52cb0f130 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -35,7 +35,6 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" -#include #include "wmc_auto.h" diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index ed4ece7b6..f3d675a99 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -35,7 +35,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c index 531c45f83..954ae2759 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index f7ecc3dda..30746b3d8 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -35,7 +35,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c index 3357eaeb8..3c090f204 100644 --- a/lib_rend/ivas_rom_binauralRenderer_fx.c +++ b/lib_rend/ivas_rom_binauralRenderer_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index c05ed40c3..9c204af31 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -35,14 +35,13 @@ #include "basop_util.h" #include "ivas_cnst.h" #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" -#include #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif #include "ivas_rom_binaural_crend_head.h" @@ -719,7 +718,7 @@ void rotateFrame_shd( move32(); BREAK; case L_SUBFRAME_32k: - tmp = Q31_BY_NUM_SAMPLES_160; + tmp = Q31_BY_SUB_FRAME_160; move32(); BREAK; case L_SUBFRAME_16k: @@ -856,7 +855,7 @@ void rotateFrame_sd( move32(); BREAK; case L_SUBFRAME_32k: - tmp = Q31_BY_NUM_SAMPLES_160; + tmp = Q31_BY_SUB_FRAME_160; move32(); BREAK; case L_SUBFRAME_16k: diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index ff077e63e..c60e68090 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -36,15 +36,16 @@ #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * ivas_sba_prototype_renderer() * * Render prototype audio signals using SBA mixing matrices *-------------------------------------------------------------------*/ + void ivas_sba_prototype_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real Q(q_cldfb[][])*/ diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index 36af55838..631e5351e 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -32,7 +32,6 @@ #include "options.h" #include -#include #include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 87f4e0832..4d0dec7a6 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -37,8 +37,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_stat_com.h" // note: needed for DIRAC_DEC_BIN_HANDLE until #156 is solved -#include "stat_com.h" /* Note: Currently needed for CLDFB. */ #include "common_api_types.h" #include "isar_stat.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 14795da41..4f51a8b5f 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -36,43 +36,48 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" -#include "math.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" #endif + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ -static const Word16 ivas_hadamard_decorr_APD_coeff[IVAS_APD_16_SECT][IVAS_APD_16_SECT] = { /* Q15 */ - { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107 }, - { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107 }, - { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107 }, - { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107 }, - { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107 }, - { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107 }, - { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107 }, - { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107 }, - { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107 }, - { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107 }, - { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107 }, - { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107 }, - { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107 }, - { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107 }, - { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107 }, - { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107 } + +static const Word16 ivas_hadamard_decorr_APD_coeff[IVAS_APD_16_SECT][IVAS_APD_16_SECT] = { + /* Q15 */ + { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107 }, + { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107 }, + { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107 }, + { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107 }, + { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107 }, + { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107 }, + { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107 }, + { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107 }, + { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107 }, + { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107 }, + { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107 }, + { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107 }, + { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107 }, + { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107 }, + { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107 }, + { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107 } }; /* For R = 3.^([0:obj.parm_APD_nSections-1]/4); Q22 */ -static const Word32 ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { /* Q22 */ - 4194304, 5520015, 7264748, 9560946, 12582912, 16560043, 21794242, - 28682836, 37748736, 49680132, 65382728, 86048512, 113246208, - 149040384, 196148192, 258145536 +static const Word32 ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { + /* Q22 */ + 4194304, 5520015, 7264748, 9560946, 12582912, 16560043, 21794242, + 28682836, 37748736, 49680132, 65382728, 86048512, 113246208, + 149040384, 196148192, 258145536 }; #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 1073741824 ) // Q29 #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 1610612736 ) // Q29 + + /*------------------------------------------------------------------------------------------* * Local functions declaration *------------------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index ec24a3362..fdbd4f530 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -33,13 +33,13 @@ #include #include "options.h" #include -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 1dd238afd..9519a0bb9 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -58,7 +58,6 @@ * Renderer structures *---------------------------------------------------------------------*/ -typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][RENDERER_MAX_OUTPUT_CHANNELS]; typedef Word32 IVAS_REND_LfePanMtx_fx[RENDERER_MAX_INPUT_LFE_CHANNELS][RENDERER_MAX_OUTPUT_CHANNELS]; typedef struct diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b70cdcadb..4bf93f011 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -33,7 +33,6 @@ #include "basop32.h" #include "basop_util.h" #include "options.h" -#include "cnst.h" #include "common_api_types.h" #include "enh32.h" #include "lib_rend.h" @@ -50,13 +49,13 @@ #include "stl.h" #include "typedef.h" #include -#include #include #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" #endif + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -5931,6 +5930,17 @@ ivas_error IVAS_REND_SetReverbRoomSize( This function takes 2 gain vectors - one for the beginning and one for the end of the buffer. Gain values are lineraly interpolated for all samples in between. */ +#define NUM_SAMPLES_960 ( 960 ) +#define NUM_SAMPLES_720 ( 720 ) +#define NUM_SAMPLES_640 ( 640 ) +#define NUM_SAMPLES_320 ( 320 ) +#define NUM_SAMPLES_160 ( 160 ) +#define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */ +#define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */ +#define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */ +#define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */ +#define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */ + static void renderBufferChannelLerp_fx( const IVAS_REND_AudioBuffer inAudio, const Word32 inChannelIdx, diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 6b506e7ed..713e88f60 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -59,6 +59,9 @@ #define INV_SQRT_8_OVER_5_Q29 424433728l /* 1.0f/INV_SQRT_8_OVER_5_Q29 */ #define INV_SQRT_45_OVER_32_Q29 452729280l /* 1.0f/SQRT_45_OVER_32_Q29 */ +#define MAX16B 32767 +#define MIN16B ( -32768 ) + /* -------------------------------- normalization conversion tables @@ -425,7 +428,7 @@ AMBI_CONVERT_ERROR renormalize_channels( Word64 tmp; tmp = W_mult0_32_32( (Word32) in[i_chan][i], conversion_factor ); /* tmp = W_add( tmp, ONE_OVER_2_Q29); */ /* rounding up */ - outval = W_extract_l( W_shr( tmp, Q29 ) ); + outval = W_extract_l( W_shr( tmp, 29 ) ); minval = L_min( minval, outval ); maxval = L_min( maxval, outval ); outval = L_min( MAX16B, L_max( MIN16B, outval ) ); /* saturation */ diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index cbb50af3f..95a447f15 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -33,11 +33,10 @@ #ifndef AMBI_CONVERT_H #define AMBI_CONVERT_H -#include "options.h" +#include "common_api_types.h" #include "stl.h" -#include "cnst.h" -#define AMBI_MAX_FRAME_LENGTH 960 /* 20ms at 48 kHz Sampling rate */ +#define AMBI_MAX_FRAME_LENGTH IVAS_MAX_FRAME_SIZE /* = 960 == 20ms at 48 kHz Sampling rate */ #define AMBI_MAX_CHANNELS 16 typedef enum diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 0a23a6d7b..31fc024e9 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -48,11 +48,6 @@ #endif -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "cnst.h" -#include -#endif - #ifdef IVAS_RTPDUMP /* Generic PI data packing/unpacking functions */ @@ -71,6 +66,10 @@ static __inline int16_t readInt16( const uint8_t *buffer ) return (int16_t) ( (uint16_t) buffer[0] << 8 ) | ( (uint16_t) buffer[1] ); } +#define ONE_IN_Q22 4194304 +#define ONE_IN_Q26 67108864 +#define ONE_IN_Q30 1073741824 + /*-----------------------------------------------------------------------* * ivasPayload_convertToQ15() * @@ -417,7 +416,7 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num aeEnv->roomDimensions.x_fx = (Word32) ( aeEnv->roomDimensions.x * ONE_IN_Q22 ); /* Q22 */ aeEnv->roomDimensions.y_fx = (Word32) ( aeEnv->roomDimensions.y * ONE_IN_Q22 ); aeEnv->roomDimensions.z_fx = (Word32) ( aeEnv->roomDimensions.z * ONE_IN_Q22 ); - aeEnv->roomDimensions.q_fact = Q22; + aeEnv->roomDimensions.q_fact = 22; aeEnv->absorbCoeffs_fx[IVAS_PI_AE_FRONT] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] * ONE_IN_Q30 ); /* Q30 */ aeEnv->absorbCoeffs_fx[IVAS_PI_AE_BACK] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] * ONE_IN_Q30 ); -- GitLab From 50d6a56184a18e48aa2595f1f97b57546bdc4242 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 19 Nov 2025 13:45:14 +0000 Subject: [PATCH 051/750] Address Tommy's comments. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index ced1f13ed..b6686bde1 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3497,7 +3497,7 @@ static Word32 eig2x2_div_fx( Word32 num, Word32 den ); static Word32 eig2x2_div_fx( Word32 num, Word32 den ) { - if ( EQ_32( den, 0x40000000 ) ) + IF ( EQ_32( den, 0x40000000 ) ) { return num; } @@ -3521,7 +3521,7 @@ static void eig2x2_fx( #ifdef NONBE_OPT_2193_EIG2X2 Word32 pm_fx, add_fx; Word32 tmp1, tmp2, e1, e2, c_re, c_im, c0_im, c1_im; - Word32 condition, s0_fx, s1_fx, nval0_fx, nval1_fx; + Word32 s0_fx, s1_fx, nval0_fx, nval1_fx; Word64 crossSquare_fx, tmp3, tmp4; Word16 q_crossSquare, q_min, q_diff, q_tmp1, q_tmp2, exp, q_e, q_c; Word16 nval0_q, nval1_q; @@ -3635,8 +3635,8 @@ static void eig2x2_fx( // Numeric case, when input is practically zeros // if ( D_fx[0] < EPSILON_FX ) - condition = LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ); - if ( condition != 0 ) + + IF ( LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ) ) { return; } @@ -3647,8 +3647,8 @@ static void eig2x2_fx( { tmp1 = L_shr( tmp1, q_diff ); } - condition = LT_32( tmp2, tmp1 ); - if ( condition != 0 ) + + IF ( LT_32( tmp2, tmp1 ) ) { return; } -- GitLab From 733ab359bd007e22a9c61896226053851946f0d1 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 19 Nov 2025 14:13:00 +0000 Subject: [PATCH 052/750] Apply clang format. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index b6686bde1..2509129ac 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3497,7 +3497,7 @@ static Word32 eig2x2_div_fx( Word32 num, Word32 den ); static Word32 eig2x2_div_fx( Word32 num, Word32 den ) { - IF ( EQ_32( den, 0x40000000 ) ) + IF( EQ_32( den, 0x40000000 ) ) { return num; } @@ -3636,7 +3636,7 @@ static void eig2x2_fx( // Numeric case, when input is practically zeros // if ( D_fx[0] < EPSILON_FX ) - IF ( LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ) ) + IF( LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ) ) { return; } @@ -3648,7 +3648,7 @@ static void eig2x2_fx( tmp1 = L_shr( tmp1, q_diff ); } - IF ( LT_32( tmp2, tmp1 ) ) + IF( LT_32( tmp2, tmp1 ) ) { return; } -- GitLab From af00b514184949ec4cf5a3494ab8bc21a4245029 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 18 Nov 2025 16:55:27 +0000 Subject: [PATCH 053/750] Implement ivas_iir_2_filter_fx64. --- lib_com/ivas_filters_fx.c | 93 +++++++++++++++-- lib_com/ivas_prot_fx.h | 9 +- lib_com/ivas_transient_det_fx.c | 174 ++++++++++++++++++-------------- 3 files changed, 190 insertions(+), 86 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index ab1b4ce96..93d36fcf5 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -43,8 +43,8 @@ *------------------------------------------------------------------------------------------*/ static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); -static void ivas_iir_2_filter_fixed_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); - +static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); +static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); /*-----------------------------------------------------------------------------------------* * Function ivas_filters_init() @@ -342,7 +342,7 @@ static void ivas_iir_2_filter_fx( return; } -void ivas_filter_process_fixed_fx( +void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ const Word16 length, /* i : filter order */ @@ -351,11 +351,11 @@ void ivas_filter_process_fixed_fx( SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); - ivas_iir_2_filter_fixed_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; @@ -364,17 +364,38 @@ void ivas_filter_process_fixed_fx( return; } -static void ivas_iir_2_filter_fixed_fx( +void ivas_filter_process_fx64( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ + const Word16 length, /* i : filter order */ + Word16 q ) +{ + SWITCH( filter_state->order ) + { + case IVAS_FILTER_ORDER_1: + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + BREAK; + case IVAS_FILTER_ORDER_4: + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); + BREAK; + default: + BREAK; + } + + return; +} + +static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, - Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) + Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { - Word16 i, j, shift; - Word64 tmp_prod, tmp; Word32 in, out; + Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { @@ -398,7 +419,57 @@ static void ivas_iir_2_filter_fixed_fx( shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); - filter_state->state64_fx[stage][j - 1] = W_add( tmp, W_neg( tmp_prod ) ); + filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + move32(); + } + } + + return; +} + +static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) +{ + Word32 var1_l; + Word64 var_out; + var1_l = W_extract_l( W_var1 ); // 1 + var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 + var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 + var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 + return var_out; +} + +static void ivas_iir_2_filter_fx64( + ivas_filters_process_state_t *filter_state, + Word64 *pIn_Out_fx, + const Word16 length, + const Word16 stage, + Word16 q ) +{ + Word64 tmp_prod, tmp, in, out; + Word16 i, j, shift; + + FOR( i = 0; i < length; i++ ) + { + in = pIn_Out_fx[i]; + move32(); + + shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); + + pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); + move32(); + + FOR( j = 1; j < filter_state->filt_len; j++ ) + { + shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); + + tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); + + shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; + tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); + + filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index ddcb33fef..d7d4fbdfc 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3817,13 +3817,20 @@ void ivas_filter_process_exp_fx( Word16 *pIn_Out_e ); -void ivas_filter_process_fixed_fx( +void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ Word16 q ); +void ivas_filter_process_fx64( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word64 *pIn_Out_fx, /* i : signal subject to filtering */ + const Word16 length, /* i : filter order */ + Word16 q +); + ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 2bcb1b7cb..e5e0ebe1c 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -376,24 +376,24 @@ static Word32 ivas_calc_duck_gain_fx( *-----------------------------------------------------------------------------------------*/ #if 0 -static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ); +static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ); -static void check( Word32 computed_fx, Word16 computed_q, Word32 expected_fx, Word16 expected_q ) +static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ) { - Word32 cfx, efx; + Word64 cfx, efx; Word16 q_diff = computed_q - expected_q; if ( q_diff >= 0 ) { - cfx = L_shr( computed_fx, +q_diff ); + cfx = W_shr( computed_fx, +q_diff ); efx = expected_fx; } else { cfx = computed_fx; - efx = L_shr( expected_fx, -q_diff ); + efx = W_shr( expected_fx, -q_diff ); } - Word32 error = abs( cfx - efx ); - if ( error > ( 1 << 16 ) ) + Word64 error = llabs( cfx - efx ); + if ( error > ( (Word64) 1 << 16 ) ) { assert( false ); } @@ -409,7 +409,6 @@ void ivas_td_decorr_get_ducking_gains_fx( const Word16 tdet_flag /*Q0*/ ) { Word16 i; - Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; Word32 in_duck_gain = hTranDet->in_duck_gain; /*Q30*/ move32(); Word32 out_duck_gain = hTranDet->out_duck_gain; /*Q30*/ @@ -421,17 +420,22 @@ void ivas_td_decorr_get_ducking_gains_fx( Word32 duck_mult_fac = hTranDet->duck_mult_fac; /*Q29*/ move32(); - Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ +#ifdef OPT_2239_IVAS_FILTER_PROCESS + Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; + + for ( i = 0; i < frame_len; i++ ) + { + e_fast_fx[i] = ( (Word64) pIn_pcm[i] ) << 32; + } -#ifdef OPT_2239_IVAS_FILTER_PROCESS /* env hpf */ - Word16 q_fast = Q11; + Word16 q_fast = Q11 + 32; - ivas_filter_process_fixed_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, q_fast ); + ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, q_fast ); - Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; - Word16 env_eps_q = Q31; + Word64 env_eps_fx = ( (Word64) IVAS_TDET_PARM_ENV_EPS_fx ) << 32; + Word16 env_eps_q = Q31 + 32; Word16 q_diff = sub( q_fast, env_eps_q ); q_fast = s_min( q_fast, env_eps_q ); @@ -440,7 +444,7 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { - e_fast_fx[i] = L_add( L_abs( L_shr( e_fast_fx[i], q_diff ) ), env_eps_fx ); + e_fast_fx[i] = W_add( W_abs( W_shr( e_fast_fx[i], q_diff ) ), env_eps_fx ); move32(); e_slow_fx[i] = e_fast_fx[i]; move32(); @@ -448,10 +452,10 @@ void ivas_td_decorr_get_ducking_gains_fx( } ELSE { - env_eps_fx = L_shl( env_eps_fx, q_diff ); + env_eps_fx = W_shl( env_eps_fx, q_diff ); FOR( i = 0; i < frame_len; i++ ) { - e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), env_eps_fx ); + e_fast_fx[i] = W_add( W_abs( e_fast_fx[i] ), env_eps_fx ); move32(); e_slow_fx[i] = e_fast_fx[i]; move32(); @@ -461,18 +465,25 @@ void ivas_td_decorr_get_ducking_gains_fx( Word16 q_slow = q_fast; /* env fast*/ - ivas_filter_process_fixed_fx( &hTranDet->env_fast, e_fast_fx, frame_len, q_fast ); + ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, q_fast ); /* env slow */ - ivas_filter_process_fixed_fx( &hTranDet->env_slow, e_slow_fx, frame_len, q_slow ); + ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, q_slow ); IF( tdet_flag ) { FOR( i = 0; i < frame_len; i++ ) { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], 31 - q_slow, e_fast_fx[i], 31 - q_fast, duck_mult_fac ); /*Q30*/ - pIn_duck_gains[i] = in_duck_gain; /*Q30*/ + Word16 fast_e = W_norm( e_fast_fx[i] ); + Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); + fast_e = 31 - ( q_fast + fast_e - 32 ); + Word16 slow_e = W_norm( e_slow_fx[i] ); + Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); + slow_e = 31 - ( q_slow + slow_e - 32 ); + + in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ + pIn_duck_gains[i] = in_duck_gain; /*Q30*/ move32(); } hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ @@ -482,11 +493,18 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], 31 - q_slow, e_fast_fx[i], 31 - q_fast, duck_mult_fac ); /*Q30*/ - pIn_duck_gains[i] = in_duck_gain; /*Q30*/ + Word16 fast_e = W_norm( e_fast_fx[i] ); + Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); + fast_e = 31 - ( q_fast + fast_e - 32 ); + Word16 slow_e = W_norm( e_slow_fx[i] ); + Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); + slow_e = 31 - ( q_slow + slow_e - 32 ); + + in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ + pIn_duck_gains[i] = in_duck_gain; /*Q30*/ move32(); - out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], 31 - q_fast, e_slow_fx[i], 31 - q_slow, duck_mult_fac ); /*Q30*/ - pOut_duck_gains[i] = out_duck_gain; /*Q30*/ + out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, fast_fx, fast_e, slow_fx, slow_e, duck_mult_fac ); /*Q30*/ + pOut_duck_gains[i] = out_duck_gain; /*Q30*/ move32(); } hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ @@ -495,6 +513,9 @@ void ivas_td_decorr_get_ducking_gains_fx( move32(); } #else + Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; + Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ + Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k]; set16_fx( e_fast_e, 31 - Q11, L_FRAME48k ); @@ -504,10 +525,15 @@ void ivas_td_decorr_get_ducking_gains_fx( // ==================================================================================================== - Word32 test_e_fast_fx[L_FRAME48k]; - Word16 q_fast = Q11; - Copy32( pIn_pcm, test_e_fast_fx, frame_len ); /*Q11*/ - ivas_filter_process_fixed_fx( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, q_fast ); + Word64 test_e_fast_fx[L_FRAME48k]; + Word16 q_fast = Q11 + 32; + + for ( i = 0; i < frame_len; i++ ) + { + test_e_fast_fx[i] = (Word64) pIn_pcm[i] << 32; + } + + ivas_filter_process_fx64( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, q_fast ); for ( i = 0; i < frame_len; i++ ) { @@ -528,65 +554,65 @@ void ivas_td_decorr_get_ducking_gains_fx( } // ==================================================================================================== - Word32 test_e_slow_fx[L_FRAME48k]; - Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; - Word16 env_eps_q = Q31; - - Word16 q_diff = sub( q_fast, env_eps_q ); - q_fast = s_min( q_fast, env_eps_q ); - - if ( q_diff >= 0 ) - { - for ( i = 0; i < frame_len; i++ ) - { - test_e_fast_fx[i] = L_add( L_abs( L_shr( test_e_fast_fx[i], q_diff ) ), env_eps_fx ); - move32(); - test_e_slow_fx[i] = test_e_fast_fx[i]; - move32(); - } - } - else - { - env_eps_fx = L_shl( env_eps_fx, q_diff ); - for ( i = 0; i < frame_len; i++ ) - { - test_e_fast_fx[i] = L_add( L_abs( test_e_fast_fx[i] ), env_eps_fx ); - move32(); - test_e_slow_fx[i] = test_e_fast_fx[i]; - move32(); - } - } - - Word16 q_slow = q_fast; - - for ( i = 0; i < frame_len; i++ ) - { - check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); - } + // Word32 test_e_slow_fx[L_FRAME48k]; + // Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; + // Word16 env_eps_q = Q31; + + // Word16 q_diff = sub( q_fast, env_eps_q ); + // q_fast = s_min( q_fast, env_eps_q ); + + // if ( q_diff >= 0 ) + // { + // for ( i = 0; i < frame_len; i++ ) + // { + // test_e_fast_fx[i] = L_add( L_abs( L_shr( test_e_fast_fx[i], q_diff ) ), env_eps_fx ); + // move32(); + // test_e_slow_fx[i] = test_e_fast_fx[i]; + // move32(); + // } + // } + // else + // { + // env_eps_fx = L_shl( env_eps_fx, q_diff ); + // for ( i = 0; i < frame_len; i++ ) + // { + // test_e_fast_fx[i] = L_add( L_abs( test_e_fast_fx[i] ), env_eps_fx ); + // move32(); + // test_e_slow_fx[i] = test_e_fast_fx[i]; + // move32(); + // } + // } + + // Word16 q_slow = q_fast; + + // for ( i = 0; i < frame_len; i++ ) + // { + // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); + // } // ==================================================================================================== /* env fast*/ ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e ); // ==================================================================================================== - ivas_filter_process_fixed_fx( &hTranDet->test_env_fast, test_e_fast_fx, frame_len, q_fast ); + // ivas_filter_process_fx32( &hTranDet->test_env_fast, test_e_fast_fx, frame_len, q_fast ); - for ( i = 0; i < frame_len; i++ ) - { - check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); - } + // for ( i = 0; i < frame_len; i++ ) + // { + // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); + // } // ==================================================================================================== /* env slow */ ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e ); // ==================================================================================================== - ivas_filter_process_fixed_fx( &hTranDet->test_env_slow, test_e_slow_fx, frame_len, q_slow ); + // ivas_filter_process_fx32( &hTranDet->test_env_slow, test_e_slow_fx, frame_len, q_slow ); - for ( i = 0; i < frame_len; i++ ) - { - check( test_e_slow_fx[i], q_slow, e_slow_fx[i], 31 - e_slow_e[i] ); - } + // for ( i = 0; i < frame_len; i++ ) + // { + // check( test_e_slow_fx[i], q_slow, e_slow_fx[i], 31 - e_slow_e[i] ); + // } // ==================================================================================================== IF( tdet_flag ) -- GitLab From aa3187784ec6ab7e0d2d59a9499124206bcf3fbd Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 20 Nov 2025 12:57:43 +0000 Subject: [PATCH 054/750] Simplify ivas_td_decorr_get_ducking_gains_fx. --- lib_com/cnst.h | 2 + lib_com/ivas_transient_det_fx.c | 96 +++++++++------------------------ 2 files changed, 27 insertions(+), 71 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 03bcc42b8..a6a0258bf 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -99,6 +99,8 @@ #define Q30 30 #define Q31 31 +#define Q43 43 + /*----------------------------------------------------------------------------------* * one in Q *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index e5e0ebe1c..55e301e8b 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -43,8 +43,12 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) +#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) +#ifdef OPT_2239_IVAS_FILTER_PROCESS +#define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32 +#else #define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 +#endif #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 #define IVAS_TDET_PARM_TRANS_THR ( 107374182 ) // Q30 @@ -375,31 +379,6 @@ static Word32 ivas_calc_duck_gain_fx( * Calculate in/out ducking gains *-----------------------------------------------------------------------------------------*/ -#if 0 -static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ); - -static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ) -{ - Word64 cfx, efx; - Word16 q_diff = computed_q - expected_q; - if ( q_diff >= 0 ) - { - cfx = W_shr( computed_fx, +q_diff ); - efx = expected_fx; - } - else - { - cfx = computed_fx; - efx = W_shr( expected_fx, -q_diff ); - } - Word64 error = llabs( cfx - efx ); - if ( error > ( (Word64) 1 << 16 ) ) - { - assert( false ); - } -} -#endif - void ivas_td_decorr_get_ducking_gains_fx( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ Word32 *pIn_pcm, /*Q11*/ @@ -423,64 +402,39 @@ void ivas_td_decorr_get_ducking_gains_fx( #ifdef OPT_2239_IVAS_FILTER_PROCESS Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; - for ( i = 0; i < frame_len; i++ ) + FOR( i = 0; i < frame_len; i++ ) { - e_fast_fx[i] = ( (Word64) pIn_pcm[i] ) << 32; + e_fast_fx[i] = W_deposit32_h( pIn_pcm[i] ); /*Q43*/ + move64(); } - /* env hpf */ - Word16 q_fast = Q11 + 32; - - ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, q_fast ); - - Word64 env_eps_fx = ( (Word64) IVAS_TDET_PARM_ENV_EPS_fx ) << 32; - Word16 env_eps_q = Q31 + 32; + ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, Q43 ); - Word16 q_diff = sub( q_fast, env_eps_q ); - q_fast = s_min( q_fast, env_eps_q ); - - IF( q_diff >= 0 ) - { - FOR( i = 0; i < frame_len; i++ ) - { - e_fast_fx[i] = W_add( W_abs( W_shr( e_fast_fx[i], q_diff ) ), env_eps_fx ); - move32(); - e_slow_fx[i] = e_fast_fx[i]; - move32(); - } - } - ELSE + FOR( i = 0; i < frame_len; i++ ) { - env_eps_fx = W_shl( env_eps_fx, q_diff ); - FOR( i = 0; i < frame_len; i++ ) - { - e_fast_fx[i] = W_add( W_abs( e_fast_fx[i] ), env_eps_fx ); - move32(); - e_slow_fx[i] = e_fast_fx[i]; - move32(); - } + e_fast_fx[i] = W_add( W_abs( e_fast_fx[i] ), IVAS_TDET_PARM_ENV_EPS_fx ); + move64(); + e_slow_fx[i] = e_fast_fx[i]; + move64(); } - Word16 q_slow = q_fast; - /* env fast*/ - ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, q_fast ); + ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, Q43 ); /* env slow */ - ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, q_slow ); - + ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, Q43 ); IF( tdet_flag ) { FOR( i = 0; i < frame_len; i++ ) { Word16 fast_e = W_norm( e_fast_fx[i] ); - Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); - fast_e = 31 - ( q_fast + fast_e - 32 ); + Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ + fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ Word16 slow_e = W_norm( e_slow_fx[i] ); - Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); - slow_e = 31 - ( q_slow + slow_e - 32 ); + Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ + slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ @@ -494,11 +448,11 @@ void ivas_td_decorr_get_ducking_gains_fx( FOR( i = 0; i < frame_len; i++ ) { Word16 fast_e = W_norm( e_fast_fx[i] ); - Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); - fast_e = 31 - ( q_fast + fast_e - 32 ); + Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ + fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ Word16 slow_e = W_norm( e_slow_fx[i] ); - Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); - slow_e = 31 - ( q_slow + slow_e - 32 ); + Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ + slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ @@ -526,7 +480,7 @@ void ivas_td_decorr_get_ducking_gains_fx( // ==================================================================================================== Word64 test_e_fast_fx[L_FRAME48k]; - Word16 q_fast = Q11 + 32; + Word16 q_fast = Q43; for ( i = 0; i < frame_len; i++ ) { -- GitLab From 90759dca226c808d2541284e6cab62cfc387fbb3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 20 Nov 2025 15:36:14 +0100 Subject: [PATCH 055/750] fastest version bit with no msub --- lib_enc/ivas_mcmasa_enc_fx.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index f88c7d4db..de4637499 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1081,6 +1081,15 @@ void ivas_mcmasa_param_est_enc_fx( #ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix */ + + assert( mrange[1] - mrange[0] == 1 ); + /*if this ever comes up, + 1. backup COVls to COVls_old + 2. reinitialize COVls (setzero) + 3. call compute_cov_mtx_fx(..,COVls,...) + 4. Add COVls_old to COVls + */ + compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); FOR( i = 0; i < num_freq_bands; i++ ) @@ -2135,9 +2144,7 @@ static void compute_cov_mtx_fx( Word16 freq; int k; int i, j; - Word16 max_exp_r, max_exp_i; Word64 temp64_1_r_acc, temp64_1_i_acc; - Word64 temp64_1; Word16 tmp_16; Word16 temp_exp = shl( inp_exp, 1 ); @@ -2154,36 +2161,29 @@ static void compute_cov_mtx_fx( move16(); CovarianceMatrix *COVls = &( pCOVls[k] ); - temp64_1_r_acc = W_deposit32_h( COVls->xr_fx[i][j] ); - max_exp_r = s_max( COVls->xr_e[i][j], temp_exp ); - temp64_1_r_acc = W_shl( temp64_1_r_acc, sub( COVls->xr_e[i][j], max_exp_r ) ); // exp:max_exp_r - - temp64_1_i_acc = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j] - max_exp_i = s_max( COVls->xi_e[i][j], temp_exp ); - temp64_1_i_acc = W_shl( temp64_1_i_acc, sub( COVls->xi_e[i][j], max_exp_i ) ); // exp:max_exp_i + temp64_1_r_acc = 0; + temp64_1_i_acc = 0; FOR( freq = brange[0]; freq < brange[1]; freq++ ) { - temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r - temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r + temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp - temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i - temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i + temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); + temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32(sr[i][freq], si[j][freq]) ); } tmp_16 = W_norm( temp64_1_r_acc ); COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1_r_acc, tmp_16 ) ); // exp:max_exp-tmp_16 - COVls->xr_e[i][j] = sub( max_exp_r, tmp_16 ); + COVls->xr_e[i][j] = sub( temp_exp, tmp_16 ); move32(); move16(); tmp_16 = W_norm( temp64_1_i_acc ); COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1_i_acc, tmp_16 ) ); // exp:max_exp-tmp_16 - COVls->xi_e[i][j] = sub( max_exp_i, tmp_16 ); + COVls->xi_e[i][j] = sub( temp_exp, tmp_16 ); move32(); move16(); } -- GitLab From a3b4967bbf0c8af8e31a1b039c1a6944dec95c46 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 20 Nov 2025 14:19:43 +0000 Subject: [PATCH 056/750] Tidy up code. --- lib_com/ivas_filters_fx.c | 325 ++++++++++++++++++-------------- lib_com/ivas_prot_fx.h | 32 ++-- lib_com/ivas_transient_det_fx.c | 105 ++--------- lib_dec/ivas_lfe_dec_fx.c | 4 + lib_enc/ivas_lfe_enc_fx.c | 4 + 5 files changed, 217 insertions(+), 253 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 93d36fcf5..22a296bdd 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -38,14 +38,6 @@ #include "ivas_rom_com.h" #include "ivas_prot_fx.h" -/*------------------------------------------------------------------------------------------* - * Local functions declaration - *------------------------------------------------------------------------------------------*/ - -static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); -static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); -static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); - /*-----------------------------------------------------------------------------------------* * Function ivas_filters_init() * @@ -204,6 +196,185 @@ void ivas_filters_init_fx( return; } +#ifdef OPT_2239_IVAS_FILTER_PROCESS +static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); +static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); +static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); + +/*-----------------------------------------------------------------------------------------* + * Function Mpy_64_32() + * + * Performs the the following operation: + * + * z = ((int128_t)x * (int128_t)y) >> 31 + * + * where: + * - x is a 64-bit signed integer + * - y is a 32-bit signed integer + * - z is a 64-bit signed integer + *-----------------------------------------------------------------------------------------*/ + +static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) +{ + Word32 var1_l; + Word64 var_out; + var1_l = W_extract_l( W_var1 ); // 1 + var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 + var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 + var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 + return var_out; +} + +/*-----------------------------------------------------------------------------------------* + * Function ivas_iir_2_filter_fx32() + * + * Process call for filtering a signal + *-----------------------------------------------------------------------------------------*/ + +static void ivas_iir_2_filter_fx32( + ivas_filters_process_state_t *filter_state, + Word32 *pIn_Out_fx, + const Word16 length, + const Word16 stage, + Word16 q ) +{ + Word64 tmp_prod, tmp; + Word32 in, out; + Word16 i, j, shift; + + FOR( i = 0; i < length; i++ ) + { + in = pIn_Out_fx[i]; + move32(); + + shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; + tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); + + shift = sub( filter_state->state64_q[stage], q ); + pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); + move32(); + + FOR( j = 1; j < filter_state->filt_len; j++ ) + { + shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; + tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); + + tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); + + shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; + tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); + + filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + move32(); + } + } + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function ivas_filter_process_fx32() + * + * Process call for filtering a signal + *-----------------------------------------------------------------------------------------*/ + +void ivas_filter_process_fx32( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ + const Word16 length, /* i : filter order */ + Word16 q ) +{ + SWITCH( filter_state->order ) + { + case IVAS_FILTER_ORDER_1: + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + BREAK; + case IVAS_FILTER_ORDER_4: + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); + BREAK; + default: + BREAK; + } + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function ivas_iir_2_filter_fx64() + * + * Process call for filtering a signal + *-----------------------------------------------------------------------------------------*/ + +static void ivas_iir_2_filter_fx64( + ivas_filters_process_state_t *filter_state, + Word64 *pIn_Out_fx, + const Word16 length, + const Word16 stage, + Word16 q ) +{ + Word64 tmp_prod, tmp, in, out; + Word16 i, j, shift; + + FOR( i = 0; i < length; i++ ) + { + in = pIn_Out_fx[i]; + move32(); + + shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); + + pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); + move32(); + + FOR( j = 1; j < filter_state->filt_len; j++ ) + { + shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); + + tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); + + shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; + tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); + + filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + move32(); + } + } + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function ivas_filter_process_fx64() + * + * Process call for filtering a signal + *-----------------------------------------------------------------------------------------*/ + +void ivas_filter_process_fx64( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ + const Word16 length, /* i : filter order */ + Word16 q ) +{ + SWITCH( filter_state->order ) + { + case IVAS_FILTER_ORDER_1: + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + BREAK; + case IVAS_FILTER_ORDER_4: + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); + BREAK; + default: + BREAK; + } + + return; +} + +#else +static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process() @@ -252,7 +423,6 @@ void ivas_filter_process_fx( return; } - void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ @@ -279,7 +449,6 @@ void ivas_filter_process_exp_fx( return; } - /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter() * @@ -341,138 +510,4 @@ static void ivas_iir_2_filter_fx( return; } - -void ivas_filter_process_fx32( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ - Word16 q ) -{ - SWITCH( filter_state->order ) - { - case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); - BREAK; - case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); - BREAK; - default: - BREAK; - } - - return; -} - -void ivas_filter_process_fx64( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ - Word16 q ) -{ - SWITCH( filter_state->order ) - { - case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); - BREAK; - case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); - BREAK; - default: - BREAK; - } - - return; -} - -static void ivas_iir_2_filter_fx32( - ivas_filters_process_state_t *filter_state, - Word32 *pIn_Out_fx, - const Word16 length, - const Word16 stage, - Word16 q ) -{ - Word64 tmp_prod, tmp; - Word32 in, out; - Word16 i, j, shift; - - FOR( i = 0; i < length; i++ ) - { - in = pIn_Out_fx[i]; - move32(); - - shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; - tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); - - shift = sub( filter_state->state64_q[stage], q ); - pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); - move32(); - - FOR( j = 1; j < filter_state->filt_len; j++ ) - { - shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; - tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); - - tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - - shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; - tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); - - filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); - move32(); - } - } - - return; -} - -static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) -{ - Word32 var1_l; - Word64 var_out; - var1_l = W_extract_l( W_var1 ); // 1 - var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 - var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 - var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 - return var_out; -} - -static void ivas_iir_2_filter_fx64( - ivas_filters_process_state_t *filter_state, - Word64 *pIn_Out_fx, - const Word16 length, - const Word16 stage, - Word16 q ) -{ - Word64 tmp_prod, tmp, in, out; - Word16 i, j, shift; - - FOR( i = 0; i < length; i++ ) - { - in = pIn_Out_fx[i]; - move32(); - - shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - - pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); - move32(); - - FOR( j = 1; j < filter_state->filt_len; j++ ) - { - shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); - - tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - - shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; - tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); - - filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); - move32(); - } - } - - return; -} +#endif diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index d7d4fbdfc..ce6c223e3 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3803,34 +3803,35 @@ void ivas_lfe_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); -void ivas_filter_process_fx( +#ifdef OPT_2239_IVAS_FILTER_PROCESS +void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ - Word16 q_factor + Word16 q ); -void ivas_filter_process_exp_fx( +void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ + Word64 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ - Word16 *pIn_Out_e + Word16 q ); - -void ivas_filter_process_fx32( +#else +void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ - Word16 q + Word16 q_factor ); -void ivas_filter_process_fx64( +void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word64 *pIn_Out_fx, /* i : signal subject to filtering */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ const Word16 length, /* i : filter order */ - Word16 q + Word16 *pIn_Out_e ); - +#endif ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); @@ -6821,13 +6822,6 @@ void ivas_filters_init_fx( const Word16 order ); -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ - Word16 q_factor -); - /*----------------------------------------------------------------------------------* * OSBA prototypes *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 55e301e8b..fca80ce82 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -401,6 +401,8 @@ void ivas_td_decorr_get_ducking_gains_fx( #ifdef OPT_2239_IVAS_FILTER_PROCESS Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; + Word32 fast_fx, slow_fx; + Word16 fast_e, slow_e; FOR( i = 0; i < frame_len; i++ ) { @@ -429,12 +431,12 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { - Word16 fast_e = W_norm( e_fast_fx[i] ); - Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ - fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ - Word16 slow_e = W_norm( e_slow_fx[i] ); - Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ - slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ + fast_e = W_norm( e_fast_fx[i] ); + fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ + fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ + slow_e = W_norm( e_slow_fx[i] ); + slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ + slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ @@ -447,12 +449,12 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { - Word16 fast_e = W_norm( e_fast_fx[i] ); - Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ - fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ - Word16 slow_e = W_norm( e_slow_fx[i] ); - Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ - slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ + fast_e = W_norm( e_fast_fx[i] ); + fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ + fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ + slow_e = W_norm( e_slow_fx[i] ); + slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ + slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ @@ -468,34 +470,16 @@ void ivas_td_decorr_get_ducking_gains_fx( } #else Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; - Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ - Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k]; + Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ + set16_fx( e_fast_e, 31 - Q11, L_FRAME48k ); /* env hpf */ ivas_filter_process_exp_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, e_fast_e ); - // ==================================================================================================== - Word64 test_e_fast_fx[L_FRAME48k]; - Word16 q_fast = Q43; - - for ( i = 0; i < frame_len; i++ ) - { - test_e_fast_fx[i] = (Word64) pIn_pcm[i] << 32; - } - - ivas_filter_process_fx64( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, q_fast ); - - for ( i = 0; i < frame_len; i++ ) - { - check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); - } - // ==================================================================================================== - - FOR( i = 0; i < frame_len; i++ ) { // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ @@ -507,68 +491,12 @@ void ivas_td_decorr_get_ducking_gains_fx( move16(); } - // ==================================================================================================== - // Word32 test_e_slow_fx[L_FRAME48k]; - // Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; - // Word16 env_eps_q = Q31; - - // Word16 q_diff = sub( q_fast, env_eps_q ); - // q_fast = s_min( q_fast, env_eps_q ); - - // if ( q_diff >= 0 ) - // { - // for ( i = 0; i < frame_len; i++ ) - // { - // test_e_fast_fx[i] = L_add( L_abs( L_shr( test_e_fast_fx[i], q_diff ) ), env_eps_fx ); - // move32(); - // test_e_slow_fx[i] = test_e_fast_fx[i]; - // move32(); - // } - // } - // else - // { - // env_eps_fx = L_shl( env_eps_fx, q_diff ); - // for ( i = 0; i < frame_len; i++ ) - // { - // test_e_fast_fx[i] = L_add( L_abs( test_e_fast_fx[i] ), env_eps_fx ); - // move32(); - // test_e_slow_fx[i] = test_e_fast_fx[i]; - // move32(); - // } - // } - - // Word16 q_slow = q_fast; - - // for ( i = 0; i < frame_len; i++ ) - // { - // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); - // } - // ==================================================================================================== - /* env fast*/ ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e ); - // ==================================================================================================== - // ivas_filter_process_fx32( &hTranDet->test_env_fast, test_e_fast_fx, frame_len, q_fast ); - - // for ( i = 0; i < frame_len; i++ ) - // { - // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); - // } - // ==================================================================================================== - /* env slow */ ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e ); - // ==================================================================================================== - // ivas_filter_process_fx32( &hTranDet->test_env_slow, test_e_slow_fx, frame_len, q_slow ); - - // for ( i = 0; i < frame_len; i++ ) - // { - // check( test_e_slow_fx[i], q_slow, e_slow_fx[i], 31 - e_slow_e[i] ); - // } - // ==================================================================================================== - IF( tdet_flag ) { FOR( i = 0; i < frame_len; i++ ) @@ -598,6 +526,5 @@ void ivas_td_decorr_get_ducking_gains_fx( } #endif - return; } diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 74d8de662..3a6fa2c91 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -408,7 +408,11 @@ void ivas_lfe_dec_fx( IF( hLFE->filter_state.order > 0 ) { /* Low Pass Filter */ +#ifdef OPT_2239_IVAS_FILTER_PROCESS + ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); +#else ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); +#endif } /* add delay to make overall max(block_offset, 11.5) */ diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 96959c9dd..11b02ca14 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -684,7 +684,11 @@ void ivas_lfe_lpf_enc_apply_fx( const Word16 input_frame /* i : input frame length per channel */ ) { +#ifdef OPT_2239_IVAS_FILTER_PROCESS + ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); +#else ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); +#endif return; } -- GitLab From 192c9dc294f90ab38167b260b841a56d876e0941 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 20 Nov 2025 14:54:26 +0000 Subject: [PATCH 057/750] Apply clang format. --- lib_com/ivas_filters_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 22a296bdd..b9f7714c9 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -205,9 +205,9 @@ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); * Function Mpy_64_32() * * Performs the the following operation: - * + * * z = ((int128_t)x * (int128_t)y) >> 31 - * + * * where: * - x is a 64-bit signed integer * - y is a 32-bit signed integer -- GitLab From b07d40d1eacc782ce41fcfb9d915c6fa913c197a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 20 Nov 2025 15:55:38 +0100 Subject: [PATCH 058/750] clang format --- lib_enc/ivas_mcmasa_enc_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index de4637499..54b0d6028 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1081,13 +1081,13 @@ void ivas_mcmasa_param_est_enc_fx( #ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix */ - - assert( mrange[1] - mrange[0] == 1 ); - /*if this ever comes up, + + assert( mrange[1] - mrange[0] == 1 ); + /*if this ever comes up, 1. backup COVls to COVls_old 2. reinitialize COVls (setzero) 3. call compute_cov_mtx_fx(..,COVls,...) - 4. Add COVls_old to COVls + 4. Add COVls_old to COVls */ compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); @@ -2170,7 +2170,7 @@ static void compute_cov_mtx_fx( temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); - temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32(sr[i][freq], si[j][freq]) ); + temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32( sr[i][freq], si[j][freq] ) ); } tmp_16 = W_norm( temp64_1_r_acc ); -- GitLab From c280a982a118f503a81eb829fa05c2f376b1141b Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 20 Nov 2025 15:03:20 +0000 Subject: [PATCH 059/750] Tidy up code. --- lib_com/ivas_filters_fx.c | 109 ++++++++++++++------------------ lib_com/ivas_stat_com.h | 14 ++-- lib_com/ivas_transient_det_fx.c | 3 - 3 files changed, 53 insertions(+), 73 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index b9f7714c9..6804e24b6 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -64,43 +64,42 @@ void ivas_filters_init_fx( FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ ) { filter_state->num_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i]; - filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1; filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN]; - filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1; move32(); move32(); - move16(); - move16(); #ifdef OPT_2239_IVAS_FILTER_PROCESS filter_state->num_q[IVAS_FILTER_STAGE_0][i] = Q30; filter_state->den_q[IVAS_FILTER_STAGE_0][i] = Q30; move16(); move16(); +#else + filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1; + filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1; + move16(); + move16(); #endif } +#ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; + move64(); + move64(); + move64(); +#else filter_state->state_fx[0][0] = 0; - filter_state->state_e[0][0] = 0; filter_state->state_fx[0][1] = 0; - filter_state->state_e[0][1] = 0; filter_state->state_fx[0][2] = 0; - filter_state->state_e[0][2] = 0; move32(); move32(); move32(); + filter_state->state_e[0][0] = 0; + filter_state->state_e[0][1] = 0; + filter_state->state_e[0][2] = 0; move16(); move16(); move16(); - -#ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; - move64(); - move64(); - move64(); - filter_state->state64_q[IVAS_FILTER_STAGE_0] = Q30; - move16(); #endif } ELSE @@ -108,30 +107,16 @@ void ivas_filters_init_fx( filter_state->filt_len = IVAS_BIQUAD_FILT_LEN; move16(); -#ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->state64_q[IVAS_FILTER_STAGE_0] = 63; - filter_state->state64_q[IVAS_FILTER_STAGE_1] = 63; -#endif - FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ ) { - filter_state->num_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i]; - filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i]; filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN]; - filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN]; filter_state->num_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN * 2]; - filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2]; filter_state->den_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN * 3]; - filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3]; move32(); move32(); move32(); move32(); - move16(); - move16(); - move16(); - move16(); #ifdef OPT_2239_IVAS_FILTER_PROCESS filter_state->num_q[IVAS_FILTER_STAGE_0][i] = sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ); filter_state->den_q[IVAS_FILTER_STAGE_0][i] = sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ); @@ -141,10 +126,11 @@ void ivas_filters_init_fx( move16(); move16(); move16(); - filter_state->state64_q[IVAS_FILTER_STAGE_0] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_0], filter_state->num_q[IVAS_FILTER_STAGE_0][i] ); - filter_state->state64_q[IVAS_FILTER_STAGE_0] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_0], filter_state->den_q[IVAS_FILTER_STAGE_0][i] ); - filter_state->state64_q[IVAS_FILTER_STAGE_1] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_1], filter_state->num_q[IVAS_FILTER_STAGE_1][i] ); - filter_state->state64_q[IVAS_FILTER_STAGE_1] = s_min( filter_state->state64_q[IVAS_FILTER_STAGE_1], filter_state->den_q[IVAS_FILTER_STAGE_1][i] ); +#else + filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i]; + filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN]; + filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2]; + filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3]; move16(); move16(); move16(); @@ -152,44 +138,44 @@ void ivas_filters_init_fx( #endif } +#ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][2] = 0; + move64(); + move64(); + move64(); + move64(); + move64(); + move64(); +#else filter_state->state_fx[0][0] = 0; - filter_state->state_e[0][0] = 0; filter_state->state_fx[0][1] = 0; - filter_state->state_e[0][1] = 0; filter_state->state_fx[0][2] = 0; - filter_state->state_e[0][2] = 0; filter_state->state_fx[1][0] = 0; - filter_state->state_e[1][0] = 0; filter_state->state_fx[1][1] = 0; - filter_state->state_e[1][1] = 0; filter_state->state_fx[1][2] = 0; - filter_state->state_e[1][2] = 0; move32(); move32(); move32(); move32(); move32(); move32(); + filter_state->state_e[0][0] = 0; + filter_state->state_e[0][1] = 0; + filter_state->state_e[0][2] = 0; + filter_state->state_e[1][0] = 0; + filter_state->state_e[1][1] = 0; + filter_state->state_e[1][2] = 0; move16(); move16(); move16(); move16(); move16(); move16(); - -#ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][2] = 0; - move64(); - move64(); - move64(); - move64(); - move64(); - move64(); #endif } @@ -240,28 +226,29 @@ static void ivas_iir_2_filter_fx32( { Word64 tmp_prod, tmp; Word32 in, out; - Word16 i, j, shift; + Word16 i, j, shift, state_q; + + state_q = add( q, 32 ); FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); - shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; + shift = filter_state->num_q[stage][0] + q - state_q; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); - shift = sub( filter_state->state64_q[stage], q ); - pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); + pIn_Out_fx[i] = out = W_extract_l( W_add( filter_state->state64_fx[stage][0], tmp_prod ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { - shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; + shift = filter_state->num_q[stage][j] + q - state_q; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; + shift = filter_state->den_q[stage][j] + q - state_q; tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 97a4f58a8..7ab869605 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -656,16 +656,15 @@ typedef struct ivas_filters_process_state_t Word16 filt_len; Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - #ifdef OPT_2239_IVAS_FILTER_PROCESS Word64 state64_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 state64_q[IVAS_FILTER_MAX_STAGES]; +#else + Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #endif } ivas_filters_process_state_t; @@ -680,9 +679,6 @@ typedef struct ivas_trans_det_state_t ivas_filters_process_state_t env_hpf; ivas_filters_process_state_t env_fast; ivas_filters_process_state_t env_slow; - ivas_filters_process_state_t test_env_hpf; - ivas_filters_process_state_t test_env_fast; - ivas_filters_process_state_t test_env_slow; Word32 in_duck_coeff; Word32 out_duck_coeff; Word32 in_duck_gain; diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index fca80ce82..1c9d58693 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -229,9 +229,6 @@ static void ivas_transient_det_init( ivas_filters_init_fx( &hTranDet->env_hpf, (const Word32 *) filt_coeff_arr_fx[0], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); ivas_filters_init_fx( &hTranDet->env_fast, (const Word32 *) filt_coeff_arr_fx[1], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); ivas_filters_init_fx( &hTranDet->env_slow, (const Word32 *) filt_coeff_arr_fx[2], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); - ivas_filters_init_fx( &hTranDet->test_env_hpf, (const Word32 *) filt_coeff_arr_fx[0], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); - ivas_filters_init_fx( &hTranDet->test_env_fast, (const Word32 *) filt_coeff_arr_fx[1], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); - ivas_filters_init_fx( &hTranDet->test_env_slow, (const Word32 *) filt_coeff_arr_fx[2], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); hTranDet->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC; /*Q29*/ move32(); -- GitLab From 2a0924b8257f3eb05f98bf3362c414b7b0fea576 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 20 Nov 2025 15:47:47 +0000 Subject: [PATCH 060/750] Fix ivas_iir_2_filter_fx32. --- lib_com/ivas_filters_fx.c | 39 +++++++++++++++------------------------ lib_com/ivas_stat_com.h | 2 +- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 6804e24b6..29ca10cc4 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -80,17 +80,14 @@ void ivas_filters_init_fx( #endif } + filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; #ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; move64(); move64(); move64(); #else - filter_state->state_fx[0][0] = 0; - filter_state->state_fx[0][1] = 0; - filter_state->state_fx[0][2] = 0; move32(); move32(); move32(); @@ -138,13 +135,13 @@ void ivas_filters_init_fx( #endif } + filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0; #ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][2] = 0; move64(); move64(); move64(); @@ -152,12 +149,6 @@ void ivas_filters_init_fx( move64(); move64(); #else - filter_state->state_fx[0][0] = 0; - filter_state->state_fx[0][1] = 0; - filter_state->state_fx[0][2] = 0; - filter_state->state_fx[1][0] = 0; - filter_state->state_fx[1][1] = 0; - filter_state->state_fx[1][2] = 0; move32(); move32(); move32(); @@ -238,7 +229,7 @@ static void ivas_iir_2_filter_fx32( shift = filter_state->num_q[stage][0] + q - state_q; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); - pIn_Out_fx[i] = out = W_extract_l( W_add( filter_state->state64_fx[stage][0], tmp_prod ) ); + pIn_Out_fx[i] = out = W_extract_h( W_add( filter_state->state_fx[stage][0], tmp_prod ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) @@ -246,12 +237,12 @@ static void ivas_iir_2_filter_fx32( shift = filter_state->num_q[stage][j] + q - state_q; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); - tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); + tmp = W_add( filter_state->state_fx[stage][j], tmp_prod ); shift = filter_state->den_q[stage][j] + q - state_q; tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); - filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } @@ -311,7 +302,7 @@ static void ivas_iir_2_filter_fx64( shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); + pIn_Out_fx[i] = out = W_add( filter_state->state_fx[stage][0], tmp_prod ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) @@ -319,12 +310,12 @@ static void ivas_iir_2_filter_fx64( shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); - tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); + tmp = W_add( filter_state->state_fx[stage][j], tmp_prod ); shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); - filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 7ab869605..b46e5e66b 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -657,7 +657,7 @@ typedef struct ivas_filters_process_state_t Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #ifdef OPT_2239_IVAS_FILTER_PROCESS - Word64 state64_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #else -- GitLab From 83d041a606b8f2d4a37a57ce092928369326ae74 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 20 Nov 2025 16:41:48 +0000 Subject: [PATCH 061/750] Debug fx32. --- lib_com/ivas_filters_fx.c | 67 +++++++++++++++++++++++---------------- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_stat_com.h | 4 +-- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 29ca10cc4..92c773928 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -72,7 +72,7 @@ void ivas_filters_init_fx( filter_state->den_q[IVAS_FILTER_STAGE_0][i] = Q30; move16(); move16(); -#else + // #else FIXME filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1; filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1; move16(); @@ -80,14 +80,17 @@ void ivas_filters_init_fx( #endif } - filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; #ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; move64(); move64(); move64(); -#else + // #else FIXME + filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; move32(); move32(); move32(); @@ -123,7 +126,7 @@ void ivas_filters_init_fx( move16(); move16(); move16(); -#else + // #else FIXME filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i]; filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN]; filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2]; @@ -135,20 +138,26 @@ void ivas_filters_init_fx( #endif } - filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0; #ifdef OPT_2239_IVAS_FILTER_PROCESS + filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][0] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][1] = 0; + filter_state->state64_fx[IVAS_FILTER_STAGE_1][2] = 0; move64(); move64(); move64(); move64(); move64(); move64(); -#else + // #else FIXME + filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0; move32(); move32(); move32(); @@ -219,30 +228,28 @@ static void ivas_iir_2_filter_fx32( Word32 in, out; Word16 i, j, shift, state_q; - state_q = add( q, 32 ); - FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); - shift = filter_state->num_q[stage][0] + q - state_q; + shift = sub( filter_state->num_q[stage][0], 32 ); tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); - pIn_Out_fx[i] = out = W_extract_h( W_add( filter_state->state_fx[stage][0], tmp_prod ) ); + pIn_Out_fx[i] = out = W_extract_h( W_add( filter_state->state64_fx[stage][0], tmp_prod ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { - shift = filter_state->num_q[stage][j] + q - state_q; + shift = sub( filter_state->num_q[stage][j], 32 ); tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); - tmp = W_add( filter_state->state_fx[stage][j], tmp_prod ); + tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - shift = filter_state->den_q[stage][j] + q - state_q; + shift = sub( filter_state->den_q[stage][j], 32 ); tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); - filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } @@ -262,6 +269,9 @@ void ivas_filter_process_fx32( const Word16 length, /* i : filter order */ Word16 q ) { +#if 1 + ivas_filter_process_fx( filter_state, pIn_Out_fx, length, q ); +#else SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: @@ -274,6 +284,7 @@ void ivas_filter_process_fx32( default: BREAK; } +#endif return; } @@ -299,23 +310,23 @@ static void ivas_iir_2_filter_fx64( in = pIn_Out_fx[i]; move32(); - shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; + shift = sub( filter_state->num_q[stage][0], 31 ); tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - pIn_Out_fx[i] = out = W_add( filter_state->state_fx[stage][0], tmp_prod ); + pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { - shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; + shift = sub( filter_state->num_q[stage][j], 31 ); tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); - tmp = W_add( filter_state->state_fx[stage][j], tmp_prod ); + tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; + shift = sub( filter_state->den_q[stage][j], 31 ); tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); - filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } @@ -351,7 +362,7 @@ void ivas_filter_process_fx64( return; } -#else +// #else FIXME static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); /*-----------------------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index ce6c223e3..6a9b5b32a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3817,7 +3817,7 @@ void ivas_filter_process_fx64( const Word16 length, /* i : filter order */ Word16 q ); -#else +// #else FIXME void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index b46e5e66b..4da7e53aa 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -657,10 +657,10 @@ typedef struct ivas_filters_process_state_t Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #ifdef OPT_2239_IVAS_FILTER_PROCESS - Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word64 state64_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#else + // #else FIXME Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -- GitLab From 52dee0c437cfb63122791fdd9995bc386a67a411 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 21 Nov 2025 08:13:49 +0000 Subject: [PATCH 062/750] Debug fx32. --- lib_com/ivas_filters_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 92c773928..37ba0f20f 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -216,7 +216,7 @@ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ - +#if 0 static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, @@ -226,7 +226,7 @@ static void ivas_iir_2_filter_fx32( { Word64 tmp_prod, tmp; Word32 in, out; - Word16 i, j, shift, state_q; + Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { @@ -256,6 +256,7 @@ static void ivas_iir_2_filter_fx32( return; } +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process_fx32() -- GitLab From bd1617b756ae69e0a1a19c610954394fd0221247 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 21 Nov 2025 08:45:20 +0000 Subject: [PATCH 063/750] Debug fx32. --- lib_com/ivas_filters_fx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 37ba0f20f..d93bf720f 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -183,7 +183,6 @@ void ivas_filters_init_fx( } #ifdef OPT_2239_IVAS_FILTER_PROCESS -static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); @@ -217,6 +216,7 @@ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ #if 0 +static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, @@ -233,21 +233,21 @@ static void ivas_iir_2_filter_fx32( in = pIn_Out_fx[i]; move32(); - shift = sub( filter_state->num_q[stage][0], 32 ); - tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); + shift = sub( filter_state->num_q[stage][0], 31 ); // (num_q + q + 1) - (q + 32) + tmp_prod = W_shr( W_mult_32_32( filter_state->num_fx[stage][0], in ), shift ); pIn_Out_fx[i] = out = W_extract_h( W_add( filter_state->state64_fx[stage][0], tmp_prod ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { - shift = sub( filter_state->num_q[stage][j], 32 ); - tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); + shift = sub( filter_state->num_q[stage][j], 31 ); + tmp_prod = W_shr( W_mult_32_32( filter_state->num_fx[stage][j], in ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - shift = sub( filter_state->den_q[stage][j], 32 ); - tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); + shift = sub( filter_state->den_q[stage][j], 31 ); + tmp_prod = W_shr( W_mult_32_32( filter_state->den_fx[stage][j], out ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); @@ -311,7 +311,7 @@ static void ivas_iir_2_filter_fx64( in = pIn_Out_fx[i]; move32(); - shift = sub( filter_state->num_q[stage][0], 31 ); + shift = sub( filter_state->num_q[stage][0], 31 ); // (q + numq - 31) - q tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); -- GitLab From 106c565791fa5aedb76ace83bcefa0db5e756a76 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 21 Nov 2025 09:10:49 +0000 Subject: [PATCH 064/750] Debug fx32. --- lib_com/ivas_filters_fx.c | 26 ++++++++++++-------------- lib_com/ivas_prot_fx.h | 3 +-- lib_com/ivas_transient_det_fx.c | 6 +++--- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index d93bf720f..20a1669bd 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -183,7 +183,7 @@ void ivas_filters_init_fx( } #ifdef OPT_2239_IVAS_FILTER_PROCESS -static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); +static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage ); static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); /*-----------------------------------------------------------------------------------------* @@ -216,13 +216,12 @@ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ #if 0 -static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); +static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage ); static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, - const Word16 stage, - Word16 q ) + const Word16 stage ) { Word64 tmp_prod, tmp; Word32 in, out; @@ -276,11 +275,11 @@ void ivas_filter_process_fx32( SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); BREAK; case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); + ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1 ); BREAK; default: BREAK; @@ -300,8 +299,7 @@ static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, - const Word16 stage, - Word16 q ) + const Word16 stage ) { Word64 tmp_prod, tmp, in, out; Word16 i, j, shift; @@ -344,17 +342,17 @@ static void ivas_iir_2_filter_fx64( void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ - const Word16 length, /* i : filter order */ - Word16 q ) + const Word16 length ) /* i : filter order */ + { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); BREAK; case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); + ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1 ); BREAK; default: BREAK; diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6a9b5b32a..4a25844a3 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3814,8 +3814,7 @@ void ivas_filter_process_fx32( void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i : signal subject to filtering */ - const Word16 length, /* i : filter order */ - Word16 q + const Word16 length /* i : filter order */ ); // #else FIXME void ivas_filter_process_fx( diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 1c9d58693..ac285873c 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -408,7 +408,7 @@ void ivas_td_decorr_get_ducking_gains_fx( } /* env hpf */ - ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, Q43 ); + ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len ); /*Q43*/ FOR( i = 0; i < frame_len; i++ ) { @@ -419,10 +419,10 @@ void ivas_td_decorr_get_ducking_gains_fx( } /* env fast*/ - ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, Q43 ); + ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len ); /*Q43*/ /* env slow */ - ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, Q43 ); + ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len ); /*Q43*/ IF( tdet_flag ) { -- GitLab From 291b49038326b7ad5996359f9aaeb67543b87d9f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 21 Nov 2025 10:01:36 +0000 Subject: [PATCH 065/750] Add headroom to state. --- lib_com/ivas_filters_fx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 20a1669bd..f58c35e71 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -309,20 +309,21 @@ static void ivas_iir_2_filter_fx64( in = pIn_Out_fx[i]; move32(); - shift = sub( filter_state->num_q[stage][0], 31 ); // (q + numq - 31) - q + shift = sub( filter_state->num_q[stage][0], 30 ); tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); + out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); + pIn_Out_fx[i] = W_shl( out, 1 ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { - shift = sub( filter_state->num_q[stage][j], 31 ); + shift = sub( filter_state->num_q[stage][j], 30 ); tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - shift = sub( filter_state->den_q[stage][j], 31 ); + shift = sub( filter_state->den_q[stage][j], 30 ); tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); -- GitLab From dedd38232edf865c8e36922fa01f1437841321e6 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 21 Nov 2025 10:24:42 +0000 Subject: [PATCH 066/750] Increase precision in ivas_iir_2_filter_fx32. --- lib_com/ivas_filters_fx.c | 37 +++++++++++++++---------------------- lib_com/ivas_prot_fx.h | 3 +-- lib_dec/ivas_lfe_dec_fx.c | 2 +- lib_enc/ivas_lfe_enc_fx.c | 2 +- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index f58c35e71..d11088adf 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -183,6 +183,7 @@ void ivas_filters_init_fx( } #ifdef OPT_2239_IVAS_FILTER_PROCESS +static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage ); static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage ); static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); @@ -215,38 +216,37 @@ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ -#if 0 -static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage ); + static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage ) { - Word64 tmp_prod, tmp; - Word32 in, out; + Word64 tmp_prod, tmp, in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { - in = pIn_Out_fx[i]; + in = W_deposit32_h( pIn_Out_fx[i] ); move32(); - shift = sub( filter_state->num_q[stage][0], 31 ); // (num_q + q + 1) - (q + 32) - tmp_prod = W_shr( W_mult_32_32( filter_state->num_fx[stage][0], in ), shift ); + shift = sub( filter_state->num_q[stage][0], 31 ); + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - pIn_Out_fx[i] = out = W_extract_h( W_add( filter_state->state64_fx[stage][0], tmp_prod ) ); + out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); + pIn_Out_fx[i] = W_extract_h( out ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = sub( filter_state->num_q[stage][j], 31 ); - tmp_prod = W_shr( W_mult_32_32( filter_state->num_fx[stage][j], in ), shift ); + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = sub( filter_state->den_q[stage][j], 31 ); - tmp_prod = W_shr( W_mult_32_32( filter_state->den_fx[stage][j], out ), shift ); + tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); @@ -255,7 +255,6 @@ static void ivas_iir_2_filter_fx32( return; } -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process_fx32() @@ -266,12 +265,8 @@ static void ivas_iir_2_filter_fx32( void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ - const Word16 length, /* i : filter order */ - Word16 q ) + const Word16 length ) /* i : filter order */ { -#if 1 - ivas_filter_process_fx( filter_state, pIn_Out_fx, length, q ); -#else SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: @@ -284,7 +279,6 @@ void ivas_filter_process_fx32( default: BREAK; } -#endif return; } @@ -309,21 +303,20 @@ static void ivas_iir_2_filter_fx64( in = pIn_Out_fx[i]; move32(); - shift = sub( filter_state->num_q[stage][0], 30 ); + shift = sub( filter_state->num_q[stage][0], 31 ); tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); - pIn_Out_fx[i] = W_shl( out, 1 ); + pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { - shift = sub( filter_state->num_q[stage][j], 30 ); + shift = sub( filter_state->num_q[stage][j], 31 ); tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - shift = sub( filter_state->den_q[stage][j], 30 ); + shift = sub( filter_state->den_q[stage][j], 31 ); tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4a25844a3..3124b7537 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3807,8 +3807,7 @@ void ivas_lfe_enc_fx( void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ - const Word16 length, /* i : filter order */ - Word16 q + const Word16 length /* i : filter order */ ); void ivas_filter_process_fx64( diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 3a6fa2c91..1078a1a02 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -409,7 +409,7 @@ void ivas_lfe_dec_fx( { /* Low Pass Filter */ #ifdef OPT_2239_IVAS_FILTER_PROCESS - ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); + ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame ); #else ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); #endif diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 11b02ca14..96fdc7b5c 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -685,7 +685,7 @@ void ivas_lfe_lpf_enc_apply_fx( ) { #ifdef OPT_2239_IVAS_FILTER_PROCESS - ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); + ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame ); #else ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); #endif -- GitLab From 32180c9b5507331f59bd1f74aa7aee8c81f7acc4 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Fri, 21 Nov 2025 14:07:25 +0000 Subject: [PATCH 067/750] Implement ivas_iir_2_filter_fx. --- lib_com/ivas_filters_fx.c | 178 ++++++++++++++++++-------------------- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_stat_com.h | 4 +- 3 files changed, 86 insertions(+), 98 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index d11088adf..bbde0fff4 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -72,7 +72,7 @@ void ivas_filters_init_fx( filter_state->den_q[IVAS_FILTER_STAGE_0][i] = Q30; move16(); move16(); - // #else FIXME +#else filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1; filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1; move16(); @@ -81,13 +81,13 @@ void ivas_filters_init_fx( } #ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; move64(); move64(); move64(); - // #else FIXME +#else filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; @@ -126,7 +126,7 @@ void ivas_filters_init_fx( move16(); move16(); move16(); - // #else FIXME +#else filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i]; filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN]; filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2]; @@ -139,19 +139,19 @@ void ivas_filters_init_fx( } #ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->state64_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_0][2] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][0] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][1] = 0; - filter_state->state64_fx[IVAS_FILTER_STAGE_1][2] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0; + filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0; move64(); move64(); move64(); move64(); move64(); move64(); - // #else FIXME +#else filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; @@ -183,8 +183,7 @@ void ivas_filters_init_fx( } #ifdef OPT_2239_IVAS_FILTER_PROCESS -static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage ); -static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage ); +static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in ); static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); /*-----------------------------------------------------------------------------------------* @@ -212,48 +211,39 @@ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) } /*-----------------------------------------------------------------------------------------* - * Function ivas_iir_2_filter_fx32() + * Function ivas_iir_2_filter_fx() * - * Process call for filtering a signal + * Process call for filtering a sample *-----------------------------------------------------------------------------------------*/ -static void ivas_iir_2_filter_fx32( +static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, - Word32 *pIn_Out_fx, - const Word16 length, - const Word16 stage ) + const Word16 stage, + const Word64 in ) { - Word64 tmp_prod, tmp, in, out; - Word16 i, j, shift; - - FOR( i = 0; i < length; i++ ) - { - in = W_deposit32_h( pIn_Out_fx[i] ); - move32(); + Word64 tmp_prod, tmp, out; + Word16 j, shift; - shift = sub( filter_state->num_q[stage][0], 31 ); - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); + shift = sub( filter_state->num_q[stage][0], 31 ); + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); - pIn_Out_fx[i] = W_extract_h( out ); - move32(); + out = W_add( filter_state->state_fx[stage][0], tmp_prod ); - FOR( j = 1; j < filter_state->filt_len; j++ ) - { - shift = sub( filter_state->num_q[stage][j], 31 ); - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); + FOR( j = 1; j < filter_state->filt_len; j++ ) + { + shift = sub( filter_state->num_q[stage][j], 31 ); + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); - tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); + tmp = W_add( filter_state->state_fx[stage][j], tmp_prod ); - shift = sub( filter_state->den_q[stage][j], 31 ); - tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); + shift = sub( filter_state->den_q[stage][j], 31 ); + tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); - filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); - move32(); - } + filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); + move32(); } - return; + return out; } /*-----------------------------------------------------------------------------------------* @@ -267,14 +257,35 @@ void ivas_filter_process_fx32( Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ const Word16 length ) /* i : filter order */ { + Word64 in, out; + Word16 i; + SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); + FOR( i = 0; i < length; i++ ) + { + in = W_deposit32_h( pIn_Out_fx[i] ); + move32(); + + out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in ); + + pIn_Out_fx[i] = W_extract_h( out ); + move32(); + } BREAK; case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); - ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1 ); + FOR( i = 0; i < length; i++ ) + { + in = W_deposit32_h( pIn_Out_fx[i] ); + move32(); + + out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in ); + out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_1, out ); + + pIn_Out_fx[i] = W_extract_h( out ); + move32(); + } BREAK; default: BREAK; @@ -283,50 +294,6 @@ void ivas_filter_process_fx32( return; } -/*-----------------------------------------------------------------------------------------* - * Function ivas_iir_2_filter_fx64() - * - * Process call for filtering a signal - *-----------------------------------------------------------------------------------------*/ - -static void ivas_iir_2_filter_fx64( - ivas_filters_process_state_t *filter_state, - Word64 *pIn_Out_fx, - const Word16 length, - const Word16 stage ) -{ - Word64 tmp_prod, tmp, in, out; - Word16 i, j, shift; - - FOR( i = 0; i < length; i++ ) - { - in = pIn_Out_fx[i]; - move32(); - - shift = sub( filter_state->num_q[stage][0], 31 ); - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); - - pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); - move32(); - - FOR( j = 1; j < filter_state->filt_len; j++ ) - { - shift = sub( filter_state->num_q[stage][j], 31 ); - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); - - tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); - - shift = sub( filter_state->den_q[stage][j], 31 ); - tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); - - filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); - move32(); - } - } - - return; -} - /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process_fx64() * @@ -339,14 +306,35 @@ void ivas_filter_process_fx64( const Word16 length ) /* i : filter order */ { + Word64 in, out; + Word16 i; + SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); + FOR( i = 0; i < length; i++ ) + { + in = pIn_Out_fx[i]; + move64(); + + out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in ); + + pIn_Out_fx[i] = out; + move64(); + } BREAK; case IVAS_FILTER_ORDER_4: - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0 ); - ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1 ); + FOR( i = 0; i < length; i++ ) + { + in = pIn_Out_fx[i]; + move64(); + + out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in ); + out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_1, out ); + + pIn_Out_fx[i] = out; + move64(); + } BREAK; default: BREAK; @@ -355,7 +343,7 @@ void ivas_filter_process_fx64( return; } -// #else FIXME +#else static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); /*-----------------------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 3124b7537..318ad9c2c 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3815,7 +3815,7 @@ void ivas_filter_process_fx64( Word64 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length /* i : filter order */ ); -// #else FIXME +#else void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 4da7e53aa..b46e5e66b 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -657,10 +657,10 @@ typedef struct ivas_filters_process_state_t Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #ifdef OPT_2239_IVAS_FILTER_PROCESS - Word64 state64_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - // #else FIXME +#else Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -- GitLab From 18eeb708eb378b3cec2c961ad22d4a0830ebfea0 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 24 Nov 2025 08:40:51 +0000 Subject: [PATCH 068/750] Finalize optimization. --- lib_com/ivas_filters_fx.c | 27 ++++++++++----------------- lib_com/ivas_stat_com.h | 4 ++-- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index bbde0fff4..becb59c21 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -68,8 +68,8 @@ void ivas_filters_init_fx( move32(); move32(); #ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->num_q[IVAS_FILTER_STAGE_0][i] = Q30; - filter_state->den_q[IVAS_FILTER_STAGE_0][i] = Q30; + filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; + filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; move16(); move16(); #else @@ -118,10 +118,10 @@ void ivas_filters_init_fx( move32(); move32(); #ifdef OPT_2239_IVAS_FILTER_PROCESS - filter_state->num_q[IVAS_FILTER_STAGE_0][i] = sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ); - filter_state->den_q[IVAS_FILTER_STAGE_0][i] = sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ); - filter_state->num_q[IVAS_FILTER_STAGE_1][i] = sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ); - filter_state->den_q[IVAS_FILTER_STAGE_1][i] = sub( 31, filt_coeff_e[i + 3 * IVAS_BIQUAD_FILT_LEN] ); + filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); + filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); + filter_state->num_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); + filter_state->den_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 3 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); move16(); move16(); move16(); @@ -222,23 +222,16 @@ static Word64 ivas_iir_2_filter_fx( const Word64 in ) { Word64 tmp_prod, tmp, out; - Word16 j, shift; - - shift = sub( filter_state->num_q[stage][0], 31 ); - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); + Word16 j; + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), filter_state->num_shr[stage][0] ); out = W_add( filter_state->state_fx[stage][0], tmp_prod ); FOR( j = 1; j < filter_state->filt_len; j++ ) { - shift = sub( filter_state->num_q[stage][j], 31 ); - tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); - + tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), filter_state->num_shr[stage][j] ); tmp = W_add( filter_state->state_fx[stage][j], tmp_prod ); - - shift = sub( filter_state->den_q[stage][j], 31 ); - tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); - + tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), filter_state->den_shr[stage][j] ); filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index b46e5e66b..0d4063777 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -658,8 +658,8 @@ typedef struct ivas_filters_process_state_t Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #ifdef OPT_2239_IVAS_FILTER_PROCESS Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 num_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 den_q[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 num_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + Word16 den_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #else Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -- GitLab From 214f10eefc687f5e97416fc78614060c1a1a661e Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 25 Nov 2025 08:29:56 +0100 Subject: [PATCH 069/750] remove obsolete comment --- lib_dec/ivas_jbm_dec_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f8664b60b..b7cf3c95b 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2144,7 +2144,6 @@ ivas_error ivas_jbm_dec_render_fx( return error; } - // Todo main-pc update: This might be needed also in the split rendering path ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); } -- GitLab From 9890784fc887e8de1aeadf596c2a1f0e4b857389 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 25 Nov 2025 14:02:30 +0100 Subject: [PATCH 070/750] remove unused psNoiseGen and related components from ISAR --- lib_com/options.h | 1 + lib_isar/isar_NoiseGen.c | 55 ------------------------------------ lib_isar/isar_lcld_decoder.c | 28 ++++++++++++++---- lib_isar/isar_lcld_prot.h | 6 ++-- 4 files changed, 27 insertions(+), 63 deletions(-) delete mode 100644 lib_isar/isar_NoiseGen.c diff --git a/lib_com/options.h b/lib_com/options.h index 0f23d8082..75ccc1d63 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,6 +116,7 @@ #define NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS /* Nokia: fix basop issue 2233: Fix differing rtpdump streams */ #define NONBE_FIX_2237_ZERO_CURR_NOISE_PROBLEM /* FhG: Modify sum of hTonalMDCTConc->curr_noise_nrg to avoid inaccurate zero */ +#define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ /* ################### End FIXES switches ########################### */ diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c deleted file mode 100644 index 363e758ff..000000000 --- a/lib_isar/isar_NoiseGen.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include -#include "prot_fx.h" -#include "isar_lcld_prot.h" -#include "wmc_auto.h" - - -/*------------------------------------------------------------------------------------------* - * Function DeleteNoiseGen() - * - * - *------------------------------------------------------------------------------------------*/ - -void DeleteNoiseGen( NoiseGen *psNoiseGen ) -{ - free( psNoiseGen->pfNoiseBuffer ); - free( psNoiseGen ); - - return; -} - -extern Word32 GetNoise_fx( NoiseGen *psNoiseGen ); diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 8bb931e3f..1868b9d95 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -106,8 +106,9 @@ struct LCLD_DECODER PredictionDecoder *psPredictionDecoder; - +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR NoiseGen *psNoiseGen; +#endif }; static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables ); @@ -604,7 +605,9 @@ ivas_error CreateLCLDDecoder( { return error; } +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR psLCLDDecoder->psNoiseGen = NULL; /* CreateNoiseGen(); No noise fill for now*/ +#endif *psLCLDDecoder_out = psLCLDDecoder; return IVAS_ERR_OK; @@ -766,10 +769,12 @@ void DeleteLCLDDecoder( psLCLDDecoder->psPredictionDecoder = NULL; } +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR IF( psLCLDDecoder->psNoiseGen != NULL ) { DeleteNoiseGen( psLCLDDecoder->psNoiseGen ); } +#endif free( psLCLDDecoder ); } @@ -788,7 +793,11 @@ static void ApplyRMSEnvelope_fx( const Word32 iNumBands, const Word32 *piBandwid static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, Word32 **ppiSignReal, Word32 **ppiSignImag, Word32 **ppfReal, Word32 **ppfImag, const Word32 *piBandwidths ); -static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag, NoiseGen *psNoiseGen ); +static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR + , NoiseGen *psNoiseGen +#endif +); static void InvMSCoding_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiffs, const Word32 *piMSPredCoefs, Word32 ***pppfReal, Word32 ***pppfImag ); @@ -1010,8 +1019,11 @@ Word32 DecodeLCLDFrame( psLCLDDecoder->pppiAlloc[n], psLCLDDecoder->pppiQLCLDReal[n], psLCLDDecoder->pppiQLCLDImag[n], - pppfLCLDReal_fx[n], pppfLCLDImag_fx[n], - psLCLDDecoder->psNoiseGen ); + pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR + ,psLCLDDecoder->psNoiseGen +#endif + ); ReplaceSign_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiLCLDSignReal[n], @@ -1281,8 +1293,10 @@ static void InvQuantizeSpectrum_fx( Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, - Word32 **ppfImag, - NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ + Word32 **ppfImag +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR + ,NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ +#endif ) { Word32 b, k, n; @@ -1322,6 +1336,7 @@ static void InvQuantizeSpectrum_fx( iFBOffset++; } } +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR ELSE IF( psNoiseGen != NULL ) { FOR( m = 0; m < piBandwidths[b]; m++ ) @@ -1333,6 +1348,7 @@ static void InvQuantizeSpectrum_fx( iFBOffset++; } } +#endif ELSE { iFBOffset = L_add( iFBOffset, piBandwidths[b] ); diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index 00c185901..90d0c1d63 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -170,6 +170,8 @@ Word32 CountMSBits( ); +#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR + /*----------------------------------------------------------------------------------* * NoiseGen prototypes *----------------------------------------------------------------------------------*/ @@ -190,13 +192,13 @@ inline Word32 GetNoise_fx( NoiseGen *psNoiseGen ) { Word32 fNoiseSample; - fNoiseSample = (Word32) (psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex]* (1<<14)); + fNoiseSample = (Word32) (psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex] * (1<<14)); psNoiseGen->iNoiseBufferIndex++; psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask; return fNoiseSample; } - +#endif /*----------------------------------------------------------------------------------* * PereptualModel prototypes -- GitLab From 071c55b4645f769eaba94fa38242165969b59d6f Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 25 Nov 2025 14:02:59 +0100 Subject: [PATCH 071/750] remove also from .vcxproj file --- Workspace_msvc/lib_isar.vcxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index 0271901c8..20c636309 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -133,7 +133,6 @@ - -- GitLab From 358046a569bbcdac6c5ce29e8f90bf968f057bc2 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 25 Nov 2025 14:14:17 +0100 Subject: [PATCH 072/750] clang format --- lib_isar/isar_lcld_decoder.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 1868b9d95..85db837ce 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -795,7 +795,8 @@ static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag #ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - , NoiseGen *psNoiseGen + , + NoiseGen *psNoiseGen #endif ); @@ -1021,7 +1022,8 @@ Word32 DecodeLCLDFrame( psLCLDDecoder->pppiQLCLDImag[n], pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] #ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - ,psLCLDDecoder->psNoiseGen + , + psLCLDDecoder->psNoiseGen #endif ); @@ -1295,7 +1297,8 @@ static void InvQuantizeSpectrum_fx( Word32 **ppfReal, Word32 **ppfImag #ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - ,NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ + , + NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ #endif ) { -- GitLab From d6aaa03c29a9cfa6a50afda2c5e967db1f50f229 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 16:22:02 +0100 Subject: [PATCH 073/750] add true single cycle commands --- lib_com/basop_util.c | 9 +++++++++ lib_com/basop_util.h | 4 ++++ lib_enc/ivas_mcmasa_enc_fx.c | 16 ++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 3a0a72bc3..da7f9e702 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3071,3 +3071,12 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ) #endif return result; } + +#ifndef FUNCTION_W_msu0_32_32 +Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) +{ + /* no saturation (like hexagon) */ + L64_var1 = W_sub( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + return L64_var1; +} +#endif \ No newline at end of file diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 7929db932..f5725ec93 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -913,4 +913,8 @@ cmplx CL_scale_t( cmplx x, Word16 y ); cmplx CL_dscale_t( cmplx x, Word16 y1, Word16 y2 ); cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ); +#ifndef FUNCTION_W_msu0_32_32 +Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ); +#endif + #endif /* __BASOP_UTIL_H__ */ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 54b0d6028..6cedf083b 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2144,10 +2144,13 @@ static void compute_cov_mtx_fx( Word16 freq; int k; int i, j; - Word64 temp64_1_r_acc, temp64_1_i_acc; Word16 tmp_16; +#if 1 + Word16 temp_exp = add( 1, shl( inp_exp, 1 ) ); +#else Word16 temp_exp = shl( inp_exp, 1 ); - +#endif + Word64 temp64_1_r_acc, temp64_1_i_acc; FOR( i = 0; i < N; i++ ) { @@ -2166,11 +2169,19 @@ static void compute_cov_mtx_fx( FOR( freq = brange[0]; freq < brange[1]; freq++ ) { +#if 1 + temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp + + temp64_1_i_acc = W_mac0_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); + temp64_1_i_acc = W_msu0_32_32( temp64_1_i_acc, sr[i][freq], si[j][freq] ); +#else temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32( sr[i][freq], si[j][freq] ) ); +#endif } tmp_16 = W_norm( temp64_1_r_acc ); @@ -2193,6 +2204,7 @@ static void compute_cov_mtx_fx( } + #else /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( -- GitLab From 092a74afc8e9f40e4392352d3eaca2d5d99b17a9 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 16:30:30 +0100 Subject: [PATCH 074/750] clang patch --- lib_com/basop_util.c | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index da7f9e702..0662929b6 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3079,4 +3079,4 @@ Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) L64_var1 = W_sub( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); return L64_var1; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 6cedf083b..b16cc770c 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2204,7 +2204,6 @@ static void compute_cov_mtx_fx( } - #else /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( -- GitLab From 2d12fab1e4f33b139e28b957f585619d0a2eabd8 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 16:47:16 +0100 Subject: [PATCH 075/750] add wmac03232 --- lib_com/basop_util.c | 8 ++++++++ lib_com/basop_util.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 0662929b6..9f1de3809 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3080,3 +3080,11 @@ Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) return L64_var1; } #endif +#ifndef FUNCTION_W_mac0_32_32 +Word64 W_mac0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) +{ + /* no saturation (like hexagon) */ + L64_var1 = W_add( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + return L64_var1; +} +#endif diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index f5725ec93..0dea22811 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -916,5 +916,8 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ); #ifndef FUNCTION_W_msu0_32_32 Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ); #endif +#ifndef FUNCTION_W_mac0_32_32 +Word64 W_mac0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ); +#endif #endif /* __BASOP_UTIL_H__ */ -- GitLab From 8acf9bf4a3e03563af49c6db313233972cac8e6c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 17:12:02 +0100 Subject: [PATCH 076/750] correct instrumentation --- lib_com/basop_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 9f1de3809..dbaa49f12 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3076,7 +3076,7 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ) Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) { /* no saturation (like hexagon) */ - L64_var1 = W_sub( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + L64_var1 = W_sub_nosat( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); return L64_var1; } #endif @@ -3084,7 +3084,7 @@ Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) Word64 W_mac0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) { /* no saturation (like hexagon) */ - L64_var1 = W_add( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + L64_var1 = W_add_nosat( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); return L64_var1; } #endif -- GitLab From 5757e94828f08995478d063847829c1765036439 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 17:13:04 +0100 Subject: [PATCH 077/750] use only mac0/msu0 in compute_cov_mtx_fx() --- lib_enc/ivas_mcmasa_enc_fx.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index b16cc770c..6a9b80c27 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2145,11 +2145,7 @@ static void compute_cov_mtx_fx( int k; int i, j; Word16 tmp_16; -#if 1 Word16 temp_exp = add( 1, shl( inp_exp, 1 ) ); -#else - Word16 temp_exp = shl( inp_exp, 1 ); -#endif Word64 temp64_1_r_acc, temp64_1_i_acc; FOR( i = 0; i < N; i++ ) @@ -2169,19 +2165,11 @@ static void compute_cov_mtx_fx( FOR( freq = brange[0]; freq < brange[1]; freq++ ) { -#if 1 temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp temp64_1_i_acc = W_mac0_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); temp64_1_i_acc = W_msu0_32_32( temp64_1_i_acc, sr[i][freq], si[j][freq] ); -#else - temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp - temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp - - temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); - temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32( sr[i][freq], si[j][freq] ) ); -#endif } tmp_16 = W_norm( temp64_1_r_acc ); -- GitLab From 95b9d07a4d656ab4d1f1817c693708b3facea7b3 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 27 Nov 2025 11:14:37 +0000 Subject: [PATCH 078/750] Add missing Q values from Q32 to Q63. --- lib_com/cnst.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index a6a0258bf..7f5882ca0 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -98,8 +98,38 @@ #define Q29 29 #define Q30 30 #define Q31 31 - +#define Q32 32 +#define Q33 33 +#define Q34 34 +#define Q35 35 +#define Q36 36 +#define Q37 37 +#define Q38 38 +#define Q39 39 +#define Q40 40 +#define Q41 41 +#define Q42 42 #define Q43 43 +#define Q44 44 +#define Q45 45 +#define Q46 46 +#define Q47 47 +#define Q48 48 +#define Q49 49 +#define Q50 50 +#define Q51 51 +#define Q52 52 +#define Q53 53 +#define Q54 54 +#define Q55 55 +#define Q56 56 +#define Q57 57 +#define Q58 58 +#define Q59 59 +#define Q60 60 +#define Q61 61 +#define Q62 62 +#define Q63 63 /*----------------------------------------------------------------------------------* * one in Q -- GitLab From fecb3ab35304ba584a52d48008d7715f2f2a9931 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 27 Nov 2025 13:00:22 +0100 Subject: [PATCH 079/750] move multi-pose CLDFB ring buffer declarations --- lib_com/ivas_prot_fx.h | 38 ------------------------------------ lib_rend/ivas_prot_rend_fx.h | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b75b38137..cafb67425 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6695,44 +6695,6 @@ void ivas_binaural_hrtf_close_fx( HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ ); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP - -/*---------------------------------------------------------------------------------* - * Multi-pose ring buffer Prototypes -*-----------------------------------------------------------------------------------*/ - -ivas_error ivas_CLDFB_RINGBUF_Open( - ISAR_CLDFB_RINGBUF_HANDLE *ph, - const Word16 capacity_columns -); - -void ivas_CLDFB_RINGBUF_Close( - ISAR_CLDFB_RINGBUF_HANDLE *ph -); - -void ivas_CLDFB_RINGBUF_Push( - ISAR_CLDFB_RINGBUF_HANDLE h, - const Word32 *real, - const Word32 *imag, - const Word16 num_bands -); - -void ivas_CLDFB_RINGBUF_Pop( - ISAR_CLDFB_RINGBUF_HANDLE h, - Word32 *real, - Word32 *imag, - const Word16 num_bands -); - -void ivas_CLDFB_RINGBUF_GetByIdx( - ISAR_CLDFB_RINGBUF_HANDLE h, - Word32 **p_real, - Word32 **p_imag, - const Word16 idx -); - -#endif - /*----------------------------------------------------------------------------------* * renderer prototypes *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index fed740577..499378a8c 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1669,6 +1669,44 @@ Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + +/*---------------------------------------------------------------------------------* + * Multi-pose ring buffer Prototypes +*-----------------------------------------------------------------------------------*/ + +ivas_error ivas_CLDFB_RINGBUF_Open( + ISAR_CLDFB_RINGBUF_HANDLE *ph, + const Word16 capacity_columns +); + +void ivas_CLDFB_RINGBUF_Close( + ISAR_CLDFB_RINGBUF_HANDLE *ph +); + +void ivas_CLDFB_RINGBUF_Push( + ISAR_CLDFB_RINGBUF_HANDLE h, + const Word32 *real, + const Word32 *imag, + const Word16 num_bands +); + +void ivas_CLDFB_RINGBUF_Pop( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 *real, + Word32 *imag, + const Word16 num_bands +); + +void ivas_CLDFB_RINGBUF_GetByIdx( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 **p_real, + Word32 **p_imag, + const Word16 idx +); + +#endif + /* clang-format on */ #endif /* IVAS_PROT_REND_H */ -- GitLab From ba2a5d94830515cb93b44d0b06ca191e47906b37 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 27 Nov 2025 13:12:51 +0100 Subject: [PATCH 080/750] add the right header file --- lib_rend/ivas_cldfb_ring_buffer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 49d88e8f3..4526ac2e0 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -35,6 +35,7 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" +#include "ivas_prot_rend_fx.h" #include #ifdef DEBUGGING #include "debug.h" -- GitLab From 412658b1b01bfb5e6c1ddf21d4e338833c14e083 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 27 Nov 2025 12:59:49 +0000 Subject: [PATCH 081/750] Address Tommy's comments. --- lib_com/ivas_filters_fx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index becb59c21..73ab4deb1 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -233,7 +233,7 @@ static Word64 ivas_iir_2_filter_fx( tmp = W_add( filter_state->state_fx[stage][j], tmp_prod ); tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), filter_state->den_shr[stage][j] ); filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); - move32(); + move64(); } return out; @@ -259,7 +259,6 @@ void ivas_filter_process_fx32( FOR( i = 0; i < length; i++ ) { in = W_deposit32_h( pIn_Out_fx[i] ); - move32(); out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in ); @@ -271,7 +270,6 @@ void ivas_filter_process_fx32( FOR( i = 0; i < length; i++ ) { in = W_deposit32_h( pIn_Out_fx[i] ); - move32(); out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in ); out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_1, out ); -- GitLab From 9f34f359d173d0b643069b8d120d2c46d0f7edbe Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Thu, 27 Nov 2025 15:10:19 +0000 Subject: [PATCH 082/750] Fixed wrong comments. --- lib_com/ivas_filters_fx.c | 12 ++++++------ lib_com/ivas_prot_fx.h | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 73ab4deb1..1e1246fda 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -247,8 +247,8 @@ static Word64 ivas_iir_2_filter_fx( void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ - const Word16 length ) /* i : filter order */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering */ + const Word16 length ) /* i : number of samples to filter */ { Word64 in, out; Word16 i; @@ -293,8 +293,8 @@ void ivas_filter_process_fx32( void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ - const Word16 length ) /* i : filter order */ + Word64 *pIn_Out_fx, /* i/o: signal subject to filtering */ + const Word16 length ) /* i : number of samples to filter */ { Word64 in, out; @@ -346,7 +346,7 @@ static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Wo void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ + const Word16 length, /* i : number of samples to filter */ Word16 q_factor ) { Word16 pIn_Out_e[L_FRAME_MAX]; @@ -387,7 +387,7 @@ void ivas_filter_process_fx( void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ - const Word16 length, /* i : filter order */ + const Word16 length, /* i : number of samples to filter */ Word16 *pIn_Out_e ) { SWITCH( filter_state->order ) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 38a5ca340..fea5d03c1 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3800,26 +3800,26 @@ void ivas_lfe_enc_fx( void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ - const Word16 length /* i : filter order */ + const Word16 length /* i : number of samples to filter */ ); void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i : signal subject to filtering */ - const Word16 length /* i : filter order */ + const Word16 length /* i : number of samples to filter */ ); #else void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ - const Word16 length, /* i : filter order */ + const Word16 length, /* i : number of samples to filter */ Word16 q_factor ); void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ - const Word16 length, /* i : filter order */ + const Word16 length, /* i : number of samples to filter */ Word16 *pIn_Out_e ); #endif -- GitLab From 17860a518c599ca091ee03d29551ffcf9de6aba6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 27 Nov 2025 17:27:52 +0100 Subject: [PATCH 083/750] clang=format --- lib_util/ivas_rtp_pi_data.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index f137440d6..c521bd795 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -44,7 +44,6 @@ #endif - /* Generic PI data packing/unpacking functions */ typedef ivas_error ( *PACK_PI_FN )( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ); typedef ivas_error ( *UNPACK_PI_FN )( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ); -- GitLab From 8d98e35772b2d758051d4b0ae61832eb84d5c98b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 28 Nov 2025 10:58:53 +0100 Subject: [PATCH 084/750] add missing include --- lib_basop/move.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_basop/move.h b/lib_basop/move.h index fc4d4e18b..1df6ae17d 100644 --- a/lib_basop/move.h +++ b/lib_basop/move.h @@ -37,6 +37,8 @@ #ifndef _MOVE_H #define _MOVE_H +#include "wmc_auto.h" + static __inline void move16( void ) { #ifdef WMOPS -- GitLab From e79a4a5778bff20df4e2fe890d726981ce60d0bc Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 28 Nov 2025 13:56:40 +0100 Subject: [PATCH 085/750] remove obsolete include --- lib_rend/ivas_cldfb_ring_buffer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 358eb41cf..07f38590c 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include #ifdef DEBUGGING -- GitLab From ae95d91651141a3aecc68310fcbd4257d5f326b7 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 28 Nov 2025 14:01:39 +0100 Subject: [PATCH 086/750] remove accepted #ifdef --- lib_rend/ivas_prot_rend_fx.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index e66f4e070..d7af3e3f4 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1648,8 +1648,6 @@ Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP - /*---------------------------------------------------------------------------------* * Multi-pose ring buffer Prototypes *-----------------------------------------------------------------------------------*/ @@ -1688,4 +1686,3 @@ void ivas_CLDFB_RINGBUF_GetByIdx( /* clang-format on */ -#endif /* IVAS_PROT_REND_H */ -- GitLab From cbf13d7fa6fc42120d69c86860cd459e81d9b730 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 28 Nov 2025 14:14:06 +0100 Subject: [PATCH 087/750] clang format --- lib_rend/ivas_prot_rend_fx.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index d7af3e3f4..19b827c87 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1685,4 +1685,3 @@ void ivas_CLDFB_RINGBUF_GetByIdx( #endif /* clang-format on */ - -- GitLab From 1798262ddf6369ced3e6659b6f38a774c6e08622 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 28 Nov 2025 10:34:10 -0500 Subject: [PATCH 088/750] fix clang --- lib_enc/ivas_td_low_rate_enc_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 85c6bc41e..20980127b 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -340,17 +340,17 @@ void encod_gen_2sbfr( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ move16(); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ - Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ - Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ + Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ + Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[2 * L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ Ltmp = L_msu( Ltmp, y1[2 * L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */ -- GitLab From 1effef0d4423919fc79b70473fca388fb7186813 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 28 Nov 2025 10:44:58 -0500 Subject: [PATCH 089/750] fix linux build --- lib_com/options.h | 1 + lib_dec/ivas_stereo_cng_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 018f57665..6639215ba 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,5 +85,6 @@ #define IMPROV_PRECISION /* Places where precision can be improved without increasing complexity */ +#define IMPROV_COMPLEX /* Places where complexity is reduced, coudl be non-BE */ #define IMPROV_COMPLEX_BE /* Places where complexity is reduced, BE (no big impact on complexity) */ #endif diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 844f4d594..a8c41a4f3 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -121,7 +121,7 @@ static void stereo_dft_generate_comfort_noise_fx( Word32 tmp32_1, tmp32_2; Word16 q_div, q_sqrt1, q_sqrt2, q_sqrt, sqrt_res; Word16 q_shift, q_shift_1, q_shift_2, min_q; -#ifdef IMPROV_PRECISION +#ifdef IMPROV_COMPLEX Word16 tmp16, tmp_p, tmp_s; #endif hFdCngCom = st->hFdCngDec->hFdCngCom; -- GitLab From 9bc79e932d23ccf3d048f7e168877e27b9648e14 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 28 Nov 2025 10:57:46 -0500 Subject: [PATCH 090/750] add space to trigger full pipeline --- lib_dec/ivas_stereo_cng_dec_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index a8c41a4f3..8b77e0fba 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -128,6 +128,7 @@ static void stereo_dft_generate_comfort_noise_fx( push_wmops( "DFT_CNG" ); + set16_fx( dmpf, 0, M + 2 ); set16_fx( Atmp, 0, M + 2 ); -- GitLab From 76edd691a9bb70cc1579510ff8ef698abcb9e6e2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 28 Nov 2025 11:21:25 -0500 Subject: [PATCH 091/750] Fix clang --- lib_dec/ivas_stereo_cng_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 8b77e0fba..30d3d84c2 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -128,7 +128,7 @@ static void stereo_dft_generate_comfort_noise_fx( push_wmops( "DFT_CNG" ); - + set16_fx( dmpf, 0, M + 2 ); set16_fx( Atmp, 0, M + 2 ); -- GitLab From 8d5ad835e0a1aace449b7a8d2007437f04437c10 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 1 Dec 2025 10:46:28 +0000 Subject: [PATCH 092/750] Move Mpy_64_32 to lib_com/basop_util. --- lib_com/basop_util.c | 11 +++++++++++ lib_com/basop_util.h | 20 ++++++++++++++++++++ lib_com/ivas_filters_fx.c | 25 ------------------------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index b116ef6c7..0aac849ab 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -2958,3 +2958,14 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ) #endif return result; } + +Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) +{ + Word32 var1_l; + Word64 var_out; + var1_l = W_extract_l( W_var1 ); + var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); + var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); + var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); + return var_out; +} diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 1df2c8010..04556e697 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -907,4 +907,24 @@ cmplx CL_scale_t( cmplx x, Word16 y ); cmplx CL_dscale_t( cmplx x, Word16 y1, Word16 y2 ); cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ); + +/*! + \brief 64-bit/32-bit multiplication with shift + + This multiplication is similar to Mpy_32_32 except for the fact that the first argument + and the return type are Word64. The function performs the following operation: + + z = ((int128_t)x (int128_t)y) >> 31 + + where: + - x is a 64-bit signed integer + - y is a 32-bit signed integer + - z is a 64-bit signed integer + + \param W_var1 64-bit signed integer argument + \param L_var2 32-bit signed integer argument + \return 64-bit signed integer representing the result of the multiplication with shift +*/ +Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); + #endif /* __BASOP_UTIL_H__ */ diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 1e1246fda..c7435ab40 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -184,31 +184,6 @@ void ivas_filters_init_fx( #ifdef OPT_2239_IVAS_FILTER_PROCESS static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in ); -static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); - -/*-----------------------------------------------------------------------------------------* - * Function Mpy_64_32() - * - * Performs the the following operation: - * - * z = ((int128_t)x * (int128_t)y) >> 31 - * - * where: - * - x is a 64-bit signed integer - * - y is a 32-bit signed integer - * - z is a 64-bit signed integer - *-----------------------------------------------------------------------------------------*/ - -static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) -{ - Word32 var1_l; - Word64 var_out; - var1_l = W_extract_l( W_var1 ); // 1 - var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 - var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 - var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 - return var_out; -} /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter_fx() -- GitLab From 1ae8bc79ce44331079c2cd98e423756b63e60f29 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 1 Dec 2025 11:16:01 +0000 Subject: [PATCH 093/750] Apply clang format. --- lib_com/basop_util.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 04556e697..b907ef5d6 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -909,18 +909,18 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ); /*! - \brief 64-bit/32-bit multiplication with shift - - This multiplication is similar to Mpy_32_32 except for the fact that the first argument + \brief 64-bit/32-bit multiplication with shift + + This multiplication is similar to Mpy_32_32 except for the fact that the first argument and the return type are Word64. The function performs the following operation: - + z = ((int128_t)x (int128_t)y) >> 31 - + where: - x is a 64-bit signed integer - y is a 32-bit signed integer - z is a 64-bit signed integer - + \param W_var1 64-bit signed integer argument \param L_var2 32-bit signed integer argument \return 64-bit signed integer representing the result of the multiplication with shift -- GitLab From d232e69f3609e89c375fa0fc7136f772e41670e4 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 1 Dec 2025 11:18:57 +0000 Subject: [PATCH 094/750] Apply clang format. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index a243a9105..e0c49cf20 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4823,8 +4823,8 @@ static void formulate2x2MixingMatrix_fx( } #ifdef OPT_2182_MATRIX_SCALE_OPS - matrixTransp2Mul_fx( - tmpRe_fx, tmpIm_fx, &q_temp, + matrixTransp2Mul_fx( + tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ #else @@ -4970,8 +4970,8 @@ static void formulate2x2MixingMatrix_fx( matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp ); #ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); - matrixTransp2Mul_fx( - tmpRe_fx, tmpIm_fx, &q_temp, + matrixTransp2Mul_fx( + tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, Mre_fx, Mim_fx, q_M ); #else -- GitLab From 61c31ac7aec53aaf5027af5e498ca4ea44e3ce4a Mon Sep 17 00:00:00 2001 From: "Malenovsky, Vladimir" Date: Mon, 1 Dec 2025 13:22:53 +0100 Subject: [PATCH 095/750] add missing include, use stl.h instead of move.h --- lib_basop/move.h | 2 -- lib_com/hq2_noise_inject_fx.c | 2 +- lib_dec/fd_cng_dec_fx.c | 10 ++++------ lib_dec/ivas_ism_metadata_dec_fx.c | 4 ++-- lib_rend/lib_rend_fx.c | 14 +++++--------- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/lib_basop/move.h b/lib_basop/move.h index 1df6ae17d..fc4d4e18b 100644 --- a/lib_basop/move.h +++ b/lib_basop/move.h @@ -37,8 +37,6 @@ #ifndef _MOVE_H #define _MOVE_H -#include "wmc_auto.h" - static __inline void move16( void ) { #ifdef WMOPS diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index 76efad10e..7fc9f8fe9 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot_fx.h" #include "oper_32b.h" -#include "move.h" +#include "stl.h" /*--------------------------------------------------------------------------* * hq2_noise_inject() diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 0f8cec8e0..17a543038 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -3,17 +3,15 @@ ====================================================================================*/ -#include "basop32.h" +#include +#include +#include "options.h" +#include "stl.h" #include "cnst.h" -#include "enh1632.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "move.h" #include "wmc_auto.h" -#include #include "typedef.h" -#include -#include "options.h" #include "rom_com.h" #include "stat_dec.h" #include "prot_fx.h" diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index a193cba2e..1a3f4bdfe 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,15 +30,15 @@ *******************************************************************************************************/ -#include "move.h" #include +#include #include "options.h" +#include "stl.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "prot_fx.h" #include "ivas_stat_enc.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index d45c79be0..fac70415a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -30,14 +30,15 @@ *******************************************************************************************************/ -#include "basop32.h" -#include "basop_util.h" +#include +#include +#include #include "options.h" +#include "stl.h" +#include "basop_util.h" #include "cnst.h" #include "common_api_types.h" -#include "enh32.h" #include "lib_rend.h" -#include "move.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" @@ -47,11 +48,6 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" -#include "stl.h" -#include "typedef.h" -#include -#include -#include #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" -- GitLab From 1ce02a244a9e3c3fb175365efa28de4d70e00a7e Mon Sep 17 00:00:00 2001 From: "Malenovsky, Vladimir" Date: Mon, 1 Dec 2025 13:53:46 +0100 Subject: [PATCH 096/750] fix warnings about dangling pointer --- lib_debug/wmc_auto.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 5afd9de16..ce7b69e28 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -820,7 +820,6 @@ static void *mem_alloc_block( size_t size, const char *size_str ); void reset_mem( Counting_Size cnt_size ) { - int16_t something; size_t tmp_size; /* initialize list of stack records */ @@ -840,7 +839,13 @@ void reset_mem( Counting_Size cnt_size ) max_num_calls = MAX_NUM_RECORDS; /* initialize stack pointers */ +#if defined( __GNUC__ ) || defined( __clang__ ) + /* GCC/Clang: use builtin (works for many targets) */ + ptr_base_stack = __builtin_frame_address( 0 ); +#else + int16_t something; ptr_base_stack = &something; +#endif ptr_max_stack = ptr_base_stack; ptr_current_stack = ptr_base_stack; @@ -945,10 +950,14 @@ void reset_mem( Counting_Size cnt_size ) void reset_stack( void ) { - int16_t something; - /* initialize/reset stack pointers */ +#if defined( __GNUC__ ) || defined( __clang__ ) + /* GCC/Clang: use builtin (works for many targets) */ + ptr_base_stack = __builtin_frame_address( 0 ); +#else + int16_t something; ptr_base_stack = &something; +#endif ptr_max_stack = ptr_base_stack; ptr_current_stack = ptr_base_stack; @@ -963,10 +972,15 @@ void reset_stack( void ) int push_stack( const char *filename, const char *fctname ) { - int16_t something; int32_t current_stack_size; +#if defined( __GNUC__ ) || defined( __clang__ ) + /* GCC/Clang: use builtin (works for many targets) */ + ptr_base_stack = __builtin_frame_address( 0 ); +#else + int16_t something; ptr_current_stack = &something; +#endif (void) *filename; /* to avoid compilation warning */ -- GitLab From b7d836f3cd798a1494bbc3491ea47f74dd68e7a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 1 Dec 2025 16:58:59 +0100 Subject: [PATCH 097/750] fix FIX_2255_ISAR_RENDER_POSES --- lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 708e7f633..440c6f0fa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -73,6 +73,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ +#define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ /* ################### End FIXES switches ########################### */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7954afd69..eca1a9ee2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1207,8 +1207,18 @@ static ivas_error isar_render_poses( /* hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ /* set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ Word16 num_samples_flushbuffer; +#ifdef FIX_2255_ISAR_RENDER_POSES + num_samples_flushbuffer = mult0( numPoses, shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 /* shl(x) == BINAURAL_CHANNELS * x */ ) ); +#else num_samples_flushbuffer = mult0( mult0( numPoses, BINAURAL_CHANNELS ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); +#endif hIvasDec->flushbuffer = (void *) malloc( L_mult0( sizeof( Word16 ), num_samples_flushbuffer ) ); +#ifdef FIX_2255_ISAR_RENDER_POSES + if ( hIvasDec->flushbuffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); + } +#endif set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, num_samples_flushbuffer ); } -- GitLab From 0ca7f4bc92dee46a81b90ca4de9c32e1f7a4d03a Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 2 Dec 2025 09:03:45 +0100 Subject: [PATCH 098/750] replace characters in wrong encoding --- lib_com/common_api_types.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 688567e3c..34bc08d43 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -397,7 +397,7 @@ typedef enum IVAS_PI_PLAYBACK_DEVICE_ORIENTATION, /* orientation of the playback device in quaternions */ IVAS_PI_HEAD_ORIENTATION, /* head orientation of the listener in Quaternions */ IVAS_PI_LISTENER_POSITION, /* position of the listener in 3D space */ - IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST, /* receiver’s preference with respect to audio suppression */ + IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST, /* receiver’s preference with respect to audio suppression */ IVAS_PI_AUDIO_FOCUS_REQUEST, /* direction of interest for the listener in Quaternions and/or audio focus level */ IVAS_PI_PI_LATENCY, /* round-trip latency for PI frames */ IVAS_PI_R_ISM_ID, /* id of an object for editing */ @@ -437,9 +437,9 @@ typedef struct * * acoustic environment ID * late reverb parameters - * - RT60 – indicating the time that it takes for the reflections to reduce 60 dB in energy level, per frequency band - * - DSR – diffuse to source signal energy ratio, per frequency band - * - Pre-delay – delay at which the computation of DSR values was performed + * - RT60 – indicating the time that it takes for the reflections to reduce 60 dB in energy level, per frequency band + * - DSR – diffuse to source signal energy ratio, per frequency band + * - Pre-delay – delay at which the computation of DSR values was performed * early reflections * - 3D rectangular virtual room dimensions * - Broadband energy absorption coefficient per wall surface @@ -692,7 +692,7 @@ typedef struct IVAS_VECTOR3 position; /* Position data */ } IVAS_PIDATA_POSITION; -/* Dynamic Audio Suppression describes receiver’s preference with respect to the +/* Dynamic Audio Suppression describes receiver’s preference with respect to the * type of audio content that should be enhanced and the amount of suppression to * be applied to the background noise */ @@ -777,7 +777,7 @@ typedef struct size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_DIRECTION) */ uint32_t piDataType; /* IVAS_PI_R_ISM_DIRECTION */ float azimuth; /* azimuth angle in degrees [-180, 180] */ - float elevation; /* elevation angle in degrees [-90°, 90°] */ + float elevation; /* elevation angle in degrees [-90°, 90°] */ } IVAS_PIDATA_ISM_EDIT_DIRECTION; -- GitLab From 64f6fb338367ee6f6841fee64447f3a9413ff707 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 2 Dec 2025 09:04:40 +0100 Subject: [PATCH 099/750] remove lib_util dependency in CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21bb3e738..9cb79ae46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,7 +174,7 @@ file(GLOB libDecSrcs "lib_dec/*.c") file(GLOB libDecHeaders "lib_dec/*.h") add_library(lib_dec ${libDecSrcs} ${libDecHeaders}) target_link_libraries(lib_dec lib_com lib_basop lib_rend lib_debug lib_isar) -target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_basop lib_enc lib_isar lib_util) +target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_basop lib_enc lib_isar) file(GLOB libUtilSrcs "lib_util/*.c") file(GLOB libUtilHeaders "lib_util/*.h") @@ -184,7 +184,7 @@ target_include_directories(lib_util PRIVATE lib_lc3plus lib_isar) if(NOT WMOPS) add_executable(ivas_lc3plus_unit_test ${CMAKE_SOURCE_DIR}/scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test.c) - target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_com lib_basop lib_debug lib_isar) + target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_com lib_basop lib_debug lib_isar) endif() file(GLOB libISARSrcs "lib_isar/*.c") -- GitLab From 677a2b2071b6adca2f5293e0ce6bf6b41ee758f6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 2 Dec 2025 09:05:25 +0100 Subject: [PATCH 100/750] remove lib_util dependency in Makefile --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c9ae4493d..68f950b25 100644 --- a/Makefile +++ b/Makefile @@ -219,16 +219,16 @@ $(LIB_LC3PLUS): $(OBJS_LC3PLUS) $(LIB_LIBUTIL): $(OBJS_LIBUTIL) $(OBJS_LIBBASOP) $(OBJS_LIBCOM) $(QUIET_AR)$(AR) rcs $@ $^ -$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) +$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC) -$(CLI_APIENC_FMTSW): $(OBJS_CLI_APIENC_FMTSW) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) +$(CLI_APIENC_FMTSW): $(OBJS_CLI_APIENC_FMTSW) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC_FMTSW) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC_FMTSW) -$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBBASOP) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) +$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBBASOP) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasbasop -livasdec -livascom -livasutil -livasdebug -llc3plus $(LDLIBS) -o $(CLI_APIDEC) -$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBBASOP) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(LIB_LC3PLUS) $(LIB_LIBISAR) +$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBBASOP) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(LIB_LC3PLUS) $(LIB_LIBISAR) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasbasop -livasrend -lisar -livasdec -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIREND) $(CLI_APIPOSTREND): $(OBJS_CLI_APPPOSTREND) $(LIB_LIBBASOP) $(LIB_LIBISAR) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) -- GitLab From 5fbfa2c385b38f4a181a8810c913a0f58818b9e2 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 2 Dec 2025 08:14:44 +0000 Subject: [PATCH 101/750] Address Thomas Dettbarn's comment. --- .../ivas_dirac_dec_binaural_functions_fx.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 31ccdd9cd..c07c573ea 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3507,12 +3507,6 @@ static void eig2x2_fx( set32_fx( (Word32 *) Ure_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); set32_fx( (Word32 *) Uim_fx, 0, BINAURAL_CHANNELS * BINAURAL_CHANNELS ); - Ure_fx[0][0] = ONE_IN_Q30; - move32(); - Ure_fx[1][1] = ONE_IN_Q30; - move32(); - *q_U = Q30; - move16(); exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); c_re = L_shl( Cre_fx, exp ); @@ -3612,6 +3606,12 @@ static void eig2x2_fx( IF( LT_32( L_shl_sat( D_fx[0], sub( 31 - EPSILON_EXP, *q_D ) ), EPSILON_MANT ) ) { + Ure_fx[0][0] = ONE_IN_Q30; + move32(); + Ure_fx[1][1] = ONE_IN_Q30; + move32(); + *q_U = Q30; + move16(); return; } @@ -3624,6 +3624,12 @@ static void eig2x2_fx( IF( LT_32( tmp2, tmp1 ) ) { + Ure_fx[0][0] = ONE_IN_Q30; + move32(); + Ure_fx[1][1] = ONE_IN_Q30; + move32(); + *q_U = Q30; + move16(); return; } -- GitLab From 7ced18c4c18954c3dcb24674cc84be2f4190cc15 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 2 Dec 2025 13:23:01 +0100 Subject: [PATCH 102/750] Revert "remove lib_util dependency in Makefile" This reverts commit 677a2b2071b6adca2f5293e0ce6bf6b41ee758f6. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 68f950b25..c9ae4493d 100644 --- a/Makefile +++ b/Makefile @@ -219,16 +219,16 @@ $(LIB_LC3PLUS): $(OBJS_LC3PLUS) $(LIB_LIBUTIL): $(OBJS_LIBUTIL) $(OBJS_LIBBASOP) $(OBJS_LIBCOM) $(QUIET_AR)$(AR) rcs $@ $^ -$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) +$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC) -$(CLI_APIENC_FMTSW): $(OBJS_CLI_APIENC_FMTSW) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) +$(CLI_APIENC_FMTSW): $(OBJS_CLI_APIENC_FMTSW) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC_FMTSW) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC_FMTSW) -$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBBASOP) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) +$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBBASOP) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasbasop -livasdec -livascom -livasutil -livasdebug -llc3plus $(LDLIBS) -o $(CLI_APIDEC) -$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBBASOP) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(LIB_LC3PLUS) $(LIB_LIBISAR) +$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBBASOP) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(LIB_LC3PLUS) $(LIB_LIBISAR) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasbasop -livasrend -lisar -livasdec -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIREND) $(CLI_APIPOSTREND): $(OBJS_CLI_APPPOSTREND) $(LIB_LIBBASOP) $(LIB_LIBISAR) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) -- GitLab From 417d9326159b17c68fa77976059edb4354a48a67 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 2 Dec 2025 13:58:14 +0000 Subject: [PATCH 103/750] Apply clang format. --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b79c649f2..17347d0d9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,7 +106,7 @@ /* #################### Start BASOP optimization switches ############################ */ -#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ +#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From e9d31526e3089034fcab282ae253c05d514ef863 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Tue, 2 Dec 2025 16:10:54 +0000 Subject: [PATCH 104/750] Apply clang format. --- lib_com/options.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7c6a5b476..bf55847d1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,12 +109,7 @@ #define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ #define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ #define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ - -/* #################### End BASOP optimization switches ############################ */ - -/* #################### Start BASOP optimization switches ############################ */ - -#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ +#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From a68981d1ac09c6fca1b16f80f07d801399831d65 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Mon, 24 Nov 2025 09:59:56 +0100 Subject: [PATCH 105/750] fixed scaling of x_fx after noise generation and scale xn_buf_fx correctly to Q(-2) --- lib_com/options.h | 2 +- lib_dec/dec_tcx_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index bf55847d1..1a7b596d5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,7 @@ #define FIX_1454_FIX_STEREO_TO_FOA_JBM /* VA: issue 1454: fix buggy stereo to FOA in JBM */ #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 */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index f9377d53f..02e82fc6a 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4044,7 +4044,11 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 +#ifdef NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, -( Q14 - 2 ) ); // Scaling xn_buf_fx to Q(-2) +#else Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn +#endif x_e = sub( 31, 11 ); IF( st->igf != 0 ) @@ -5645,7 +5649,11 @@ void decoder_tcx_imdct_fx( generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { +#ifdef NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES + x_fx[ind] = L_shl( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x +#else x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x +#endif } } -- GitLab From f0a166ca950c384287772d29568f0ee317246968 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Mon, 24 Nov 2025 10:03:48 +0100 Subject: [PATCH 106/750] clang format --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 02e82fc6a..36385ae3b 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4043,7 +4043,7 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); - Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 + Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 #ifdef NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, -( Q14 - 2 ) ); // Scaling xn_buf_fx to Q(-2) #else -- GitLab From 64ce086d29e14b525ce2fc51bb9e74cc2fab1948 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Wed, 3 Dec 2025 08:37:22 +0100 Subject: [PATCH 107/750] clang format --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 36385ae3b..3cb3a6d15 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5652,7 +5652,7 @@ void decoder_tcx_imdct_fx( #ifdef NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES x_fx[ind] = L_shl( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x #else - x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x + x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x #endif } } -- GitLab From 28d31761171291f3343d223a8c47fa6a92440642 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 3 Dec 2025 08:41:47 +0000 Subject: [PATCH 108/750] Apply clang format. --- lib_com/options.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4509d48e3..f60dbd576 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,12 +110,7 @@ #define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ #define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ #define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ - -/* #################### End BASOP optimization switches ############################ */ - -/* #################### Start BASOP optimization switches ############################ */ - -#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ +#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From d0cfec0e5e252912f3dc3f84bbceb804336fb512 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 3 Dec 2025 12:58:53 +0100 Subject: [PATCH 109/750] add missing move()s --- lib_enc/ivas_mcmasa_enc_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 6a9b80c27..bbc275acf 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2160,7 +2160,9 @@ static void compute_cov_mtx_fx( move16(); CovarianceMatrix *COVls = &( pCOVls[k] ); + move64(); temp64_1_r_acc = 0; + move64(); temp64_1_i_acc = 0; FOR( freq = brange[0]; freq < brange[1]; freq++ ) -- GitLab From 4b105fe80536f39abec0b4cda1400004d3d1683f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 3 Dec 2025 13:03:28 +0100 Subject: [PATCH 110/750] formatting --- lib_com/options.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 24694543e..8c2660e77 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,11 +106,11 @@ /* #################### Start BASOP optimization switches ############################ */ -#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ -#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ -#define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ -#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ -#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ +#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ +#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ +#define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ +#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ +#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From 0a255f32f82cd33436c6a438e94d52c556e6b9ce Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Dec 2025 15:20:37 +0100 Subject: [PATCH 111/750] more removal of obsolete defines - address issue #1467 --- lib_com/cldfb_fx.c | 1 - lib_com/codec_tcx_common_fx.c | 1 - lib_com/env_stab_fx.c | 1 - lib_com/env_stab_trans_fx.c | 4 ++-- lib_com/fft_fx.c | 1 - lib_com/findpulse_fx.c | 1 - lib_com/frame_ener_fx.c | 1 - lib_com/gs_gains_fx.c | 1 - lib_com/gs_preech_fx.c | 1 - lib_com/hp50_fx.c | 1 - lib_com/ivas_pca_tools_fx.c | 1 - lib_com/logqnorm_fx.c | 2 +- lib_com/modif_fs_fx.c | 1 - lib_com/tcx_mdct_window_fx.c | 1 - lib_com/tools_fx.c | 1 - lib_dec/acelp_core_dec_fx.c | 1 - lib_dec/dec_higher_acelp_fx.c | 1 - lib_dec/dec_tcx_fx.c | 1 - lib_dec/fd_cng_dec_fx.c | 1 - lib_dec/igf_dec_fx.c | 2 +- lib_dec/ivas_core_dec_fx.c | 1 - lib_dec/ivas_init_dec_fx.c | 1 - lib_dec/ivas_ism_metadata_dec_fx.c | 2 -- lib_dec/ivas_mct_dec_mct_fx_fx.c | 1 - lib_dec/jbm_jb4sb_fx.c | 1 - lib_dec/jbm_pcmdsp_apa_fx.c | 1 - lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 1 - lib_dec/jbm_pcmdsp_window_fx.c | 1 - lib_dec/tonalMDCTconcealment_fx.c | 3 --- lib_enc/analy_sp_fx.c | 3 +-- lib_enc/avq_cod_fx.c | 6 +++++- lib_enc/cod4t64_fast_fx.c | 1 - lib_enc/cod_tcx_fx.c | 1 - lib_enc/ext_sig_ana_fx.c | 2 -- lib_enc/ivas_init_enc_fx.c | 1 - lib_enc/ivas_ism_metadata_enc_fx.c | 1 - lib_enc/ivas_mcmasa_enc_fx.c | 2 -- lib_enc/speech_music_classif_fx.c | 1 - lib_isar/isar_NoiseGen.c | 1 - lib_isar/isar_PredDecoder.c | 1 - lib_isar/isar_PredEncoder.c | 1 - lib_isar/isar_RMSEnvGrouping.c | 1 - lib_isar/isar_lcld_encoder.c | 1 - lib_isar/isar_splitRendererPLC.c | 1 - lib_isar/isar_splitRendererPost.c | 2 -- lib_isar/isar_splitRendererPre.c | 1 - lib_isar/isar_splitRenderer_utils.c | 1 - lib_isar/lib_isar_post_rend.c | 1 - lib_isar/lib_isar_pre_rend.c | 1 - 49 files changed, 10 insertions(+), 57 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 449e197ac..1cfb30d57 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -37,7 +37,6 @@ #include #include #include "options.h" -#include #include "stat_dec.h" #include "prot_fx.h" #include "rom_com.h" diff --git a/lib_com/codec_tcx_common_fx.c b/lib_com/codec_tcx_common_fx.c index d7f30d905..8517668e5 100644 --- a/lib_com/codec_tcx_common_fx.c +++ b/lib_com/codec_tcx_common_fx.c @@ -4,7 +4,6 @@ #include #include -#include #include "options.h" #include "prot_fx.h" #include "basop_util.h" diff --git a/lib_com/env_stab_fx.c b/lib_com/env_stab_fx.c index 29908b126..f8e1e0ba4 100644 --- a/lib_com/env_stab_fx.c +++ b/lib_com/env_stab_fx.c @@ -37,7 +37,6 @@ #include #include "options.h" -#include #include "cnst.h" #include "prot_fx.h" #include "rom_com.h" diff --git a/lib_com/env_stab_trans_fx.c b/lib_com/env_stab_trans_fx.c index 5cdc93ff7..c4b6efe5c 100644 --- a/lib_com/env_stab_trans_fx.c +++ b/lib_com/env_stab_trans_fx.c @@ -36,12 +36,12 @@ #include #include "options.h" -#include #include "cnst.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -/*--------------------------------------------------------------------------* + + /*--------------------------------------------------------------------------* * env_stab_transient_detect() * * Transient detector for envelope stability measure diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 461e1c7b6..6213e7a64 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -37,7 +37,6 @@ #include #include #include "options.h" -#include #include "cnst.h" #include "prot_fx.h" #include "rom_com.h" diff --git a/lib_com/findpulse_fx.c b/lib_com/findpulse_fx.c index f30990c1e..64a311431 100644 --- a/lib_com/findpulse_fx.c +++ b/lib_com/findpulse_fx.c @@ -36,7 +36,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index d63d7e79f..163142bbf 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -36,7 +36,6 @@ #include #include "options.h" -#include #include "cnst.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8e29f34bd..88e9f41d4 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -35,7 +35,6 @@ ====================================================================================*/ #include -#include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index bee644b0e..083f0d9ca 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -36,7 +36,6 @@ #include #include "options.h" -#include #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index bef9956e4..6a1e70a16 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -35,7 +35,6 @@ ====================================================================================*/ #include -#include #include "options.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index e0d42e404..3b94a85fb 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include #include #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c index 833ff03fb..70def05ae 100644 --- a/lib_com/logqnorm_fx.c +++ b/lib_com/logqnorm_fx.c @@ -35,7 +35,7 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "cnst.h" /* Common constants */ -#include + /*--------------------------------------------------------------------------* * Local constants *--------------------------------------------------------------------------*/ diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 7977bc49b..9420d6523 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -3,7 +3,6 @@ ====================================================================================*/ #include -#include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "prot_fx.h" diff --git a/lib_com/tcx_mdct_window_fx.c b/lib_com/tcx_mdct_window_fx.c index 942eb15fa..6075d034b 100644 --- a/lib_com/tcx_mdct_window_fx.c +++ b/lib_com/tcx_mdct_window_fx.c @@ -37,7 +37,6 @@ #include #include #include "options.h" -#include #include "cnst.h" #include "prot_fx.h" #include "rom_com.h" diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 66dde5a95..4d5107de7 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -39,7 +39,6 @@ #include #include "options.h" #include "stl.h" -#include #include "cnst.h" #include "prot_fx.h" #include "basop_util.h" diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 958b8064d..70221e166 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -35,7 +35,6 @@ ====================================================================================*/ #include #include -#include #include "options.h" #include "cnst.h" #include "rom_com.h" diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 85f83ca61..e6cc62e23 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -3,7 +3,6 @@ ====================================================================================*/ #include #include "options.h" /* Compilation switches */ -#include #include "cnst.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index f9377d53f..c5bb38426 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -9,7 +9,6 @@ #include "options.h" #include "basop_util.h" #include "stl.h" -#include "math.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 0f8cec8e0..fd9f7138e 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -21,7 +21,6 @@ #include "basop_util.h" #include "rom_basop_util.h" #include "ivas_rom_dec.h" -#include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index b08a0cb64..e7fec9492 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -14,7 +14,7 @@ #include "stat_dec.h" #include "basop_util.h" #define MID 57 /* (.89*1<<6)*/ -#include "ivas_prot_fx.h" + /**********************************************************************/ /* get scalefactor of an Word32 array with condition diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 128373154..b7b645df4 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -39,7 +39,6 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 710e881c9..603999706 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" -#include "ivas_stat_enc.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 10aaa02bd..04b29372d 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -36,9 +36,7 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "ivas_stat_enc.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index c5e884f46..8f8d3c7b1 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -36,7 +36,6 @@ #include "prot_fx.h" #include "wmc_auto.h" #include -#include "stat_enc.h" #include "ivas_prot_fx.h" /*----------------------------------------------------------* diff --git a/lib_dec/jbm_jb4sb_fx.c b/lib_dec/jbm_jb4sb_fx.c index 43ef69a98..c4b33817c 100644 --- a/lib_dec/jbm_jb4sb_fx.c +++ b/lib_dec/jbm_jb4sb_fx.c @@ -39,7 +39,6 @@ /* system headers */ #include #include -#include #include #include "options.h" #include "wmc_auto.h" diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index f33ca4b66..3de02c296 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -38,7 +38,6 @@ /* system headers */ #include -#include #include #include #include diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index ee800fcc0..f6a15302a 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -38,7 +38,6 @@ /* system headers */ #include -#include #include #include #include "options.h" diff --git a/lib_dec/jbm_pcmdsp_window_fx.c b/lib_dec/jbm_pcmdsp_window_fx.c index 3afeaf106..62565ba52 100644 --- a/lib_dec/jbm_pcmdsp_window_fx.c +++ b/lib_dec/jbm_pcmdsp_window_fx.c @@ -34,7 +34,6 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ -#include #include #include #include "options.h" diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 767e5c8e7..eec8198bf 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -2,11 +2,8 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ -#define _USE_MATH_DEFINES - #include #include -#include #include "options.h" #include "basop_util.h" #include "options.h" diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index dc34ccc5b..6909c512d 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -6,13 +6,12 @@ #include "options.h" #include "cnst.h" #include "basop_util.h" -// #include "prot_fx.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_enc.h" #include "rom_com.h" #include -#include + /*-------------------------------------------------------------------* * Local prototypes *-------------------------------------------------------------------*/ diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index d42ae6c4d..b7b55c576 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -3,10 +3,12 @@ ====================================================================================*/ #include -#include #include "options.h" /* Compilation switches */ #include "cnst.h" #include /* Compilation switches */ +#ifdef DEBUGGING +#include +#endif #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ @@ -547,7 +549,9 @@ void AVQ_encmux_fx( bit_tmp = add( unusedbitsFlag, unused_bits_idx ); /*nq_est = (int16_t)ceil(0.2f * (bits - 5 * (unusedbitsFlag + unused_bits_idx)));*/ nq_est = mult( 6554, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) ); +#ifdef DEBUGGING assert( (Word16) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); +#endif if ( EQ_16( nq_est, 1 ) ) { diff --git a/lib_enc/cod4t64_fast_fx.c b/lib_enc/cod4t64_fast_fx.c index 7079f6597..0cf8074f6 100644 --- a/lib_enc/cod4t64_fast_fx.c +++ b/lib_enc/cod4t64_fast_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index a60d070a5..5d54b9729 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -12,7 +12,6 @@ #include "basop_util.h" #include "stl.h" #include "prot_fx_enc.h" -#include #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #ifdef DEBUGGING diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 435bfb52d..c3958e543 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -6,13 +6,11 @@ #include #include "options.h" #include "cnst.h" -// #include "prot_fx.h" #include "rom_com.h" #include "basop_util.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include -#include /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index ce623be9c..e4d8b13ee 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_stat_enc.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" #include "prot_fx_enc.h" #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 65d6452da..f13b24b63 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 280da9456..5da139327 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include #include #include "ivas_cnst.h" @@ -41,7 +40,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index d3cc666f6..b1e9751e8 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -14,7 +14,6 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include #include "ivas_prot_fx.h" diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c index 363e758ff..c0b5d16ed 100644 --- a/lib_isar/isar_NoiseGen.c +++ b/lib_isar/isar_NoiseGen.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "isar_lcld_prot.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index f6e031e45..5e68d90c9 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "isar_prot.h" #include "isar_lcld_prot.h" diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 769ae86a5..c933e7f36 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "isar_lcld_prot.h" #include "isar_rom_lcld_tables.h" #include "prot_fx.h" diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 428cc66b3..28685b23e 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -34,7 +34,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "isar_lcld_prot.h" #include "isar_rom_lcld_tables.h" diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 915e2a5e4..760d653f5 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include #include "isar_lcld_prot.h" #include "isar_rom_lcld_tables.h" diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index d807a26e6..8c096da3d 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "ivas_prot_fx.h" #include "prot_fx.h" #include "isar_cnst.h" diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index ce04691f1..dbefc4386 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG #include #endif @@ -43,7 +42,6 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include "prot_fx.h" #include "wmc_auto.h" #include "basop_util.h" #define Q31_BY_360 ( 5965232 ) // Q31 diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 2e5c0236c..44135cd1c 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG #include #endif diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 6f72ce651..9aeda2289 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "ivas_prot_fx.h" #include "prot_fx.h" #include "cnst.h" diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 2dcf72622..61b4c02cb 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -38,7 +38,6 @@ #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include -#include #include "wmc_auto.h" diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index f926b65a4..3257df8de 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "ivas_prot_fx.h" #include "prot_fx.h" #include "isar_cnst.h" -- GitLab From b804c6d556c88064352ea11d84e4a03c4a9bf26f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Dec 2025 15:37:06 +0100 Subject: [PATCH 112/750] clang-format --- lib_com/env_stab_trans_fx.c | 2 +- lib_enc/avq_cod_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/env_stab_trans_fx.c b/lib_com/env_stab_trans_fx.c index c4b6efe5c..498301ef9 100644 --- a/lib_com/env_stab_trans_fx.c +++ b/lib_com/env_stab_trans_fx.c @@ -41,7 +41,7 @@ #include "rom_com.h" #include "wmc_auto.h" - /*--------------------------------------------------------------------------* +/*--------------------------------------------------------------------------* * env_stab_transient_detect() * * Transient detector for envelope stability measure diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index b7b55c576..253c05956 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -5,7 +5,7 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" -#include /* Compilation switches */ +#include /* Compilation switches */ #ifdef DEBUGGING #include #endif -- GitLab From 79e85f9cfcb916b36505fe18d66cc70e515f59b9 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Wed, 3 Dec 2025 16:11:09 +0100 Subject: [PATCH 113/750] ready to merge --- lib_com/options.h | 2 +- lib_rend/ivas_crend_fx.c | 10 +++++- lib_util/hrtf_file_reader.c | 62 ++++++++++++++++++++++++++++++++++++- lib_util/hrtf_file_reader.h | 34 +++++++++++++++----- 4 files changed, 98 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1a7b596d5..9557223fd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,7 @@ #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_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 */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index bb1c5519a..b16e740fb 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -94,6 +94,11 @@ ivas_error ivas_Crend_hrtf_init_fx( hHrtf->pIndex_frequency_max[i][j] = NULL; hHrtf->pOut_to_bin_re_fx[i][j] = NULL; hHrtf->pOut_to_bin_im_fx[i][j] = NULL; +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + hHrtf->pOut_to_bin_re_dyn_fx[i][j] = NULL; + hHrtf->pOut_to_bin_im_dyn_fx[i][j] = NULL; + hHrtf->pIndex_frequency_max_dyn_fx[i][j] = NULL; +#endif } } @@ -102,9 +107,12 @@ ivas_error ivas_Crend_hrtf_init_fx( hHrtf->num_iterations_diffuse[j] = 0; move16(); hHrtf->pIndex_frequency_max_diffuse[j] = NULL; - hHrtf->pOut_to_bin_diffuse_re_fx[j] = NULL; hHrtf->pOut_to_bin_diffuse_im_fx[j] = NULL; +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + hHrtf->pOut_to_bin_diffuse_re_dyn_fx[j] = NULL; + hHrtf->pOut_to_bin_diffuse_im_dyn_fx[j] = NULL; +#endif } hHrtf->init_from_rom = 1; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index db7d42d7c..d274a0ccf 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -179,8 +179,13 @@ static ivas_error read_and_check_hrtf_binary_file_header( static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header ) { +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + if ( hrtf_header == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } +#endif /* Check the renderer type */ - if ( ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) && @@ -787,7 +792,11 @@ static ivas_error load_reverb_from_binary( if ( hrtf_header.frequency != sampleRate ) { free( hrtf_data ); +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; +#else return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); +#endif } } } @@ -954,7 +963,11 @@ static ivas_error TDREND_MIX_LoadHRTF( if ( hrtf_header.frequency != sampleRate ) { free( hrtf_data ); +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; +#else return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); +#endif } } } @@ -1723,7 +1736,11 @@ ivas_error load_fastconv_HRTF_from_binary( if ( hrtf_header.frequency != 48000 ) /* note: Parametric renderer data are always stored at 48 kHz */ { free( hrtf_data ); +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; +#else return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); +#endif } if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -1823,7 +1840,11 @@ ivas_error load_parambin_HRTF_from_binary( if ( hrtf_header.frequency != 48000 ) /* note: Parametric renderer data are always stored at 48 kHz */ { free( hrtf_data ); +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; +#else return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); +#endif } if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -1943,7 +1964,11 @@ ivas_error load_Crend_HRTF_from_binary( if ( hrtf_header.frequency != sampleRate ) { free( hrtf_data ); +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; +#else return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); +#endif } if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -2035,6 +2060,7 @@ void destroy_crend_hrtf( } +#ifndef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -2065,6 +2091,7 @@ void destroy_hrtf_statistics( return; } +#endif /*---------------------------------------------------------------------* * destroy_fastconv_hrtf() @@ -2100,3 +2127,36 @@ void destroy_parambin_hrtf( return; } + +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ + +void destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +{ + if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) + { + if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_l_dyn ); + } + if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_r_dyn ); + } + if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) + { + free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); + } + } + + ivas_HRTF_statistics_close_fx( hHrtfStatistics ); + + return; +} +#endif diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 105ee0ace..f949308d7 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -56,7 +56,7 @@ typedef enum { BINAURAL_INPUT_AUDIO_CONFIG_INVALID, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */ - BINAURAL_INPUT_AUDIO_CONFIG_HOA3, /* HOA3 */ + BINAURAL_INPUT_AUDIO_CONFIG_HOA3, /* HOA3 */ BINAURAL_INPUT_AUDIO_CONFIG_HOA2, /* HOA2 */ BINAURAL_INPUT_AUDIO_CONFIG_FOA, /* FOA */ BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */ @@ -118,13 +118,17 @@ ivas_error load_reverb_binary( ); /*---------------------------------------------------------------------* - * create_SetOfHRTF_from_binary() + * load_Crend_HRTF_from_binary() * - * Create the HRTF data set from the binary file + * Create the Crend HRTF data set from the binary file *---------------------------------------------------------------------*/ ivas_error load_Crend_HRTF_from_binary( - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + IVAS_DEC_HRTF_CREND_HANDLE hHrtfCrend, /* i/o: HRTF CRend handle */ +#else + IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ +#endif const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ @@ -134,11 +138,15 @@ ivas_error load_Crend_HRTF_from_binary( /*---------------------------------------------------------------------* * destroy_crend_hrtf() * - * Destroy the HRTF data set. + * Destroy the Crend HRTF data set *---------------------------------------------------------------------*/ void destroy_crend_hrtf( +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND + IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */ +#else IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +#endif ); /*---------------------------------------------------------------------* @@ -174,7 +182,7 @@ ivas_error load_parambin_HRTF_from_binary( IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin, /* i/o: Parambin HRTF handle */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); - +#ifndef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -184,7 +192,7 @@ ivas_error load_parambin_HRTF_from_binary( void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ); - +#endif /*---------------------------------------------------------------------* * destroy_parambin_hrtf() * @@ -205,4 +213,16 @@ void destroy_td_hrtf( IVAS_DEC_HRTF_TD_HANDLE *hHRTF /* i/o: TD rend. HRTF handle */ ); +#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * free memory allocated for HRTF statistics binary data + *---------------------------------------------------------------------*/ + +void destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +); +#endif + #endif /* IVAS_HRTF_FILE_READER_H */ -- GitLab From 8576b0f97fe1a68b1e50ce69fc9b04a80e77028e Mon Sep 17 00:00:00 2001 From: marc emerit Date: Wed, 3 Dec 2025 16:59:34 +0100 Subject: [PATCH 114/750] typo fix --- lib_com/options.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9557223fd..79b51a057 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #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 */ /* #################### End BE switches ################################## */ @@ -96,7 +96,6 @@ #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_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 */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 8d903edcba85e12ba4c8f893c1fee5385098bcae Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 3 Dec 2025 11:23:06 -0500 Subject: [PATCH 115/750] 2261, remove unnecessary Aq scaling --- lib_com/options.h | 2 +- lib_enc/acelp_core_enc_fx.c | 8 ++++++++ lib_enc/ivas_core_enc_fx.c | 4 ++++ lib_enc/ivas_front_vad_fx.c | 3 ++- lib_enc/ivas_ism_enc_fx.c | 3 ++- lib_enc/updt_enc_fx.c | 5 +++++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1a7b596d5..bf41d29d9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,7 @@ #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_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ff4c684e8..80a2847b8 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1099,11 +1099,13 @@ ivas_error acelp_core_enc_ivas_fx( move16(); st->hLPDmem->q_mem_syn = st->Q_syn; move16(); +#ifndef FIX_2261_REMOVE_LP_RESCALING // Scaling Aq to Q12 FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) { Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); } +#endif /* synthesis at 12.8kHz sampling rate */ syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn ); @@ -1244,11 +1246,13 @@ ivas_error acelp_core_enc_ivas_fx( st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15 move16(); } +#ifndef FIX_2261_REMOVE_LP_RESCALING // Scaling Aq to Q12 FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) { Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); } +#endif test(); IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { @@ -1455,6 +1459,10 @@ ivas_error acelp_core_enc_ivas_fx( { Copy( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12 } +#ifdef FIX_2261_REMOVE_LP_RESCALING + // Scaling Aq to Q12 + Scale_sig( st->hBWE_TD->cur_sub_Aq_fx, M + 1, sub( norm_s( st->hBWE_TD->cur_sub_Aq_fx[0] ), 2 ) ); +#endif } diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 96bbca887..4aa814406 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -224,11 +224,13 @@ ivas_error ivas_core_enc_fx( Scale_sig( fft_buff_fx[n], ( 2 * L_FFT ), -1 ); // To create 1 headroom for addition of magnitude square spectrum // fft_buff_fx_exp = add(fft_buff_fx_exp,1); +#ifndef FIX_2261_REMOVE_LP_RESCALING FOR( i = 0; i < st->nb_subfr; i++ ) { Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } +#endif IF( EQ_32( ivas_format, SBA_FORMAT ) ) { IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, @@ -334,10 +336,12 @@ ivas_error ivas_core_enc_fx( test(); IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { +#ifndef FIX_2261_REMOVE_LP_RESCALING FOR( i = 0; i < st->nb_subfr; i++ ) { Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } +#endif TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; Word16 Q_spec_old, L_spec; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 35400f652..f3809f436 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -636,8 +636,9 @@ ivas_error front_vad_spar_fx( } relE_fx = sub( Etot_fx[0], extract_h( st->lp_speech_32fx ) ); +#ifndef FIX_2261_REMOVE_LP_RESCALING Scale_sig( A_fx, ( L_FRAME / L_SUBFR ) * ( M + 1 ), -2 ); // Q12 - +#endif st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */ st->mem_wsp_q = Q_inp_12k8; move16(); diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index ea509dd10..6a1d1e676 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -238,11 +238,12 @@ ivas_error ivas_ism_enc_fx( /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ +#ifndef FIX_2261_REMOVE_LP_RESCALING FOR( i = 0; i < hSCE->hCoreCoder[0]->nb_subfr; i++ ) { Scale_sig( &A_fx[sce_id][0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[sce_id][0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } - +#endif set16_fx( old_wsp_fx[sce_id][0], 0, L_WSP ); q_old_wsp = Q15; move16(); diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 62af228a0..b8975905e 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -141,6 +141,11 @@ void updt_enc_fx( } /* core switching updates */ Copy( &Aq[( st->L_frame / L_SUBFR - 1 ) * ( M + 1 )], st->old_Aq_12_8_fx, M + 1 ); +#ifdef FIX_2261_REMOVE_LP_RESCALING + // Scaling Aq to Q12 + Scale_sig( st->old_Aq_12_8_fx, M + 1, sub( norm_s( st->old_Aq_12_8_fx[0] ), 2 ) ); +#endif + st->old_Es_pred_fx = Es_pred; move16(); -- GitLab From 85ddbe3bbfa22fa04c132343c75f0bfb06b9ad9f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 3 Dec 2025 16:05:41 -0500 Subject: [PATCH 116/750] Tentative to fix crash, and EVS BE --- lib_enc/acelp_core_enc_fx.c | 4 ---- lib_enc/ivas_core_enc_fx.c | 4 ++-- lib_enc/updt_enc_fx.c | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 80a2847b8..6fe47c6dd 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1459,10 +1459,6 @@ ivas_error acelp_core_enc_ivas_fx( { Copy( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12 } -#ifdef FIX_2261_REMOVE_LP_RESCALING - // Scaling Aq to Q12 - Scale_sig( st->hBWE_TD->cur_sub_Aq_fx, M + 1, sub( norm_s( st->hBWE_TD->cur_sub_Aq_fx[0] ), 2 ) ); -#endif } diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 4aa814406..36ee1a0da 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -224,13 +224,13 @@ ivas_error ivas_core_enc_fx( Scale_sig( fft_buff_fx[n], ( 2 * L_FFT ), -1 ); // To create 1 headroom for addition of magnitude square spectrum // fft_buff_fx_exp = add(fft_buff_fx_exp,1); -#ifndef FIX_2261_REMOVE_LP_RESCALING FOR( i = 0; i < st->nb_subfr; i++ ) { +#ifndef FIX_2261_REMOVE_LP_RESCALING Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 +#endif Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } -#endif IF( EQ_32( ivas_format, SBA_FORMAT ) ) { IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index b8975905e..a9b15cfe4 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -141,10 +141,6 @@ void updt_enc_fx( } /* core switching updates */ Copy( &Aq[( st->L_frame / L_SUBFR - 1 ) * ( M + 1 )], st->old_Aq_12_8_fx, M + 1 ); -#ifdef FIX_2261_REMOVE_LP_RESCALING - // Scaling Aq to Q12 - Scale_sig( st->old_Aq_12_8_fx, M + 1, sub( norm_s( st->old_Aq_12_8_fx[0] ), 2 ) ); -#endif st->old_Es_pred_fx = Es_pred; move16(); -- GitLab From f9b88a260e86b535d148fd641c62b659dc0ad11e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 3 Dec 2025 16:44:03 -0500 Subject: [PATCH 117/750] Fix clang --- lib_enc/ivas_core_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 36ee1a0da..e79c5bd4c 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -227,7 +227,7 @@ ivas_error ivas_core_enc_fx( FOR( i = 0; i < st->nb_subfr; i++ ) { #ifndef FIX_2261_REMOVE_LP_RESCALING - Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 + Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 #endif Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } -- GitLab From 44cfaeb2ceef024a0995f382df0b027b71cca45a Mon Sep 17 00:00:00 2001 From: "Malenovsky, Vladimir" Date: Thu, 4 Dec 2025 10:31:49 +0100 Subject: [PATCH 118/750] initialize FD CNG with EVS-type of init function --- lib_com/options.h | 1 + lib_dec/init_dec_fx.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1a7b596d5..175072bf6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,6 +85,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ +#define FIX_2245_INIT_FD_CNG_EVS /* Dolby: Issue 2245: initialize FD CNG with EVS-type of init function */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index ec2c0ce0b..d8b8ba05f 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -928,7 +928,18 @@ ivas_error init_decoder_fx( } /* Init FD-CNG */ - initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); +#ifdef FIX_2245_INIT_FD_CNG_EVS + if ( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); + } + else + { +#endif + initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); +#ifdef FIX_2245_INIT_FD_CNG_EVS + } +#endif } ELSE { -- GitLab From 2eb26e382b80b3b2521c2bd405d16a3155088988 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 4 Dec 2025 11:25:48 +0100 Subject: [PATCH 119/750] Add FIX_1461_CNG_BW_SWITCHING to address BW switching in Stereo CNG --- lib_com/options.h | 2 +- lib_enc/ivas_cpe_enc_fx.c | 9 +++++++++ lib_enc/ivas_stereo_dft_enc_fx.c | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1a7b596d5..6ad55f796 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,7 @@ #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_1461_CNG_BW_SWITCHING /* Eri: float issue 1461: Stereo parameters are not updated when SID/NODATA forces BW to stay the same */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 033e13034..4aea3ff61 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -130,6 +130,9 @@ ivas_error ivas_cpe_enc_fx( Word16 old_wsp_fx[CPE_CHANNELS][L_WSP]; Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp; Word16 Q_new[CPE_CHANNELS] = { 0 }; +#ifdef FIX_1461_CNG_BW_SWITCHING + Word16 NFFT_inner; +#endif move16(); move16(); Word16 q_com, shift, q_min, gb; @@ -1124,6 +1127,12 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) { /* Reconfigure DFT Stereo for inactive frames */ +#ifdef FIX_1461_CNG_BW_SWITCHING + /* -- nbands may need to be updated here in case the bandwidth was changed due to inactive frames */ + NFFT_inner = shl( inner_frame_tbl[sts[0]->bwidth], 1 ); + hCPE->hStereoDft->nbands = stereo_dft_band_config_fx( hCPE->hStereoDft->band_limits, hCPE->hStereoDft->hConfig->band_res, NFFT_inner, ENC ); + move16(); +#endif IF( EQ_32( sts[0]->core_brate, SID_2k40 ) ) { stereo_dft_config_fx( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index e5522fb37..5f78defdd 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -3853,6 +3853,17 @@ static void stereo_dft_enc_compute_prm_fx( hStereoDft->nrg_past_pos = ( pos + 1 ) % STEREO_DFT_NRG_PAST_LEN; move16(); +#ifdef FIX_1461_CNG_BW_SWITCHING + /* Replicate last band for remaining bands in case the bandwidth is higher after SID/NODATA is considered */ + FOR( i = hStereoDft->nbands; i < STEREO_DFT_BAND_MAX; i++ ) + { + pPredGain[i] = pPredGain[i - 1]; + move32(); + pSideGain[i] = pSideGain[i - 1]; + move32(); + } +#endif + /*------------------------------------------------------------------* * Compute IPDs -- GitLab From fea60c4bb4207ca676144eea2514dd880d61221f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Dec 2025 13:19:26 +0100 Subject: [PATCH 120/750] harmonize use of FD CNG init function --- lib_com/fd_cng_com_fx.c | 12 +++++++++--- lib_com/ivas_prot_fx.h | 3 ++- lib_com/options.h | 2 +- lib_dec/fd_cng_dec_fx.c | 14 ++++++++++++++ lib_dec/init_dec_fx.c | 13 +++---------- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 4 ++++ lib_dec/ivas_stereo_switching_dec_fx.c | 13 +++++++++++++ 7 files changed, 46 insertions(+), 15 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 1a85899d3..992540d66 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -58,7 +58,13 @@ ivas_error createFdCngCom_fx( * *-------------------------------------------------------------------*/ -void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) +#ifdef FIX_2245_INIT_FD_CNG_EVS +void initFdCngCom( +#else +void ivas_initFdCngCom_fx( +#endif + HANDLE_FD_CNG_COM hFdCngCom, + Word16 scale ) { /* Calculate CLDFB scaling factor */ /* shl(i_mult2(scale, scale), 3) does not fit in 16 bit */ @@ -172,7 +178,7 @@ void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) return; } - +#ifndef FIX_2245_INIT_FD_CNG_EVS void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) { /* Calculate CLDFB scaling factor */ @@ -277,7 +283,7 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) return; } - +#endif /*------------------------------------------------------------------- * deleteFdCngCom() * diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 3c7f54074..7cee85a2c 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1990,6 +1990,7 @@ ivas_error stereo_memory_dec_fx( const Word16 nchan_transport /* i : number of transport channels */ ); +#ifndef FIX_2245_INIT_FD_CNG_EVS void initFdCngDec_ivas_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ Word16 scale @@ -1998,7 +1999,7 @@ void initFdCngDec_ivas_fx( void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ); - +#endif Word16 set_ACELP_flag_IVAS( const Word16 element_mode, /* i : element mode */ const Word32 element_brate, /* i : element bitrate */ diff --git a/lib_com/options.h b/lib_com/options.h index 175072bf6..6590c90c7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ -#define FIX_2245_INIT_FD_CNG_EVS /* Dolby: Issue 2245: initialize FD CNG with EVS-type of init function */ +#define FIX_2245_INIT_FD_CNG_EVS /* Dolby/VA: Issue 2245: initialize FD CNG with EVS-type of init function */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 2c62fd653..042d72c64 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -81,16 +81,27 @@ ivas_error createFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ) return error; } +#ifdef FIX_2245_INIT_FD_CNG_EVS +void initFdCngDec_fx( + DEC_CORE_HANDLE st, /* i/o: decoder state structure */ + const Word16 scale /* i : Q factor */ +) +#else void initFdCngDec_ivas_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ Word16 scale /*Q15*/ ) +#endif { /* Initialize common */ HANDLE_FD_CNG_DEC hFdCngDec; hFdCngDec = st->hFdCngDec; +#ifdef FIX_2245_INIT_FD_CNG_EVS + initFdCngCom( hFdCngDec->hFdCngCom, scale ); +#else ivas_initFdCngCom_fx( hFdCngDec->hFdCngCom, scale ); +#endif set16_fx( hFdCngDec->olapBufferAna, 0, FFTLEN ); hFdCngDec->hFdCngCom->olapBufferAna = hFdCngDec->olapBufferAna; set16_fx( hFdCngDec->olapBufferSynth2, 0, FFTLEN ); @@ -196,9 +207,11 @@ void initFdCngDec_ivas_fx( move16(); Copy( st->lsp_old_fx, st->lspCNG_fx, M ); /*Q15*/ hFdCngDec->hFdCngCom->sid_frame_counter = 0; + return; } +#ifndef FIX_2245_INIT_FD_CNG_EVS void initFdCngDec_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ const Word16 scale /*Q15*/ ) @@ -287,6 +300,7 @@ void initFdCngDec_fx( return; } +#endif /* configureFdCngDec_fx diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index d8b8ba05f..e46991dc8 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -929,16 +929,9 @@ ivas_error init_decoder_fx( /* Init FD-CNG */ #ifdef FIX_2245_INIT_FD_CNG_EVS - if ( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); - } - else - { -#endif - initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); -#ifdef FIX_2245_INIT_FD_CNG_EVS - } + initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); +#else + initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); #endif } ELSE diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 1a639a3d7..1f7710376 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -571,7 +571,11 @@ ivas_error initMdctStereoDtxData_fx( } /* Init FD-CNG */ +#ifdef FIX_2245_INIT_FD_CNG_EVS + initFdCngDec_fx( st, st->cldfbSyn->scale ); +#else initFdCngDec_ivas_fx( st, st->cldfbSyn->scale ); +#endif } IF( st->first_CNG == 0 ) diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 237b5f9d5..5ac255026 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -652,7 +652,11 @@ ivas_error stereo_memory_dec_fx( return error; } +#ifdef FIX_2245_INIT_FD_CNG_EVS + initFdCngDec_fx( st, st->cldfbSyn->scale ); +#else initFdCngDec_ivas_fx( st, st->cldfbSyn->scale ); +#endif configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); } @@ -759,7 +763,11 @@ ivas_error stereo_memory_dec_fx( } /* Init FD-CNG */ +#ifdef FIX_2245_INIT_FD_CNG_EVS + initFdCngDec_fx( st, st->cldfbSyn->scale ); +#else initFdCngDec_ivas_fx( st, st->cldfbSyn->scale ); +#endif if ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { @@ -1079,7 +1087,12 @@ ivas_error stereo_memory_dec_fx( { return error; } + +#ifdef FIX_2245_INIT_FD_CNG_EVS + initFdCngDec_fx( hCPE->hCoreCoder[i], hCPE->hCoreCoder[i]->cldfbSyn->scale ); +#else initFdCngDec_ivas_fx( hCPE->hCoreCoder[i], hCPE->hCoreCoder[i]->cldfbSyn->scale ); +#endif } } } -- GitLab From 5c78c00f16ad2bddf02ea4d6bf73103aad2cf440 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Dec 2025 13:23:12 +0100 Subject: [PATCH 121/750] commit the actual fix --- lib_dec/fd_cng_dec_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 042d72c64..a5161ecc1 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -136,6 +136,7 @@ void initFdCngDec_ivas_fx( set16_fx( hFdCngDec->msPsd, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msPsd_fx, 0, NPART_SHAPING ); + set16_fx( hFdCngDec->msNoiseFloor, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msNoiseFloor_32fx, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msNoiseEst, 0, NPART_SHAPING ); -- GitLab From fbf0056f433f0855edc0b809cf8838f2f5d6c580 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Dec 2025 13:25:00 +0100 Subject: [PATCH 122/750] add compilation switch --- lib_dec/fd_cng_dec_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index a5161ecc1..89cdc6d12 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -136,7 +136,9 @@ void initFdCngDec_ivas_fx( set16_fx( hFdCngDec->msPsd, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msPsd_fx, 0, NPART_SHAPING ); +#ifdef FIX_2245_INIT_FD_CNG_EVS set16_fx( hFdCngDec->msNoiseFloor, 0, NPART_SHAPING ); +#endif set32_fx( hFdCngDec->msNoiseFloor_32fx, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msNoiseEst, 0, NPART_SHAPING ); -- GitLab From a5aaa5b0865e1aeef0fb835f0517905cb6cc9556 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Dec 2025 13:31:33 +0100 Subject: [PATCH 123/750] clang-format --- lib_com/fd_cng_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 992540d66..45dd66f45 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -61,9 +61,9 @@ ivas_error createFdCngCom_fx( #ifdef FIX_2245_INIT_FD_CNG_EVS void initFdCngCom( #else -void ivas_initFdCngCom_fx( +void ivas_initFdCngCom_fx( #endif - HANDLE_FD_CNG_COM hFdCngCom, + HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) { /* Calculate CLDFB scaling factor */ -- GitLab From 07717fd562b899c7b81ebdf286ec8ff8a5101f9b Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Dec 2025 14:13:44 +0100 Subject: [PATCH 124/750] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Archit Tamarapu --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index eca1a9ee2..df984bd02 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1208,7 +1208,7 @@ static ivas_error isar_render_poses( /* set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ Word16 num_samples_flushbuffer; #ifdef FIX_2255_ISAR_RENDER_POSES - num_samples_flushbuffer = mult0( numPoses, shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 /* shl(x) == BINAURAL_CHANNELS * x */ ) ); + num_samples_flushbuffer = mult0( shl( numPoses, 1 ) /* shl() == numPoses * BINAURAL_CHANNELS */, div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); #else num_samples_flushbuffer = mult0( mult0( numPoses, BINAURAL_CHANNELS ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); #endif -- GitLab From a602a1cf9c70e4bf299b1bb71382319af766238c Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Dec 2025 14:17:17 +0100 Subject: [PATCH 125/750] more fix --- lib_dec/fd_cng_dec_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 89cdc6d12..9f8263016 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -164,6 +164,9 @@ void initFdCngDec_ivas_fx( move16(); set16_fx( hFdCngDec->msLogPeriodog, 0, NPART_SHAPING ); +#ifdef FIX_2245_INIT_FD_CNG_EVS + set16_fx( hFdCngDec->msLogNoiseEst, 0, NPART_SHAPING ); +#endif set32_fx( hFdCngDec->msLogNoiseEst_32fx, 0, NPART_SHAPING ); set16_fx( hFdCngDec->psize_shaping, 0, NPART_SHAPING ); -- GitLab From dbaa1e12460384c395885fd07b5b0d512dd15226 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 4 Dec 2025 09:35:48 -0500 Subject: [PATCH 126/750] Fix assert in EVS path --- lib_com/options.h | 2 +- lib_enc/enc_acelpx_fx.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1a7b596d5..6cbfe7e97 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,6 +85,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ +#define FIX_2248_EVS_ASSERT /* VA: Include _sat in an EVS related part of the code */ /* #################### End BE switches ################################## */ @@ -97,7 +98,6 @@ #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 */ - /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 95104c76c..5c3ac2f69 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -293,8 +293,11 @@ static void E_ACELP_1pulse_searchx_fx( ps0 = *ps; /* Qdn */ move16(); alp0 = L_deposit_h( *alp ); /* Q22 */ +#ifndef FIX_2248_EVS_ASSERT alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ - +#else + alp0 = L_mac_sat( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ +#endif /* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */ move16(); move16(); -- GitLab From ff4a5823760b430b1173c619831b915b409c5be4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Dec 2025 15:46:27 +0100 Subject: [PATCH 127/750] fix --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index cb969a4e3..c01728032 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1210,7 +1210,7 @@ static ivas_error isar_render_poses( /* set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ Word16 num_samples_flushbuffer; #ifdef FIX_2255_ISAR_RENDER_POSES - num_samples_flushbuffer = mult0( shl( numPoses, 1 ) /* shl() == numPoses * BINAURAL_CHANNELS */, div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + num_samples_flushbuffer = mult0( shl( numPoses, 1 ) /* shl() == numPoses * BINAURAL_CHANNELS */, div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); #else num_samples_flushbuffer = mult0( mult0( numPoses, BINAURAL_CHANNELS ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); #endif -- GitLab From 1f0ed6f47dedcea16f441427cd1cb47d6da7d362 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 4 Dec 2025 09:58:59 -0500 Subject: [PATCH 128/750] Fix clang --- lib_enc/enc_acelpx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 5c3ac2f69..089c3bbb4 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -292,7 +292,7 @@ static void E_ACELP_1pulse_searchx_fx( /*alp0 = *alp + R[0]; INDIRECT(1);*/ ps0 = *ps; /* Qdn */ move16(); - alp0 = L_deposit_h( *alp ); /* Q22 */ + alp0 = L_deposit_h( *alp ); /* Q22 */ #ifndef FIX_2248_EVS_ASSERT alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ #else -- GitLab From 74aa4782f55c6684eecfa917a9c8176c688148e5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 5 Dec 2025 09:52:47 +0100 Subject: [PATCH 129/750] formatting --- lib_com/options.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 710e64071..dd41dd1bc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,12 +105,12 @@ /* #################### Start BASOP optimization switches ############################ */ -#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ -#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ -#define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ -#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ -#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ -#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ +#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ +#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ +#define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ +#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ +#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ +#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From fc3f167366f364348350856119543d6a41ac9315 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 5 Dec 2025 10:21:41 +0100 Subject: [PATCH 130/750] fix issue --- lib_com/options.h | 1 + lib_rend/ivas_hrtf_fx.c | 31 +++++++++++++++++++++++++++++++ lib_rend/ivas_prot_rend_fx.h | 6 ++++++ lib_util/hrtf_file_reader.c | 5 ++++- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b73b5ee8a..5e49d033e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,7 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #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_2249_MEMORY_LEAK_IN_SBA /* OR : issue 2249 : Memory leak in SBA to BINAURAL_ROOM_REVERB with memory instrumentation */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index dee0fe052..a4246e9e0 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -424,3 +424,34 @@ ivas_error ivas_HRTF_statistics_init_fx( return IVAS_ERR_OK; } + +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*---------------------------------------------------------------------* + * ivas_HRTF_statistics_destroy_fx() + * + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ + +void ivas_HRTF_statistics_destroy_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +{ + if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) + { + if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_l_dyn ); + } + if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_r_dyn ); + } + if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) + { + free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); + } + } + + return; +} +#endif \ No newline at end of file diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 5f37622a8..469e46f5e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -621,6 +621,12 @@ ivas_error ivas_HRTF_statistics_init_fx( const Word32 sampleRate /* i : Sample rate */ ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +void ivas_HRTF_statistics_destroy_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +); +#endif + void ivas_HRTF_statistics_close_fx( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ ); diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index d274a0ccf..ee6e384c9 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2071,6 +2071,9 @@ void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_destroy_fx( hHrtfStatistics ); +#else if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) @@ -2086,7 +2089,7 @@ void destroy_hrtf_statistics( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } - +#endif ivas_HRTF_statistics_close_fx( hHrtfStatistics ); return; -- GitLab From 3b500614ae786b4f6e7bf9c4faa6c6c2ddec18ab Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 5 Dec 2025 10:31:08 +0100 Subject: [PATCH 131/750] fix merge --- lib_util/hrtf_file_reader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index ee6e384c9..584c2f344 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2142,6 +2142,9 @@ void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_destroy_fx( hHrtfStatistics ); +#else if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) @@ -2157,7 +2160,7 @@ void destroy_hrtf_statistics( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } - +#endif ivas_HRTF_statistics_close_fx( hHrtfStatistics ); return; -- GitLab From 5edf0db90bf35bcafb844503840b29d8583a49b6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 5 Dec 2025 13:47:35 +0100 Subject: [PATCH 132/750] add IVAS_cod_fmtsw to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 9dcfcdcf8..31c3b4576 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Compiler output Unix IVAS_cod +IVAS_cod_fmtsw IVAS_dec IVAS_rend ISAR_post_rend @@ -16,6 +17,7 @@ build*/**/* # Compiler output VS2017 IVAS_cod.exe +IVAS_cod_fmtsw.exe IVAS_dec.exe IVAS_rend.exe ISAR_post_rend.exe -- GitLab From 5a518fa78c273cd4935d5946c2bea8d9a076f025 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 5 Dec 2025 13:56:32 +0100 Subject: [PATCH 133/750] fix FIX_2252_TD_CNG_STARTS_SID --- lib_com/options.h | 1 + lib_dec/decision_matrix_dec_fx.c | 10 ++++++++++ lib_dec/init_dec_fx.c | 18 ++++++++++++++++++ lib_dec/ivas_decision_matrix_dec_fx.c | 6 ++++++ 4 files changed, 35 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index dd41dd1bc..fe7fead81 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,6 +96,7 @@ #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_2252_TD_CNG_STARTS_SID /* VA: issues 2251 and 2252: Resolve "MSAN with bitstream that starts with an SID" */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index 1bd406e7a..e905b8237 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -76,10 +76,20 @@ void decision_matrix_dec_fx( move16(); tmp16 = get_next_indice_fx( st, 1 ); // Q0 +#ifdef FIX_2252_TD_CNG_STARTS_SID + IF ( EQ_16( tmp16, 1 ) ) +#else if ( EQ_16( tmp16, 1 ) ) +#endif { st->L_frame = L_FRAME16k; move16(); +#ifdef FIX_2252_TD_CNG_STARTS_SID + st->nb_subfr = NB_SUBFR16k; + move16(); + st->bwidth = WB; + move16(); +#endif } } ELSE diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index ec2c0ce0b..4288a6722 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -91,12 +91,30 @@ ivas_error init_decoder_fx( move16(); st_fx->ini_frame = 0; move16(); +#ifdef FIX_2252_TD_CNG_STARTS_SID + IF( st->element_mode == EVS_MONO ) + { + st->bwidth = NB; + move16(); + st->last_bwidth = NB; + move16(); + } + ELSE + { + st_fx->bwidth = WB; + move16(); + st_fx->last_bwidth = WB; + move16(); + } +#else st_fx->bwidth = NB; move16(); st_fx->last_bwidth = NB; move16(); +#endif st_fx->extl_brate = 0; move16(); + st_fx->coder_type = GENERIC; /* low-rate mode flag */ move16(); st_fx->last_coder_type = GENERIC; diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index 4ba2a386a..20f7159a9 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -115,6 +115,12 @@ void ivas_decision_matrix_dec_fx( { st->L_frame = L_FRAME16k; move16(); +#ifdef FIX_2252_TD_CNG_STARTS_SID + st->nb_subfr = NB_SUBFR16k; + move16(); + st->bwidth = WB; + move16(); +#endif } ELSE { -- GitLab From 2137b4e735bdea3d6e576ebf0df7d609c86680af Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 5 Dec 2025 14:06:48 +0100 Subject: [PATCH 134/750] clang-format --- lib_dec/decision_matrix_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index e905b8237..85a6e1f35 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -77,7 +77,7 @@ void decision_matrix_dec_fx( tmp16 = get_next_indice_fx( st, 1 ); // Q0 #ifdef FIX_2252_TD_CNG_STARTS_SID - IF ( EQ_16( tmp16, 1 ) ) + IF( EQ_16( tmp16, 1 ) ) #else if ( EQ_16( tmp16, 1 ) ) #endif -- GitLab From 2259aa70684f196709b7e389708b5b31912eef4e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 5 Dec 2025 14:57:54 +0100 Subject: [PATCH 135/750] [revert-me] change CI ref --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f84bc99f..1e36678fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF fix-name-checks-basop-ci # If you need to set some config variable only in a local branch, then add an overwrite here # One example is DISABLE_HRTF - this will be set on a branch which is about to be merged and will be removed in a subsequent second MR # this is more easily done directly here in the child repo -- GitLab From 822d4483143d25da4af5fc2923929463021dae4a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 5 Dec 2025 15:19:38 +0100 Subject: [PATCH 136/750] Revert "[revert-me] change CI ref" This reverts commit 2259aa70684f196709b7e389708b5b31912eef4e. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e36678fc..3f84bc99f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF fix-name-checks-basop-ci + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main # If you need to set some config variable only in a local branch, then add an overwrite here # One example is DISABLE_HRTF - this will be set on a branch which is about to be merged and will be removed in a subsequent second MR # this is more easily done directly here in the child repo -- GitLab From 260458b717df12ba7c1e55d56701f449818de74e Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 5 Dec 2025 17:39:18 +0100 Subject: [PATCH 137/750] fix --- lib_com/options.h | 2 +- lib_dec/decision_matrix_dec_fx.c | 5 ++--- lib_dec/init_dec_fx.c | 12 ++++++------ lib_dec/ivas_decision_matrix_dec_fx.c | 5 ++--- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fe7fead81..7422af1cf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,7 @@ #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_2252_TD_CNG_STARTS_SID /* VA: issues 2251 and 2252: Resolve "MSAN with bitstream that starts with an SID" */ +#define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index 85a6e1f35..cddc16314 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -84,11 +84,10 @@ void decision_matrix_dec_fx( { st->L_frame = L_FRAME16k; move16(); -#ifdef FIX_2252_TD_CNG_STARTS_SID +#ifdef FIX_2252_LP_CNG_STARTS_SID st->nb_subfr = NB_SUBFR16k; move16(); - st->bwidth = WB; - move16(); + st->bwidth = s_max( st->bwidth, WB ); #endif } } diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 4288a6722..2033f284a 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -91,20 +91,20 @@ ivas_error init_decoder_fx( move16(); st_fx->ini_frame = 0; move16(); -#ifdef FIX_2252_TD_CNG_STARTS_SID - IF( st->element_mode == EVS_MONO ) +#ifdef FIX_2252_LP_CNG_STARTS_SID + IF( st_fx->element_mode == EVS_MONO ) { - st->bwidth = NB; + st_fx->bwidth = NB; move16(); - st->last_bwidth = NB; + st_fx->last_bwidth = NB; move16(); } ELSE { st_fx->bwidth = WB; move16(); - st_fx->last_bwidth = WB; - move16(); + // st_fx->last_bwidth = WB; // TBV + // move16(); } #else st_fx->bwidth = NB; diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index 20f7159a9..fadd9d008 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -115,11 +115,10 @@ void ivas_decision_matrix_dec_fx( { st->L_frame = L_FRAME16k; move16(); -#ifdef FIX_2252_TD_CNG_STARTS_SID +#ifdef FIX_2252_LP_CNG_STARTS_SID st->nb_subfr = NB_SUBFR16k; move16(); - st->bwidth = WB; - move16(); + st->bwidth = s_max( st->bwidth, WB ); #endif } ELSE -- GitLab From b58c9f747903ccc0692a2f7da4b35d6bdd962db6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 5 Dec 2025 17:56:11 +0100 Subject: [PATCH 138/750] fix --- lib_dec/init_dec_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 1a064689d..51195ca8c 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -103,8 +103,9 @@ ivas_error init_decoder_fx( { st_fx->bwidth = WB; move16(); + st_fx->last_bwidth = NB; // st_fx->last_bwidth = WB; // TBV - // move16(); + move16(); } #else st_fx->bwidth = NB; -- GitLab From 8d30cdc16b622acdc14c994f8e3ef6442a1fe4b6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 14:31:29 -0500 Subject: [PATCH 139/750] Fix proposal for 2264, out-of-bound access in log2 --- lib_com/log2.c | 7 +++++-- lib_com/options.h | 2 +- lib_enc/swb_pre_proc_fx.c | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 70e6b93c0..8fa3a7120 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -57,10 +57,13 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val { Word16 i, a; Word16 y; - +#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); - +#else + assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ + L_x = L_max( L_x, 0x40000000 ); +#endif L_x = L_shr( L_x, 9 ); a = extract_l( L_x ); /* Extract b10-b24 of fraction */ a = lshr( a, 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index 1b4f59296..b84e1a499 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #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_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()*/ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a966f70cc..a2ade8d3b 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,6 +1125,9 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } +#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC + exp = norm_l( CldfbHB_fx ); +#endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); -- GitLab From 3f92402cdfbe7364688dd419178d6361267d686d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 14:31:29 -0500 Subject: [PATCH 140/750] Fix proposal for 2264, out-of-bound access in log2 --- lib_com/log2.c | 7 +++++-- lib_com/options.h | 2 +- lib_enc/swb_pre_proc_fx.c | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 70e6b93c0..8fa3a7120 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -57,10 +57,13 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val { Word16 i, a; Word16 y; - +#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); - +#else + assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ + L_x = L_max( L_x, 0x40000000 ); +#endif L_x = L_shr( L_x, 9 ); a = extract_l( L_x ); /* Extract b10-b24 of fraction */ a = lshr( a, 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index e9b94dbad..2b9461b2c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #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_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()*/ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a966f70cc..a2ade8d3b 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,6 +1125,9 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } +#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC + exp = norm_l( CldfbHB_fx ); +#endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); -- GitLab From 1f525044637dca0073042c4fb7e4f6a7e6354ac4 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 14:39:03 -0500 Subject: [PATCH 141/750] Revert "Fix proposal for 2264, out-of-bound access in log2" This reverts commit 8d30cdc16b622acdc14c994f8e3ef6442a1fe4b6. --- lib_com/log2.c | 7 ++----- lib_com/options.h | 2 +- lib_enc/swb_pre_proc_fx.c | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 8fa3a7120..70e6b93c0 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -57,13 +57,10 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val { Word16 i, a; Word16 y; -#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC + if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); -#else - assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ - L_x = L_max( L_x, 0x40000000 ); -#endif + L_x = L_shr( L_x, 9 ); a = extract_l( L_x ); /* Extract b10-b24 of fraction */ a = lshr( a, 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index b84e1a499..1b4f59296 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #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_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()*/ + /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a2ade8d3b..a966f70cc 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,9 +1125,6 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } -#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC - exp = norm_l( CldfbHB_fx ); -#endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); -- GitLab From 84d67a562f66c8375ee609760e62e8a917450692 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 14:41:35 -0500 Subject: [PATCH 142/750] fix clang --- lib_enc/swb_pre_proc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a2ade8d3b..ffdb1d454 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,7 +1125,7 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } -#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC +#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC exp = norm_l( CldfbHB_fx ); #endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ -- GitLab From d951d39c03f3a5090214e2c34a91f18539053c65 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 15:06:05 -0500 Subject: [PATCH 143/750] Prevent the assert to catch cases that are == 0 --- lib_com/log2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 8fa3a7120..850090270 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -61,7 +61,9 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); #else - assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ + + if ( L_x > 0 ) /* There are many cases in the code where L_x == 0 */ + assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ L_x = L_max( L_x, 0x40000000 ); #endif L_x = L_shr( L_x, 9 ); -- GitLab From a16ec4a74b180e3f949b544d40fb69f35f897812 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 15:08:44 -0500 Subject: [PATCH 144/750] Fix clang --- lib_com/log2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 850090270..42b1f1b3d 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -61,7 +61,7 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); #else - + if ( L_x > 0 ) /* There are many cases in the code where L_x == 0 */ assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ L_x = L_max( L_x, 0x40000000 ); -- GitLab From ff7b1776d1314d6ab090dd69e5b9ec624a48583e Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 5 Dec 2025 21:33:18 +0100 Subject: [PATCH 145/750] another attempt to get BE --- lib_dec/init_dec_fx.c | 1549 +++++++++++++++++++++-------------------- 1 file changed, 777 insertions(+), 772 deletions(-) diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 51195ca8c..65b2ea925 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -101,960 +101,965 @@ ivas_error init_decoder_fx( } ELSE { +#if 0 // keep deactivated for the moment to keep BE st_fx->bwidth = WB; move16(); + st_fx->last_bwidth = WB; +#else + st_fx->bwidth = NB; + move16(); st_fx->last_bwidth = NB; - // st_fx->last_bwidth = WB; // TBV +#endif move16(); } #else - st_fx->bwidth = NB; - move16(); - st_fx->last_bwidth = NB; - move16(); + st_fx->bwidth = NB; + move16(); + st_fx->last_bwidth = NB; + move16(); #endif - st_fx->extl_brate = 0; - move16(); + st_fx->extl_brate = 0; + move16(); - st_fx->coder_type = GENERIC; /* low-rate mode flag */ - move16(); - st_fx->last_coder_type = GENERIC; - move16(); - st_fx->inactive_coder_type_flag = 0; - move16(); - st_fx->last_L_frame = st_fx->L_frame; - move16(); - st_fx->last_core_brate = st_fx->core_brate; - move16(); - st_fx->last_core = -1; - move16(); - st_fx->last_extl = st_fx->extl; - move16(); + st_fx->coder_type = GENERIC; /* low-rate mode flag */ + move16(); + st_fx->last_coder_type = GENERIC; + move16(); + st_fx->inactive_coder_type_flag = 0; + move16(); + st_fx->last_L_frame = st_fx->L_frame; + move16(); + st_fx->last_core_brate = st_fx->core_brate; + move16(); + st_fx->last_core = -1; + move16(); + st_fx->last_extl = st_fx->extl; + move16(); - st_fx->flag_ACELP16k = set_ACELP_flag( st_fx->element_mode, st_fx->total_brate, st_fx->total_brate, idchan, 0, -1, -1 ); - move16(); + st_fx->flag_ACELP16k = set_ACELP_flag( st_fx->element_mode, st_fx->total_brate, st_fx->total_brate, idchan, 0, -1, -1 ); + move16(); - /*-----------------------------------------------------------------* - * ACELP core parameters - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * ACELP core parameters + *-----------------------------------------------------------------*/ - /* LSF initilaizations */ - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); + /* LSF initilaizations */ + Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); + init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); - set16_fx( st_fx->mem_MA_fx, 0, M ); + set16_fx( st_fx->mem_MA_fx, 0, M ); - st_fx->dm_fx.prev_state = 0; /* This corresponds to st_fx->dispMem in FLP */ - move16(); - st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); - FOR( i = 2; i < 8; i++ ) - { - st_fx->dm_fx.prev_gain_pit[i - 2] = 0; + st_fx->dm_fx.prev_state = 0; /* This corresponds to st_fx->dispMem in FLP */ + move16(); + st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); + FOR( i = 2; i < 8; i++ ) + { + st_fx->dm_fx.prev_gain_pit[i - 2] = 0; + move16(); + } + st_fx->tilt_code_fx = 0; + move16(); + st_fx->gc_threshold_fx = 0; + move32(); + st_fx->last_good = UNVOICED_CLAS; + move16(); + st_fx->clas_dec = UNVOICED_CLAS; + move16(); + st_fx->low_rate_mode = 0; /* low-rate mode flag */ + move16(); + st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ + move16(); + st_fx->lp_gainp_fx = 0; + move16(); + st_fx->lp_gainc_fx = 0; move16(); - } - st_fx->tilt_code_fx = 0; - move16(); - st_fx->gc_threshold_fx = 0; - move32(); - st_fx->last_good = UNVOICED_CLAS; - move16(); - st_fx->clas_dec = UNVOICED_CLAS; - move16(); - st_fx->low_rate_mode = 0; /* low-rate mode flag */ - move16(); - st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ - move16(); - st_fx->lp_gainp_fx = 0; - move16(); - st_fx->lp_gainc_fx = 0; - move16(); - - set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); - /* AVQ pre-quantizer memory */ - st_fx->mem_preemp_preQ_fx = 0; - move16(); - st_fx->last_nq_preQ = 0; - move16(); - st_fx->use_acelp_preq = 0; - move16(); + set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); - st_fx->mem_deemph_fx = 0; - move16(); + /* AVQ pre-quantizer memory */ + st_fx->mem_preemp_preQ_fx = 0; + move16(); + st_fx->last_nq_preQ = 0; + move16(); + st_fx->use_acelp_preq = 0; + move16(); - set16_fx( st_fx->mem_syn1_fx, 0, M ); - set16_fx( st_fx->mem_syn2_fx, 0, M ); - st_fx->stab_fac_fx = 0; - move16(); - st_fx->stab_fac_smooth_fx = 0; - move16(); - set16_fx( st_fx->agc_mem_fx, 0, 2 ); - set16_fx( st_fx->mem_syn3_fx, 0, M ); + st_fx->mem_deemph_fx = 0; + move16(); - st_fx->stab_fac_smooth_lt_fx = 0; - move16(); - st_fx->log_energy_diff_lt_fx = 0; - move32(); - st_fx->log_energy_old_fx = 0; - move32(); + set16_fx( st_fx->mem_syn1_fx, 0, M ); + set16_fx( st_fx->mem_syn2_fx, 0, M ); + st_fx->stab_fac_fx = 0; + move16(); + st_fx->stab_fac_smooth_fx = 0; + move16(); + set16_fx( st_fx->agc_mem_fx, 0, 2 ); + set16_fx( st_fx->mem_syn3_fx, 0, M ); - Copy( GEWB_Ave_fx, st_fx->lsf_old_fx, M ); - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_12k8 ); + st_fx->stab_fac_smooth_lt_fx = 0; + move16(); + st_fx->log_energy_diff_lt_fx = 0; + move32(); + st_fx->log_energy_old_fx = 0; + move32(); - st_fx->mid_lsf_int = 0; - move16(); - st_fx->safety_net = 0; - move16(); + Copy( GEWB_Ave_fx, st_fx->lsf_old_fx, M ); + lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_12k8 ); - /* FEC */ - st_fx->scaling_flag = 0; - move16(); - st_fx->lp_ener_FEC_av = 500000; - move32(); - st_fx->lp_ener_FEC_max = 500000; - move32(); - st_fx->prev_bfi = 0; - move16(); - st_fx->lp_ener_FER_fx = 15360; /*60 in Q8*/ - move16(); - st_fx->old_enr_LP = 0; - move16(); - st_fx->lp_ener_fx = L_deposit_l( 0 ); - st_fx->enr_old_fx = L_deposit_l( 0 ); - st_fx->bfi_pitch_fx = L_SUBFR_Q6; - move16(); - st_fx->bfi_pitch_frame = L_FRAME; - move16(); - set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); - st_fx->classifier_Q_mem_syn = 0; - move16(); - st_fx->last_con_tcx = 0; - move16(); + st_fx->mid_lsf_int = 0; + move16(); + st_fx->safety_net = 0; + move16(); - FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) - { - st_fx->old_pitch_buf_fx[i] = L_SUBFR << 16; /*15Q16*/ + /* FEC */ + st_fx->scaling_flag = 0; + move16(); + st_fx->lp_ener_FEC_av = 500000; move32(); - } + st_fx->lp_ener_FEC_max = 500000; + move32(); + st_fx->prev_bfi = 0; + move16(); + st_fx->lp_ener_FER_fx = 15360; /*60 in Q8*/ + move16(); + st_fx->old_enr_LP = 0; + move16(); + st_fx->lp_ener_fx = L_deposit_l( 0 ); + st_fx->enr_old_fx = L_deposit_l( 0 ); + st_fx->bfi_pitch_fx = L_SUBFR_Q6; + move16(); + st_fx->bfi_pitch_frame = L_FRAME; + move16(); + set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); + st_fx->classifier_Q_mem_syn = 0; + move16(); + st_fx->last_con_tcx = 0; + move16(); - st_fx->upd_cnt = MAX_UPD_CNT; - move16(); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); + FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) + { + st_fx->old_pitch_buf_fx[i] = L_SUBFR << 16; /*15Q16*/ + move32(); + } - st_fx->seed_acelp = RANDOM_INITSEED; - move16(); - st_fx->seed = RANDOM_INITSEED; - move16(); - st_fx->nbLostCmpt = 0; - move16(); - st_fx->decision_hyst = 0; - move16(); - st_fx->unv_cnt = 0; - move16(); - st_fx->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ - st_fx->uv_count = 0; - move16(); - st_fx->act_count = 3; - move16(); - Copy( st_fx->lsp_old_fx, st_fx->lspold_s_fx, M ); - st_fx->noimix_seed = RANDOM_INITSEED; - move16(); - st_fx->min_alpha_fx = 32767; /*1; Q15*/ - move16(); - st_fx->exc_pe_fx = 0; - move16(); - st_fx->Q_stat_noise = 31; - move16(); - st_fx->prev_coder_type = GENERIC; - move16(); + st_fx->upd_cnt = MAX_UPD_CNT; + move16(); + Copy( GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); + Copy( GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); + Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); - st_fx->tilt_wb_fx = 0; // Q11 - move16(); + st_fx->seed_acelp = RANDOM_INITSEED; + move16(); + st_fx->seed = RANDOM_INITSEED; + move16(); + st_fx->nbLostCmpt = 0; + move16(); + st_fx->decision_hyst = 0; + move16(); + st_fx->unv_cnt = 0; + move16(); + st_fx->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ + st_fx->uv_count = 0; + move16(); + st_fx->act_count = 3; + move16(); + Copy( st_fx->lsp_old_fx, st_fx->lspold_s_fx, M ); + st_fx->noimix_seed = RANDOM_INITSEED; + move16(); + st_fx->min_alpha_fx = 32767; /*1; Q15*/ + move16(); + st_fx->exc_pe_fx = 0; + move16(); + st_fx->Q_stat_noise = 31; + move16(); + st_fx->prev_coder_type = GENERIC; + move16(); - st_fx->last_voice_factor_fx = 0; - move16(); + st_fx->tilt_wb_fx = 0; // Q11 + move16(); - set16_fx( st_fx->prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); - st_fx->Qprev_synth_buffer_fx = 15; - move16(); - set32_fx( st_fx->prev_synth_buffer32_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); + st_fx->last_voice_factor_fx = 0; + move16(); - st_fx->old_bfi_cnt = 0; - move16(); + set16_fx( st_fx->prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); + st_fx->Qprev_synth_buffer_fx = 15; + move16(); + set32_fx( st_fx->prev_synth_buffer32_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); - /*-----------------------------------------------------------------* - * parameters for AC mode (GSC) - *-----------------------------------------------------------------*/ + st_fx->old_bfi_cnt = 0; + move16(); - st_fx->GSC_noisy_speech = 0; - move16(); - st_fx->GSC_IVAS_mode = 0; - move16(); - st_fx->Last_GSC_noisy_speech_flag = 0; - move16(); + /*-----------------------------------------------------------------* + * parameters for AC mode (GSC) + *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) + st_fx->GSC_noisy_speech = 0; + move16(); + st_fx->GSC_IVAS_mode = 0; + move16(); + st_fx->Last_GSC_noisy_speech_flag = 0; + move16(); + + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); - } + IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); + } - GSC_dec_init_fx( st_fx->hGSCDec ); - } - ELSE - { - st_fx->hGSCDec = NULL; - } + GSC_dec_init_fx( st_fx->hGSCDec ); + } + ELSE + { + st_fx->hGSCDec = NULL; + } - /*-----------------------------------------------------------------* - * parameters for fast recovery (WI) - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * parameters for fast recovery (WI) + *-----------------------------------------------------------------*/ - test(); - IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) + test(); + IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FEC WI\n" ) ); + IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FEC WI\n" ) ); + } + set16_fx( st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM ); + set16_fx( st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM ); + } + ELSE + { + st_fx->hWIDec = NULL; } - set16_fx( st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM ); - set16_fx( st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM ); - } - ELSE - { - st_fx->hWIDec = NULL; - } - /*-----------------------------------------------------------------* - * NB/formant post-filter - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * NB/formant post-filter + *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) malloc( sizeof( PFSTAT ) ) ) == NULL ) + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); + IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) malloc( sizeof( PFSTAT ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); + } + + Init_post_filter_fx( st_fx->hPFstat ); + st_fx->psf_lp_noise_fx = 0; + move16(); + } + ELSE + { + st_fx->hPFstat = NULL; } - Init_post_filter_fx( st_fx->hPFstat ); - st_fx->psf_lp_noise_fx = 0; - move16(); - } - ELSE - { - st_fx->hPFstat = NULL; - } + /*-----------------------------------------------------------------* + * HF (6-7kHz) (zero) BWE parameters + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * HF (6-7kHz) (zero) BWE parameters - *-----------------------------------------------------------------*/ + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for zero BWE\n" ) ); + } - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) + hf_synth_init_fx( st_fx->hBWE_zero ); + set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for zero BWE\n" ) ); + st_fx->hBWE_zero = NULL; } - hf_synth_init_fx( st_fx->hBWE_zero ); - set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); - } - ELSE - { - st_fx->hBWE_zero = NULL; - } + /*-----------------------------------------------------------------* + * LD music post-filter + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * LD music post-filter - *-----------------------------------------------------------------*/ + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LD music postflter\n" ) ); + } - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) + music_postfilt_init( st_fx->hMusicPF ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LD music postflter\n" ) ); + st_fx->hMusicPF = NULL; } - music_postfilt_init( st_fx->hMusicPF ); - } - ELSE - { - st_fx->hMusicPF = NULL; - } + /*-----------------------------------------------------------------* + * CNG and DTX + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * CNG and DTX - *-----------------------------------------------------------------*/ + st_fx->first_CNG = 0; + move16(); + st_fx->cng_type = -1; + move16(); + st_fx->last_active_brate = ACELP_7k20; + move32(); + st_fx->last_CNG_L_frame = L_FRAME; + move16(); + st_fx->last_vad_fx = 0; + move16(); + st_fx->active_cnt = CNG_TYPE_HO; + move16(); - st_fx->first_CNG = 0; - move16(); - st_fx->cng_type = -1; - move16(); - st_fx->last_active_brate = ACELP_7k20; - move32(); - st_fx->last_CNG_L_frame = L_FRAME; - move16(); - st_fx->last_vad_fx = 0; - move16(); - st_fx->active_cnt = CNG_TYPE_HO; - move16(); + test(); + test(); + test(); + IF( idchan == 0 && ( ( st_fx->element_mode == EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) + { + IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); + } - test(); - test(); - test(); - IF( idchan == 0 && ( ( st_fx->element_mode == EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) - { - IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + td_cng_dec_init_fx( st_fx ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); + st_fx->hTdCngDec = NULL; } - td_cng_dec_init_fx( st_fx ); - } - ELSE - { - st_fx->hTdCngDec = NULL; - } - - st_fx->masa_sid_format = 0; - move16(); - st_fx->Q_stat_noise_ge = GE_SHIFT; - move16(); - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ + st_fx->masa_sid_format = 0; + move16(); + st_fx->Q_stat_noise_ge = GE_SHIFT; + move16(); - st_fx->prev_old_bfi = 0; - move16(); + /*-----------------------------------------------------------------* + * HQ core parameters + *-----------------------------------------------------------------*/ - set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); - set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); + st_fx->prev_old_bfi = 0; + move16(); - set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); - set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k ); + set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); + set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); - IF( st_fx->element_mode == EVS_MONO ) - { - set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); - } + set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); + set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k ); - test(); - test(); - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) - { - IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) + IF( st_fx->element_mode == EVS_MONO ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); + set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); } - /* HQ core initialization */ - HQ_core_dec_init_fx( st_fx->hHQ_core ); - - IF( st_fx->element_mode == EVS_MONO ) + test(); + test(); + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) { - /* HQ NB FEC initialization */ - IF( ( st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE) malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL ) + IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); } - HQ_nbfec_init_fx( st_fx->hHQ_nbfec ); + /* HQ core initialization */ + HQ_core_dec_init_fx( st_fx->hHQ_core ); + + IF( st_fx->element_mode == EVS_MONO ) + { + /* HQ NB FEC initialization */ + IF( ( st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE) malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n" ) ); + } + + HQ_nbfec_init_fx( st_fx->hHQ_nbfec ); + } + ELSE + { + st_fx->hHQ_nbfec = NULL; + } } ELSE { + st_fx->hHQ_core = NULL; st_fx->hHQ_nbfec = NULL; } - } - ELSE - { - st_fx->hHQ_core = NULL; - st_fx->hHQ_nbfec = NULL; - } - /*-----------------------------------------------------------------* - * TBE parameters - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * TBE parameters + *-----------------------------------------------------------------*/ - test(); - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + test(); + IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); - } + IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); + } + + td_bwe_dec_init_fx( st_fx->hBWE_TD, st_fx->extl, st_fx->output_Fs ); - td_bwe_dec_init_fx( st_fx->hBWE_TD, st_fx->extl, st_fx->output_Fs ); + st_fx->prev_Q_bwe_exc = 31; + move16(); + } + ELSE + { + st_fx->hBWE_TD = NULL; + } - st_fx->prev_Q_bwe_exc = 31; + st_fx->old_bwe_delay = -1; /*Q0*/ move16(); - } - ELSE - { - st_fx->hBWE_TD = NULL; - } + set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS ) ); - st_fx->old_bwe_delay = -1; /*Q0*/ - move16(); - set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS ) ); + /*-----------------------------------------------------------------* + * SWB BWE parameters + *-----------------------------------------------------------------*/ + test(); + IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); + } - /*-----------------------------------------------------------------* - * SWB BWE parameters - *-----------------------------------------------------------------*/ - test(); - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) + fd_bwe_dec_init_fx( st_fx->hBWE_FD ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); + st_fx->hBWE_FD = NULL; } - fd_bwe_dec_init_fx( st_fx->hBWE_FD ); - } - ELSE - { - st_fx->hBWE_FD = NULL; - } + /*-----------------------------------------------------------------* + * WB/SWB bandwidth switching parameters + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * WB/SWB bandwidth switching parameters - *-----------------------------------------------------------------*/ + st_fx->tilt_swb_fx = 0; // Q24 + move16(); + st_fx->prev_ener_shb_fx = 0; // Q1 + move16(); + st_fx->prev_enerLH_fx = 0; // Q1 + move16(); + st_fx->enerLH_fx = L_deposit_l( 0 ); + st_fx->enerLL_fx = L_deposit_l( 0 ); + st_fx->prev_enerLL_fx = 0; + move16(); + st_fx->prev_fractive = 0; + move16(); + st_fx->prev_bws_cnt = 0; + move16(); + st_fx->bws_cnt = N_WS2N_FRAMES; + move16(); + st_fx->bws_cnt1 = N_NS2W_FRAMES; + move16(); + st_fx->attenu_fx = 3277; // Q15 + move16(); + st_fx->last_inner_frame = L_FRAME8k; + move16(); - st_fx->tilt_swb_fx = 0; // Q24 - move16(); - st_fx->prev_ener_shb_fx = 0; // Q1 - move16(); - st_fx->prev_enerLH_fx = 0; // Q1 - move16(); - st_fx->enerLH_fx = L_deposit_l( 0 ); - st_fx->enerLL_fx = L_deposit_l( 0 ); - st_fx->prev_enerLL_fx = 0; - move16(); - st_fx->prev_fractive = 0; - move16(); - st_fx->prev_bws_cnt = 0; - move16(); - st_fx->bws_cnt = N_WS2N_FRAMES; - move16(); - st_fx->bws_cnt1 = N_NS2W_FRAMES; - move16(); - st_fx->attenu_fx = 3277; // Q15 - move16(); - st_fx->last_inner_frame = L_FRAME8k; - move16(); + /*-----------------------------------------------------------------* + * HR SWB BWE parameters + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * HR SWB BWE parameters - *-----------------------------------------------------------------*/ + IF( ( st_fx->element_mode == EVS_MONO ) ) + { + IF( ( st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE) malloc( sizeof( HR_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HR BWE\n" ) ); + } - IF( ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE) malloc( sizeof( HR_BWE_DEC_DATA ) ) ) == NULL ) + hr_bwe_dec_init( st_fx->hBWE_FD_HR ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HR BWE\n" ) ); + st_fx->hBWE_FD_HR = NULL; } - hr_bwe_dec_init( st_fx->hBWE_FD_HR ); - } - ELSE - { - st_fx->hBWE_FD_HR = NULL; - } + /*----------------------------------------------------------------------------------* + * AMR-WB IO mode parameters + *----------------------------------------------------------------------------------*/ + test(); + IF( st_fx->Opt_AMR_WB || ( st_fx->element_mode == EVS_MONO ) ) + { + IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); + } - /*----------------------------------------------------------------------------------* - * AMR-WB IO mode parameters - *----------------------------------------------------------------------------------*/ - test(); - IF( st_fx->Opt_AMR_WB || ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) + /* AMR-WB IO init */ + amr_wb_dec_init_fx( st_fx->hAmrwb_IO ); + + /* AMR-WB IO HF synth init */ + hf_synth_amr_wb_init_fx( st_fx->hAmrwb_IO ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); + st_fx->hAmrwb_IO = NULL; } - /* AMR-WB IO init */ - amr_wb_dec_init_fx( st_fx->hAmrwb_IO ); + /*-----------------------------------------------------------------* + * channel-aware mode parameters + *-----------------------------------------------------------------*/ - /* AMR-WB IO HF synth init */ - hf_synth_amr_wb_init_fx( st_fx->hAmrwb_IO ); - } - ELSE - { - st_fx->hAmrwb_IO = NULL; - } + set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k ); + st_fx->use_partial_copy = 0; + move16(); + st_fx->prev_use_partial_copy = 0; + move16(); + st_fx->rf_flag = 0; + move16(); + st_fx->rf_flag_last = 0; + move16(); + st_fx->prev_rf_frame_type = 0; + move16(); + st_fx->next_coder_type = 0; + move16(); + st_fx->rf_target_bits = 0; + move16(); + st_fx->rf_indx_nelp_fid = 0; + move16(); + st_fx->rf_indx_nelp_iG1 = 0; + move16(); + st_fx->rf_indx_nelp_iG2[0] = 0; + move16(); + st_fx->rf_indx_nelp_iG2[1] = 0; + move16(); + st_fx->rf_indx_tbeGainFr = 0; + move16(); - /*-----------------------------------------------------------------* - * channel-aware mode parameters - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * Bass post-filter parameters + *-----------------------------------------------------------------*/ - set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k ); - st_fx->use_partial_copy = 0; - move16(); - st_fx->prev_use_partial_copy = 0; - move16(); - st_fx->rf_flag = 0; - move16(); - st_fx->rf_flag_last = 0; - move16(); - st_fx->prev_rf_frame_type = 0; - move16(); - st_fx->next_coder_type = 0; - move16(); - st_fx->rf_target_bits = 0; - move16(); - st_fx->rf_indx_nelp_fid = 0; - move16(); - st_fx->rf_indx_nelp_iG1 = 0; - move16(); - st_fx->rf_indx_nelp_iG2[0] = 0; - move16(); - st_fx->rf_indx_nelp_iG2[1] = 0; - move16(); - st_fx->rf_indx_tbeGainFr = 0; - move16(); + st_fx->bpf_off = 0; + move16(); - /*-----------------------------------------------------------------* - * Bass post-filter parameters - *-----------------------------------------------------------------*/ + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF\n" ) ); + } - st_fx->bpf_off = 0; - move16(); + bass_psfilter_init_fx( st_fx->hBPF ); + } + ELSE + { + st_fx->hBPF = NULL; + } - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) + /*-----------------------------------------------------------------* + * FD BPF & resampling tools parameters + *-----------------------------------------------------------------*/ + + IF( st_fx->element_mode == EVS_MONO ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF\n" ) ); + /* open analysis for max. SR 48kHz */ + IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000 ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* open analysis BPF for max. SR 16kHz */ + IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000 ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* open synthesis for output SR */ + IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs ) ), IVAS_ERR_OK ) ) + { + return error; + } } + ELSE + { + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + /* open analysis for max. SR 48kHz */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* open analysis BPF for max. SR 16kHz */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE + { + st_fx->cldfbAna = NULL; + st_fx->cldfbBPF = NULL; + } - bass_psfilter_init_fx( st_fx->hBPF ); - } - ELSE - { - st_fx->hBPF = NULL; - } + /* open synthesis for output SR */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + { + return error; + } + } - /*-----------------------------------------------------------------* - * FD BPF & resampling tools parameters - *-----------------------------------------------------------------*/ + st_fx->cldfbSynHB = NULL; + st_fx->last_active_bandsToZero_bwdec = 0; + move16(); + st_fx->perc_bwddec = 0; + move16(); + st_fx->last_flag_filter_NB = 0; + move16(); + st_fx->active_frame_cnt_bwddec = 0; + move16(); + st_fx->total_frame_cnt_bwddec = 0; + move16(); + set16_fx( st_fx->flag_buffer, 0, 20 ); + st_fx->avg_nrg_LT = 0; + move32(); + + /*-----------------------------------------------------------------* + * Noise gate parameters + *-----------------------------------------------------------------*/ + + set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); + st_fx->old_Aq_12_8_fx[0] = ONE_IN_Q12; + move16(); + st_fx->Ng_ener_ST_fx = -13056; /*-51 IN Q8*/ + move16(); + st_fx->old_Es_pred_fx = 0; + move16(); + set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); + st_fx->old_Aq_12_8_fx[0] = 4096; /*1 in Q12*/ + move16(); + + /*-----------------------------------------------------------------* + * SC-VBR parameters + *-----------------------------------------------------------------*/ + + IF( st_fx->element_mode == EVS_MONO ) + { + IF( ( st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE) malloc( sizeof( SC_VBR_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); + } - IF( st_fx->element_mode == EVS_MONO ) - { - /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000 ) ), IVAS_ERR_OK ) ) + sc_vbr_dec_init( st_fx->hSC_VBR ); + } + ELSE { - return error; + st_fx->hSC_VBR = NULL; } - /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000 ) ), IVAS_ERR_OK ) ) + st_fx->last_ppp_mode_dec = 0; + move16(); + st_fx->old_ppp_mode = 0; + move16(); + st_fx->ppp_mode_dec = 0; + move16(); + st_fx->last_nelp_mode_dec = 0; + move16(); + st_fx->nelp_mode_dec = 0; + move16(); + st_fx->prev_gain_pit_dec_fx = 0; + move16(); + st_fx->prev_tilt_code_dec_fx = 0; + move16(); + st_fx->vbr_hw_BWE_disable_dec = 0; + move16(); + st_fx->last_vbr_hw_BWE_disable_dec = 0; + move16(); + + /*-----------------------------------------------------------------* + * TCX core + *-----------------------------------------------------------------*/ + + /* TCX-LTP */ + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { - return error; + IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); + } } - - /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs ) ), IVAS_ERR_OK ) ) + ELSE { - return error; + st_fx->hTcxLtpDec = NULL; } - } - ELSE - { - test(); + + /* TCX core */ test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) { - return error; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n" ) ); } - /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + set32_fx( st_fx->hTcxDec->FBTCXdelayBuf_32, 0, 111 ); + + st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ); + st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); + } + ELSE + { + st_fx->hTcxDec = NULL; + } + + /* TCX config. data structure */ + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) { - return error; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } + st_fx->hTcxCfg->tcx_mdct_window_length = L_FRAME32k / 2; + move16(); } ELSE { - st_fx->cldfbAna = NULL; - st_fx->cldfbBPF = NULL; + st_fx->hTcxCfg = NULL; } - /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + /* Tonal MDCT concealment data structure */ + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { - return error; + IF( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n" ) ); + } + } + ELSE + { + st_fx->hTonalMDCTConc = NULL; } - } - - st_fx->cldfbSynHB = NULL; - st_fx->last_active_bandsToZero_bwdec = 0; - move16(); - st_fx->perc_bwddec = 0; - move16(); - st_fx->last_flag_filter_NB = 0; - move16(); - st_fx->active_frame_cnt_bwddec = 0; - move16(); - st_fx->total_frame_cnt_bwddec = 0; - move16(); - set16_fx( st_fx->flag_buffer, 0, 20 ); - st_fx->avg_nrg_LT = 0; - move32(); - - /*-----------------------------------------------------------------* - * Noise gate parameters - *-----------------------------------------------------------------*/ - set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); - st_fx->old_Aq_12_8_fx[0] = ONE_IN_Q12; - move16(); - st_fx->Ng_ener_ST_fx = -13056; /*-51 IN Q8*/ - move16(); - st_fx->old_Es_pred_fx = 0; - move16(); - set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); - st_fx->old_Aq_12_8_fx[0] = 4096; /*1 in Q12*/ - move16(); + /*-----------------------------------------------------------------* + * IGF + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * SC-VBR parameters - *-----------------------------------------------------------------*/ + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) ); + } - IF( st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE) malloc( sizeof( SC_VBR_DEC_DATA ) ) ) == NULL ) + st_fx->igf = 0; + move16(); + init_igf_dec( st_fx->hIGFDec ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); + st_fx->hIGFDec = NULL; } - sc_vbr_dec_init( st_fx->hSC_VBR ); - } - ELSE - { - st_fx->hSC_VBR = NULL; - } - - st_fx->last_ppp_mode_dec = 0; - move16(); - st_fx->old_ppp_mode = 0; - move16(); - st_fx->ppp_mode_dec = 0; - move16(); - st_fx->last_nelp_mode_dec = 0; - move16(); - st_fx->nelp_mode_dec = 0; - move16(); - st_fx->prev_gain_pit_dec_fx = 0; - move16(); - st_fx->prev_tilt_code_dec_fx = 0; - move16(); - st_fx->vbr_hw_BWE_disable_dec = 0; - move16(); - st_fx->last_vbr_hw_BWE_disable_dec = 0; - move16(); - - /*-----------------------------------------------------------------* - * TCX core - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * Mode 2 initialization + *-----------------------------------------------------------------*/ - /* TCX-LTP */ - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) + IF( ( st_fx->element_mode == EVS_MONO ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); + IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PLC handle\n" ) ); + } } - } - ELSE - { - st_fx->hTcxLtpDec = NULL; - } - - /* TCX core */ - test(); - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n" ) ); + st_fx->hPlcInfo = NULL; } - set32_fx( st_fx->hTcxDec->FBTCXdelayBuf_32, 0, 111 ); - - st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ); - st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); - } - ELSE - { - st_fx->hTcxDec = NULL; - } - - /* TCX config. data structure */ - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) + IF( st_fx->element_mode == EVS_MONO ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); + IF( ( st_fx->hTECDec = (TEC_DEC_HANDLE) malloc( sizeof( TEC_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); + } } - st_fx->hTcxCfg->tcx_mdct_window_length = L_FRAME32k / 2; - move16(); - } - ELSE - { - st_fx->hTcxCfg = NULL; - } - - /* Tonal MDCT concealment data structure */ - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - IF( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n" ) ); + st_fx->hTECDec = NULL; } - } - ELSE - { - st_fx->hTonalMDCTConc = NULL; - } - - /*-----------------------------------------------------------------* - * IGF - *-----------------------------------------------------------------*/ - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) + /* Init Decoder */ + IF( st_fx->element_mode == EVS_MONO ) + { + open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth ); + } + ELSE { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) ); + Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); } - st_fx->igf = 0; + /* PLC mode initialization */ + st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; move16(); - init_igf_dec( st_fx->hIGFDec ); - } - ELSE - { - st_fx->hIGFDec = NULL; - } - /*-----------------------------------------------------------------* - * Mode 2 initialization - *-----------------------------------------------------------------*/ + /* Init bandwidth / frame_type */ + st_fx->m_frame_type = ACTIVE_FRAME; + move16(); + st_fx->m_old_frame_type = ACTIVE_FRAME; + move16(); - IF( ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL ) + IF( st_fx->element_mode == EVS_MONO ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PLC handle\n" ) ); + resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + } + ELSE + { + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + } } - } - ELSE - { - st_fx->hPlcInfo = NULL; - } - IF( st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hTECDec = (TEC_DEC_HANDLE) malloc( sizeof( TEC_DEC_DATA ) ) ) == NULL ) + /*-----------------------------------------------------------------* + * FD-CNG decoder + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); + /* Create FD_CNG instance */ + IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* Init FD-CNG */ +#ifdef FIX_2245_INIT_FD_CNG_EVS + initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); +#else + initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); +#endif + } + ELSE + { + st_fx->hFdCngDec = NULL; } - } - ELSE - { - st_fx->hTECDec = NULL; - } - /* Init Decoder */ - IF( st_fx->element_mode == EVS_MONO ) - { - open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth ); - } - ELSE - { - Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; + st_fx->cngTDLevel = 0; move16(); + st_fx->cngTDLevel_e = 0; move16(); + st_fx->lp_noise = -167772160l /*-20.f Q23*/; + move32(); + st_fx->force_lpd_reset = 0; move16(); + + + /*-----------------------------------------------------------------* + * initialzie Q values + *-----------------------------------------------------------------*/ + + st_fx->Q_syn2 = 0; move16(); + st_fx->Q_exc = 8; move16(); + st_fx->prev_Q_exc = 0; move16(); + st_fx->Q_syn = 0; move16(); + st_fx->prev_Q_syn = 0; move16(); - open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); - } - - /* PLC mode initialization */ - st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; - move16(); - - /* Init bandwidth / frame_type */ - st_fx->m_frame_type = ACTIVE_FRAME; - move16(); - st_fx->m_old_frame_type = ACTIVE_FRAME; - move16(); - IF( st_fx->element_mode == EVS_MONO ) - { - resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); - resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); - } - ELSE - { - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + FOR( i = 0; i < L_Q_MEM; i++ ) { - resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + st_fx->Q_subfr[i] = 8; + move16(); } - } - - /*-----------------------------------------------------------------* - * FD-CNG decoder - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) - { - /* Create FD_CNG instance */ - IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) ) - { - return error; - } + st_fx->prev_Q_exc_fr = 0; + move16(); + st_fx->prev_Q_syn_fr = 0; + move16(); - /* Init FD-CNG */ -#ifdef FIX_2245_INIT_FD_CNG_EVS - initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); -#else - initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); -#endif - } - ELSE - { - st_fx->hFdCngDec = NULL; - } + /*-----------------------------------------------------------------* + * IVAS parameters + *-----------------------------------------------------------------*/ - st_fx->cngTDLevel = 0; - move16(); - st_fx->cngTDLevel_e = 0; - move16(); - st_fx->lp_noise = -167772160l /*-20.f Q23*/; - move32(); - st_fx->force_lpd_reset = 0; - move16(); + st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ + move16(); + st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ + move16(); + st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ + move16(); + st_fx->cng_ism_flag = 0; + move16(); + return error; + } - /*-----------------------------------------------------------------* - * initialzie Q values - *-----------------------------------------------------------------*/ - st_fx->Q_syn2 = 0; - move16(); - st_fx->Q_exc = 8; - move16(); - st_fx->prev_Q_exc = 0; - move16(); - st_fx->Q_syn = 0; - move16(); - st_fx->prev_Q_syn = 0; - move16(); + /*----------------------------------------------------------------------* + * reset_preecho_dec() + * + * Initialization of static variables for pre-echo + *----------------------------------------------------------------------*/ - FOR( i = 0; i < L_Q_MEM; i++ ) + void reset_preecho_dec_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ + ) { - st_fx->Q_subfr[i] = 8; + hHQ_core->memfilt_lb_fx = 0; + move16(); + hHQ_core->mean_prev_hb_fx = L_deposit_l( 0 ); + hHQ_core->smoothmem_fx = 32767; + move16(); + hHQ_core->mean_prev_fx = L_deposit_l( 0 ); + hHQ_core->mean_prev_nc_fx = L_deposit_l( 0 ); + hHQ_core->wmold_hb_fx = 32767; + move16(); + hHQ_core->prevflag = 0; + move16(); + hHQ_core->pastpre = 0; move16(); - } - - st_fx->prev_Q_exc_fr = 0; - move16(); - st_fx->prev_Q_syn_fr = 0; - move16(); - - /*-----------------------------------------------------------------* - * IVAS parameters - *-----------------------------------------------------------------*/ - - st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ - move16(); - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - move16(); - st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ - move16(); - st_fx->cng_ism_flag = 0; - move16(); - - return error; -} - - -/*----------------------------------------------------------------------* - * reset_preecho_dec() - * - * Initialization of static variables for pre-echo - *----------------------------------------------------------------------*/ - -void reset_preecho_dec_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ -) -{ - hHQ_core->memfilt_lb_fx = 0; - move16(); - hHQ_core->mean_prev_hb_fx = L_deposit_l( 0 ); - hHQ_core->smoothmem_fx = 32767; - move16(); - hHQ_core->mean_prev_fx = L_deposit_l( 0 ); - hHQ_core->mean_prev_nc_fx = L_deposit_l( 0 ); - hHQ_core->wmold_hb_fx = 32767; - move16(); - hHQ_core->prevflag = 0; - move16(); - hHQ_core->pastpre = 0; - move16(); - return; -} + return; + } -/*----------------------------------------------------------------------* - * destroy_cldfb_decoder_fx() - * - * Free memory which was allocated in init_decoder() - *----------------------------------------------------------------------*/ + /*----------------------------------------------------------------------* + * destroy_cldfb_decoder_fx() + * + * Free memory which was allocated in init_decoder() + *----------------------------------------------------------------------*/ -void destroy_cldfb_decoder_fx( - Decoder_State *st_fx /* o: Decoder static variables structure */ -) -{ - /* CLDFB BPF & resampling tools */ - deleteCldfb_fx( &st_fx->cldfbAna ); /* delete analysis for max. SR 16kHz */ - deleteCldfb_fx( &st_fx->cldfbBPF ); /* delete analysis BPF for max. SR 16kHz */ - deleteCldfb_fx( &st_fx->cldfbSyn ); /* delete synthesis for output SR */ - deleteCldfb_fx( &st_fx->cldfbSynHB ); + void destroy_cldfb_decoder_fx( + Decoder_State * st_fx /* o: Decoder static variables structure */ + ) + { + /* CLDFB BPF & resampling tools */ + deleteCldfb_fx( &st_fx->cldfbAna ); /* delete analysis for max. SR 16kHz */ + deleteCldfb_fx( &st_fx->cldfbBPF ); /* delete analysis BPF for max. SR 16kHz */ + deleteCldfb_fx( &st_fx->cldfbSyn ); /* delete synthesis for output SR */ + deleteCldfb_fx( &st_fx->cldfbSynHB ); - deleteFdCngDec_fx( &st_fx->hFdCngDec ); + deleteFdCngDec_fx( &st_fx->hFdCngDec ); - return; -} + return; + } -- GitLab From 1f8dfc0fb3aab00b97beb61fbdac41c070be2949 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 5 Dec 2025 21:52:25 +0100 Subject: [PATCH 146/750] clang-format --- lib_dec/init_dec_fx.c | 1548 ++++++++++++++++++++--------------------- 1 file changed, 774 insertions(+), 774 deletions(-) diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 65b2ea925..763b581ad 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -113,953 +113,953 @@ ivas_error init_decoder_fx( move16(); } #else - st_fx->bwidth = NB; - move16(); - st_fx->last_bwidth = NB; - move16(); + st_fx->bwidth = NB; + move16(); + st_fx->last_bwidth = NB; + move16(); #endif - st_fx->extl_brate = 0; - move16(); + st_fx->extl_brate = 0; + move16(); - st_fx->coder_type = GENERIC; /* low-rate mode flag */ - move16(); - st_fx->last_coder_type = GENERIC; - move16(); - st_fx->inactive_coder_type_flag = 0; - move16(); - st_fx->last_L_frame = st_fx->L_frame; - move16(); - st_fx->last_core_brate = st_fx->core_brate; - move16(); - st_fx->last_core = -1; - move16(); - st_fx->last_extl = st_fx->extl; - move16(); + st_fx->coder_type = GENERIC; /* low-rate mode flag */ + move16(); + st_fx->last_coder_type = GENERIC; + move16(); + st_fx->inactive_coder_type_flag = 0; + move16(); + st_fx->last_L_frame = st_fx->L_frame; + move16(); + st_fx->last_core_brate = st_fx->core_brate; + move16(); + st_fx->last_core = -1; + move16(); + st_fx->last_extl = st_fx->extl; + move16(); - st_fx->flag_ACELP16k = set_ACELP_flag( st_fx->element_mode, st_fx->total_brate, st_fx->total_brate, idchan, 0, -1, -1 ); - move16(); + st_fx->flag_ACELP16k = set_ACELP_flag( st_fx->element_mode, st_fx->total_brate, st_fx->total_brate, idchan, 0, -1, -1 ); + move16(); - /*-----------------------------------------------------------------* - * ACELP core parameters - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * ACELP core parameters + *-----------------------------------------------------------------*/ - /* LSF initilaizations */ - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); + /* LSF initilaizations */ + Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); + init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); - set16_fx( st_fx->mem_MA_fx, 0, M ); + set16_fx( st_fx->mem_MA_fx, 0, M ); - st_fx->dm_fx.prev_state = 0; /* This corresponds to st_fx->dispMem in FLP */ - move16(); - st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); - FOR( i = 2; i < 8; i++ ) - { - st_fx->dm_fx.prev_gain_pit[i - 2] = 0; - move16(); - } - st_fx->tilt_code_fx = 0; - move16(); - st_fx->gc_threshold_fx = 0; - move32(); - st_fx->last_good = UNVOICED_CLAS; - move16(); - st_fx->clas_dec = UNVOICED_CLAS; - move16(); - st_fx->low_rate_mode = 0; /* low-rate mode flag */ - move16(); - st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ - move16(); - st_fx->lp_gainp_fx = 0; - move16(); - st_fx->lp_gainc_fx = 0; + st_fx->dm_fx.prev_state = 0; /* This corresponds to st_fx->dispMem in FLP */ + move16(); + st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); + FOR( i = 2; i < 8; i++ ) + { + st_fx->dm_fx.prev_gain_pit[i - 2] = 0; move16(); + } + st_fx->tilt_code_fx = 0; + move16(); + st_fx->gc_threshold_fx = 0; + move32(); + st_fx->last_good = UNVOICED_CLAS; + move16(); + st_fx->clas_dec = UNVOICED_CLAS; + move16(); + st_fx->low_rate_mode = 0; /* low-rate mode flag */ + move16(); + st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ + move16(); + st_fx->lp_gainp_fx = 0; + move16(); + st_fx->lp_gainc_fx = 0; + move16(); - set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); - - /* AVQ pre-quantizer memory */ - st_fx->mem_preemp_preQ_fx = 0; - move16(); - st_fx->last_nq_preQ = 0; - move16(); - st_fx->use_acelp_preq = 0; - move16(); + set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); - st_fx->mem_deemph_fx = 0; - move16(); + /* AVQ pre-quantizer memory */ + st_fx->mem_preemp_preQ_fx = 0; + move16(); + st_fx->last_nq_preQ = 0; + move16(); + st_fx->use_acelp_preq = 0; + move16(); - set16_fx( st_fx->mem_syn1_fx, 0, M ); - set16_fx( st_fx->mem_syn2_fx, 0, M ); - st_fx->stab_fac_fx = 0; - move16(); - st_fx->stab_fac_smooth_fx = 0; - move16(); - set16_fx( st_fx->agc_mem_fx, 0, 2 ); - set16_fx( st_fx->mem_syn3_fx, 0, M ); + st_fx->mem_deemph_fx = 0; + move16(); - st_fx->stab_fac_smooth_lt_fx = 0; - move16(); - st_fx->log_energy_diff_lt_fx = 0; - move32(); - st_fx->log_energy_old_fx = 0; - move32(); + set16_fx( st_fx->mem_syn1_fx, 0, M ); + set16_fx( st_fx->mem_syn2_fx, 0, M ); + st_fx->stab_fac_fx = 0; + move16(); + st_fx->stab_fac_smooth_fx = 0; + move16(); + set16_fx( st_fx->agc_mem_fx, 0, 2 ); + set16_fx( st_fx->mem_syn3_fx, 0, M ); - Copy( GEWB_Ave_fx, st_fx->lsf_old_fx, M ); - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_12k8 ); + st_fx->stab_fac_smooth_lt_fx = 0; + move16(); + st_fx->log_energy_diff_lt_fx = 0; + move32(); + st_fx->log_energy_old_fx = 0; + move32(); - st_fx->mid_lsf_int = 0; - move16(); - st_fx->safety_net = 0; - move16(); + Copy( GEWB_Ave_fx, st_fx->lsf_old_fx, M ); + lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_12k8 ); - /* FEC */ - st_fx->scaling_flag = 0; - move16(); - st_fx->lp_ener_FEC_av = 500000; - move32(); - st_fx->lp_ener_FEC_max = 500000; - move32(); - st_fx->prev_bfi = 0; - move16(); - st_fx->lp_ener_FER_fx = 15360; /*60 in Q8*/ - move16(); - st_fx->old_enr_LP = 0; - move16(); - st_fx->lp_ener_fx = L_deposit_l( 0 ); - st_fx->enr_old_fx = L_deposit_l( 0 ); - st_fx->bfi_pitch_fx = L_SUBFR_Q6; - move16(); - st_fx->bfi_pitch_frame = L_FRAME; - move16(); - set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); - st_fx->classifier_Q_mem_syn = 0; - move16(); - st_fx->last_con_tcx = 0; - move16(); + st_fx->mid_lsf_int = 0; + move16(); + st_fx->safety_net = 0; + move16(); - FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) - { - st_fx->old_pitch_buf_fx[i] = L_SUBFR << 16; /*15Q16*/ - move32(); - } + /* FEC */ + st_fx->scaling_flag = 0; + move16(); + st_fx->lp_ener_FEC_av = 500000; + move32(); + st_fx->lp_ener_FEC_max = 500000; + move32(); + st_fx->prev_bfi = 0; + move16(); + st_fx->lp_ener_FER_fx = 15360; /*60 in Q8*/ + move16(); + st_fx->old_enr_LP = 0; + move16(); + st_fx->lp_ener_fx = L_deposit_l( 0 ); + st_fx->enr_old_fx = L_deposit_l( 0 ); + st_fx->bfi_pitch_fx = L_SUBFR_Q6; + move16(); + st_fx->bfi_pitch_frame = L_FRAME; + move16(); + set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); + st_fx->classifier_Q_mem_syn = 0; + move16(); + st_fx->last_con_tcx = 0; + move16(); - st_fx->upd_cnt = MAX_UPD_CNT; - move16(); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); + FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) + { + st_fx->old_pitch_buf_fx[i] = L_SUBFR << 16; /*15Q16*/ + move32(); + } - st_fx->seed_acelp = RANDOM_INITSEED; - move16(); - st_fx->seed = RANDOM_INITSEED; - move16(); - st_fx->nbLostCmpt = 0; - move16(); - st_fx->decision_hyst = 0; - move16(); - st_fx->unv_cnt = 0; - move16(); - st_fx->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ - st_fx->uv_count = 0; - move16(); - st_fx->act_count = 3; - move16(); - Copy( st_fx->lsp_old_fx, st_fx->lspold_s_fx, M ); - st_fx->noimix_seed = RANDOM_INITSEED; - move16(); - st_fx->min_alpha_fx = 32767; /*1; Q15*/ - move16(); - st_fx->exc_pe_fx = 0; - move16(); - st_fx->Q_stat_noise = 31; - move16(); - st_fx->prev_coder_type = GENERIC; - move16(); + st_fx->upd_cnt = MAX_UPD_CNT; + move16(); + Copy( GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); + Copy( GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); + Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); - st_fx->tilt_wb_fx = 0; // Q11 - move16(); + st_fx->seed_acelp = RANDOM_INITSEED; + move16(); + st_fx->seed = RANDOM_INITSEED; + move16(); + st_fx->nbLostCmpt = 0; + move16(); + st_fx->decision_hyst = 0; + move16(); + st_fx->unv_cnt = 0; + move16(); + st_fx->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ + st_fx->uv_count = 0; + move16(); + st_fx->act_count = 3; + move16(); + Copy( st_fx->lsp_old_fx, st_fx->lspold_s_fx, M ); + st_fx->noimix_seed = RANDOM_INITSEED; + move16(); + st_fx->min_alpha_fx = 32767; /*1; Q15*/ + move16(); + st_fx->exc_pe_fx = 0; + move16(); + st_fx->Q_stat_noise = 31; + move16(); + st_fx->prev_coder_type = GENERIC; + move16(); - st_fx->last_voice_factor_fx = 0; - move16(); + st_fx->tilt_wb_fx = 0; // Q11 + move16(); - set16_fx( st_fx->prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); - st_fx->Qprev_synth_buffer_fx = 15; - move16(); - set32_fx( st_fx->prev_synth_buffer32_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); + st_fx->last_voice_factor_fx = 0; + move16(); - st_fx->old_bfi_cnt = 0; - move16(); + set16_fx( st_fx->prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); + st_fx->Qprev_synth_buffer_fx = 15; + move16(); + set32_fx( st_fx->prev_synth_buffer32_fx, 0, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); - /*-----------------------------------------------------------------* - * parameters for AC mode (GSC) - *-----------------------------------------------------------------*/ + st_fx->old_bfi_cnt = 0; + move16(); - st_fx->GSC_noisy_speech = 0; - move16(); - st_fx->GSC_IVAS_mode = 0; - move16(); - st_fx->Last_GSC_noisy_speech_flag = 0; - move16(); + /*-----------------------------------------------------------------* + * parameters for AC mode (GSC) + *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); - } + st_fx->GSC_noisy_speech = 0; + move16(); + st_fx->GSC_IVAS_mode = 0; + move16(); + st_fx->Last_GSC_noisy_speech_flag = 0; + move16(); - GSC_dec_init_fx( st_fx->hGSCDec ); - } - ELSE + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) { - st_fx->hGSCDec = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); } - /*-----------------------------------------------------------------* - * parameters for fast recovery (WI) - *-----------------------------------------------------------------*/ + GSC_dec_init_fx( st_fx->hGSCDec ); + } + ELSE + { + st_fx->hGSCDec = NULL; + } - test(); - IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FEC WI\n" ) ); - } - set16_fx( st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM ); - set16_fx( st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM ); - } - ELSE + /*-----------------------------------------------------------------* + * parameters for fast recovery (WI) + *-----------------------------------------------------------------*/ + + test(); + IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) ) + { + IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) { - st_fx->hWIDec = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FEC WI\n" ) ); } + set16_fx( st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM ); + set16_fx( st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM ); + } + ELSE + { + st_fx->hWIDec = NULL; + } - /*-----------------------------------------------------------------* - * NB/formant post-filter - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) malloc( sizeof( PFSTAT ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); - } + /*-----------------------------------------------------------------* + * NB/formant post-filter + *-----------------------------------------------------------------*/ - Init_post_filter_fx( st_fx->hPFstat ); - st_fx->psf_lp_noise_fx = 0; - move16(); - } - ELSE + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) malloc( sizeof( PFSTAT ) ) ) == NULL ) { - st_fx->hPFstat = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); } - /*-----------------------------------------------------------------* - * HF (6-7kHz) (zero) BWE parameters - *-----------------------------------------------------------------*/ + Init_post_filter_fx( st_fx->hPFstat ); + st_fx->psf_lp_noise_fx = 0; + move16(); + } + ELSE + { + st_fx->hPFstat = NULL; + } - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for zero BWE\n" ) ); - } + /*-----------------------------------------------------------------* + * HF (6-7kHz) (zero) BWE parameters + *-----------------------------------------------------------------*/ - hf_synth_init_fx( st_fx->hBWE_zero ); - set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); - } - ELSE + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) { - st_fx->hBWE_zero = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for zero BWE\n" ) ); } - /*-----------------------------------------------------------------* - * LD music post-filter - *-----------------------------------------------------------------*/ + hf_synth_init_fx( st_fx->hBWE_zero ); + set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); + } + ELSE + { + st_fx->hBWE_zero = NULL; + } - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LD music postflter\n" ) ); - } + /*-----------------------------------------------------------------* + * LD music post-filter + *-----------------------------------------------------------------*/ - music_postfilt_init( st_fx->hMusicPF ); - } - ELSE + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) { - st_fx->hMusicPF = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LD music postflter\n" ) ); } - /*-----------------------------------------------------------------* - * CNG and DTX - *-----------------------------------------------------------------*/ + music_postfilt_init( st_fx->hMusicPF ); + } + ELSE + { + st_fx->hMusicPF = NULL; + } - st_fx->first_CNG = 0; - move16(); - st_fx->cng_type = -1; - move16(); - st_fx->last_active_brate = ACELP_7k20; - move32(); - st_fx->last_CNG_L_frame = L_FRAME; - move16(); - st_fx->last_vad_fx = 0; - move16(); - st_fx->active_cnt = CNG_TYPE_HO; - move16(); + /*-----------------------------------------------------------------* + * CNG and DTX + *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( idchan == 0 && ( ( st_fx->element_mode == EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) - { - IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); - } + st_fx->first_CNG = 0; + move16(); + st_fx->cng_type = -1; + move16(); + st_fx->last_active_brate = ACELP_7k20; + move32(); + st_fx->last_CNG_L_frame = L_FRAME; + move16(); + st_fx->last_vad_fx = 0; + move16(); + st_fx->active_cnt = CNG_TYPE_HO; + move16(); - td_cng_dec_init_fx( st_fx ); - } - ELSE + test(); + test(); + test(); + IF( idchan == 0 && ( ( st_fx->element_mode == EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) + { + IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) { - st_fx->hTdCngDec = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - st_fx->masa_sid_format = 0; - move16(); - st_fx->Q_stat_noise_ge = GE_SHIFT; - move16(); - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ - - st_fx->prev_old_bfi = 0; - move16(); + td_cng_dec_init_fx( st_fx ); + } + ELSE + { + st_fx->hTdCngDec = NULL; + } - set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); - set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); + st_fx->masa_sid_format = 0; + move16(); + st_fx->Q_stat_noise_ge = GE_SHIFT; + move16(); - set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); - set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k ); + /*-----------------------------------------------------------------* + * HQ core parameters + *-----------------------------------------------------------------*/ - IF( st_fx->element_mode == EVS_MONO ) - { - set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); - } + st_fx->prev_old_bfi = 0; + move16(); - test(); - test(); - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) - { - IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); - } + set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); + set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); - /* HQ core initialization */ - HQ_core_dec_init_fx( st_fx->hHQ_core ); + set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); + set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k ); - IF( st_fx->element_mode == EVS_MONO ) - { - /* HQ NB FEC initialization */ - IF( ( st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE) malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n" ) ); - } + IF( st_fx->element_mode == EVS_MONO ) + { + set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); + } - HQ_nbfec_init_fx( st_fx->hHQ_nbfec ); - } - ELSE - { - st_fx->hHQ_nbfec = NULL; - } - } - ELSE + test(); + test(); + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) + { + IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { - st_fx->hHQ_core = NULL; - st_fx->hHQ_nbfec = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); } - /*-----------------------------------------------------------------* - * TBE parameters - *-----------------------------------------------------------------*/ + /* HQ core initialization */ + HQ_core_dec_init_fx( st_fx->hHQ_core ); - test(); - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( st_fx->element_mode == EVS_MONO ) { - IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + /* HQ NB FEC initialization */ + IF( ( st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE) malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n" ) ); } - td_bwe_dec_init_fx( st_fx->hBWE_TD, st_fx->extl, st_fx->output_Fs ); - - st_fx->prev_Q_bwe_exc = 31; - move16(); + HQ_nbfec_init_fx( st_fx->hHQ_nbfec ); } ELSE { - st_fx->hBWE_TD = NULL; + st_fx->hHQ_nbfec = NULL; } + } + ELSE + { + st_fx->hHQ_core = NULL; + st_fx->hHQ_nbfec = NULL; + } - st_fx->old_bwe_delay = -1; /*Q0*/ - move16(); - set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS ) ); - - /*-----------------------------------------------------------------* - * SWB BWE parameters - *-----------------------------------------------------------------*/ - test(); - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); - } + /*-----------------------------------------------------------------* + * TBE parameters + *-----------------------------------------------------------------*/ - fd_bwe_dec_init_fx( st_fx->hBWE_FD ); - } - ELSE + test(); + IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) { - st_fx->hBWE_FD = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - /*-----------------------------------------------------------------* - * WB/SWB bandwidth switching parameters - *-----------------------------------------------------------------*/ + td_bwe_dec_init_fx( st_fx->hBWE_TD, st_fx->extl, st_fx->output_Fs ); - st_fx->tilt_swb_fx = 0; // Q24 - move16(); - st_fx->prev_ener_shb_fx = 0; // Q1 - move16(); - st_fx->prev_enerLH_fx = 0; // Q1 + st_fx->prev_Q_bwe_exc = 31; move16(); - st_fx->enerLH_fx = L_deposit_l( 0 ); - st_fx->enerLL_fx = L_deposit_l( 0 ); - st_fx->prev_enerLL_fx = 0; - move16(); - st_fx->prev_fractive = 0; - move16(); - st_fx->prev_bws_cnt = 0; - move16(); - st_fx->bws_cnt = N_WS2N_FRAMES; - move16(); - st_fx->bws_cnt1 = N_NS2W_FRAMES; - move16(); - st_fx->attenu_fx = 3277; // Q15 - move16(); - st_fx->last_inner_frame = L_FRAME8k; - move16(); - - /*-----------------------------------------------------------------* - * HR SWB BWE parameters - *-----------------------------------------------------------------*/ - - IF( ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE) malloc( sizeof( HR_BWE_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HR BWE\n" ) ); - } - - hr_bwe_dec_init( st_fx->hBWE_FD_HR ); - } - ELSE - { - st_fx->hBWE_FD_HR = NULL; - } - - /*----------------------------------------------------------------------------------* - * AMR-WB IO mode parameters - *----------------------------------------------------------------------------------*/ - test(); - IF( st_fx->Opt_AMR_WB || ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); - } + } + ELSE + { + st_fx->hBWE_TD = NULL; + } - /* AMR-WB IO init */ - amr_wb_dec_init_fx( st_fx->hAmrwb_IO ); + st_fx->old_bwe_delay = -1; /*Q0*/ + move16(); + set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS ) ); - /* AMR-WB IO HF synth init */ - hf_synth_amr_wb_init_fx( st_fx->hAmrwb_IO ); - } - ELSE + /*-----------------------------------------------------------------* + * SWB BWE parameters + *-----------------------------------------------------------------*/ + test(); + IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) { - st_fx->hAmrwb_IO = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); } - /*-----------------------------------------------------------------* - * channel-aware mode parameters - *-----------------------------------------------------------------*/ - - set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k ); - st_fx->use_partial_copy = 0; - move16(); - st_fx->prev_use_partial_copy = 0; - move16(); - st_fx->rf_flag = 0; - move16(); - st_fx->rf_flag_last = 0; - move16(); - st_fx->prev_rf_frame_type = 0; - move16(); - st_fx->next_coder_type = 0; - move16(); - st_fx->rf_target_bits = 0; - move16(); - st_fx->rf_indx_nelp_fid = 0; - move16(); - st_fx->rf_indx_nelp_iG1 = 0; - move16(); - st_fx->rf_indx_nelp_iG2[0] = 0; - move16(); - st_fx->rf_indx_nelp_iG2[1] = 0; - move16(); - st_fx->rf_indx_tbeGainFr = 0; - move16(); + fd_bwe_dec_init_fx( st_fx->hBWE_FD ); + } + ELSE + { + st_fx->hBWE_FD = NULL; + } - /*-----------------------------------------------------------------* - * Bass post-filter parameters - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * WB/SWB bandwidth switching parameters + *-----------------------------------------------------------------*/ - st_fx->bpf_off = 0; - move16(); + st_fx->tilt_swb_fx = 0; // Q24 + move16(); + st_fx->prev_ener_shb_fx = 0; // Q1 + move16(); + st_fx->prev_enerLH_fx = 0; // Q1 + move16(); + st_fx->enerLH_fx = L_deposit_l( 0 ); + st_fx->enerLL_fx = L_deposit_l( 0 ); + st_fx->prev_enerLL_fx = 0; + move16(); + st_fx->prev_fractive = 0; + move16(); + st_fx->prev_bws_cnt = 0; + move16(); + st_fx->bws_cnt = N_WS2N_FRAMES; + move16(); + st_fx->bws_cnt1 = N_NS2W_FRAMES; + move16(); + st_fx->attenu_fx = 3277; // Q15 + move16(); + st_fx->last_inner_frame = L_FRAME8k; + move16(); - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF\n" ) ); - } + /*-----------------------------------------------------------------* + * HR SWB BWE parameters + *-----------------------------------------------------------------*/ - bass_psfilter_init_fx( st_fx->hBPF ); - } - ELSE + IF( ( st_fx->element_mode == EVS_MONO ) ) + { + IF( ( st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE) malloc( sizeof( HR_BWE_DEC_DATA ) ) ) == NULL ) { - st_fx->hBPF = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HR BWE\n" ) ); } - /*-----------------------------------------------------------------* - * FD BPF & resampling tools parameters - *-----------------------------------------------------------------*/ - - IF( st_fx->element_mode == EVS_MONO ) - { - /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000 ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000 ) ), IVAS_ERR_OK ) ) - { - return error; - } + hr_bwe_dec_init( st_fx->hBWE_FD_HR ); + } + ELSE + { + st_fx->hBWE_FD_HR = NULL; + } - /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE + /*----------------------------------------------------------------------------------* + * AMR-WB IO mode parameters + *----------------------------------------------------------------------------------*/ + test(); + IF( st_fx->Opt_AMR_WB || ( st_fx->element_mode == EVS_MONO ) ) + { + IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) { - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE - { - st_fx->cldfbAna = NULL; - st_fx->cldfbBPF = NULL; - } - - /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) - { - return error; - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); } - st_fx->cldfbSynHB = NULL; - st_fx->last_active_bandsToZero_bwdec = 0; - move16(); - st_fx->perc_bwddec = 0; - move16(); - st_fx->last_flag_filter_NB = 0; - move16(); - st_fx->active_frame_cnt_bwddec = 0; - move16(); - st_fx->total_frame_cnt_bwddec = 0; - move16(); - set16_fx( st_fx->flag_buffer, 0, 20 ); - st_fx->avg_nrg_LT = 0; - move32(); - - /*-----------------------------------------------------------------* - * Noise gate parameters - *-----------------------------------------------------------------*/ + /* AMR-WB IO init */ + amr_wb_dec_init_fx( st_fx->hAmrwb_IO ); - set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); - st_fx->old_Aq_12_8_fx[0] = ONE_IN_Q12; - move16(); - st_fx->Ng_ener_ST_fx = -13056; /*-51 IN Q8*/ - move16(); - st_fx->old_Es_pred_fx = 0; - move16(); - set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); - st_fx->old_Aq_12_8_fx[0] = 4096; /*1 in Q12*/ - move16(); - - /*-----------------------------------------------------------------* - * SC-VBR parameters - *-----------------------------------------------------------------*/ + /* AMR-WB IO HF synth init */ + hf_synth_amr_wb_init_fx( st_fx->hAmrwb_IO ); + } + ELSE + { + st_fx->hAmrwb_IO = NULL; + } - IF( st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE) malloc( sizeof( SC_VBR_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); - } + /*-----------------------------------------------------------------* + * channel-aware mode parameters + *-----------------------------------------------------------------*/ - sc_vbr_dec_init( st_fx->hSC_VBR ); - } - ELSE - { - st_fx->hSC_VBR = NULL; - } + set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k ); + st_fx->use_partial_copy = 0; + move16(); + st_fx->prev_use_partial_copy = 0; + move16(); + st_fx->rf_flag = 0; + move16(); + st_fx->rf_flag_last = 0; + move16(); + st_fx->prev_rf_frame_type = 0; + move16(); + st_fx->next_coder_type = 0; + move16(); + st_fx->rf_target_bits = 0; + move16(); + st_fx->rf_indx_nelp_fid = 0; + move16(); + st_fx->rf_indx_nelp_iG1 = 0; + move16(); + st_fx->rf_indx_nelp_iG2[0] = 0; + move16(); + st_fx->rf_indx_nelp_iG2[1] = 0; + move16(); + st_fx->rf_indx_tbeGainFr = 0; + move16(); - st_fx->last_ppp_mode_dec = 0; - move16(); - st_fx->old_ppp_mode = 0; - move16(); - st_fx->ppp_mode_dec = 0; - move16(); - st_fx->last_nelp_mode_dec = 0; - move16(); - st_fx->nelp_mode_dec = 0; - move16(); - st_fx->prev_gain_pit_dec_fx = 0; - move16(); - st_fx->prev_tilt_code_dec_fx = 0; - move16(); - st_fx->vbr_hw_BWE_disable_dec = 0; - move16(); - st_fx->last_vbr_hw_BWE_disable_dec = 0; - move16(); + /*-----------------------------------------------------------------* + * Bass post-filter parameters + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * TCX core - *-----------------------------------------------------------------*/ + st_fx->bpf_off = 0; + move16(); - /* TCX-LTP */ - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); - } - } - ELSE + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) { - st_fx->hTcxLtpDec = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF\n" ) ); } - /* TCX core */ - test(); - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n" ) ); - } + bass_psfilter_init_fx( st_fx->hBPF ); + } + ELSE + { + st_fx->hBPF = NULL; + } - set32_fx( st_fx->hTcxDec->FBTCXdelayBuf_32, 0, 111 ); + /*-----------------------------------------------------------------* + * FD BPF & resampling tools parameters + *-----------------------------------------------------------------*/ - st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ); - st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); - } - ELSE + IF( st_fx->element_mode == EVS_MONO ) + { + /* open analysis for max. SR 48kHz */ + IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000 ) ), IVAS_ERR_OK ) ) { - st_fx->hTcxDec = NULL; + return error; } - /* TCX config. data structure */ - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + /* open analysis BPF for max. SR 16kHz */ + IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000 ) ), IVAS_ERR_OK ) ) { - IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); - } - st_fx->hTcxCfg->tcx_mdct_window_length = L_FRAME32k / 2; - move16(); - } - ELSE - { - st_fx->hTcxCfg = NULL; + return error; } - /* Tonal MDCT concealment data structure */ - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - IF( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n" ) ); - } - } - ELSE + /* open synthesis for output SR */ + IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs ) ), IVAS_ERR_OK ) ) { - st_fx->hTonalMDCTConc = NULL; + return error; } - - /*-----------------------------------------------------------------* - * IGF - *-----------------------------------------------------------------*/ - + } + ELSE + { test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) + /* open analysis for max. SR 48kHz */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) ); + return error; } - st_fx->igf = 0; - move16(); - init_igf_dec( st_fx->hIGFDec ); - } - ELSE - { - st_fx->hIGFDec = NULL; - } - - /*-----------------------------------------------------------------* - * Mode 2 initialization - *-----------------------------------------------------------------*/ - - IF( ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL ) + /* open analysis BPF for max. SR 16kHz */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PLC handle\n" ) ); + return error; } } ELSE { - st_fx->hPlcInfo = NULL; + st_fx->cldfbAna = NULL; + st_fx->cldfbBPF = NULL; } - IF( st_fx->element_mode == EVS_MONO ) + /* open synthesis for output SR */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { - IF( ( st_fx->hTECDec = (TEC_DEC_HANDLE) malloc( sizeof( TEC_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); - } + return error; } - ELSE + } + + st_fx->cldfbSynHB = NULL; + st_fx->last_active_bandsToZero_bwdec = 0; + move16(); + st_fx->perc_bwddec = 0; + move16(); + st_fx->last_flag_filter_NB = 0; + move16(); + st_fx->active_frame_cnt_bwddec = 0; + move16(); + st_fx->total_frame_cnt_bwddec = 0; + move16(); + set16_fx( st_fx->flag_buffer, 0, 20 ); + st_fx->avg_nrg_LT = 0; + move32(); + + /*-----------------------------------------------------------------* + * Noise gate parameters + *-----------------------------------------------------------------*/ + + set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); + st_fx->old_Aq_12_8_fx[0] = ONE_IN_Q12; + move16(); + st_fx->Ng_ener_ST_fx = -13056; /*-51 IN Q8*/ + move16(); + st_fx->old_Es_pred_fx = 0; + move16(); + set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); + st_fx->old_Aq_12_8_fx[0] = 4096; /*1 in Q12*/ + move16(); + + /*-----------------------------------------------------------------* + * SC-VBR parameters + *-----------------------------------------------------------------*/ + + IF( st_fx->element_mode == EVS_MONO ) + { + IF( ( st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE) malloc( sizeof( SC_VBR_DEC_DATA ) ) ) == NULL ) { - st_fx->hTECDec = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); } - /* Init Decoder */ - IF( st_fx->element_mode == EVS_MONO ) + sc_vbr_dec_init( st_fx->hSC_VBR ); + } + ELSE + { + st_fx->hSC_VBR = NULL; + } + + st_fx->last_ppp_mode_dec = 0; + move16(); + st_fx->old_ppp_mode = 0; + move16(); + st_fx->ppp_mode_dec = 0; + move16(); + st_fx->last_nelp_mode_dec = 0; + move16(); + st_fx->nelp_mode_dec = 0; + move16(); + st_fx->prev_gain_pit_dec_fx = 0; + move16(); + st_fx->prev_tilt_code_dec_fx = 0; + move16(); + st_fx->vbr_hw_BWE_disable_dec = 0; + move16(); + st_fx->last_vbr_hw_BWE_disable_dec = 0; + move16(); + + /*-----------------------------------------------------------------* + * TCX core + *-----------------------------------------------------------------*/ + + /* TCX-LTP */ + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) { - open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); } - ELSE + } + ELSE + { + st_fx->hTcxLtpDec = NULL; + } + + /* TCX core */ + test(); + IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) { - Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n" ) ); } - /* PLC mode initialization */ - st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; - move16(); + set32_fx( st_fx->hTcxDec->FBTCXdelayBuf_32, 0, 111 ); - /* Init bandwidth / frame_type */ - st_fx->m_frame_type = ACTIVE_FRAME; - move16(); - st_fx->m_old_frame_type = ACTIVE_FRAME; - move16(); + st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ); + st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); + } + ELSE + { + st_fx->hTcxDec = NULL; + } - IF( st_fx->element_mode == EVS_MONO ) + /* TCX config. data structure */ + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) { - resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); - resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } - ELSE + st_fx->hTcxCfg->tcx_mdct_window_length = L_FRAME32k / 2; + move16(); + } + ELSE + { + st_fx->hTcxCfg = NULL; + } + + /* Tonal MDCT concealment data structure */ + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) { - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n" ) ); } + } + ELSE + { + st_fx->hTonalMDCTConc = NULL; + } - /*-----------------------------------------------------------------* - * FD-CNG decoder - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * IGF + *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) + test(); + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) { - /* Create FD_CNG instance */ - IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) ) - { - return error; - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) ); + } - /* Init FD-CNG */ -#ifdef FIX_2245_INIT_FD_CNG_EVS - initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); -#else - initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); -#endif + st_fx->igf = 0; + move16(); + init_igf_dec( st_fx->hIGFDec ); + } + ELSE + { + st_fx->hIGFDec = NULL; + } + + /*-----------------------------------------------------------------* + * Mode 2 initialization + *-----------------------------------------------------------------*/ + + IF( ( st_fx->element_mode == EVS_MONO ) ) + { + IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PLC handle\n" ) ); } - ELSE + } + ELSE + { + st_fx->hPlcInfo = NULL; + } + + IF( st_fx->element_mode == EVS_MONO ) + { + IF( ( st_fx->hTECDec = (TEC_DEC_HANDLE) malloc( sizeof( TEC_DEC_DATA ) ) ) == NULL ) { - st_fx->hFdCngDec = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); } + } + ELSE + { + st_fx->hTECDec = NULL; + } - st_fx->cngTDLevel = 0; + /* Init Decoder */ + IF( st_fx->element_mode == EVS_MONO ) + { + open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth ); + } + ELSE + { + Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; move16(); - st_fx->cngTDLevel_e = 0; move16(); - st_fx->lp_noise = -167772160l /*-20.f Q23*/; - move32(); - st_fx->force_lpd_reset = 0; move16(); - - - /*-----------------------------------------------------------------* - * initialzie Q values - *-----------------------------------------------------------------*/ - - st_fx->Q_syn2 = 0; move16(); - st_fx->Q_exc = 8; move16(); - st_fx->prev_Q_exc = 0; move16(); - st_fx->Q_syn = 0; move16(); - st_fx->prev_Q_syn = 0; move16(); + open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); + } + + /* PLC mode initialization */ + st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; + move16(); + + /* Init bandwidth / frame_type */ + st_fx->m_frame_type = ACTIVE_FRAME; + move16(); + st_fx->m_old_frame_type = ACTIVE_FRAME; + move16(); - FOR( i = 0; i < L_Q_MEM; i++ ) + IF( st_fx->element_mode == EVS_MONO ) + { + resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + } + ELSE + { + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { - st_fx->Q_subfr[i] = 8; - move16(); + resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); } + } - st_fx->prev_Q_exc_fr = 0; - move16(); - st_fx->prev_Q_syn_fr = 0; - move16(); - - /*-----------------------------------------------------------------* - * IVAS parameters - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * FD-CNG decoder + *-----------------------------------------------------------------*/ - st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ - move16(); - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - move16(); - st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ - move16(); - st_fx->cng_ism_flag = 0; - move16(); + test(); + test(); + test(); + IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) + { + /* Create FD_CNG instance */ + IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) ) + { + return error; + } - return error; + /* Init FD-CNG */ +#ifdef FIX_2245_INIT_FD_CNG_EVS + initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); +#else + initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); +#endif + } + ELSE + { + st_fx->hFdCngDec = NULL; } + st_fx->cngTDLevel = 0; + move16(); + st_fx->cngTDLevel_e = 0; + move16(); + st_fx->lp_noise = -167772160l /*-20.f Q23*/; + move32(); + st_fx->force_lpd_reset = 0; + move16(); + + + /*-----------------------------------------------------------------* + * initialzie Q values + *-----------------------------------------------------------------*/ - /*----------------------------------------------------------------------* - * reset_preecho_dec() - * - * Initialization of static variables for pre-echo - *----------------------------------------------------------------------*/ + st_fx->Q_syn2 = 0; + move16(); + st_fx->Q_exc = 8; + move16(); + st_fx->prev_Q_exc = 0; + move16(); + st_fx->Q_syn = 0; + move16(); + st_fx->prev_Q_syn = 0; + move16(); - void reset_preecho_dec_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ - ) + FOR( i = 0; i < L_Q_MEM; i++ ) { - hHQ_core->memfilt_lb_fx = 0; - move16(); - hHQ_core->mean_prev_hb_fx = L_deposit_l( 0 ); - hHQ_core->smoothmem_fx = 32767; - move16(); - hHQ_core->mean_prev_fx = L_deposit_l( 0 ); - hHQ_core->mean_prev_nc_fx = L_deposit_l( 0 ); - hHQ_core->wmold_hb_fx = 32767; + st_fx->Q_subfr[i] = 8; move16(); - hHQ_core->prevflag = 0; - move16(); - hHQ_core->pastpre = 0; - move16(); - - return; } - /*----------------------------------------------------------------------* - * destroy_cldfb_decoder_fx() - * - * Free memory which was allocated in init_decoder() - *----------------------------------------------------------------------*/ + st_fx->prev_Q_exc_fr = 0; + move16(); + st_fx->prev_Q_syn_fr = 0; + move16(); + + /*-----------------------------------------------------------------* + * IVAS parameters + *-----------------------------------------------------------------*/ - void destroy_cldfb_decoder_fx( - Decoder_State * st_fx /* o: Decoder static variables structure */ - ) - { - /* CLDFB BPF & resampling tools */ - deleteCldfb_fx( &st_fx->cldfbAna ); /* delete analysis for max. SR 16kHz */ - deleteCldfb_fx( &st_fx->cldfbBPF ); /* delete analysis BPF for max. SR 16kHz */ - deleteCldfb_fx( &st_fx->cldfbSyn ); /* delete synthesis for output SR */ - deleteCldfb_fx( &st_fx->cldfbSynHB ); + st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ + move16(); + st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ + move16(); + st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ + move16(); + st_fx->cng_ism_flag = 0; + move16(); - deleteFdCngDec_fx( &st_fx->hFdCngDec ); + return error; +} - return; - } + +/*----------------------------------------------------------------------* + * reset_preecho_dec() + * + * Initialization of static variables for pre-echo + *----------------------------------------------------------------------*/ + +void reset_preecho_dec_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ +) +{ + hHQ_core->memfilt_lb_fx = 0; + move16(); + hHQ_core->mean_prev_hb_fx = L_deposit_l( 0 ); + hHQ_core->smoothmem_fx = 32767; + move16(); + hHQ_core->mean_prev_fx = L_deposit_l( 0 ); + hHQ_core->mean_prev_nc_fx = L_deposit_l( 0 ); + hHQ_core->wmold_hb_fx = 32767; + move16(); + hHQ_core->prevflag = 0; + move16(); + hHQ_core->pastpre = 0; + move16(); + + return; +} + +/*----------------------------------------------------------------------* + * destroy_cldfb_decoder_fx() + * + * Free memory which was allocated in init_decoder() + *----------------------------------------------------------------------*/ + +void destroy_cldfb_decoder_fx( + Decoder_State *st_fx /* o: Decoder static variables structure */ +) +{ + /* CLDFB BPF & resampling tools */ + deleteCldfb_fx( &st_fx->cldfbAna ); /* delete analysis for max. SR 16kHz */ + deleteCldfb_fx( &st_fx->cldfbBPF ); /* delete analysis BPF for max. SR 16kHz */ + deleteCldfb_fx( &st_fx->cldfbSyn ); /* delete synthesis for output SR */ + deleteCldfb_fx( &st_fx->cldfbSynHB ); + + deleteFdCngDec_fx( &st_fx->hFdCngDec ); + + return; +} -- GitLab From a4a7053776df40ad3d604c85c1a704915d1c217c Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 6 Dec 2025 10:58:40 +0100 Subject: [PATCH 147/750] fix FIX_2252_SCALING_SAVE_HB_SYNTH --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index e9b94dbad..fd3235f5c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,6 +87,7 @@ #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 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 */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 958b8064d..521ab4f18 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2334,9 +2334,17 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->element_mode, EVS_MONO ) ) { +#ifdef FIX_2252_SCALING_SAVE_HB_SYNTH + IF( save_hb_synth_fx16 != NULL ) +#else IF( save_hb_synth_fx16 ) +#endif { +#ifdef FIX_2252_SCALING_SAVE_HB_SYNTH + Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0 +#else Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0 +#endif } Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 } -- GitLab From 9f871c490a59ea8de0abc9437ff9335ae071adb7 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 8 Dec 2025 09:50:30 +0000 Subject: [PATCH 148/750] Fix macro definition. --- lib_com/ivas_filters_fx.c | 10 +++++----- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_stat_com.h | 2 +- lib_com/ivas_transient_det_fx.c | 4 ++-- lib_com/options.h | 2 +- lib_dec/ivas_lfe_dec_fx.c | 2 +- lib_enc/ivas_lfe_enc_fx.c | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index c7435ab40..f9e35c65a 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -67,7 +67,7 @@ void ivas_filters_init_fx( filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN]; move32(); move32(); -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; move16(); @@ -80,7 +80,7 @@ void ivas_filters_init_fx( #endif } -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; @@ -117,7 +117,7 @@ void ivas_filters_init_fx( move32(); move32(); move32(); -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); filter_state->num_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); @@ -138,7 +138,7 @@ void ivas_filters_init_fx( #endif } -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; @@ -182,7 +182,7 @@ void ivas_filters_init_fx( return; } -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in ); /*-----------------------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7cee85a2c..156088e7f 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3803,7 +3803,7 @@ void ivas_lfe_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 0d4063777..3d811d341 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -656,7 +656,7 @@ typedef struct ivas_filters_process_state_t Word16 filt_len; Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index ac285873c..a925ee92d 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -44,7 +44,7 @@ *------------------------------------------------------------------------------------------*/ #define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS #define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32 #else #define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 @@ -396,7 +396,7 @@ void ivas_td_decorr_get_ducking_gains_fx( Word32 duck_mult_fac = hTranDet->duck_mult_fac; /*Q29*/ move32(); -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; Word32 fast_fx, slow_fx; Word16 fast_e, slow_e; diff --git a/lib_com/options.h b/lib_com/options.h index e9b94dbad..0cdf2b0ae 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ #define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ #define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ -#define OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ +#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 1078a1a02..65021b61f 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -408,7 +408,7 @@ void ivas_lfe_dec_fx( IF( hLFE->filter_state.order > 0 ) { /* Low Pass Filter */ -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame ); #else ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 96fdc7b5c..8af213467 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -684,7 +684,7 @@ void ivas_lfe_lpf_enc_apply_fx( const Word16 input_frame /* i : input frame length per channel */ ) { -#ifdef OPT_2239_IVAS_FILTER_PROCESS +#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame ); #else ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); -- GitLab From 15ba25a996e96fb5e6424a01054359cc345f52e6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 8 Dec 2025 15:51:15 -0500 Subject: [PATCH 149/750] 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 150/750] 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 0f04d0986ae8ebab2d360aa1ab900ed936524d92 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 9 Dec 2025 16:49:33 +0100 Subject: [PATCH 151/750] Revert "fix warnings about dangling pointer" This reverts commit 1ce02a244a9e3c3fb175365efa28de4d70e00a7e. --- lib_debug/wmc_auto.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index ce7b69e28..5afd9de16 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -820,6 +820,7 @@ static void *mem_alloc_block( size_t size, const char *size_str ); void reset_mem( Counting_Size cnt_size ) { + int16_t something; size_t tmp_size; /* initialize list of stack records */ @@ -839,13 +840,7 @@ void reset_mem( Counting_Size cnt_size ) max_num_calls = MAX_NUM_RECORDS; /* initialize stack pointers */ -#if defined( __GNUC__ ) || defined( __clang__ ) - /* GCC/Clang: use builtin (works for many targets) */ - ptr_base_stack = __builtin_frame_address( 0 ); -#else - int16_t something; ptr_base_stack = &something; -#endif ptr_max_stack = ptr_base_stack; ptr_current_stack = ptr_base_stack; @@ -950,14 +945,10 @@ void reset_mem( Counting_Size cnt_size ) void reset_stack( void ) { - /* initialize/reset stack pointers */ -#if defined( __GNUC__ ) || defined( __clang__ ) - /* GCC/Clang: use builtin (works for many targets) */ - ptr_base_stack = __builtin_frame_address( 0 ); -#else int16_t something; + + /* initialize/reset stack pointers */ ptr_base_stack = &something; -#endif ptr_max_stack = ptr_base_stack; ptr_current_stack = ptr_base_stack; @@ -972,15 +963,10 @@ void reset_stack( void ) int push_stack( const char *filename, const char *fctname ) { + int16_t something; int32_t current_stack_size; -#if defined( __GNUC__ ) || defined( __clang__ ) - /* GCC/Clang: use builtin (works for many targets) */ - ptr_base_stack = __builtin_frame_address( 0 ); -#else - int16_t something; ptr_current_stack = &something; -#endif (void) *filename; /* to avoid compilation warning */ -- GitLab From 2ae408f7c7f40598796b1e618b9f070f3949af4c Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 9 Dec 2025 13:53:55 -0500 Subject: [PATCH 152/750] add 1 BE complexity reduction in pred_lt4 --- lib_com/pred_lt4_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index cc7e544e8..b943cedd1 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -58,9 +58,13 @@ void pred_lt4_ivas_fx( FOR( i = 0; i < nb_coef; i++ ) { /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/ +#ifdef IMPROV_COMPLEX_BE + s64 = W_mac_32_16( s64, ( *c1 ), *x1-- ); /* Q_exc + Q32 */ + s64 = W_mac_32_16( s64, ( *c2 ), *x2++ ); /* Q_exc + Q32 */ +#else 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 */ - +#endif c1 += up_sample; c2 += up_sample; } -- GitLab From ce0691f44f0a852d74866685abfc08f73a2ec5b9 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 9 Dec 2025 14:13:30 -0500 Subject: [PATCH 153/750] rename the swicthes to be inline with the ticket number and split between BE and non-BE, non-BE deactivated first to get a first all green pipepline --- lib_com/ivas_pca_tools_fx.c | 4 ++-- lib_com/options.h | 5 ++--- lib_com/pred_lt4_fx.c | 2 +- lib_dec/bass_psfilter_fx.c | 2 +- lib_dec/ivas_sns_dec_fx.c | 4 ++-- lib_dec/ivas_stereo_cng_dec_fx.c | 10 +++++----- lib_dec/ivas_stereo_dft_dec_fx.c | 2 +- lib_dec/ivas_stereo_ica_dec_fx.c | 2 +- lib_enc/ivas_ism_param_enc_fx.c | 4 ++-- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_stereo_td_enc_fx.c | 6 +++--- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 4 ++-- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- 14 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index 25389967b..a265a1496 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -1375,7 +1375,7 @@ void pca_enc_s3_fx( q_ang_2surv_fx( ph1_fx, n1, ph1_q_fx, ind1 ); -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE tmp = mac_r( L_mac( L_mult( q_fx[1], q_fx[1] ), q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ); // Q15 + Q15 - Q15 -> Q15 #else tmp = add( add( mult( q_fx[1], q_fx[1] ), mult( q_fx[2], q_fx[2] ) ), mult( q_fx[3], q_fx[3] ) ); // Q15 + Q15 - Q15 -> Q15 @@ -1433,7 +1433,7 @@ void pca_enc_s3_fx( q_ang_2surv_fx( ph2_fx, n2[i], ph2_q_fx + 2 * i, ind2 + 2 * i ); } -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE r_fx = Sqrt16( mac_r( L_mult( q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ), &r_e ); #else r_fx = Sqrt16( add( mult( q_fx[2], q_fx[2] ), mult( q_fx[3], q_fx[3] ) ), &r_e ); diff --git a/lib_com/options.h b/lib_com/options.h index abb4d51c3..d84e94314 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,6 +90,7 @@ #define FIX_2245_INIT_FD_CNG_EVS /* Dolby/VA: Issue 2245: initialize FD CNG with EVS-type of init function */ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ /* #################### End BE switches ################################## */ @@ -103,6 +104,7 @@ #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_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ /* ##################### End NON-BE switches ########################### */ @@ -122,7 +124,4 @@ /* #################### End BASOP optimization switches ############################ */ -#define IMPROV_PRECISION /* Places where precision can be improved without increasing complexity */ -#define IMPROV_COMPLEX /* Places where complexity is reduced, coudl be non-BE */ -#define IMPROV_COMPLEX_BE /* Places where complexity is reduced, BE (no big impact on complexity) */ #endif diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index b943cedd1..591eab841 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -58,7 +58,7 @@ void pred_lt4_ivas_fx( FOR( i = 0; i < nb_coef; i++ ) { /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/ -#ifdef IMPROV_COMPLEX_BE +#ifdef FIX_2254_IMPROV_COMPLEXITY_BE s64 = W_mac_32_16( s64, ( *c1 ), *x1-- ); /* Q_exc + Q32 */ s64 = W_mac_32_16( s64, ( *c2 ), *x2++ ); /* Q_exc + Q32 */ #else diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 76d80eb89..29672d3e0 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -1041,7 +1041,7 @@ Word16 res_bpf_adapt_ivas_fx( bpf_error_ratio = ONE_IN_Q14; // Q13 move16(); } -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE bpf_error_ratio = mac_r( L_mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ); #else bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 3298bc114..2f0217b48 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -81,7 +81,7 @@ static void sns_1st_dec_fx( FOR( i = 0; i < M / 2; i++ ) { -#ifdef IMPROV_COMPLEX_BE +#ifdef FIX_2254_IMPROV_COMPLEXITY_BE snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); // Q16 #else snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); // Q16 @@ -93,7 +93,7 @@ static void sns_1st_dec_fx( FOR( i = M / 2; i < M; i++ ) { -#ifdef IMPROV_COMPLEX_BE +#ifdef FIX_2254_IMPROV_COMPLEXITY_BE snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); /*Q16*/ #else snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); /*Q16*/ diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 13c5810cf..d08b38852 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -119,7 +119,7 @@ static void stereo_dft_generate_comfort_noise_fx( Word32 tmp32_1, tmp32_2; Word16 q_div, q_sqrt1, q_sqrt2, q_sqrt, sqrt_res; Word16 q_shift, q_shift_1, q_shift_2, min_q; -#ifdef IMPROV_COMPLEX +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE Word16 tmp16, tmp_p, tmp_s; #endif hFdCngCom = st->hFdCngDec->hFdCngCom; @@ -164,7 +164,7 @@ static void stereo_dft_generate_comfort_noise_fx( } ELSE { -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE hStereoDft->g_state_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), A_GFILT_FX, hStereoDft->g_state_fx[b] ); /* Q15 */ #else hStereoDft->g_state_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), mult( A_GFILT_FX, hStereoDft->g_state_fx[b] ) ); /* Q15 */ @@ -195,7 +195,7 @@ static void stereo_dft_generate_comfort_noise_fx( } ELSE { -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ #else hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ @@ -205,7 +205,7 @@ static void stereo_dft_generate_comfort_noise_fx( } ELSE { -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ #else hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ @@ -241,7 +241,7 @@ static void stereo_dft_generate_comfort_noise_fx( } LR_ratio = extract_h( tdm_ratio_tabl_fx[hStereoCng->last_tdm_idx] ); /* Q15 */ -#ifdef IMPROV_COMPLEX +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE tmp16 = shr( hStereoDft->g_state_fx[b], 2 ); tmp_p = add( ONE_IN_Q13, tmp16 ); tmp_s = sub( ONE_IN_Q13, tmp16 ); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index ebd8fe5e3..72527526a 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -3719,7 +3719,7 @@ void stereo_dft_dec_sid_coh_fx( pred_fx = add( pred_fx, shl( mult( ( *pptr_fx++ ), cohBandq_fx[i] ), 2 ) ); /*q-13*/ } /* Weighted intra/inter-frame prediction */ -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE pred_fx = mac_r( L_mult( alpha_fx, pred_fx ), sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ); /*q-13*/ #else pred_fx = add( mult( alpha_fx, pred_fx ), mult( sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ) ); /*q-13*/ diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index d6128c9f3..b6bdb559b 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -193,7 +193,7 @@ void stereo_tca_dec_fx( IF( currentNCShift != 0 ) { -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE currentNCShift = mac_r( L_mult( 19660 /* 0.6 in Q15 */, prevNCShift ), 13106 /* 0.4 in Q15 */, currentNCShift ); /* Q0 */ #else currentNCShift = add( mult( 19660 /* 0.6 in Q15 */, prevNCShift ), mult( 13106 /* 0.4 in Q15 */, currentNCShift ) ); /* Q0 */ diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index de174823d..f29313147 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -292,7 +292,7 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = L_add( tmp, 2 * EVS_PI_FX ); } -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ); // Q14 #else cardioid_left[i] = add( shr( alpha, 1 ), mult( sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ) ); // Q14 @@ -304,7 +304,7 @@ void ivas_param_ism_stereo_dmx_fx( Word16 last_cardioid_right; last_cardioid_right = sub( ONE_IN_Q14 /* 1.0f in Q14 */, last_cardioid_left ); /* Smoothing */ -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE cardioid_left[i] = mac_r( L_mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), 8192 /* 0.25f in Q15 */, last_cardioid_left ); // Q14 #else cardioid_left[i] = add( mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), mult( 8192 /* 0.25f in Q15 */, last_cardioid_left ) ); // Q14 diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index d6689862b..49418c8fc 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1542,7 +1542,7 @@ static void ivas_omasa_dmx_fx( g1 = interpolator[k]; move16(); g2 = sub( MAX_WORD16, g1 ); /*q15*/ -#ifdef IMPROV_COMPLEX_BE +#ifdef FIX_2254_IMPROV_COMPLEXITY_BE data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_mac( L_mult( g1, gains[j] ), g2, prev_gains[i][j] ) /*q31*/, data_in[i][k] ) ); /*Qx*/ #else data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_add( L_mult( g1, gains[j] ), L_mult( g2, prev_gains[i][j] ) ) /*q31*/, data_in[i][k] ) ); /*Qx*/ diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index a39b03464..b26b688dc 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -396,7 +396,7 @@ void tdm_configure_enc_fx( hStereoTD->tdm_use_IAWB_Ave_lpc = 0; /* Flag initialisation */ move16(); -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE sts[0]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx ); move16(); sts[1]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx ); @@ -801,7 +801,7 @@ static void tdm_downmix_plain_ivas_fx( ) { Word16 i; -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE Word16 One_m_Ratio_fx16, ratio_L_fx16; One_m_Ratio_fx16 = extract_h( One_m_Ratio_fx ); ratio_L_fx16 = extract_h( ratio_L_fx ); @@ -809,7 +809,7 @@ static void tdm_downmix_plain_ivas_fx( FOR( i = start_index; i < end_index; i++ ) { -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE FR_Y_fx[i] = mac_r( L_mult( Right_in_fx[i], One_m_Ratio_fx16 ), Left_in_fx[i], ratio_L_fx16 ); LR_X_fx[i] = msu_r( L_mult( Left_in_fx[i], One_m_Ratio_fx16 ), Right_in_fx[i], ratio_L_fx16 ); #else diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index f7df9a9b6..05fabedfe 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -302,7 +302,7 @@ void encod_gen_2sbfr( lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); /* update long-term pitch gain for speech/music classifier */ -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE st->hSpMusClas->lowrate_pitchGain = mac_r( L_mult( 29491, st->hSpMusClas->lowrate_pitchGain ), 3277 /*Q15*/, gain_pit ); // Q14 #else st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14 diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 7695cfbca..a837b2bd1 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -3986,7 +3986,7 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { // GainShape[i] = ( 1 - feedback ) * GainShape[i] + feedback * GainShape_Interp[i]; -#ifdef IMPROV_COMPLEX_BE +#ifdef FIX_2254_IMPROV_COMPLEXITY_BE GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), feedback, GainShape_Interp_fx[i] ) ); #else GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) ); @@ -4104,7 +4104,7 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { // GainShape[i] = ( 1 - feedback ) * GainShape[i * NUM_SHB_SUBGAINS] + feedback * GainShape_Interp[i]; -#ifdef IMPROV_COMPLEX_BE +#ifdef FIX_2254_IMPROV_COMPLEXITY_BE GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), feedback, GainShape_Interp_fx[i] ) ); // Q15 #else GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) ); // Q15 diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 72ac408b0..abe06416b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2931,7 +2931,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( { Word16 gain; /* Mixing using the formulated processing matrix M */ -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ); // Q11 #else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ) ); // Q11 @@ -2941,7 +2941,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( move32(); move32(); -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ); // Q11 #else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ) ); // Q11 @@ -2956,7 +2956,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( LT_16( bin, max_band_decorr ) && LT_16( chB, 2 ) ) { -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ); // Q11 #else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ) ); // Q11 @@ -2970,7 +2970,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ) ); // Q11 -#ifdef IMPROV_PRECISION +#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ); // Q11 #else gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ) ); // Q11 -- GitLab From e71cea0d8394d117eb7fa0417c9eadd8cd93ea86 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 9 Dec 2025 14:51:19 -0500 Subject: [PATCH 154/750] activating the non-be switch --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index d84e94314..aca40e293 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,7 +104,7 @@ #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_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ +#define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 17dc22a422730914abd1ef9c9644228ed06f0d63 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 9 Dec 2025 17:35:17 -0500 Subject: [PATCH 155/750] 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 0f90b4a0bd939a8e69957768d0a86d82d4766c94 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 10 Dec 2025 13:44:30 +0100 Subject: [PATCH 156/750] [cleanup] accept FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND --- lib_com/options.h | 1 - lib_rend/ivas_crend_fx.c | 4 --- lib_util/hrtf_file_reader.c | 56 ------------------------------------- lib_util/hrtf_file_reader.h | 21 -------------- 4 files changed, 82 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 73fa992a6..0fa622fcd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #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 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 */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 79439d753..845976352 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -92,11 +92,9 @@ ivas_error ivas_Crend_hrtf_init_fx( hHrtf->pIndex_frequency_max[i][j] = NULL; hHrtf->pOut_to_bin_re_fx[i][j] = NULL; hHrtf->pOut_to_bin_im_fx[i][j] = NULL; -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND hHrtf->pOut_to_bin_re_dyn_fx[i][j] = NULL; hHrtf->pOut_to_bin_im_dyn_fx[i][j] = NULL; hHrtf->pIndex_frequency_max_dyn_fx[i][j] = NULL; -#endif } } @@ -107,10 +105,8 @@ ivas_error ivas_Crend_hrtf_init_fx( hHrtf->pIndex_frequency_max_diffuse[j] = NULL; hHrtf->pOut_to_bin_diffuse_re_fx[j] = NULL; hHrtf->pOut_to_bin_diffuse_im_fx[j] = NULL; -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND hHrtf->pOut_to_bin_diffuse_re_dyn_fx[j] = NULL; hHrtf->pOut_to_bin_diffuse_im_dyn_fx[j] = NULL; -#endif } hHrtf->init_from_rom = 1; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index d274a0ccf..970548f60 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -179,12 +179,10 @@ static ivas_error read_and_check_hrtf_binary_file_header( static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header ) { -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND if ( hrtf_header == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#endif /* Check the renderer type */ if ( ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && @@ -792,11 +790,7 @@ static ivas_error load_reverb_from_binary( if ( hrtf_header.frequency != sampleRate ) { free( hrtf_data ); -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; -#else - return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); -#endif } } } @@ -963,11 +957,7 @@ static ivas_error TDREND_MIX_LoadHRTF( if ( hrtf_header.frequency != sampleRate ) { free( hrtf_data ); -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; -#else - return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); -#endif } } } @@ -1736,11 +1726,7 @@ ivas_error load_fastconv_HRTF_from_binary( if ( hrtf_header.frequency != 48000 ) /* note: Parametric renderer data are always stored at 48 kHz */ { free( hrtf_data ); -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; -#else - return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); -#endif } if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -1840,11 +1826,7 @@ ivas_error load_parambin_HRTF_from_binary( if ( hrtf_header.frequency != 48000 ) /* note: Parametric renderer data are always stored at 48 kHz */ { free( hrtf_data ); -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; -#else - return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); -#endif } if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -1964,11 +1946,7 @@ ivas_error load_Crend_HRTF_from_binary( if ( hrtf_header.frequency != sampleRate ) { free( hrtf_data ); -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; -#else - return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF invalid sampling rate" ); -#endif } if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -2060,38 +2038,6 @@ void destroy_crend_hrtf( } -#ifndef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND -/*---------------------------------------------------------------------* - * destroy_hrtf_statistics() - * - * Destroy the HRTF statistics set. - *---------------------------------------------------------------------*/ - -void destroy_hrtf_statistics( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ -) -{ - if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) - { - if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_l_dyn ); - } - if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_r_dyn ); - } - if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) - { - free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); - } - } - - ivas_HRTF_statistics_close_fx( hHrtfStatistics ); - - return; -} -#endif /*---------------------------------------------------------------------* * destroy_fastconv_hrtf() @@ -2128,7 +2074,6 @@ void destroy_parambin_hrtf( return; } -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -2159,4 +2104,3 @@ void destroy_hrtf_statistics( return; } -#endif diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index f949308d7..2ec97895f 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -124,11 +124,7 @@ ivas_error load_reverb_binary( *---------------------------------------------------------------------*/ ivas_error load_Crend_HRTF_from_binary( -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND IVAS_DEC_HRTF_CREND_HANDLE hHrtfCrend, /* i/o: HRTF CRend handle */ -#else - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ -#endif const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ @@ -142,11 +138,7 @@ ivas_error load_Crend_HRTF_from_binary( *---------------------------------------------------------------------*/ void destroy_crend_hrtf( -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */ -#else - IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -#endif ); /*---------------------------------------------------------------------* @@ -182,17 +174,6 @@ ivas_error load_parambin_HRTF_from_binary( IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin, /* i/o: Parambin HRTF handle */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); -#ifndef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND -/*---------------------------------------------------------------------* - * destroy_hrtf_statistics() - * - * free memory allocated for HRTF statistics binary data - *---------------------------------------------------------------------*/ - -void destroy_hrtf_statistics( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ -); -#endif /*---------------------------------------------------------------------* * destroy_parambin_hrtf() * @@ -213,7 +194,6 @@ void destroy_td_hrtf( IVAS_DEC_HRTF_TD_HANDLE *hHRTF /* i/o: TD rend. HRTF handle */ ); -#ifdef FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -223,6 +203,5 @@ void destroy_td_hrtf( void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ); -#endif #endif /* IVAS_HRTF_FILE_READER_H */ -- GitLab From c2a9cd79724148635483c1b7e53911bc1d0ab39b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 10 Dec 2025 13:45:50 +0100 Subject: [PATCH 157/750] [cleanup] accept FIX_2245_INIT_FD_CNG_EVS --- lib_com/fd_cng_com_fx.c | 110 ----------------------- lib_com/ivas_prot_fx.h | 10 --- lib_com/options.h | 1 - lib_dec/fd_cng_dec_fx.c | 104 --------------------- lib_dec/init_dec_fx.c | 4 - lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 4 - lib_dec/ivas_stereo_switching_dec_fx.c | 12 --- 7 files changed, 245 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 45dd66f45..ac6d781a4 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -58,11 +58,7 @@ ivas_error createFdCngCom_fx( * *-------------------------------------------------------------------*/ -#ifdef FIX_2245_INIT_FD_CNG_EVS void initFdCngCom( -#else -void ivas_initFdCngCom_fx( -#endif HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) { @@ -178,112 +174,6 @@ void ivas_initFdCngCom_fx( return; } -#ifndef FIX_2245_INIT_FD_CNG_EVS -void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) -{ - /* Calculate CLDFB scaling factor */ - /* shl(i_mult2(scale, scale), 3) does not fit in 16 bit */ - /*hFdCngCom->scalingFactor = div_s(1, shl(i_mult2(scale, scale), 3));*/ - assert( 2048 /*1.0/(1<<4) Q15*/ < mult( scale, scale ) ); - /* Exponent invScalingFactor: -16 = -(2*7 (scale) + 2 (8.0) */ - hFdCngCom->invScalingFactor = shl( mult( scale, scale ), 1 ); - move16(); - /* Exponent scalingFactor: -15 = -(2*7 (scale) + 2 (8.0) - 1 (1.0)) */ - hFdCngCom->scalingFactor = div_s( 0x4000, hFdCngCom->invScalingFactor ); - move16(); - - /* Initialize the overlap-add */ - set16_fx( hFdCngCom->timeDomainBuffer, 0, L_FRAME16k ); - hFdCngCom->olapBufferAna = NULL; - set16_fx( hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); - - set16_fx( hFdCngCom->olapBufferSynth, 0, FFTLEN ); - hFdCngCom->olapBufferSynth2 = NULL; - - /* Initialize the comfort noise generation */ - set32_fx( hFdCngCom->fftBuffer, 0, FFTLEN ); - set32_fx( hFdCngCom->cngNoiseLevel, 0, FFTCLDFBLEN ); - set16_fx( &hFdCngCom->cngNoiseLevelExp, 0, 1 ); - - /* Initialize quantizer */ - set32_fx( hFdCngCom->sidNoiseEst, 0, NPART ); - set16_fx( &hFdCngCom->sidNoiseEstExp, 0, 1 ); - set16_fx( hFdCngCom->A_cng, 0, M + 1 ); - hFdCngCom->A_cng[0] = 4096 /*1.f Q12*/; /* 3Q12 */ - move16(); - - /* Set some counters and flags */ - hFdCngCom->inactive_frame_counter = 0; /* Either SID or zero frames */ - move16(); - hFdCngCom->active_frame_counter = 0; - move16(); - hFdCngCom->frame_type_previous = ACTIVE_FRAME; - move16(); - hFdCngCom->flag_noisy_speech = 0; - move16(); - hFdCngCom->likelihood_noisy_speech = 0; - move16(); - hFdCngCom->numCoreBands = 0; - move16(); - hFdCngCom->stopBand = 0; - move16(); - hFdCngCom->startBand = 0; - move16(); - hFdCngCom->stopFFTbin = 0; - move16(); - hFdCngCom->frameSize = 0; - move16(); - hFdCngCom->fftlen = 0; - move16(); - hFdCngCom->seed = 0; - move16(); - // hFdCngCom->seed2 = 1; - // move16(); - // hFdCngCom->seed3 = 2; - // move16(); - hFdCngCom->CngBitrate = -1; - move16(); - - /* Initialize noise estimation algorithm */ - set32_fx( hFdCngCom->periodog, 0, PERIODOGLEN ); - mhvals( MSNUMSUBFR * MSSUBFRLEN, &( hFdCngCom->msM_win ) ); - mhvals( MSSUBFRLEN, &( hFdCngCom->msM_subwin ) ); - set32_fx( hFdCngCom->msPeriodogSum, 0, 2 ); - hFdCngCom->msPeriodogSum_exp[0] = 0; - move16(); - hFdCngCom->msPeriodogSum_exp[1] = 0; - move16(); - set32_fx( hFdCngCom->msPsdSum, 0, 2 ); - set16_fx( hFdCngCom->msSlope, 0, 2 ); - set32_fx( hFdCngCom->msQeqInvAv, 0, 2 ); - hFdCngCom->msQeqInvAv_exp[0] = 0; - move16(); - hFdCngCom->msQeqInvAv_exp[1] = 0; - move16(); - hFdCngCom->msFrCnt_init_counter = 0; - move16(); - hFdCngCom->msFrCnt_init_thresh = 1; - move16(); - hFdCngCom->init_old = 0; - move16(); - hFdCngCom->offsetflag = 0; - move16(); - hFdCngCom->msFrCnt = MSSUBFRLEN; - move16(); - hFdCngCom->msMinBufferPtr = 0; - move16(); - hFdCngCom->msAlphaCor[0] = 644245120l /*0.3f Q31*/; - move16(); - hFdCngCom->msAlphaCor[1] = 644245120l /*0.3f Q31*/; - move16(); - set16_fx( hFdCngCom->psize, 0, NPART ); - /* Initialize exponents */ - hFdCngCom->exp_cldfb_periodog = 0; - move16(); - - return; -} -#endif /*------------------------------------------------------------------- * deleteFdCngCom() * diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 156088e7f..068d7c1f1 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1990,16 +1990,6 @@ ivas_error stereo_memory_dec_fx( const Word16 nchan_transport /* i : number of transport channels */ ); -#ifndef FIX_2245_INIT_FD_CNG_EVS -void initFdCngDec_ivas_fx( - DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - Word16 scale -); - -void ivas_initFdCngCom_fx( - HANDLE_FD_CNG_COM hFdCngCom, Word16 scale -); -#endif Word16 set_ACELP_flag_IVAS( const Word16 element_mode, /* i : element mode */ const Word32 element_brate, /* i : element bitrate */ diff --git a/lib_com/options.h b/lib_com/options.h index 0fa622fcd..0a38a3b32 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ -#define FIX_2245_INIT_FD_CNG_EVS /* Dolby/VA: Issue 2245: initialize FD CNG with EVS-type of init function */ #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 */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 647c845d2..8c4d10499 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -78,27 +78,17 @@ ivas_error createFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ) return error; } -#ifdef FIX_2245_INIT_FD_CNG_EVS void initFdCngDec_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ const Word16 scale /* i : Q factor */ ) -#else -void initFdCngDec_ivas_fx( - DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - Word16 scale /*Q15*/ ) -#endif { /* Initialize common */ HANDLE_FD_CNG_DEC hFdCngDec; hFdCngDec = st->hFdCngDec; -#ifdef FIX_2245_INIT_FD_CNG_EVS initFdCngCom( hFdCngDec->hFdCngCom, scale ); -#else - ivas_initFdCngCom_fx( hFdCngDec->hFdCngCom, scale ); -#endif set16_fx( hFdCngDec->olapBufferAna, 0, FFTLEN ); hFdCngDec->hFdCngCom->olapBufferAna = hFdCngDec->olapBufferAna; set16_fx( hFdCngDec->olapBufferSynth2, 0, FFTLEN ); @@ -133,9 +123,7 @@ void initFdCngDec_ivas_fx( set16_fx( hFdCngDec->msPsd, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msPsd_fx, 0, NPART_SHAPING ); -#ifdef FIX_2245_INIT_FD_CNG_EVS set16_fx( hFdCngDec->msNoiseFloor, 0, NPART_SHAPING ); -#endif set32_fx( hFdCngDec->msNoiseFloor_32fx, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msNoiseEst, 0, NPART_SHAPING ); @@ -161,9 +149,7 @@ void initFdCngDec_ivas_fx( move16(); set16_fx( hFdCngDec->msLogPeriodog, 0, NPART_SHAPING ); -#ifdef FIX_2245_INIT_FD_CNG_EVS set16_fx( hFdCngDec->msLogNoiseEst, 0, NPART_SHAPING ); -#endif set32_fx( hFdCngDec->msLogNoiseEst_32fx, 0, NPART_SHAPING ); set16_fx( hFdCngDec->psize_shaping, 0, NPART_SHAPING ); @@ -214,96 +200,6 @@ void initFdCngDec_ivas_fx( return; } -#ifndef FIX_2245_INIT_FD_CNG_EVS -void initFdCngDec_fx( - DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - const Word16 scale /*Q15*/ ) -{ - /* Initialize common */ - HANDLE_FD_CNG_DEC hFdCngDec; - - hFdCngDec = st->hFdCngDec; - - initFdCngCom( hFdCngDec->hFdCngCom, scale ); - set16_fx( hFdCngDec->olapBufferAna, 0, 320 ); - hFdCngDec->hFdCngCom->olapBufferAna = hFdCngDec->olapBufferAna; - move16(); - set16_fx( hFdCngDec->olapBufferSynth2, 0, FFTLEN ); - hFdCngDec->hFdCngCom->olapBufferSynth2 = hFdCngDec->olapBufferSynth2; - move16(); - - /* Set some counters and flags */ - - hFdCngDec->flag_dtx_mode = 0; - move16(); - hFdCngDec->lp_noise = -167772160l /*-20.f Q23*/; /* format: Q8.24 */ - move32(); - hFdCngDec->lp_speech = 209715200l /* 25.f Q23*/; /* format: Q8.24 */ - move32(); - - /* Initialization of the noise estimation algorithm */ - - set32_fx( hFdCngDec->bandNoiseShape, 0, FFTLEN2 ); - set16_fx( &hFdCngDec->bandNoiseShape_exp, 0, 1 ); - - set32_fx( hFdCngDec->partNoiseShape, 0, NPART ); - set16_fx( &hFdCngDec->partNoiseShape_exp, 0, 1 ); - - set32_fx( hFdCngDec->msPeriodog, 0, NPART_SHAPING ); - set16_fx( &hFdCngDec->msPeriodog_exp, 0, 1 ); - - set32_fx( hFdCngDec->msAlpha, 0, NPART_SHAPING ); - - set32_fx( hFdCngDec->msBminWin, 0, NPART_SHAPING ); - - set32_fx( hFdCngDec->msBminSubWin, 0, NPART_SHAPING ); - - set16_fx( hFdCngDec->msPsd, 0, NPART_SHAPING ); - set32_fx( hFdCngDec->msPsd_fx, 0, NPART_SHAPING ); - set16_fx( hFdCngDec->msNoiseFloor, 0, NPART_SHAPING ); - - set32_fx( hFdCngDec->msNoiseEst, 0, NPART_SHAPING ); - set16_fx( &hFdCngDec->msNoiseEst_exp, 0, 1 ); - - set32_fx( hFdCngDec->msMinBuf, 2147483647l /*1.0 Q31*/, MSNUMSUBFR * NPART_SHAPING ); - - set32_fx( hFdCngDec->msCurrentMin, 2147483647l /*1.0 Q31*/, NPART_SHAPING ); - - set32_fx( hFdCngDec->msCurrentMinOut, 2147483647l /*1.0 Q31*/, NPART_SHAPING ); - - set32_fx( hFdCngDec->msCurrentMinSubWindow, 2147483647l /*1.0 Q31*/, NPART_SHAPING ); - - set16_fx( hFdCngDec->msLocalMinFlag, 0, NPART_SHAPING ); - set16_fx( hFdCngDec->msNewMinFlag, 0, NPART_SHAPING ); - - set16_fx( hFdCngDec->msPsdFirstMoment, 0, NPART_SHAPING ); - - set32_fx( hFdCngDec->msPsdSecondMoment, 0, NPART_SHAPING ); - set16_fx( hFdCngDec->msPeriodogBuf, 0, MSBUFLEN * NPART_SHAPING ); - - hFdCngDec->msPeriodogBufPtr = 0; - move16(); - - set16_fx( hFdCngDec->msLogPeriodog, 0, NPART_SHAPING ); - set16_fx( hFdCngDec->msLogNoiseEst, 0, NPART_SHAPING ); - - set16_fx( hFdCngDec->psize_shaping, 0, NPART_SHAPING ); - hFdCngDec->nFFTpart_shaping = 0; - move16(); - set32_fx( hFdCngDec->msPeriodog_ST_fx, 0, NPART_SHAPING ); - hFdCngDec->msPeriodog_ST_exp = 0; - move16(); - hFdCngDec->hFdCngCom->fftBuffer_exp = 0; - move16(); - hFdCngDec->hFdCngCom->periodog_exp = 0; - move16(); - set32_fx( hFdCngDec->smoothed_psd_fx, 0, L_FRAME16k ); - hFdCngDec->smoothed_psd_exp = 0; - move16(); - - return; -} -#endif /* configureFdCngDec_fx diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index e46991dc8..66c49d776 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -928,11 +928,7 @@ ivas_error init_decoder_fx( } /* Init FD-CNG */ -#ifdef FIX_2245_INIT_FD_CNG_EVS initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); -#else - initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); -#endif } ELSE { diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 76b44d94d..6ea211cb2 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -569,11 +569,7 @@ ivas_error initMdctStereoDtxData_fx( } /* Init FD-CNG */ -#ifdef FIX_2245_INIT_FD_CNG_EVS initFdCngDec_fx( st, st->cldfbSyn->scale ); -#else - initFdCngDec_ivas_fx( st, st->cldfbSyn->scale ); -#endif } IF( st->first_CNG == 0 ) diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index ea4647dae..e8fddd58c 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -649,11 +649,7 @@ ivas_error stereo_memory_dec_fx( return error; } -#ifdef FIX_2245_INIT_FD_CNG_EVS initFdCngDec_fx( st, st->cldfbSyn->scale ); -#else - initFdCngDec_ivas_fx( st, st->cldfbSyn->scale ); -#endif configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); } @@ -760,11 +756,7 @@ ivas_error stereo_memory_dec_fx( } /* Init FD-CNG */ -#ifdef FIX_2245_INIT_FD_CNG_EVS initFdCngDec_fx( st, st->cldfbSyn->scale ); -#else - initFdCngDec_ivas_fx( st, st->cldfbSyn->scale ); -#endif if ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { @@ -1085,11 +1077,7 @@ ivas_error stereo_memory_dec_fx( return error; } -#ifdef FIX_2245_INIT_FD_CNG_EVS initFdCngDec_fx( hCPE->hCoreCoder[i], hCPE->hCoreCoder[i]->cldfbSyn->scale ); -#else - initFdCngDec_ivas_fx( hCPE->hCoreCoder[i], hCPE->hCoreCoder[i]->cldfbSyn->scale ); -#endif } } } -- GitLab From eab82817eef675b16559bb448a561042079bfdbe Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 10 Dec 2025 13:47:08 +0100 Subject: [PATCH 158/750] [cleanup] accept FIX_2015_PREMPH_SAT_ALT_PART2 --- lib_com/options.h | 1 - lib_enc/enc_higher_acelp_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0a38a3b32..45787bbe5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_1454_FIX_STEREO_TO_FOA_JBM /* VA: issue 1454: fix buggy stereo to FOA in JBM */ -#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_1461_CNG_BW_SWITCHING /* Eri: float issue 1461: Stereo parameters are not updated when SID/NODATA forces BW to stay the same */ diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 455fc0322..82296aa4a 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -490,11 +490,7 @@ void transf_cdbk_enc_ivas_fx( * Split algebraic vector quantizer based on RE8 lattice *--------------------------------------------------------------*/ -#ifndef FIX_2015_PREMPH_SAT_ALT_PART2 - AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 ); -#else AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct ); -#endif /*--------------------------------------------------------------* * Find prequantizer excitation gain -- GitLab From c32b5523dd8678c4e7cb6006f2f93f34a23c1a37 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 10 Dec 2025 13:48:16 +0100 Subject: [PATCH 159/750] [cleanup] accept FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH --- lib_com/options.h | 1 - lib_enc/eval_pit_contr_fx.c | 7 ------- lib_enc/gs_enc_fx.c | 4 ---- lib_enc/prot_fx_enc.h | 3 --- 4 files changed, 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 45787bbe5..acdad6070 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_1454_FIX_STEREO_TO_FOA_JBM /* VA: issue 1454: fix buggy stereo to FOA in JBM */ -#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_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[] */ diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index b9ea2d49e..f1c8ba28b 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -422,9 +422,6 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher const Word16 *dct_res, /* i : DCT of residual Q_new*/ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Q_new*/ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ -#ifndef FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ -#endif Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ) { @@ -457,11 +454,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher Mbands_loc = MBANDS_LOC; move16(); } -#ifndef FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH - minimum_fx( pitch_buf, nb_subfr, &low_pit ); -#else minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); -#endif exp1 = norm_s( low_pit ); tmp = shl( low_pit, exp1 ); tmp_dec = 12800; diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index f3e85bd29..19d7f599c 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -675,11 +675,7 @@ void encod_audio_ivas_fx( * Find and encode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ -#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 IF( last_pit_bin == 0 ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index feaefcf53..4421e3c4c 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4039,9 +4039,6 @@ Word16 Pit_exc_contribution_len_ivas_fx( const Word16 *dct_res, /* i : DCT of residual Qnew*/ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ -#ifndef FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ -#endif Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ); -- GitLab From 4cb9d04cb0e89341e84406e402dd947237d3e56f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 10 Dec 2025 13:49:39 +0100 Subject: [PATCH 160/750] [cleanup] accept NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES --- lib_com/options.h | 1 - lib_dec/dec_tcx_fx.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index acdad6070..cabe32178 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_1454_FIX_STEREO_TO_FOA_JBM /* VA: issue 1454: fix buggy stereo to FOA in JBM */ -#define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ #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()*/ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a1724fcd7..ababbcc2d 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4043,11 +4043,7 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 -#ifdef NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, -( Q14 - 2 ) ); // Scaling xn_buf_fx to Q(-2) -#else - Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn -#endif x_e = sub( 31, 11 ); IF( st->igf != 0 ) @@ -5648,11 +5644,7 @@ void decoder_tcx_imdct_fx( generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES x_fx[ind] = L_shl( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x -#else - x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x -#endif } } -- GitLab From 279f3f20f1672c72ce8f9db85d0009dfb00c4dd0 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 10 Dec 2025 13:52:17 +0100 Subject: [PATCH 161/750] formatting --- lib_dec/dec_tcx_fx.c | 2 +- lib_enc/eval_pit_contr_fx.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- lib_util/hrtf_file_reader.c | 1 - lib_util/hrtf_file_reader.h | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index ababbcc2d..13cf9e9eb 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4042,7 +4042,7 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); - Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 + Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, -( Q14 - 2 ) ); // Scaling xn_buf_fx to Q(-2) x_e = sub( 31, 11 ); diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index f1c8ba28b..33b35f0cc 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -422,7 +422,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher const Word16 *dct_res, /* i : DCT of residual Q_new*/ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Q_new*/ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 4421e3c4c..85465d0c5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4039,7 +4039,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( const Word16 *dct_res, /* i : DCT of residual Qnew*/ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ); Word16 pvq_core_enc_fx( diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 970548f60..f1fe05c5f 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2038,7 +2038,6 @@ void destroy_crend_hrtf( } - /*---------------------------------------------------------------------* * destroy_fastconv_hrtf() * diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 2ec97895f..d1f97a191 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -124,7 +124,7 @@ ivas_error load_reverb_binary( *---------------------------------------------------------------------*/ ivas_error load_Crend_HRTF_from_binary( - IVAS_DEC_HRTF_CREND_HANDLE hHrtfCrend, /* i/o: HRTF CRend handle */ + IVAS_DEC_HRTF_CREND_HANDLE hHrtfCrend, /* i/o: HRTF CRend handle */ const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ -- GitLab From 2877f54c7de4a19e0453df937d4d0b5adad43aff Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 10 Dec 2025 10:56:10 -0500 Subject: [PATCH 162/750] 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 163/750] 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 164/750] 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 165/750] 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 166/750] 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 b0b62ddba80762174ed18105a5abbdb6c04f8d7f Mon Sep 17 00:00:00 2001 From: "Malenovsky, Vladimir" Date: Thu, 11 Dec 2025 13:32:09 +0100 Subject: [PATCH 167/750] fix stack pointer address on GNU/Clang platforms --- lib_debug/wmc_auto.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 5afd9de16..5a14edc31 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -820,7 +820,6 @@ static void *mem_alloc_block( size_t size, const char *size_str ); void reset_mem( Counting_Size cnt_size ) { - int16_t something; size_t tmp_size; /* initialize list of stack records */ @@ -840,7 +839,13 @@ void reset_mem( Counting_Size cnt_size ) max_num_calls = MAX_NUM_RECORDS; /* initialize stack pointers */ +#if defined( __GNUC__ ) || defined( __clang__ ) + /* GCC/Clang: use builtin (works for many targets) */ + ptr_base_stack = __builtin_frame_address( 0 ); +#else + int16_t something; ptr_base_stack = &something; +#endif ptr_max_stack = ptr_base_stack; ptr_current_stack = ptr_base_stack; @@ -945,10 +950,14 @@ void reset_mem( Counting_Size cnt_size ) void reset_stack( void ) { - int16_t something; - /* initialize/reset stack pointers */ +#if defined( __GNUC__ ) || defined( __clang__ ) + /* GCC/Clang: use builtin (works for many targets) */ + ptr_base_stack = __builtin_frame_address( 0 ); +#else + int16_t something; ptr_base_stack = &something; +#endif ptr_max_stack = ptr_base_stack; ptr_current_stack = ptr_base_stack; @@ -963,10 +972,15 @@ void reset_stack( void ) int push_stack( const char *filename, const char *fctname ) { - int16_t something; int32_t current_stack_size; +#if defined( __GNUC__ ) || defined( __clang__ ) + /* GCC/Clang: use builtin (works for many targets) */ + ptr_current_stack = __builtin_frame_address( 0 ); +#else + int16_t something; ptr_current_stack = &something; +#endif (void) *filename; /* to avoid compilation warning */ -- GitLab From 0a057a7200aefb30de3e08add85d06d8f291ae6d Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Wed, 10 Dec 2025 08:58:13 +0100 Subject: [PATCH 168/750] Aligned random vector generation in GenShapedSHBExcitation() with float version --- lib_com/ivas_prot_fx.h | 1 + lib_com/options.h | 1 + lib_com/prot_fx.h | 2 ++ lib_com/swb_tbe_com_fx.c | 75 ++++++++++++++++++++++++++++++++-------- lib_dec/swb_tbe_dec_fx.c | 6 ++-- lib_enc/swb_tbe_enc_fx.c | 6 ++-- 6 files changed, 71 insertions(+), 20 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 068d7c1f1..85bbcb4b1 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1884,6 +1884,7 @@ void GenShapedWBExcitation_ivas_fx( Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q_bwe_exc*/ Word16 *state_lpc_syn, /* i/o : memory Q_bwe_exc*/ const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/ const Word16 Q_bwe_exc, Word16 bwe_seed[], /* i/o : random number generator seed */ diff --git a/lib_com/options.h b/lib_com/options.h index cabe32178..64f0ce3aa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,6 +98,7 @@ #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_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bf24d493e..bba113ec0 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2992,6 +2992,7 @@ void GenShapedWBExcitation_fx( Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ Word16 *state_lpc_syn, /* i/o : memory */ const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ const Word16 Q_bwe_exc, Word16 bwe_seed[], /* i/o : random number generator seed */ @@ -3014,6 +3015,7 @@ void GenShapedSHBExcitation_fx( Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ Word16 *state_lpc_syn, /* i/o: memory */ const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ Word16 bwe_seed[], /* i/o: random number generator seed */ Word16 voice_factors[], /* i : voicing factor*/ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e63dc471e..c9d307ef2 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -26,7 +26,7 @@ * Local function prototypes *-----------------------------------------------------------------*/ -static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[] ); +static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[], Word16 element_mode ); static void flip_spectrum_fx( const Word16 input[], Word16 output[], const Word16 length ); static void Calc_st_filt_tbe( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero ); static void Hilbert_transform_fx( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id ); @@ -1415,6 +1415,7 @@ void GenShapedWBExcitation_ivas_fx( Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q_bwe_exc*/ Word16 *state_lpc_syn, /* i/o : memory Q_bwe_exc*/ const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/ const Word16 Q_bwe_exc, Word16 bwe_seed[], /* i/o : random number generator seed */ @@ -1478,7 +1479,7 @@ void GenShapedWBExcitation_ivas_fx( IF( uv_flag ) { - create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed ); + create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed, element_mode ); IF( LT_16( Q_bwe_exc, 5 ) ) { @@ -1554,7 +1555,7 @@ void GenShapedWBExcitation_ivas_fx( move32(); /* Q_bwe_exc+16 */ } - create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed ); + create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed, element_mode ); /* Ensure pow22 is greater than zero when computing normalization */ Lmax = 0; @@ -1661,6 +1662,7 @@ void GenShapedWBExcitation_fx( Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q(Q_bwe_exc) */ Word16 *state_lpc_syn, /* i/o : memory Q(Q_bwe_exc) */ const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q(Q_bwe_exc) */ const Word16 Q_bwe_exc, /* i : Q for memories */ Word16 bwe_seed[], /* i/o : random number generator seed */ @@ -1727,7 +1729,7 @@ void GenShapedWBExcitation_fx( IF( uv_flag ) { - create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed ); + create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed, element_mode ); IF( LT_16( Q_bwe_exc, 5 ) ) { FOR( i = 0; i < L_FRAME16k / 4; i++ ) @@ -1802,7 +1804,7 @@ void GenShapedWBExcitation_fx( move32(); /* Q_bwe_exc+16 */ } - create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed ); + create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed, element_mode ); /* Ensure pow22 is greater than zero when computing normalization */ Lmax = 0; @@ -2074,6 +2076,7 @@ void GenShapedSHBExcitation_fx( Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ Word16 *state_lpc_syn, /* i/o: memory */ const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ Word16 bwe_seed[], /* i/o: random number generator seed */ Word16 voice_factors[], /* i : voicing factor*/ @@ -2293,8 +2296,8 @@ void GenShapedSHBExcitation_fx( { /* create a random excitation - Reuse exc16k memory */ White_exc16k = exc16k; - create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed ); - create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); + create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode ); + create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed, element_mode ); L_tmp = L_deposit_l( 0 ); tmp = add( *Q_bwe_exc, 1 ); @@ -2978,8 +2981,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( ELSE { /* create a random excitation - Reuse exc16k memory */ - create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed ); // Q5 - create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); // Q5 + create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode ); // Q5 + create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed, element_mode ); // Q5 L_tmp = L_deposit_l( 0 ); tmp = add( *Q_bwe_exc, 1 ); @@ -4006,8 +4009,8 @@ void GenShapedSHBExcitation_ivas_dec_fx( /* create a random excitation - Reuse exc16k memory */ White_exc16k = exc16k; move16(); - create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed ); // Q5 - create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); // Q5 + create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode ); // Q5 + create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed, element_mode ); // Q5 L_tmp = L_deposit_l( 0 ); tmp = add( *Q_bwe_exc, 1 ); @@ -6109,24 +6112,68 @@ void non_linearity_ivas_fx( void create_random_vector_fx( Word16 output[], /* o : output random vector Q5*/ const Word16 length, /* i : length of random vector */ - Word16 seed[] /* i/o: start seed */ + Word16 seed[], /* i/o: start seed */ + Word16 element_mode /* i : element mode */ ) { Word16 i, j, k; Word16 scale1, scale2; Word32 L_tmp; + /* + Note: the constant 2144047674 is 0.0078f in Q38 from the float reference. + It should read 0.0078125f, which is 1/128.Since 0.0078f is nor exactly + depictable in fixed point, rounding has to be performed to get the same + j and k values for any input (e.g. if Random() returns 5000) + */ + +#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT + if ( element_mode != EVS_MONO ) + { + L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + } + else + { + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + } +#else + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ +#endif - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ j = extract_l( L_shr( L_tmp, 23 ) ); j = s_and( j, 0xff ); - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ +#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT + if ( element_mode != EVS_MONO ) + { + L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + } + else + { + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + } + +#else + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ +#endif + k = extract_l( L_shr( L_tmp, 23 ) ); k = s_and( k, 0xff ); WHILE( EQ_16( k, j ) ) { +#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT + if ( element_mode != EVS_MONO ) + { + L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + } + else + { + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + } +#else L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ +#endif + k = extract_l( L_shr( L_tmp, 23 ) ); k = s_and( k, 0xff ); } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 5ca7ba1f6..c61e4ddf3 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -895,7 +895,7 @@ void ivas_wb_tbe_dec_fx( GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, - hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, + hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); curr_pow = 0; @@ -1535,7 +1535,7 @@ void wb_tbe_dec_fx( GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, - hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, + hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); curr_pow = 0; @@ -2653,7 +2653,7 @@ void swb_tbe_dec_fx( /* Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) SHB excitation signal from the low band ACELP core excitation */ GenShapedSHBExcitation_fx( shaped_shb_excitation + L_SHB_LAHEAD, lpc_shb, White_exc16k, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified, st_fx->extl, + coder_type, st_fx->element_mode, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf, shb_ener_sf_32, shb_res_gshape, shb_res_dummy, &vind, formant_fac, hBWE_TD->fb_state_lpc_syn_fx, &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st_fx->total_brate, st_fx->prev_bfi ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index e2e66dd5f..7de83621a 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -986,7 +986,7 @@ void wb_tbe_enc_fx( GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, - hBWE_TD->state_lpc_syn_fx, coder_type, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, + hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified_fx, uv_flag, st_fx->igf ); curr_pow = 0; @@ -1592,7 +1592,7 @@ void wb_tbe_enc_ivas_fx( GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, - hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, + hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified_fx, uv_flag, st_fx->igf ); curr_pow = 0; @@ -2393,7 +2393,7 @@ void swb_tbe_enc_fx( GenShapedSHBExcitation_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, + coder_type, st_fx->element_mode, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st_fx->total_brate, 0 ); -- GitLab From 630123db7dc75e7d33d694e5da969e16bebc03ba Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 08:59:57 +0100 Subject: [PATCH 169/750] ready for test --- apps/decoder.c | 41 ++- apps/renderer.c | 2 + lib_dec/ivas_init_dec_fx.c | 23 +- lib_dec/lib_dec_fx.c | 12 +- lib_rend/ivas_crend_fx.c | 3 + lib_rend/ivas_hrtf_fx.c | 352 ++++++++++++++++++++++---- lib_rend/ivas_objectRenderer_mix_fx.c | 3 +- lib_rend/ivas_prot_rend_fx.h | 54 +++- lib_rend/ivas_stat_rend.h | 4 + lib_rend/lib_rend_fx.c | 33 ++- lib_util/hrtf_file_reader.c | 162 +++++++++++- 11 files changed, 623 insertions(+), 66 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 401a26761..197dddaa8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -142,9 +142,11 @@ typedef struct hrtfFileReader *hrtfReader; char *hrtfFileName; +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD; IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics; +#endif IVAS_BIN_RENDERER_TYPE binaural_renderer; IVAS_BIN_RENDERER_TYPE binaural_renderer_old; @@ -207,8 +209,10 @@ int main( reset_mem( USE_BYTES ); #endif +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */ hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */ +#endif splitRendBits.bits_buf = splitRendBitsBuf; @@ -730,11 +734,13 @@ cleanup: free( arg.aeSequence.pValidity ); } +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA if ( arg.hrtfReaderEnabled ) { destroy_td_hrtf( hHrtfBinary.hHrtfTD ); destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics ); } +#endif #ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD // TODO: /* This free differs from float version. @@ -3756,12 +3762,12 @@ static ivas_error load_hrtf_from_file( /*------------------------------------------------------------------------------------------* * Release HRTF binary data *------------------------------------------------------------------------------------------*/ - +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && binaural_renderer_sec != IVAS_BIN_RENDERER_TYPE_TDREND && hHrtfBinary->hHrtfTD != NULL ) { destroy_td_hrtf( hHrtfBinary->hHrtfTD ); } - +#endif if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK ) { return error; @@ -3783,13 +3789,23 @@ static ivas_error load_hrtf_from_file( if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_sec == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { + +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD = NULL; + if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_GetHrtfTDrendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -3798,7 +3814,11 @@ static ivas_error load_hrtf_from_file( } else { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + destroy_td_hrtf( hHrtfTD ); +#else destroy_td_hrtf( hHrtfBinary->hHrtfTD ); +#endif } } } @@ -3873,15 +3893,28 @@ static ivas_error load_hrtf_from_file( } } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#else if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = load_reverb_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -3890,7 +3923,11 @@ static ivas_error load_hrtf_from_file( } else { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + destroy_hrtf_statistics( hHrtfStatistics ); +#else destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); +#endif } } } diff --git a/apps/renderer.c b/apps/renderer.c index 464a9f893..4ce0b10f7 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2192,8 +2192,10 @@ cleanup: RotationFileReader_close( &externalOrientationFileReader ); RotationFileReader_close( &referenceRotReader ); Vector3PairFileReader_close( &referenceVectorReader ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA destroy_td_hrtf( hHrtfTD ); destroy_hrtf_statistics( hHrtfStatistics ); +#endif IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); RenderConfigReader_close( &renderConfigReader ); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index f93b5a69c..e212ee0a6 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1799,7 +1799,18 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { /* Init HRTF statistics */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + /* Allocate HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( st_ivas->hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* Init HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -3548,16 +3559,22 @@ void ivas_destroy_dec_fx( IF( st_ivas->hHrtfTD != NULL ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); +#else BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); +#endif } /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close_fx( &st_ivas->hHrtfCrend ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv ); +#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); @@ -3565,8 +3582,12 @@ void ivas_destroy_dec_fx( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); - /* HRTF statistics */ +/* HRTF statistics */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_binary_close_fx( &st_ivas->hHrtfStatistics ); +#else ivas_HRTF_statistics_close_fx( &st_ivas->hHrtfStatistics ); +#endif /* Config. Renderer */ ivas_render_config_close_fx( &( st_ivas->hRenderConfig ) ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0bc064d05..882d5f413 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1,4 +1,4 @@ -/****************************************************************************************************** +/****************************************************************************************************** (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., @@ -2516,7 +2516,11 @@ ivas_error IVAS_DEC_HRTF_binary_open( test(); IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfTD == NULL ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IF( ( error = ivas_HRTF_td_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2598,7 +2602,11 @@ ivas_error IVAS_DEC_HRTF_binary_close( test(); IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); +#else ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); +#endif } test(); @@ -2611,8 +2619,10 @@ ivas_error IVAS_DEC_HRTF_binary_close( test(); IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_FASTCONV ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) ) { +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv ); +#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 845976352..3ee45b7b9 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1812,8 +1812,11 @@ void ivas_rend_closeCldfbRend( pCldfbRend->hCldfbRend->hInputSetup = NULL; } + ivas_binRenderer_close_fx( &pCldfbRend->hCldfbRend ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA ivas_binaural_hrtf_close_fx( &pCldfbRend->hHrtfFastConv ); +#endif ivas_HRTF_fastconv_binary_close_fx( &pCldfbRend->hHrtfFastConv ); return; diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index a4246e9e0..9dbd30c4f 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -40,13 +40,18 @@ #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* - * ivas_HRTF_binary_open() + * ivas_HRTF_td_binary_open() * * Allocate HRTF binary handle for TD renderer *-----------------------------------------------------------------------*/ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_td_binary_open_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#else ivas_error ivas_HRTF_binary_open_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#endif { /* Allocate HR filter set for headphones configuration */ *hHrtfTD = (TDREND_HRFILT_FiltSet_t *) malloc( sizeof( TDREND_HRFILT_FiltSet_t ) ); @@ -60,15 +65,18 @@ ivas_error ivas_HRTF_binary_open_fx( return IVAS_ERR_OK; } - /*-------------------------------------------------------------------* - * ivas_HRTF_binary_close() + * ivas_HRTF_td_binary_close_fx() * * Close HRTF binary handle for TD renderer *-------------------------------------------------------------------*/ - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +void ivas_HRTF_td_binary_close_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#else void ivas_HRTF_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#endif { test(); IF( hHrtfTD == NULL || *hHrtfTD == NULL ) @@ -76,6 +84,78 @@ void ivas_HRTF_binary_close_fx( return; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + int16_t i; + IF( ( *hHrtfTD )->ModelParams.modelROM ) + { + FOR( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx ); + free( (void *) ( *hHrtfTD )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ + FOR( i = 0; i < ( *hHrtfTD )->ModelParams.elevDim3; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx ); + IF( ( *hHrtfTD )->ModelEval.hrfModR_fx != NULL ) + { + free( ( *hHrtfTD )->ModelEval.hrfModL_fx ); + } + IF( ( *hHrtfTD )->ModelEval.hrfModL_fx != NULL ) + { + free( ( *hHrtfTD )->ModelEval.hrfModR_fx ); + } + } + else + { + if ( ( *hHrtfTD )->ModelParams.UseItdModel ) + { + free( ( *hHrtfTD )->ModelParamsITD.elevKSeq_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimKSeq_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.W_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimBsShape_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.elevBsShape_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimBsLen_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimBsStart_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.elevBsLen_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.elevBsStart_dyn_fx ); + } + free( ( *hHrtfTD )->ModelParams.elevKSeq_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.azim_start_idx_dyn ); + free( ( *hHrtfTD )->ModelParams.azimDim3_dyn ); + free( ( *hHrtfTD )->ModelParams.AlphaL_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.AlphaR_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.azimSegSamples_dyn ); + + free( ( *hHrtfTD )->ModelParams.azimShapeIdx_dyn ); + free( ( *hHrtfTD )->ModelParams.azimShapeSampFactor_dyn ); + free( ( *hHrtfTD )->ModelParams.elevBsLen_dyn ); + free( ( *hHrtfTD )->ModelParams.elevBsStart_dyn ); + free( ( *hHrtfTD )->ModelParams.elevBsShape_dyn_fx ); + + for ( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx ); + + free( (void *) ( *hHrtfTD )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ + for ( i = 0; i < ( *hHrtfTD )->ModelParams.elevDim3; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx ); + + free( ( *hHrtfTD )->ModelParams.EL_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.ER_dyn_fx ); + + free( ( *hHrtfTD )->ModelEval.hrfModL_fx ); + free( ( *hHrtfTD )->ModelEval.hrfModR_fx ); + } +#endif + free( *hHrtfTD ); *hHrtfTD = NULL; @@ -113,11 +193,17 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( * * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_binary_open_buffers_int16( + Word16 **buffer, /* o : buffer to allocate */ + const UWord32 mem_size /* i : size of buffer */ +) +#else ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( Word16 **buffer, /* o : buffer to allocate */ const UWord32 mem_size /* i : size of buffer */ ) +#endif { *buffer = (Word16 *) malloc( mem_size ); @@ -129,7 +215,88 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( return IVAS_ERR_OK; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_uint16() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_uint16( + uint16_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (uint16_t *) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int32() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int32( + int32_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (int32_t *) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int32_ptr() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( + int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (int32_t **) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int32_ptr_const() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( + const int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (const int32_t **) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} +#endif /*-------------------------------------------------------------------* * ivas_HRTF_CRend_binary_close() * @@ -224,6 +391,11 @@ void ivas_HRTF_fastconv_binary_close_fx( return; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + /* Fastconv HRTF memories */ + ivas_binaural_hrtf_close_fx( hHrtfFastConv ); +#endif + free( *hHrtfFastConv ); *hHrtfFastConv = NULL; @@ -288,42 +460,160 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + set_c( (int8_t *) ( *hHrtfStatistics ), 0, (int32_t) sizeof( HRTFS_STATISTICS ) ); +#endif return IVAS_ERR_OK; } - -/*-----------------------------------------------------------------------* - * ivas_HRTF_statistics_close() +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*---------------------------------------------------------------------* + * ivas_HRTF_statistics_close_fx() * - * Close HRTF binary handle for statistics handler - *-----------------------------------------------------------------------*/ + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ -void ivas_HRTF_statistics_close_fx( - HRTFS_STATISTICS **hHrtfStatistics ) +void ivas_HRTF_statistics_binary_close_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) { test(); IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) { return; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + test(); + IF( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) + { + if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_l_dyn ); + } + if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_r_dyn ); + } + if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) + { + free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); + } + } +#endif free( *hHrtfStatistics ); *hHrtfStatistics = NULL; return; } - +#endif /*-----------------------------------------------------------------------* * ivas_HRTF_statistics_init() * * Allocates HRTF statistics handle and initializes from ROM *-----------------------------------------------------------------------*/ - -ivas_error ivas_HRTF_statistics_init_fx( +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_statistics_init_from_rom_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, const Word32 sampleRate ) +#else +ivas_error ivas_HRTF_statistics_init_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, + const Word32 sampleRate ) +#endif { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + + test(); + IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) + { + /* Tables already loaded from file */ + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + SWITCH( sampleRate ) + { + case 48000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_48kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + case 32000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_32kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + case 16000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_16kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q26 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + default: + ( *hHrtfStatistics )->average_energy_l = NULL; + ( *hHrtfStatistics )->average_energy_r = NULL; + ( *hHrtfStatistics )->inter_aural_coherence = NULL; + BREAK; + } + ( *hHrtfStatistics )->fromROM = TRUE; +#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD + ( *hHrtfStatistics )->fromROM = FALSE; // TODO: temporary hack until HRTF statistics ROM tables are converted from Word16 to Word32 +#endif + +#else HRTFS_STATISTICS *HrtfStatistics; test(); @@ -421,37 +711,7 @@ ivas_error ivas_HRTF_statistics_init_fx( #endif *hHrtfStatistics = HrtfStatistics; +#endif return IVAS_ERR_OK; } - -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA -/*---------------------------------------------------------------------* - * ivas_HRTF_statistics_destroy_fx() - * - * Destroy the HRTF statistics set. - *---------------------------------------------------------------------*/ - -void ivas_HRTF_statistics_destroy_fx( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ -) -{ - if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) - { - if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_l_dyn ); - } - if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_r_dyn ); - } - if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) - { - free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); - } - } - - return; -} -#endif \ No newline at end of file diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index 28ee13931..35cf31546 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -151,6 +151,7 @@ void TDREND_MIX_Dealloc_fx( { BSplineModelEvalDealloc_fx( &hBinRendererTd->HrFiltSet_p->ModelParams, &hBinRendererTd->HrFiltSet_p->ModelEval ); } +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA ELSE { IF( hBinRendererTd->HrFiltSet_p->Elev_p_fx != NULL ) @@ -174,7 +175,7 @@ void TDREND_MIX_Dealloc_fx( hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx = NULL; } } - +#endif IF( hBinRendererTd->HrFiltSet_p->ModelParams.modelROM ) { IF( hBinRendererTd->HrFiltSet_p->ModelParams.UseItdModel ) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 469e46f5e..fe2dada8a 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -578,7 +578,15 @@ void ivas_masa_ext_dirac_render_fx( /*----------------------------------------------------------------------------------* * HRTF *----------------------------------------------------------------------------------*/ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_td_binary_open_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); +void ivas_HRTF_td_binary_close_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); +#else ivas_error ivas_HRTF_binary_open_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); @@ -586,6 +594,7 @@ ivas_error ivas_HRTF_binary_open_fx( void ivas_HRTF_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); +#endif ivas_error ivas_HRTF_fastconv_binary_open_fx( HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ @@ -607,29 +616,64 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_binary_open_buffers_uint16( + uint16_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int16( + int16_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int32( + int32_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( + int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( + const int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); +#else ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( Word16 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ); +#endif void ivas_HRTF_CRend_binary_close_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); -ivas_error ivas_HRTF_statistics_init_fx( +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_statistics_init_from_rom_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ const Word32 sampleRate /* i : Sample rate */ ); - -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA -void ivas_HRTF_statistics_destroy_fx( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +#else +ivas_error ivas_HRTF_statistics_init_fx( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ + const Word32 sampleRate /* i : Sample rate */ ); #endif +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_statistics_close_fx( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ ); +#endif + +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +void ivas_HRTF_statistics_binary_close_fx( + HRTFS_STATISTICS **hHrtfStatistics ); /* i/o: HRTF statistics structure */ +#endif ivas_error ivas_HRTF_statistics_binary_open_fx( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index a113298e8..f06fcee67 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1166,13 +1166,17 @@ typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct Word16 NumPos; Word16 NumElev; Word32 Dist_fx; +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA Word32 *ItdSet_p_fx; +#endif Word16 FiltLength; +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA Word16 *Azim_p_fx; Word16 *Elev_p_fx; Word16 *ItdSetNominal_p_fx; Word16 *LeftFiltSet_p_fx; Word16 *RightFiltSet_p_fx; +#endif ModelParams_t ModelParams; ModelEval_t ModelEval; ModelParamsITD_t ModelParamsITD; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 9b42d17b2..a3aa7747b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -3786,10 +3786,17 @@ ivas_error IVAS_REND_Open( IF( asHrtfBinary ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IF( NE_32( ( error = ivas_HRTF_td_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) { return error; } +#endif IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) ) ), IVAS_ERR_OK ) ) { return error; @@ -3810,7 +3817,21 @@ ivas_error IVAS_REND_Open( IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( hIvasRend->hHrtfs.hHrtfStatistics == NULL ) + { + /* Allocate HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + /* Init HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -9806,15 +9827,25 @@ void IVAS_REND_Close( ivas_external_orientation_close_fx( &hIvasRend->hExternalOrientationData ); ivas_combined_orientation_close_fx( &hIvasRend->hCombinedOrientationData ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( &hIvasRend->hHrtfs.hHrtfFastConv ); +#endif - /* Parametric binauralizer HRTF filters */ +/* Parametric binauralizer HRTF filters */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ); +#else ivas_HRTF_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ); +#endif ivas_HRTF_CRend_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) ); ivas_HRTF_fastconv_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); ivas_HRTF_parambin_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfParambin ) ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); +#else ivas_HRTF_statistics_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); +#endif free( hIvasRend ); *phIvasRend = NULL; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 18422694d..95c5e634b 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -296,7 +296,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( &modelITD->elevDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( float ) ); +#else modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word16 ) ); if ( modelITD->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -311,7 +315,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); fread( &modelITD->azimDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); +#else modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ +#endif v_tmp16 = (Word16 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word16 ) ); if ( modelITD->azimKSeq_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -326,7 +334,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->W_dyn_fx, tmp * sizeof( float ) ); +#else modelITD->W_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( modelITD->W_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -348,13 +360,21 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); /* azimuth */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->azimBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->azimBsLen_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( modelITD->azimBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->azimBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->azimBsStart_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -362,7 +382,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->azimBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( float ) ); +#else modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( modelITD->azimBsShape_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -379,13 +403,21 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &modelITD->azimSegSamples, sizeof( Word16 ), 1, f_hrtf ); /* elevation */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->elevBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->elevBsLen_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( modelITD->elevBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->elevBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->elevBsStart_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -393,7 +425,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->elevBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( float ) ); +#else modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( modelITD->elevBsShape_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -489,7 +525,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->K, sizeof( Word16 ), 1, f_hrtf ); fread( &model->elevDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( float ) ); +#else model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word16 ) ); if ( model->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) @@ -503,9 +543,21 @@ static ivas_error TDREND_LoadBSplineBinary( model->elevKSeq_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q ); } free( v_tmp16 ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azimDim3_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azim_start_idx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimKSeq_fx, model->elevDim3 * sizeof( float * ) ); +#else model->azimKSeq_fx = (Word32 **) malloc( model->elevDim3 * sizeof( Word32 * ) ); +#endif if ( model->azimDim3_dyn == NULL || model->azim_start_idx_dyn == NULL || model->azimKSeq_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -515,7 +567,11 @@ static ivas_error TDREND_LoadBSplineBinary( { fread( &model->azimDim3_dyn[i], sizeof( Word16 ), 1, f_hrtf ); fread( &model->azim_start_idx_dyn[i], sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( float ) ); +#else model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word16 ) ); if ( model->azimKSeq_fx[i] == NULL || v_tmp16 == NULL ) @@ -531,8 +587,11 @@ static ivas_error TDREND_LoadBSplineBinary( free( v_tmp16 ); } fread( &model->AlphaN, sizeof( Word16 ), 1, f_hrtf ); - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( float ) ); +#else model->AlphaL_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( model->AlphaN * model->K * sizeof( Word16 ) ); if ( model->AlphaL_dyn_fx == NULL || v_tmp16 == NULL ) @@ -550,7 +609,11 @@ static ivas_error TDREND_LoadBSplineBinary( { model->AlphaL_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( float ) ); +#else model->AlphaR_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); +#endif if ( model->AlphaR_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -566,9 +629,21 @@ static ivas_error TDREND_LoadBSplineBinary( /* azimuth */ fread( &model->num_unique_azim_splines, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32_ptr_const( &model->azimBsShape_fx, model->num_unique_azim_splines * sizeof( float * ) ); +#else model->azimBsShape_fx = (const Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimBsShape_dyn_fx, model->num_unique_azim_splines * sizeof( float * ) ); +#else model->azimBsShape_dyn_fx = (Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( int16_t ) ); +#else model->azimSegSamples_dyn = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) ); +#endif if ( model->azimBsShape_fx == NULL || model->azimBsShape_dyn_fx == NULL || model->azimSegSamples_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -577,7 +652,11 @@ static ivas_error TDREND_LoadBSplineBinary( for ( i = 0; i < model->num_unique_azim_splines; i++ ) { fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->azimBsShape_dyn_fx[i], tmp * sizeof( float ) ); +#else model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( model->azimBsShape_dyn_fx[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -597,8 +676,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->azimSegSamples_dyn[i], sizeof( Word16 ), 1, f_hrtf ); free( v_tmp16 ); } - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azimShapeIdx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif if ( model->azimShapeIdx_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -612,13 +694,21 @@ static ivas_error TDREND_LoadBSplineBinary( fread( model->azimShapeSampFactor_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); /* elevation */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else model->elevBsLen_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( model->elevBsLen_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( model->elevBsLen_dyn, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else model->elevBsStart_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( model->elevBsStart_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -627,7 +717,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->elevBsShape_dyn_fx, tmp * sizeof( float ) ); +#else model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( model->elevBsShape_dyn_fx == NULL || v_tmp16 == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -643,7 +737,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->elevSegSamples, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->EL_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( float ) ); +#else model->EL_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); +#endif if ( model->EL_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -655,7 +753,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( (Word32 *) model->EL_dyn_fx, sizeof( Word32 ), model->AlphaN * HRTF_MODEL_N_SECTIONS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->ER_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( float ) ); +#else model->ER_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); +#endif if ( model->ER_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -685,8 +787,13 @@ static ivas_error TDREND_LoadBSplineBinary( HRTF_model_precalc( model ); HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModL_fx, model->K * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModR_fx, model->K * sizeof( float ) ); +#else HrFiltSet_p->ModelEval.hrfModL_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); HrFiltSet_p->ModelEval.hrfModR_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); +#endif if ( HrFiltSet_p->ModelEval.hrfModL_fx == NULL || HrFiltSet_p->ModelEval.hrfModR_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -799,10 +906,15 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_l_dyn, lr_iac_len * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_r_dyn, lr_iac_len * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->inter_aural_coherence_dyn, lr_iac_len * sizeof( float ) ); +#else hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - +#endif if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -1013,7 +1125,6 @@ ivas_error load_TDrend_HRTF_binary( return TDREND_MIX_LoadHRTF( hrtfReader->file, sampleRate, hHrtf ); } - /*---------------------------------------------------------------------* * destroy_td_hrtf() * @@ -1024,8 +1135,11 @@ void destroy_td_hrtf( IVAS_DEC_HRTF_TD_HANDLE *hHrtf /* i/o: TD rend. HRTF handle */ ) { - int16_t i; +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( hHrtf ); +#else + int16_t i; if ( ( hHrtf == NULL ) || ( *hHrtf == NULL ) ) { return; @@ -1077,8 +1191,9 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelEval.hrfModL_fx ); free( ( *hHrtf )->ModelEval.hrfModR_fx ); } - ivas_HRTF_binary_close_fx( hHrtf ); +#endif + return; } @@ -1150,7 +1265,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1177,7 +1296,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1220,7 +1343,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1247,7 +1374,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1282,7 +1413,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1306,7 +1441,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1992,6 +2131,9 @@ void destroy_crend_hrtf( IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_CRend_binary_close_fx( hHrtfCrend ); +#else uint16_t i, j; test(); @@ -2033,6 +2175,7 @@ void destroy_crend_hrtf( free( *hHrtfCrend ); *hHrtfCrend = NULL; } +#endif return; } @@ -2048,9 +2191,10 @@ void destroy_fastconv_hrtf( IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv /* i/o: FastConv HRTF handle */ ) { +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( hHrtfFastConv ); - +#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( hHrtfFastConv ); @@ -2084,7 +2228,7 @@ void destroy_hrtf_statistics( ) { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_statistics_destroy_fx( hHrtfStatistics ); + ivas_HRTF_statistics_binary_close_fx( hHrtfStatistics ); #else if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { @@ -2101,8 +2245,8 @@ void destroy_hrtf_statistics( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } -#endif ivas_HRTF_statistics_close_fx( hHrtfStatistics ); +#endif return; } -- GitLab From 5552d2c0d9ca7fa071c5bf6f3ec4b28dd893f20d Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 11:24:00 +0100 Subject: [PATCH 170/750] fix usan and missing switch --- apps/decoder.c | 28 +++++++++++++++++----------- lib_dec/ivas_init_dec_fx.c | 10 ++++++---- lib_dec/lib_dec.h | 5 +++++ lib_dec/lib_dec_fx.c | 15 +++++++++++++-- lib_rend/ivas_hrtf_fx.c | 12 ++++++++---- 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 197dddaa8..7e9113933 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -740,7 +740,6 @@ cleanup: destroy_td_hrtf( hHrtfBinary.hHrtfTD ); destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics ); } -#endif #ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD // TODO: /* This free differs from float version. @@ -748,6 +747,7 @@ cleanup: IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); destroy_hrtf_statistics( hHrtfStatistics ); +#endif #endif IVAS_DEC_Close( &hIvasDec ); CustomLsReader_close( &hLsCustomReader ); @@ -3901,7 +3901,8 @@ static ivas_error load_hrtf_from_file( { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; - if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + Word16 initFromRom; + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics, &initFromRom ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) #endif @@ -3911,25 +3912,30 @@ static ivas_error load_hrtf_from_file( } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - if ( ( error = load_reverb_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) + if ( initFromRom ) + { + if ( ( error = load_reverb_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #else if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); - return error; - } - else { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); + return error; + } + else + { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - destroy_hrtf_statistics( hHrtfStatistics ); + destroy_hrtf_statistics( hHrtfStatistics ); #else destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); #endif + } } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA } +#endif } return IVAS_ERR_OK; diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index e212ee0a6..a554e3a87 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1800,12 +1800,14 @@ ivas_error ivas_init_decoder_fx( { /* Init HRTF statistics */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - /* Allocate HRTF statistics */ - IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( st_ivas->hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + if ( st_ivas->hHrtfStatistics == NULL ) { - return error; + /* Allocate HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( st_ivas->hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + { + return error; + } } - /* Init HRTF statistics */ IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) #else diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 58c33c92d..3d60a042d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -440,6 +440,11 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( ivas_error IVAS_DEC_GetHrtfStatisticsHandle( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + , /* o : HRTF statistics handle */ + Word16 *intialisedFromRom /* o : int16_t handle */ +#endif + ); ivas_error IVAS_DEC_HRTF_binary_open( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 882d5f413..3954b7436 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2470,18 +2470,29 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfStatisticsHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + , /* o : HRTF statistics handle */ + Word16 *intialisedFromRom /* o : int16_t handle */ +#endif ) { test(); test(); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL || intialisedFromRom == NULL ) +#else IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) +#endif { return IVAS_ERR_WRONG_PARAMS; } *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + *intialisedFromRom = hIvasDec->st_ivas->hHrtfStatistics->fromROM; +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 9dbd30c4f..0b435be32 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -466,16 +466,20 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( return IVAS_ERR_OK; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /*---------------------------------------------------------------------* - * ivas_HRTF_statistics_close_fx() + * ivas_HRTF_statistics_binary_close_fx() * * Destroy the HRTF statistics set. *---------------------------------------------------------------------*/ - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_statistics_binary_close_fx( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) +#else +void ivas_HRTF_statistics_close_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +#endif { test(); IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) @@ -506,7 +510,7 @@ void ivas_HRTF_statistics_binary_close_fx( return; } -#endif + /*-----------------------------------------------------------------------* * ivas_HRTF_statistics_init() -- GitLab From c6d3dbf890130d1d8cfc3b78762e05ce6f55598e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 12:42:52 +0100 Subject: [PATCH 171/750] fix clang18 MSAN complaint in decoder init --- lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..5d6bde6f9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER /* FhG: fix CLANG18 MSAN error in decoder init */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0bc064d05..26f0f52e7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -232,43 +232,56 @@ ivas_error IVAS_DEC_Open( move16(); /* set high-level parameters */ +#ifdef FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER + st_ivas->codec_mode = 0; /* unknown before first frame */ + st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; + st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID; + st_ivas->writeFECoffset = 0; + st_ivas->sba_analysis_order = 0; /* not really used in EVS mode, but initialize here to fix MSAN complaint */ + move16(); + move16(); + move16(); + move16(); + move16(); + +#endif IF( EQ_16( mode, IVAS_DEC_MODE_EVS ) ) { +#ifndef FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER st_ivas->codec_mode = 0; /* unknown before first frame */ - st_ivas->element_mode_init = EVS_MONO; - st_ivas->ivas_format = MONO_FORMAT; st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID; st_ivas->writeFECoffset = 0; +#endif + st_ivas->element_mode_init = EVS_MONO; + st_ivas->ivas_format = MONO_FORMAT; hIvasDec->hasDecodedFirstGoodFrame = true; /* Functionality to suppress output for initial lost frames is disabled in EVS operation */ move16(); move16(); move16(); - move16(); - move16(); - move16(); - move16(); return IVAS_ERR_OK; } ELSE IF( EQ_16( mode, IVAS_DEC_MODE_IVAS ) ) { +#ifndef FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER st_ivas->codec_mode = 0; /* unknown before first frame */ - st_ivas->element_mode_init = -1; - st_ivas->ivas_format = UNDEFINED_FORMAT; st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID; + st_ivas->writeFECoffset = 0; + st_ivas->sba_analysis_order = 0; +#endif + st_ivas->element_mode_init = -1; + st_ivas->ivas_format = UNDEFINED_FORMAT; st_ivas->renderer_type = RENDERER_DISABLE; st_ivas->ini_frame = 0; st_ivas->ini_active_frame = 0; - st_ivas->writeFECoffset = 0; st_ivas->ism_mode = ISM_MODE_NONE; st_ivas->mc_mode = MC_MODE_NONE; st_ivas->sba_order = 0; st_ivas->sba_planar = 0; - st_ivas->sba_analysis_order = 0; move16(); move16(); @@ -279,11 +292,6 @@ ivas_error IVAS_DEC_Open( move16(); move16(); move16(); - move16(); - move16(); - move16(); - move16(); - move16(); return IVAS_ERR_OK; } -- GitLab From ad9353ab3556c633b11c23d27c6d0c986805ebf7 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 12:47:39 +0100 Subject: [PATCH 172/750] add initialization for hSCE->last_element_brate --- lib_com/options.h | 1 + lib_dec/ivas_sce_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..ca10111df 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE /* FhG: initialize last_element_brate to avoid CLANG18 MSAN complaint */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index a889c505d..a51b9f6f5 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -385,6 +385,10 @@ ivas_error create_sce_dec( move16(); hSCE->element_brate = element_brate; /*Q0*/ move32(); +#ifdef FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE + hSCE->last_element_brate = hSCE->element_brate; + move32(); +#endif set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); -- GitLab From 1e7023bd1a58edef252237cac09bd35f4eb3ca43 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 12:50:24 +0100 Subject: [PATCH 173/750] initialze st->element_brate per default --- lib_com/options.h | 1 + lib_dec/ivas_sce_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..bd0b7e4a0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE /* FhG: initialize st->element_brate per default */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index a889c505d..a6ba0bae6 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -402,6 +402,10 @@ ivas_error create_sce_dec( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ move32(); +#ifdef FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE + st->element_brate = 0; + move32(); +#endif st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move16(); st->is_ism_format = 0; -- GitLab From 561090e2bc5e13593318859c85101484e4788759 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 13:19:49 +0100 Subject: [PATCH 174/750] use offset instead of pre-set pointer --- lib_com/options.h | 1 + lib_enc/tcx_ltp_enc_fx.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..3c2cd73ad 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH /* FhG: fix OOB index USAN error in TCX LTP pitch search */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 012d6fa02..71ab78e64 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -4,7 +4,7 @@ #include #include "options.h" -//#include "prot_fx.h" +// #include "prot_fx.h" #include "stl.h" #include "cnst.h" #include "basop_util.h" @@ -292,7 +292,11 @@ static void tcx_ltp_pitch_search_ivas_fx( const Word16 check_border_case, Word16 *border_case ) { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 i, t, t0, t_offset, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; +#else Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; +#endif Word32 cor_max, cor[256], *pt_cor, temp; Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; @@ -417,9 +421,13 @@ static void tcx_ltp_pitch_search_ivas_fx( * Search fractional pitch with 1/4 subsample resolution. * search the fractions around t0 and choose the one which maximizes * the interpolated normalized correlation. - *-----------------------------------------------------------------*/ + *--------------FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH---------------------------------------------------*/ +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + t_offset = sub( L_INTERPOL1, t0_min ); +#else pt_cor = cor + sub( L_INTERPOL1, t0_min ); +#endif t0 = t1; move16(); @@ -437,16 +445,28 @@ static void tcx_ltp_pitch_search_ivas_fx( { fraction = 0; move16(); +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_max = interpolate_corr( &cor[t0 + t_offset], fraction, pitres ); +#else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); +#endif } ELSE /* Process negative fractions */ { t0 = sub( t0, 1 ); +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_max = interpolate_corr( &cor[t0 + t_offset], fraction, pitres ); +#else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); +#endif FOR( i = fraction + step; i < pitres; i += step ) { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + temp = interpolate_corr( &cor[t0 + t_offset], i, pitres ); +#else temp = interpolate_corr( &pt_cor[t0], i, pitres ); +#endif IF( GT_32( temp, cor_max ) ) { @@ -459,7 +479,11 @@ static void tcx_ltp_pitch_search_ivas_fx( FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + temp = interpolate_corr( &cor[t1 + t_offset], i, pitres ); +#else temp = interpolate_corr( &pt_cor[t1], i, pitres ); +#endif IF( GT_32( temp, cor_max ) ) { -- GitLab From 867348fd5eedc81d6702ac48a0b03dc722160abd Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 12 Dec 2025 13:35:38 +0100 Subject: [PATCH 175/750] fix for UBSAN issue in RC context mapping; this reflects changes from float, and corrects the BASOP instrumentation/operators --- lib_com/options.h | 1 + lib_dec/ACcontextMapping_dec_fx.c | 14 ++++++++++++++ lib_enc/ACcontextMapping_enc_fx.c | 26 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..df085b5f6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_1464_UBSAN_RC_CONTEXT_MAP /* FhG: BE UBSAN fix for float issue 1464 in the TCX range coder */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index 60269751b..f97d553e6 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -588,7 +588,11 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( ELSE /* if(!hm_cfg) */ { Word16 c, rateQ; +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + UWord32 s; +#else UWord16 s; +#endif /* Rate flag */ IF( GT_16( nbbits, 400 ) ) @@ -613,7 +617,11 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( t = 0; move16(); s = 0; +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + move32(); +#else move16(); +#endif /* Main Loop through the 2-tuples */ FOR( k = 0; k < lastnz; k += 2 ) { @@ -701,9 +709,15 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( c = add( 12, esc_nb ); } +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + s = L_shl( s, 4 ); /*Shift old 4 bits*/ + s = L_add( s, c ); /*replace last 4 bits*/ + t = extract_l( L_and( s, 0xFF ) ); +#else s = (UWord16) L_shl( s, 4 ); /*Shift old 4 bits*/ s = (UWord16) L_add( s, c ); /*replace last 4 bits*/ t = (UWord16) L_and( s, 0xFF ); +#endif } /* Decode signs */ diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 91edc47a5..689c90615 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -973,7 +973,11 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( { Word16 cp; Word16 esc_nb, rateQ; +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + UWord32 s; +#else UWord16 s; +#endif /* Rate flag */ IF( GT_16( nbbits, 400 ) ) @@ -988,7 +992,11 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( } s = 0; +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + move32(); +#else move16(); +#endif /* Find last non-zero tuple */ /* ensure termination of while loop by dummy value */ @@ -1099,8 +1107,13 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( } /*Shift old 4 bits, replace last 4 bits*/ +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + s = L_add( L_shl( s, 4 ), cp ); + t = extract_l( L_and( s, 0xFF ) ); +#else s = (UWord16) ( L_add( L_shl( s, 4 ), cp ) ); t = (UWord16) L_and( s, 0xFF ); +#endif } /*end of the 2-tuples loop*/ } @@ -1453,7 +1466,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ELSE /* if (!hm_cfg) */ { Word16 esc_nb, cp, rateQ; +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + UWord32 s; +#else UWord16 s; +#endif Word16 tot_bits2; Word16 overflow_flag = 0; move16(); @@ -1473,7 +1490,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( t = 0; move16(); s = 0; +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + move32(); +#else move16(); +#endif cp = 0; move16(); lastnz = 1; @@ -1564,8 +1585,13 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( cp = add( 12, esc_nb ); /* Q0 */ } /*shift old bits and replace last 4 bits*/ +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + s = L_add( L_shl( s, 4 ), cp ); + t = extract_l( L_and( s, 0xFF ) ); +#else s = (UWord16) L_add( L_shl( s, 4 ), cp ); t = s_and( s, 0xFF ); +#endif } /*end of the 2-tuples loop*/ tot_bits2 = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ -- GitLab From 5a744a05e96b891f62ad9e10ad67f83053ea3bb1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 14:45:09 +0100 Subject: [PATCH 176/750] cleanup fix for 2272 - rename variable - use BASOP for addition - move calculation out of loop --- lib_enc/tcx_ltp_enc_fx.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 71ab78e64..3b3923dd1 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -293,7 +293,7 @@ static void tcx_ltp_pitch_search_ivas_fx( Word16 *border_case ) { #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - Word16 i, t, t0, t_offset, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; + Word16 i, t, t0, cor_idx, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; #else Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; #endif @@ -423,7 +423,7 @@ static void tcx_ltp_pitch_search_ivas_fx( * the interpolated normalized correlation. *--------------FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH---------------------------------------------------*/ #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - t_offset = sub( L_INTERPOL1, t0_min ); + cor_idx = sub( L_INTERPOL1, t0_min ); #else pt_cor = cor + sub( L_INTERPOL1, t0_min ); @@ -443,19 +443,29 @@ static void tcx_ltp_pitch_search_ivas_fx( IF( EQ_16( t0, t0_min ) ) /* Limit case */ { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 cor_idx_tmp; + + cor_idx_tmp = add( cor_idx, t0 ); +#endif fraction = 0; move16(); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_max = interpolate_corr( &cor[t0 + t_offset], fraction, pitres ); + cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); #endif } ELSE /* Process negative fractions */ { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 cor_idx_tmp; + + cor_idx_tmp = add( cor_idx, t0 ); +#endif t0 = sub( t0, 1 ); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_max = interpolate_corr( &cor[t0 + t_offset], fraction, pitres ); + cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); #endif @@ -463,7 +473,7 @@ static void tcx_ltp_pitch_search_ivas_fx( FOR( i = fraction + step; i < pitres; i += step ) { #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - temp = interpolate_corr( &cor[t0 + t_offset], i, pitres ); + temp = interpolate_corr( &cor[cor_idx_tmp], i, pitres ); #else temp = interpolate_corr( &pt_cor[t0], i, pitres ); #endif @@ -477,10 +487,13 @@ static void tcx_ltp_pitch_search_ivas_fx( } } +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_idx = add( t1, cor_idx ); +#endif FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - temp = interpolate_corr( &cor[t1 + t_offset], i, pitres ); + temp = interpolate_corr( &cor[cor_idx], i, pitres ); #else temp = interpolate_corr( &pt_cor[t1], i, pitres ); #endif -- GitLab From 6e9d1a7e08730bb98ff1597d81157161429a7802 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 14:47:50 +0100 Subject: [PATCH 177/750] bug smoke test fix --- lib_util/hrtf_file_reader.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 95c5e634b..3247b27db 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -686,7 +686,11 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( model->azimShapeIdx_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azimShapeSampFactor_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif if ( model->azimShapeSampFactor_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); -- GitLab From 03d286d74d7e4b936a3a3a5a4db0da7fdea37f18 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 14:48:01 +0100 Subject: [PATCH 178/750] fix mistake --- lib_enc/tcx_ltp_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 3b3923dd1..f40ce2e80 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -421,7 +421,7 @@ static void tcx_ltp_pitch_search_ivas_fx( * Search fractional pitch with 1/4 subsample resolution. * search the fractions around t0 and choose the one which maximizes * the interpolated normalized correlation. - *--------------FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH---------------------------------------------------*/ + *-----------------------------------------------------------------*/ #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx = sub( L_INTERPOL1, t0_min ); #else -- GitLab From eed8d18c714d4076ff2418abdf2ae6338acf8448 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 12 Dec 2025 15:03:08 +0100 Subject: [PATCH 179/750] adapt patch, to avoid overflows --- lib_dec/ACcontextMapping_dec_fx.c | 15 ++++----------- lib_enc/ACcontextMapping_enc_fx.c | 24 ++++-------------------- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index f97d553e6..60c4d4688 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -588,11 +588,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( ELSE /* if(!hm_cfg) */ { Word16 c, rateQ; -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - UWord32 s; -#else UWord16 s; -#endif /* Rate flag */ IF( GT_16( nbbits, 400 ) ) @@ -617,11 +613,8 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( t = 0; move16(); s = 0; -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - move32(); -#else move16(); -#endif + /* Main Loop through the 2-tuples */ FOR( k = 0; k < lastnz; k += 2 ) { @@ -710,9 +703,9 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( } #ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - s = L_shl( s, 4 ); /*Shift old 4 bits*/ - s = L_add( s, c ); /*replace last 4 bits*/ - t = extract_l( L_and( s, 0xFF ) ); + s = shl( s_and( s, 0x0F ), 4 ); /*Shift old 4 bits*/ + s = add( s, c ); /*replace last 4 bits*/ + t = s_and( s, 0xFF ); #else s = (UWord16) L_shl( s, 4 ); /*Shift old 4 bits*/ s = (UWord16) L_add( s, c ); /*replace last 4 bits*/ diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 689c90615..2d2ad83b1 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -973,11 +973,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( { Word16 cp; Word16 esc_nb, rateQ; -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - UWord32 s; -#else UWord16 s; -#endif /* Rate flag */ IF( GT_16( nbbits, 400 ) ) @@ -992,11 +988,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( } s = 0; -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - move32(); -#else move16(); -#endif /* Find last non-zero tuple */ /* ensure termination of while loop by dummy value */ @@ -1108,8 +1100,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( /*Shift old 4 bits, replace last 4 bits*/ #ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - s = L_add( L_shl( s, 4 ), cp ); - t = extract_l( L_and( s, 0xFF ) ); + s = add( shl( s_and( s, 0x0F ), 4 ), cp ); + t = s_and( s, 0xFF ); #else s = (UWord16) ( L_add( L_shl( s, 4 ), cp ) ); t = (UWord16) L_and( s, 0xFF ); @@ -1466,11 +1458,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ELSE /* if (!hm_cfg) */ { Word16 esc_nb, cp, rateQ; -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - UWord32 s; -#else UWord16 s; -#endif Word16 tot_bits2; Word16 overflow_flag = 0; move16(); @@ -1490,11 +1478,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( t = 0; move16(); s = 0; -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - move32(); -#else move16(); -#endif cp = 0; move16(); lastnz = 1; @@ -1586,8 +1570,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*shift old bits and replace last 4 bits*/ #ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP - s = L_add( L_shl( s, 4 ), cp ); - t = extract_l( L_and( s, 0xFF ) ); + s = add( shl( s_and( s, 0x0F ), 4 ), cp ); + t = s_and( s, 0xFF ); #else s = (UWord16) L_add( L_shl( s, 4 ), cp ); t = s_and( s, 0xFF ); -- GitLab From 6a274a052381e3e2ea22db23bef2b096caa4f73e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 12 Dec 2025 15:08:16 +0100 Subject: [PATCH 180/750] formatting --- lib_dec/ACcontextMapping_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index 60c4d4688..e88d96aa6 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -704,7 +704,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( #ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP s = shl( s_and( s, 0x0F ), 4 ); /*Shift old 4 bits*/ - s = add( s, c ); /*replace last 4 bits*/ + s = add( s, c ); /*replace last 4 bits*/ t = s_and( s, 0xFF ); #else s = (UWord16) L_shl( s, 4 ); /*Shift old 4 bits*/ -- GitLab From fb9b4f1e7e94ff4bea52a428dfd3cafbf2e01b5c Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 15:20:19 +0100 Subject: [PATCH 181/750] bug bix and code refactoring --- lib_rend/ivas_hrtf_fx.c | 22 +++--- lib_util/hrtf_file_reader.c | 134 ++++++++++++++++++------------------ 2 files changed, 78 insertions(+), 78 deletions(-) diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 0b435be32..7854afbbb 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -85,7 +85,7 @@ void ivas_HRTF_binary_close_fx( } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - int16_t i; + Word16 i; IF( ( *hHrtfTD )->ModelParams.modelROM ) { FOR( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ ) @@ -222,11 +222,11 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_uint16( - uint16_t **buffer, /* o : buffer to allocate */ + UWord16 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (uint16_t *) malloc( mem_size ); + *buffer = (UWord16 *) malloc( mem_size ); if ( *buffer == NULL ) { @@ -242,11 +242,11 @@ ivas_error ivas_HRTF_binary_open_buffers_uint16( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_int32( - int32_t **buffer, /* o : buffer to allocate */ + Word32 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (int32_t *) malloc( mem_size ); + *buffer = (Word32 *) malloc( mem_size ); if ( *buffer == NULL ) { @@ -262,11 +262,11 @@ ivas_error ivas_HRTF_binary_open_buffers_int32( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( - int32_t ***buffer, /* o : buffer to allocate */ + Word32 ***buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (int32_t **) malloc( mem_size ); + *buffer = (Word32 **) malloc( mem_size ); if ( *buffer == NULL ) { @@ -282,11 +282,11 @@ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( - const int32_t ***buffer, /* o : buffer to allocate */ - const uint32_t mem_size /* i : size of buffer */ + const Word32 ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (const int32_t **) malloc( mem_size ); + *buffer = (const Word32 **) malloc( mem_size ); if ( *buffer == NULL ) { @@ -461,7 +461,7 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - set_c( (int8_t *) ( *hHrtfStatistics ), 0, (int32_t) sizeof( HRTFS_STATISTICS ) ); + set_c( (Word8 *) ( *hHrtfStatistics ), 0, (Word32) sizeof( HRTFS_STATISTICS ) ); #endif return IVAS_ERR_OK; } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 3247b27db..5f1b47235 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -51,9 +51,9 @@ struct hrtfFileReader typedef struct ivas_hrtfs_file_header_t { char identifier[8]; - int32_t file_size; - int16_t nb_hrtf; - int32_t max_data_size; + Word32 file_size; + Word16 nb_hrtf; + Word32 max_data_size; } ivas_hrtfs_file_header_t; @@ -129,7 +129,7 @@ static ivas_error read_and_check_hrtf_binary_file_header( ivas_hrtfs_file_header_t *hrtf_file_header, FILE *f_hrtf ) { - int32_t file_size; + Word32 file_size; if ( hrtf_file_header == NULL || f_hrtf == NULL ) { @@ -146,7 +146,7 @@ static ivas_error read_and_check_hrtf_binary_file_header( file_size = ftell( f_hrtf ); fseek( f_hrtf, 0, SEEK_SET ); - if ( file_size < (int32_t) sizeof( ivas_hrtfs_file_header_t ) ) + if ( file_size < (Word32) sizeof( ivas_hrtfs_file_header_t ) ) { return IVAS_ERROR( IVAS_ERR_END_OF_FILE, "HRTF binary file not compliant (size of file header)" ); } @@ -230,7 +230,7 @@ static ivas_error read_hrtf_binary_header( /* Sampling Frequency (4 bytes) */ /* Raw data size (4 bytes) */ - if ( ( fread( &( hrtf_header->rend_type ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) ) + if ( ( fread( &( hrtf_header->rend_type ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) ) { return IVAS_ERR_OK; } @@ -361,7 +361,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( /* azimuth */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->azimBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -371,7 +371,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( modelITD->azimBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->azimBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -404,7 +404,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( /* elevation */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->elevBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -414,7 +414,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( modelITD->elevBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->elevBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -544,12 +544,12 @@ static ivas_error TDREND_LoadBSplineBinary( } free( v_tmp16 ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azimDim3_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azim_start_idx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif @@ -640,7 +640,7 @@ static ivas_error TDREND_LoadBSplineBinary( model->azimBsShape_dyn_fx = (Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); #endif #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( Word16 ) ); #else model->azimSegSamples_dyn = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) ); #endif @@ -677,7 +677,7 @@ static ivas_error TDREND_LoadBSplineBinary( free( v_tmp16 ); } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azimShapeIdx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif @@ -687,7 +687,7 @@ static ivas_error TDREND_LoadBSplineBinary( } fread( model->azimShapeIdx_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeSampFactor_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azimShapeSampFactor_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif @@ -699,7 +699,7 @@ static ivas_error TDREND_LoadBSplineBinary( /* elevation */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else model->elevBsLen_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -709,7 +709,7 @@ static ivas_error TDREND_LoadBSplineBinary( } fread( model->elevBsLen_dyn, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else model->elevBsStart_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -830,12 +830,12 @@ static ivas_error load_reverb_from_binary( bool is_reverb; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; + Word16 hrtf_id; ivas_hrtfs_header_t hrtf_header; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; - int16_t lr_iac_len; - int16_t ind; + Word16 lr_iac_len; + Word16 ind; Word16 factorQ; Word16 tmp16; @@ -989,13 +989,13 @@ static ivas_error TDREND_MIX_LoadHRTF( IVAS_DEC_HRTF_TD_HANDLE HrFiltSet_p /* o : Loaded HR filter set */ ) { - int16_t tmp; + Word16 tmp; bool is_tdrend; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; + Word16 hrtf_id; ivas_hrtfs_header_t hrtf_header; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; if ( f_hrtf == NULL ) @@ -1010,7 +1010,7 @@ static ivas_error TDREND_MIX_LoadHRTF( /* try if it is old format for BE tests*/ fseek( f_hrtf, 0, SEEK_SET ); - if ( fread( &tmp, 1, sizeof( int16_t ), f_hrtf ) == 0 ) + if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) { header_check_result = IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -1082,7 +1082,7 @@ static ivas_error TDREND_MIX_LoadHRTF( if ( is_tdrend ) { - if ( fread( &tmp, 1, sizeof( int16_t ), f_hrtf ) == 0 ) + if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) { return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -1115,7 +1115,7 @@ static ivas_error TDREND_MIX_LoadHRTF( ivas_error load_TDrend_HRTF_binary( IVAS_DEC_HRTF_TD_HANDLE hHrtf, /* i/o: TD rend. HRTF handle */ - const int32_t sampleRate, /* i : sample rate */ + const Word32 sampleRate, /* i : sample rate */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ) { @@ -1143,7 +1143,7 @@ void destroy_td_hrtf( #ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_td_binary_close_fx( hHrtf ); #else - int16_t i; + Word16 i; if ( ( hHrtf == NULL ) || ( *hHrtf == NULL ) ) { return; @@ -1299,7 +1299,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { - mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); + mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( UWord16 ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) #else @@ -1316,7 +1316,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* index_frequency_max_diffuse */ ( *hHRTF )->index_frequency_max_diffuse = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* inv_diffuse_weight Q factor*/ ( *hHRTF )->factor_Q_inv_diffuse_weight = Q15 - *( (Word16 *) ( hrtf_data_rptr ) ); @@ -1405,8 +1405,8 @@ static ivas_error create_Crend_HRTF_from_rawdata( } /* max_total_num_fsamp_per_iteration_diff */ - max_total_num_fsamp_per_iteration_diff = *( (uint32_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint32_t ); + max_total_num_fsamp_per_iteration_diff = *( (UWord32 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord32 ); mem_size_buf = max_total_num_fsamp_per_iteration_diff * sizeof( Word16 ); @@ -1513,17 +1513,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata( latency_s = *( (Word32 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word32 ); - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( BINAURAL_CONVBANDS != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); - nbchan = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + nbchan = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); - ntaps = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + ntaps = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); ( *hHRTF )->ntaps = ntaps; ( *hHRTF )->FASTCONV_latency_s_Q_fx = Q31 - factorQ; @@ -1689,11 +1689,11 @@ static ivas_error create_parambin_HRTF_from_rawdata( char *hrtf_data /* i : pointer to binary file */ ) { - int16_t i, j, k; + Word16 i, j, k; char *hrtf_data_rptr; - uint32_t data_size_tmp; + UWord32 data_size_tmp; Word16 factorQ; - int16_t *ptW16; + Word16 *ptW16; if ( hrtf_data == NULL ) { @@ -1703,30 +1703,30 @@ static ivas_error create_parambin_HRTF_from_rawdata( hrtf_data_rptr = hrtf_data; /* HRTF_SH_CHANNELS */ - if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( HRTF_SH_CHANNELS != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* HRTF_NUM_BINS */ - if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( HRTF_NUM_BINS != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* HRTF */ /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - data_size_tmp = HRTF_NUM_BINS * sizeof( int16_t ); + data_size_tmp = HRTF_NUM_BINS * sizeof( Word16 ); for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < HRTF_NUM_BINS; k++ ) { @@ -1739,7 +1739,7 @@ static ivas_error create_parambin_HRTF_from_rawdata( { for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < HRTF_NUM_BINS; k++ ) { ( *hHRTF )->hrtfShCoeffsIm_fx[i][j][k] = shl_r( ptW16[k], Q14 - factorQ ); @@ -1749,44 +1749,44 @@ static ivas_error create_parambin_HRTF_from_rawdata( } /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( CLDFB_NO_CHANNELS_MAX != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { ( *hHRTF )->parametricReverberationTimes_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q26 - factorQ ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ); /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { ( *hHRTF )->parametricReverberationEneCorrections_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q31 - factorQ ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ); /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { ( *hHRTF )->parametricEarlyPartEneCorrection_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q28 - factorQ ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ); return IVAS_ERR_OK; } @@ -1806,13 +1806,13 @@ ivas_error load_fastconv_HRTF_from_binary( ) { FILE *f_hrtf; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; ivas_hrtfs_header_t hrtf_header; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; - int16_t asFastconv = 0; + Word16 hrtf_id; + Word16 asFastconv = 0; bool load = false; BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; @@ -1918,13 +1918,13 @@ ivas_error load_parambin_HRTF_from_binary( ) { FILE *f_hrtf; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; ivas_hrtfs_header_t hrtf_header; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; - int16_t asParam = 0; + Word16 hrtf_id; + Word16 asParam = 0; if ( hrtfReader == NULL || hrtfReader->file == NULL ) { @@ -2016,18 +2016,18 @@ ivas_error load_Crend_HRTF_from_binary( const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ - const int32_t sampleRate /* i : sample rate */ + const Word32 sampleRate /* i : sample rate */ ) { FILE *f_hrtf; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; ivas_hrtfs_header_t hrtf_header; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; + Word16 hrtf_id; bool load = false; - int16_t asCrend = 0; + Word16 asCrend = 0; BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; /* convert audio config. to HRTF binaural config */ @@ -2138,7 +2138,7 @@ void destroy_crend_hrtf( #ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_CRend_binary_close_fx( hHrtfCrend ); #else - uint16_t i, j; + UWord16 i, j; test(); if ( *hHrtfCrend != NULL && hHrtfCrend != NULL ) -- GitLab From cbef815487ff50eedff6f8195c20e0b49ecda8f3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 15:22:48 +0100 Subject: [PATCH 182/750] apply fix also to EVS part of code fixes #2279, too --- lib_enc/tcx_ltp_enc_fx.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index f40ce2e80..5533af993 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -88,7 +88,11 @@ static void tcx_ltp_pitch_search( Word16 pitmax, Word16 pitres ) { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 i, t, t0, t1, cor_idx, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; +#else Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; +#endif Word32 cor_max, cor[256], *pt_cor, temp; Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; @@ -203,7 +207,11 @@ static void tcx_ltp_pitch_search( * the interpolated normalized correlation. *-----------------------------------------------------------------*/ +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_idx = sub( L_INTERPOL1, t0_min ); +#else pt_cor = cor + sub( L_INTERPOL1, t0_min ); +#endif t0 = t1; move16(); @@ -219,18 +227,40 @@ static void tcx_ltp_pitch_search( IF( EQ_16( t0, t0_min ) ) /* Limit case */ { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 cor_idx_tmp; + + cor_idx_tmp = add( cor_idx, t0 ); +#endif fraction = 0; move16(); +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); +#else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); +#endif } ELSE /* Process negative fractions */ { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 cor_idx_tmp; + + cor_idx_tmp = add( cor_idx, t0 ); +#endif t0 = sub( t0, 1 ); +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); +#else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); +#endif FOR( i = fraction + step; i < pitres; i += step ) { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + temp = interpolate_corr( &cor[cor_idx_tmp], i, pitres ); +#else temp = interpolate_corr( &pt_cor[t0], i, pitres ); +#endif IF( GT_32( temp, cor_max ) ) { @@ -241,11 +271,16 @@ static void tcx_ltp_pitch_search( } } - i = 0; - move16(); +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_idx = add( t1, cor_idx ); +#endif FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + temp = interpolate_corr( &cor[cor_idx], i, pitres ); +#else temp = interpolate_corr( &pt_cor[t1], i, pitres ); +#endif IF( GT_32( temp, cor_max ) ) { -- GitLab From 2b9d8012cbcd651dcf0eab67249755ac897b65a9 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 12 Dec 2025 09:23:19 -0500 Subject: [PATCH 183/750] Fix 2273 to silence clang18 on ptr init --- lib_com/options.h | 2 +- lib_enc/pit_enc_fx.c | 54 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..14f10d3b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ - +#define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index b812bd6fc..9ea54aa4f 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -762,7 +762,9 @@ Word16 pitch_fr4_fx( Word16 corr_v[15 + 2 * L_INTERPOL1 + 1]; /* Total length = t0_max-t0_min+1+2*L_inter */ Word16 pit_min; Word16 cor_max; - +#ifdef FIX_2273_OOB_INDEXING_IN_PIT_FR4 + Word16 corr_off; +#endif /* initialization */ IF( limit_flag == 0 ) { @@ -805,8 +807,15 @@ Word16 pitch_fr4_fx( t_min = sub( t0_min, L_INTERPOL1 ); t_max = add( t0_max, L_INTERPOL1 ); +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 corr = &corr_v[-t_min]; +#else + corr = corr_v; + corr_off = -t_min; + move16(); +#endif /* corr[t_min..t_max] */ +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( element_mode > EVS_MONO ) { norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr, Q_new ); @@ -815,24 +824,45 @@ Word16 pitch_fr4_fx( { norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); } - +#else + if ( element_mode > EVS_MONO ) + { + norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr, Q_new ); + } + else + { + norm_corr_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr ); + } +#endif /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 max_val = corr[t0_min]; +#else + max_val = corr[t0_min + corr_off]; +#endif move16(); t0 = t0_min; move16(); FOR( i = t0_min + 1; i <= t0_max; i++ ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( GE_16( corr[i], max_val ) ) +#else + if ( GE_16( corr[i + corr_off], max_val ) ) +#endif { t0 = i; move16(); } +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 max_val = s_max( corr[i], max_val ); +#else + max_val = s_max( corr[i + corr_off], max_val ); +#endif } IF( EQ_16( t0_fr1, pit_min ) ) @@ -846,7 +876,11 @@ Word16 pitch_fr4_fx( { i = sub( i, 2 ); } +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 IF( GT_16( corr[i], corr[i + 2] ) ) +#else + IF( GT_16( corr[i + corr_off], corr[i + 2 + corr_off] ) ) +#endif { t0 = i; move16(); @@ -897,15 +931,27 @@ Word16 pitch_fr4_fx( { fraction = 0; move16(); +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 cor_max = Interpol_4( &corr[t0], fraction ); +#else + cor_max = Interpol_4( &corr[t0 + corr_off], fraction ); +#endif } ELSE { t0 = sub( t0, 1 ); +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 cor_max = Interpol_4( &corr[t0], fraction ); +#else + cor_max = Interpol_4( &corr[t0 + corr_off], fraction ); +#endif FOR( i = fraction + step; i <= 3; i = ( i + step ) ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 temp = Interpol_4( &corr[t0], i ); +#else + temp = Interpol_4( &corr[t0 + corr_off], i ); +#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; @@ -918,7 +964,11 @@ Word16 pitch_fr4_fx( FOR( i = 0; i <= 3; i = ( i + step ) ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 temp = Interpol_4( &corr[t1], i ); +#else + temp = Interpol_4( &corr[t1 + corr_off], i ); +#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; -- GitLab From 0674e858fff69de64fbb7c04a712bfe2a8905c18 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 15:26:21 +0100 Subject: [PATCH 184/750] fix index calculation - needs to be done after t0 update --- lib_enc/tcx_ltp_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 5533af993..041bfcf2a 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -245,10 +245,10 @@ static void tcx_ltp_pitch_search( #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH Word16 cor_idx_tmp; - cor_idx_tmp = add( cor_idx, t0 ); #endif t0 = sub( t0, 1 ); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_idx_tmp = add( cor_idx, t0 ); cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); @@ -496,10 +496,10 @@ static void tcx_ltp_pitch_search_ivas_fx( #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH Word16 cor_idx_tmp; - cor_idx_tmp = add( cor_idx, t0 ); #endif t0 = sub( t0, 1 ); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + cor_idx_tmp = add( cor_idx, t0 ); cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); -- GitLab From 6d0181b7ce71380201d5099d2829e1a592978a6f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 15:46:02 +0100 Subject: [PATCH 185/750] use proper IF/ELSE construct sideeffect: avoids sanitizer complaint --- lib_com/options.h | 1 + lib_com/tcx_ltp_fx.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..a29629e00 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC /* FhG: fix a USAN OOB error */ /* #################### End BE switches ################################## */ diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c index 4eb334205..1ecc8b766 100644 --- a/lib_com/tcx_ltp_fx.c +++ b/lib_com/tcx_ltp_fx.c @@ -401,9 +401,20 @@ void predict_signal( x0--; } +#ifdef FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC + IF( EQ_16( frac_max, 6 ) ) + { + win = &inter6_2tcx2[frac][0]; /* Q15 */ + } + ELSE + { + win = &inter4_2tcx2[frac][0]; /* Q15 */ + } +#else win = &inter4_2tcx2[frac][0]; /* Q15 */ if ( EQ_16( frac_max, 6 ) ) win = &inter6_2tcx2[frac][0]; /* Q15 */ +#endif FOR( j = 0; j < L_subfr; j++ ) { -- GitLab From a7a0959137a6ba95bd5701ea660d095aa8429b25 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 12 Dec 2025 10:03:40 -0500 Subject: [PATCH 186/750] Fix for 2271 to silence clang18 --- lib_com/options.h | 2 +- lib_enc/pitch_ol2_fx.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..db239d133 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ - +#define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index c28c4c5aa..f50677cf0 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -50,7 +50,9 @@ void pitch_ol2_fx( Word32 R1, R2; Word16 R0, exp_R0, exp_R1, exp_R2, j; Word16 pit_max; - +#ifdef FIX_2271_OOB_INDEXING_IN_PIT_OL2 + Word16 base_idx; +#endif /* initialization */ pit_max = PIT_MAX; move16(); @@ -104,9 +106,14 @@ void pitch_ol2_fx( * search the fractions around t0 and choose the one which maximizes * the interpolated normalized correlation. *----------------------------------------------------------------*/ +#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 pt_cor_fx = cor_fx + sub( L_INTERPOL1, t0_min ); +#endif t0s = t1s; move16(); +#ifdef FIX_2271_OOB_INDEXING_IN_PIT_OL2 + base_idx = sub( L_INTERPOL1, t0_min ); +#endif step = 1; move16(); /* 1/4 subsample resolution */ @@ -116,10 +123,18 @@ void pitch_ol2_fx( IF( NE_16( t0s, t0_min ) ) /* Process negative fractions */ { t0s = sub( t0s, 1 ); +#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 cor_max_fx = Interpol_4( &pt_cor_fx[t0s], fraction ); +#else + cor_max_fx = Interpol_4( &cor_fx[t0s + base_idx], fraction ); +#endif FOR( i = fraction + step; i <= 3; i += step ) { +#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 temp_fx = Interpol_4( &pt_cor_fx[t0s], i ); +#else + temp_fx = Interpol_4( &cor_fx[t0s + base_idx], i ); +#endif if ( GT_16( temp_fx, cor_max_fx ) ) { fraction = i; @@ -132,13 +147,20 @@ void pitch_ol2_fx( { fraction = 0; move16(); +#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 cor_max_fx = Interpol_4( &pt_cor_fx[t0s], fraction ); +#else + cor_max_fx = Interpol_4( &cor_fx[t0s + base_idx], fraction ); +#endif move16(); } FOR( i = 0; i <= 3; i += step ) /* Process positive fractions */ { +#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 temp_fx = Interpol_4( &pt_cor_fx[t1s], i ); - +#else + temp_fx = Interpol_4( &cor_fx[t1s + base_idx], i ); +#endif IF( GT_16( temp_fx, cor_max_fx ) ) { cor_max_fx = temp_fx; -- GitLab From 90ce17e5a9d1e7bb7d3ca67e2ab1c0aa12909150 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 12 Dec 2025 10:12:10 -0500 Subject: [PATCH 187/750] addition of comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index db239d133..c6add530c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ -#define FIX_2271_OOB_INDEXING_IN_PIT_OL2 +#define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ -- GitLab From 7ef2e5d9d0f6cec6056edd59f3cc0829bc77ee55 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 12 Dec 2025 16:25:26 +0100 Subject: [PATCH 188/750] slight rework of patch --- lib_enc/tcx_ltp_enc_fx.c | 50 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 041bfcf2a..bd43b84f1 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -88,10 +88,9 @@ static void tcx_ltp_pitch_search( Word16 pitmax, Word16 pitres ) { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - Word16 i, t, t0, t1, cor_idx, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; -#else Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 cor_idx_ini, cor_idx; #endif Word32 cor_max, cor[256], *pt_cor, temp; Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; @@ -208,7 +207,7 @@ static void tcx_ltp_pitch_search( *-----------------------------------------------------------------*/ #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_idx = sub( L_INTERPOL1, t0_min ); + cor_idx_ini = sub( L_INTERPOL1, t0_min ); #else pt_cor = cor + sub( L_INTERPOL1, t0_min ); #endif @@ -228,28 +227,22 @@ static void tcx_ltp_pitch_search( IF( EQ_16( t0, t0_min ) ) /* Limit case */ { #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - Word16 cor_idx_tmp; - - cor_idx_tmp = add( cor_idx, t0 ); + cor_idx = add( cor_idx_ini, t0 ); #endif fraction = 0; move16(); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); + cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); #endif } ELSE /* Process negative fractions */ { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - Word16 cor_idx_tmp; - -#endif t0 = sub( t0, 1 ); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_idx_tmp = add( cor_idx, t0 ); - cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); + cor_idx = add( cor_idx_ini, t0 ); + cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); #endif @@ -257,7 +250,7 @@ static void tcx_ltp_pitch_search( FOR( i = fraction + step; i < pitres; i += step ) { #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - temp = interpolate_corr( &cor[cor_idx_tmp], i, pitres ); + temp = interpolate_corr( &cor[cor_idx], i, pitres ); #else temp = interpolate_corr( &pt_cor[t0], i, pitres ); #endif @@ -272,7 +265,7 @@ static void tcx_ltp_pitch_search( } #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_idx = add( t1, cor_idx ); + cor_idx = add( cor_idx_ini, t1 ); #endif FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { @@ -327,10 +320,9 @@ static void tcx_ltp_pitch_search_ivas_fx( const Word16 check_border_case, Word16 *border_case ) { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - Word16 i, t, t0, cor_idx, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; -#else Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; +#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH + Word16 cor_idx_ini, cor_idx; #endif Word32 cor_max, cor[256], *pt_cor, temp; Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; @@ -458,7 +450,7 @@ static void tcx_ltp_pitch_search_ivas_fx( * the interpolated normalized correlation. *-----------------------------------------------------------------*/ #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_idx = sub( L_INTERPOL1, t0_min ); + cor_idx_ini = sub( L_INTERPOL1, t0_min ); #else pt_cor = cor + sub( L_INTERPOL1, t0_min ); @@ -479,28 +471,22 @@ static void tcx_ltp_pitch_search_ivas_fx( IF( EQ_16( t0, t0_min ) ) /* Limit case */ { #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - Word16 cor_idx_tmp; - - cor_idx_tmp = add( cor_idx, t0 ); + cor_idx = add( cor_idx_ini, t0 ); #endif fraction = 0; move16(); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); + cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); #endif } ELSE /* Process negative fractions */ { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - Word16 cor_idx_tmp; - -#endif t0 = sub( t0, 1 ); #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_idx_tmp = add( cor_idx, t0 ); - cor_max = interpolate_corr( &cor[cor_idx_tmp], fraction, pitres ); + cor_idx = add( cor_idx_ini, t0 ); + cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); #else cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); #endif @@ -508,7 +494,7 @@ static void tcx_ltp_pitch_search_ivas_fx( FOR( i = fraction + step; i < pitres; i += step ) { #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - temp = interpolate_corr( &cor[cor_idx_tmp], i, pitres ); + temp = interpolate_corr( &cor[cor_idx], i, pitres ); #else temp = interpolate_corr( &pt_cor[t0], i, pitres ); #endif @@ -523,7 +509,7 @@ static void tcx_ltp_pitch_search_ivas_fx( } #ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH - cor_idx = add( t1, cor_idx ); + cor_idx = add( cor_idx_ini, t1 ); #endif FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { -- GitLab From 935c8e25356a3646b8f0cb51ee76d7c8c8416cff Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 12 Dec 2025 10:25:37 -0500 Subject: [PATCH 189/750] fix for 2268, to silence clang18, will add some complexity to the ifft --- lib_com/ifft_rel_fx.c | 7 ++++++- lib_com/options.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_com/ifft_rel_fx.c b/lib_com/ifft_rel_fx.c index 450e9195e..12af0e14a 100644 --- a/lib_com/ifft_rel_fx.c +++ b/lib_com/ifft_rel_fx.c @@ -139,7 +139,12 @@ void ifft_rel_fx( /*Can be acheived with a shr */ step = idiv1616( N_MAX_SAS, n2 ); move16(); - +#ifdef FIX_2268_OOB_INDEXING_IN_IFFT + IF( LT_16( n8, 2) ) + { + continue; + } +#endif s = sincos_t_fx + step; /*Q15 */ c = s + 64; /*Q15 */ s3 = sincos_t_fx + i_mult2( step, 3 ); /*Q15 */ diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..976fdb89f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ - +#define FIX_2268_OOB_INDEXING_IN_IFFT /* VA: Fix for issue 2268, to silence clang18 */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ -- GitLab From 8cca2d690d0017ef0ca0e2b35a89ff0bae1296ec Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 16:36:31 +0100 Subject: [PATCH 190/750] fix for #2274 --- lib_com/options.h | 1 + lib_enc/enc_acelp_fx.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..ea6a2cc0e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index bdbc32fec..626d89aaa 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -997,7 +997,14 @@ void E_ACELP_corrmatrix_fx( p3 = &rrixiy[2][pos]; /* Q9 */ p2 = &rrixiy[1][pos]; p1 = &rrixiy[0][pos]; +#ifdef FIX_2274_OOB_INDEXING_IN_CORRMATRIX + p0 = &rrixiy[3][pos]; + /* decrement pointer instead of indexing the array to avoid CLANG Usan complaint */ + /* for last loop iteration, this points to rrixiy[3][-1], but is not actually accessed in later loop (k = 15 then, so inner loop will not run) */ + p0 -= 16; +#else p0 = &rrixiy[3][pos - 16]; +#endif cor = L_deposit_h( 0 ); ptr_h1 = h; /*Q12*/ -- GitLab From 5f80e33373ec5ff213010e77585ef93bd950270d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 12 Dec 2025 11:03:04 -0500 Subject: [PATCH 191/750] fix clang --- lib_com/ifft_rel_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ifft_rel_fx.c b/lib_com/ifft_rel_fx.c index 12af0e14a..d11e07baa 100644 --- a/lib_com/ifft_rel_fx.c +++ b/lib_com/ifft_rel_fx.c @@ -140,7 +140,7 @@ void ifft_rel_fx( step = idiv1616( N_MAX_SAS, n2 ); move16(); #ifdef FIX_2268_OOB_INDEXING_IN_IFFT - IF( LT_16( n8, 2) ) + IF( LT_16( n8, 2 ) ) { continue; } -- GitLab From 10c488dd3cff719870beca1b4b3898e48aa75fbe Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 12 Dec 2025 17:13:52 +0100 Subject: [PATCH 192/750] avoid OOB indexing in pitch search --- lib_com/options.h | 1 + lib_enc/enc_gain_fx.c | 49 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..fa0eefbbe 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c index 8c53a5d12..3ef9a029f 100644 --- a/lib_enc/enc_gain_fx.c +++ b/lib_enc/enc_gain_fx.c @@ -2,6 +2,7 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ +#include "basop32.h" #include #include #include "options.h" @@ -253,7 +254,11 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ { Word16 corr_v[32 + 2 * L_INTERPOL1 + 1]; Word16 cor_max, max, temp; +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + Word16 corr_idx; +#else Word16 *corr; +#endif Word16 i, fraction, frac1, frac2, step; Word16 t0, t_min, t_max; @@ -269,27 +274,48 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ move16(); move16(); +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + corr_idx = negate( t_min ); +#else /* allocate memory to normalized correlation vector */ corr = &corr_v[negate( t_min )]; /* corr[t_min..t_max] */ +#endif /* Compute normalized correlation between target and filtered excitation */ E_GAIN_norm_corr_fx( exc, xn, h, t_min, t_max, corr_v, L_subfr ); /* find integer pitch */ +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + max = corr_v[add( t0_min, corr_idx )]; /*(Q15+(Q_new+shift-1)+scale)*/ +#else max = corr[t0_min]; /*(Q15+(Q_new+shift-1)+scale)*/ +#endif move16(); t0 = t0_min; /*Q0*/ move16(); FOR( i = t0_min + 1; i <= t0_max; i++ ) { +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + Word16 corr_tmp; + + corr_tmp = corr_v[add( corr_idx, i )]; +#endif BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + if ( GE_16( corr_tmp, max ) ) +#else if ( GE_16( corr[i], max ) ) +#endif { t0 = i; move16(); } +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + max = s_max( max, corr_tmp ); +#else max = s_max( max, corr[i] ); +#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -354,15 +380,26 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ } assert( frac1 <= 0 && frac2 >= 0 && frac2 > frac1 ); +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + corr_idx = add( corr_idx, t0 ); +#endif IF( EQ_16( pit_res_max, 6 ) ) { +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ +#else cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ - fraction = frac1; /*Q0*/ +#endif + fraction = frac1; /*Q0*/ move16(); FOR( i = ( frac1 + step ); i <= frac2; i += step ) { +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + temp = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/ +#else temp = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ +#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/ @@ -374,13 +411,21 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ } ELSE { +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + cor_max = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ +#else cor_max = E_GAIN_norm_corr_interpolate_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ - fraction = frac1; /*Q0*/ +#endif + fraction = frac1; /*Q0*/ move16(); FOR( i = ( frac1 + step ); i <= frac2; i += step ) { +#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH + temp = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/ +#else temp = E_GAIN_norm_corr_interpolate_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ +#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/ -- GitLab From 5307a8e85d6483eef346cd2a0b22d9e59fff2094 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 14 Dec 2025 19:16:01 +0100 Subject: [PATCH 193/750] add asserts to Log2_norm_lc() and log10_fx() --- lib_com/log2.c | 20 ++++++++++++++++++++ lib_com/options.h | 1 + 2 files changed, 21 insertions(+) diff --git a/lib_com/log2.c b/lib_com/log2.c index 42b1f1b3d..e92aca2d3 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -72,6 +72,10 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val i = mac_r( L_x, -32 * 2 - 1, 16384 ); /* Extract b25-b31 minus 32 */ +#ifdef FIX_2284_ADD_ASSERT_LOG + assert( ( i >= 0 ) && ( i < (Word16) ( sizeof( L_table_Log2_norm_lc ) / sizeof( L_table_Log2_norm_lc[0] ) ) ) && ( i < (Word16) ( sizeof( table_diff_Log2_norm_lc ) / table_diff_Log2_norm_lc[0] ) ) ); +#endif + y = mac_r( L_table_Log2_norm_lc[i], table_diff_Log2_norm_lc[i], a ); /* table[i] << 16 - diff*a*2 */ return y; @@ -80,6 +84,9 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/ { Word16 n1, frac, p1, p2, q1; +#ifdef FIX_2284_ADD_ASSERT_LOG + Word16 idx; +#endif Word32 Ltemp1, Ltemp2; Word32 L_tmp; @@ -94,10 +101,23 @@ Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/ Ltemp2 = L_mult( extract_h( Ltemp1 ), 0x40 ); frac = extract_l( Ltemp2 ); +#ifdef FIX_2284_ADD_ASSERT_LOG + idx = sub( extract_h( Ltemp2 ), 0x20 ); + assert( idx >= 0 && idx < (Word16) ( sizeof( log2_tab ) / sizeof( log2_tab[0] ) ) ); + p1 = log2_tab[idx]; + move16(); + + idx = sub( extract_h( Ltemp2 ), 0x1F ); + assert( idx >= 0 && idx < (Word16) ( sizeof( log2_tab ) / sizeof( log2_tab[0] ) ) ); + p2 = log2_tab[idx]; + move16(); + +#else p1 = log2_tab[sub( extract_h( Ltemp2 ), 0x20 )]; move16(); p2 = log2_tab[sub( extract_h( Ltemp2 ), 0x1F )]; move16(); +#endif Ltemp2 = L_mult( n1, 0x200 ); n1 = extract_l( Ltemp2 ); diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..215b51ed8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_2284_ADD_ASSERT_LOG /* FhG: add asserts to Log2_norm_lc() and log10_fx() */ /* #################### End BE switches ################################## */ -- GitLab From 78bfb3487b61812ecfeb396f6c5805e22bc8d0e8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 14 Dec 2025 20:07:43 +0100 Subject: [PATCH 194/750] missing sizeof()-operator --- lib_com/log2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index e92aca2d3..55ea6aa40 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -73,7 +73,7 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val i = mac_r( L_x, -32 * 2 - 1, 16384 ); /* Extract b25-b31 minus 32 */ #ifdef FIX_2284_ADD_ASSERT_LOG - assert( ( i >= 0 ) && ( i < (Word16) ( sizeof( L_table_Log2_norm_lc ) / sizeof( L_table_Log2_norm_lc[0] ) ) ) && ( i < (Word16) ( sizeof( table_diff_Log2_norm_lc ) / table_diff_Log2_norm_lc[0] ) ) ); + assert( ( i >= 0 ) && ( i < (Word16) ( sizeof( L_table_Log2_norm_lc ) / sizeof( L_table_Log2_norm_lc[0] ) ) ) && ( i < (Word16) ( sizeof( table_diff_Log2_norm_lc ) / sizeof( table_diff_Log2_norm_lc[0] ) ) ) ); #endif y = mac_r( L_table_Log2_norm_lc[i], table_diff_Log2_norm_lc[i], a ); /* table[i] << 16 - diff*a*2 */ -- GitLab From 9ea5d5d8f7a678737729d705621ef19fe2305e7f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 Dec 2025 10:37:28 +0100 Subject: [PATCH 195/750] 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 a2fc64311b96c199f629344e88ad657cf3b40430 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 15 Dec 2025 11:18:22 +0100 Subject: [PATCH 196/750] fix warning for array subscript -2 is below array bounds of Idx2Freq_Tbl[] --- lib_com/cnst.h | 4 ++++ lib_com/options.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 7f435eaa9..036602ddc 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -2731,7 +2731,11 @@ extern const Word16 Idx2Freq_Tbl[]; /* 'x' is converted to Q6, 'Freq_Tbl'/1000 in Q9 */ /* only works for 'fs' = [8000,12800,16000,25600,32000,48000] (unpredictable otherwise) */ /* 15625 is 1000000.0f/Q6 but we use the calculated value to avoid float point code */ +#ifdef FIX_2286_GCC_WARNING_Idx2Freq_Tbl +#define NS2SA_FX2(fs,x) (chk_fs(fs) mult(Idx2Freq_Tbl[L_and(L_shr(fs,8),7)-2], (Word16)((x)/15625))) +#else #define NS2SA_FX2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625))) +#endif #define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */ #define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */ diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..7c311782c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_2286_GCC_WARNING_Idx2Freq_Tbl /* FhG: Fix compiler warning for OOB access of Idx2Freq_Tbl[] */ /* #################### End BE switches ################################## */ -- GitLab From 94092280dc713491f0caef81e2da66c6969d906d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 15 Dec 2025 12:00:50 +0100 Subject: [PATCH 197/750] initialize element_brate to explicitly invalid value --- lib_dec/ivas_sce_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index a6ba0bae6..1b9a530e8 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -403,7 +403,7 @@ ivas_error create_sce_dec( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ move32(); #ifdef FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE - st->element_brate = 0; + st->element_brate = -1; move32(); #endif st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; -- GitLab From ae84432a2c561b0e18c8b96e9af4a87573d40644 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 15 Dec 2025 12:12:23 +0100 Subject: [PATCH 198/750] apply clang-format --- lib_enc/enc_gain_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c index 3ef9a029f..a1e47b455 100644 --- a/lib_enc/enc_gain_fx.c +++ b/lib_enc/enc_gain_fx.c @@ -288,7 +288,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ #ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH max = corr_v[add( t0_min, corr_idx )]; /*(Q15+(Q_new+shift-1)+scale)*/ #else - max = corr[t0_min]; /*(Q15+(Q_new+shift-1)+scale)*/ + max = corr[t0_min]; /*(Q15+(Q_new+shift-1)+scale)*/ #endif move16(); t0 = t0_min; /*Q0*/ @@ -398,7 +398,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ #ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH temp = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/ #else - temp = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ + temp = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ #endif IF( GT_16( temp, cor_max ) ) { @@ -414,7 +414,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ #ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH cor_max = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ #else - cor_max = E_GAIN_norm_corr_interpolate_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ + cor_max = E_GAIN_norm_corr_interpolate_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ #endif fraction = frac1; /*Q0*/ move16(); @@ -424,7 +424,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ #ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH temp = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/ #else - temp = E_GAIN_norm_corr_interpolate_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ + temp = E_GAIN_norm_corr_interpolate_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ #endif IF( GT_16( temp, cor_max ) ) { -- GitLab From 5d41cc2dde743d28c5e3c8c6c6621779b2d04b96 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 15 Dec 2025 13:46:55 +0100 Subject: [PATCH 199/750] replace include of basop32.h by stl.h --- lib_enc/enc_gain_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c index a1e47b455..ed954ebed 100644 --- a/lib_enc/enc_gain_fx.c +++ b/lib_enc/enc_gain_fx.c @@ -2,10 +2,10 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ -#include "basop32.h" #include #include #include "options.h" +#include "stl.h" #include "cnst.h" #include "rom_com.h" #include "rom_enc.h" -- GitLab From c73e3650d9844476d3989fcb764148a372cf60ac Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 07:47:35 -0500 Subject: [PATCH 200/750] 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 201/750] 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 202/750] 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 From b740b893afaa6853bd04c60ef8312484e2abfe25 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 15 Dec 2025 16:17:46 +0100 Subject: [PATCH 203/750] fix typo to correct malloc size --- lib_com/options.h | 1 + lib_dec/ivas_mct_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..b08965411 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ +#define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 3b2c60277..18cc3fe9e 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -699,7 +699,11 @@ ivas_error mct_dec_reconfigure_fx( move16(); /* MDCT stereo initialization */ +#ifdef FIX_2287_MCT_MDCT_STEREO_DATA_ACLLOC_SIZE + IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL ) +#else IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); } -- GitLab From 86753cea63c9bd18e33e551b9c71c530020cf56c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 15 Dec 2025 16:24:30 +0100 Subject: [PATCH 204/750] fix typo in ifdef --- lib_dec/ivas_mct_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 18cc3fe9e..34055e84a 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -699,7 +699,7 @@ ivas_error mct_dec_reconfigure_fx( move16(); /* MDCT stereo initialization */ -#ifdef FIX_2287_MCT_MDCT_STEREO_DATA_ACLLOC_SIZE +#ifdef FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL ) #else IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL ) -- GitLab From c53d6735621bb1d11234faa3baf48a540680f9f6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 Dec 2025 16:36:21 +0100 Subject: [PATCH 205/750] introduce FIX_2285_CODE_DECODER_INIT_BW --- lib_com/options.h | 1 + lib_dec/init_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..d3eddbbd5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ #define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ +#define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index baed0184c..933bfda72 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -101,7 +101,7 @@ ivas_error init_decoder_fx( } ELSE { -#if 0 // keep deactivated for the moment to keep BE +#ifdef FIX_2285_CODE_DECODER_INIT_BW st_fx->bwidth = WB; move16(); st_fx->last_bwidth = WB; -- GitLab From 03bd34bd77c95de3f769d83d2d7620b25f39df37 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 Dec 2025 16:59:17 +0100 Subject: [PATCH 206/750] introduce FIX_1381_BWD --- lib_com/options.h | 1 + lib_enc/bw_detect_fx.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..af4afa19d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ #define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ +#define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 33e00aae1..b1283ff5c 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -16,7 +16,11 @@ /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ + #define BWD_MIN_BRATE_WIDER_BW_MDCT IVAS_48k +#ifdef FIX_1381_BWD +#define BWD_MIN_BRATE_WIDER_BW_MASA IVAS_48k +#endif #define BWD_MIN_BRATE_WIDER_BW_ISM IVAS_32k #define BWD_MAX_BRATE_WIDER_BW_MDCT IVAS_80k #define BWD_MAX_BRATE_WIDER_BW_ISM IVAS_64k @@ -28,8 +32,6 @@ #define BWD_COUNT_WIDER_BW 10 #define BWD_COUNT_WIDER_BW_MDCT 0 -#define BWD_N_BINS_MAX 13 - #define CLDFB_ENER_OFFSET_FX 26214 /* 1.6 in Q14 */ /*-------------------------------------------------------------------* @@ -40,8 +42,8 @@ void bw_detect_fx( Encoder_State *st, /* i/o: Encoder State */ - const Word16 signal_in[], /* i : input signal */ - Word16 *spectrum, /* i : MDCT spectrum Q_spec */ + const Word16 signal_in[], /* i : input signal */ + Word16 *spectrum, /* i : MDCT spectrum Q_spec */ const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ @@ -75,12 +77,22 @@ void bw_detect_fx( test(); test(); test(); +#ifdef FIX_1381_BWD + test(); + test(); +#endif if ( st->ini_frame > 0 && ( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_MDCT ) || mct_on ) ) || +#ifdef FIX_1381_BWD + ( st->is_ism_format && GE_32(st->element_brate , BWD_MIN_BRATE_WIDER_BW_ISM) ) || + ( EQ_16(ivas_format , MASA_FORMAT) && GE_32(st->element_brate , BWD_MIN_BRATE_WIDER_BW_MASA )) ) ) +#else ( EQ_16( ivas_format, ISM_FORMAT ) && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_ISM ) ) ) ) +#endif { bwd_count_wider_bw = BWD_COUNT_WIDER_BW_MDCT; move16(); } + IF( GT_32( st->input_Fs, 8000 ) ) { -- GitLab From 06fc885c202a65122eca3470d61cec7d377d70cb Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 11:29:39 -0500 Subject: [PATCH 207/750] Fix 1478, copy of un-init data --- lib_com/gs_noisefill_fx.c | 4 ++++ lib_com/options.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 8489cd66d..75db0e8fb 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -751,7 +751,11 @@ void highband_exc_dct_in_fx( test(); IF( bfi || LT_32( core_brate, 6000 ) || ( LT_32( core_brate, 8600 ) && EQ_16( coder_type, UNVOICED ) ) ) { +#ifndef FIX_1478_UNINIT_ON_BFI set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */ +#else + set16_fx( noisepb, 13107, MBANDS_GN16k ); /*0.4 in Q15 */ +#endif } ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) || ( GSC_IVAS_mode > 0 && EQ_16( GSC_noisy_speech, 1 ) ) ) { diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..a099ddcc9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ #define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ +#define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ /* ##################### End NON-BE switches ########################### */ -- GitLab From c7f24ebfa1e56462d51f21a9756c781d6f72c904 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 Dec 2025 17:53:57 +0100 Subject: [PATCH 208/750] clang-format --- lib_enc/bw_detect_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index b1283ff5c..37b79491a 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -83,8 +83,8 @@ void bw_detect_fx( #endif if ( st->ini_frame > 0 && ( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_MDCT ) || mct_on ) ) || #ifdef FIX_1381_BWD - ( st->is_ism_format && GE_32(st->element_brate , BWD_MIN_BRATE_WIDER_BW_ISM) ) || - ( EQ_16(ivas_format , MASA_FORMAT) && GE_32(st->element_brate , BWD_MIN_BRATE_WIDER_BW_MASA )) ) ) + ( st->is_ism_format && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_ISM ) ) || + ( EQ_16( ivas_format, MASA_FORMAT ) && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_MASA ) ) ) ) #else ( EQ_16( ivas_format, ISM_FORMAT ) && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_ISM ) ) ) ) #endif -- GitLab From 3438e2e1d0528b55329afe6f7fbfb09393a60777 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 11:57:16 -0500 Subject: [PATCH 209/750] Fix to prevent copy of uninit data --- lib_com/options.h | 2 +- lib_dec/ivas_core_dec_fx.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..a3908bde6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +89,7 @@ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ - +#define FIX_2290_COPY_OF_UNINIT_DATA /* VA: prevent the copy of un-initialized data */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 690797e20..c018c19b7 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -562,8 +562,11 @@ ivas_error ivas_core_dec_fx( hSCE->q_save_hb_synth_fx = Q11; move16(); } - +#ifdef FIX_2290_COPY_OF_UNINIT_DATA + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) +#else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) +#endif } Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0 -- GitLab From 653af9adfe2d332f99afbabd506d1c557c2e0dd2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 14:59:13 -0500 Subject: [PATCH 210/750] harmonise and nicer solution to 1478 --- lib_com/gs_noisefill_fx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 75db0e8fb..50072eb29 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -754,12 +754,16 @@ void highband_exc_dct_in_fx( #ifndef FIX_1478_UNINIT_ON_BFI set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */ #else - set16_fx( noisepb, 13107, MBANDS_GN16k ); /*0.4 in Q15 */ + set16_fx( noisepb, 13107, last_bin ); /*0.4 in Q15 */ #endif } ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) || ( GSC_IVAS_mode > 0 && EQ_16( GSC_noisy_speech, 1 ) ) ) { +#ifndef FIX_1478_UNINIT_ON_BFI set16_fx( noisepb, 13107 /*0.4f*/, MBANDS_GN16k ); +#else + set16_fx( noisepb, 13107 /*0.4f*/, last_bin ); +#endif } ELSE { @@ -776,7 +780,11 @@ void highband_exc_dct_in_fx( test(); IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) ) { +#ifndef FIX_1478_UNINIT_ON_BFI set16_fx( noisepb, 3277, MBANDS_GN ); +#else + set16_fx( noisepb, 3277, last_bin ); +#endif } test(); IF( LT_32( core_brate, 6000 ) && LE_16( coder_type, UNVOICED ) ) -- GitLab From a9f07905f224b85234903e15dee82c068ec3f7a6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 16:50:17 -0500 Subject: [PATCH 211/750] Complement to 2290 --- lib_dec/ivas_core_dec_fx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index c018c19b7..bf1f75333 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -563,7 +563,10 @@ ivas_error ivas_core_dec_fx( move16(); } #ifdef FIX_2290_COPY_OF_UNINIT_DATA - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) + IF( st->hBWE_FD != NULL ) + { + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) + } #else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif -- GitLab From 9cf449e19acaa0241ec321ccc42a449cd134eac3 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 16 Dec 2025 10:22:00 +0100 Subject: [PATCH 212/750] port MR 2462 from float: changes under FIX_1466_EXTREND and FIX_1435_MOVE_STEREO_PANNING --- lib_com/options.h | 1 + lib_dec/ivas_output_config_fx.c | 18 +++++ lib_rend/lib_rend_fx.c | 139 ++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..97864949f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ #define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ +#define FIX_1466_EXTREND /* FhG: float issue 1466: enable rendering of mono/stereo to other formats in the external renderer */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index abf80add0..2d825d64a 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -283,14 +283,22 @@ void ivas_renderer_select( * Non-binaural rendering configurations *-----------------------------------------------------------------*/ +#ifdef FIX_1435_MOVE_STEREO_PANNING + ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) +#else ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) +#endif { test(); test(); test(); test(); test(); +#ifdef FIX_1435_MOVE_STEREO_PANNING + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) +#else IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) +#endif { *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; move16(); @@ -300,7 +308,16 @@ void ivas_renderer_select( *renderer_type = RENDERER_MC; move16(); } +#ifdef FIX_1435_MOVE_STEREO_PANNING + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && + ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); + } +#endif } +#ifndef FIX_1435_MOVE_STEREO_PANNING ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { test(); @@ -322,6 +339,7 @@ void ivas_renderer_select( move16(); } } +#endif ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { test(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 9b42d17b2..9a1dbfe5b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1392,6 +1392,22 @@ static bool isIoConfigPairSupported( const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig ) { +#ifdef FIX_1466_EXTREND + /* input config cannot be binaural */ + test(); + test(); + IF( EQ_32( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && + NE_32( inConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + return false; + } + + /* output config cannot be object based */ + IF( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) ) + { + return false; + } +#else /* Rendering mono or stereo to binaural is not supported */ test(); test(); @@ -1399,6 +1415,7 @@ static bool isIoConfigPairSupported( { return false; } +#endif /* If not returned so far, config pair is supported */ return true; @@ -2563,15 +2580,53 @@ static ivas_error updateMcPanGainsForAmbiOut( { Word16 ch_in, ch_out, lfeIdx, i; Word16 numNonLfeInChannels, outAmbiOrder; +#ifdef FIX_1466_EXTREND + AUDIO_CONFIG inConfig; +#endif const Word32 *spkAzi_fx, *spkEle_fx; /* Q22 */ ivas_error error; +#ifdef FIX_1466_EXTREND + inConfig = inputMc->base.inConfig; + move32(); + +#endif IF( NE_32( ( error = getAmbisonicsOrder_fx( outConfig, &outAmbiOrder ) ), IVAS_ERR_OK ) ) { return error; } +#ifdef FIX_1466_EXTREND + test(); + IF( EQ_32( inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) + { + setZeroPanMatrix_fx( inputMc->panGains_fx ); + IF( EQ_32( inConfig, IVAS_AUDIO_CONFIG_MONO ) ) + { + /* W = Mono */ + inputMc->panGains_fx[0][0] = ONE_IN_Q31; + move32(); + } + ELSE + { + /* W = 0.5 * ( L + R ) */ + inputMc->panGains_fx[0][0] = ONE_IN_Q30 /* 0.5f in Q31 */; + inputMc->panGains_fx[0][1] = ONE_IN_Q30 /* 0.5f in Q31 */; + move32(); + move32(); + /* Y = 0.5 * ( L - R ) */ + inputMc->panGains_fx[1][0] = ONE_IN_Q30 /* 0.5f in Q31 */; + inputMc->panGains_fx[1][1] = -ONE_IN_Q30 /* -0.5f in Q31 */; + move32(); + move32(); + } + + return IVAS_ERR_OK; + } + ELSE IF( NE_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) +#else IF( NE_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) +#endif { IF( NE_32( ( error = getNumNonLfeChannelsInSpeakerLayout( inputMc->base.inConfig, &numNonLfeInChannels ) ), IVAS_ERR_OK ) ) { @@ -2682,6 +2737,39 @@ static ivas_error updateMcPanGainsForAmbiOut( return IVAS_ERR_OK; } +#ifdef FIX_1466_EXTREND + +static ivas_error updateMcPanGainsForBinauralOut( + input_mc *inputMc ) +{ + setZeroPanMatrix_fx( inputMc->panGains_fx ); + IF( inputMc->base.inConfig == IVAS_AUDIO_CONFIG_MONO ) + { + IF( EQ_32( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ) ) + { + inputMc->panGains_fx[0][0] = ONE_IN_Q31; + } + ELSE + { + inputMc->panGains_fx[0][0] = L_add( L_shr( inputMc->nonDiegeticPanGain_fx, 1 ), ONE_IN_Q30 /* 0.5f in Q31 */ ); /* Q31 */ + } + move32(); + inputMc->panGains_fx[0][1] = L_sub( ONE_IN_Q31, inputMc->panGains_fx[0][0] ); + move32(); + } + ELSE + { + /* stereo passthrough */ + inputMc->panGains_fx[0][0] = ONE_IN_Q31; + inputMc->panGains_fx[1][1] = ONE_IN_Q31; + move32(); + move32(); + } + + return IVAS_ERR_OK; +} + +#endif static ivas_error updateMcPanGains( input_mc *inputMc, const AUDIO_CONFIG outConfig ) @@ -2703,6 +2791,16 @@ static ivas_error updateMcPanGains( error = updateMcPanGainsForAmbiOut( inputMc, outConfig ); BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: +#ifdef FIX_1466_EXTREND + test(); + IF( EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) + { + error = updateMcPanGainsForBinauralOut( inputMc ); + BREAK; + } + + /* not mono or stereo */ +#endif SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: @@ -2760,6 +2858,14 @@ static ivas_error initMcBinauralRendering( Word32 outSampleRate; Word8 useTDRend; Word16 i; +#ifdef FIX_1466_EXTREND + + test(); + IF( EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) + { + return IVAS_ERR_OK; + } +#endif /* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation) or planar MC layouts with headrotation, CREND for the rest */ @@ -7257,6 +7363,29 @@ static ivas_error renderActiveInputsIsm( } return IVAS_ERR_OK; } +#ifdef FIX_1466_EXTREND + +static void renderMonoStereoToBinaural( + const input_mc *mcInput, + IVAS_REND_AudioBuffer outAudio ) +{ + Word16 i; + IVAS_REND_AudioBuffer inAudio; + + push_wmops( "renderMonoStereoToBinaural" ); + inAudio = mcInput->base.inputBuffer; + + FOR( i = 0; i < inAudio.config.numChannels; ++i ) + { + renderBufferChannel_fx( inAudio, i, mcInput->panGains_fx[i], outAudio ); + } + + pop_wmops(); + + return; +} + +#endif static ivas_error renderLfeToBinaural_fx( const input_mc *mcInput, @@ -8011,6 +8140,16 @@ static ivas_error renderInputMc( renderMcToSba( mcInput, outAudio ); BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: +#ifdef FIX_1466_EXTREND + test(); + IF( EQ_32( mcInput->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( mcInput->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) + { + renderMonoStereoToBinaural( mcInput, outAudio ); + BREAK; + } + + /* not mono or stereo */ +#endif SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: -- GitLab From c64161cc6bf2a5e08a1f9d1f136ad2fd7f285901 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 Dec 2025 12:27:50 +0100 Subject: [PATCH 213/750] port changes from float --- lib_com/ivas_cnst.h | 10 +- lib_com/ivas_prot_fx.h | 95 ++--- lib_dec/fd_cng_dec_fx.c | 2 +- lib_dec/ivas_dirac_dec_fx.c | 12 +- lib_dec/ivas_init_dec_fx.c | 20 +- lib_dec/ivas_ism_dec_fx.c | 44 +- lib_dec/ivas_ism_param_dec_fx.c | 17 +- lib_dec/ivas_ism_renderer_fx.c | 24 +- lib_dec/ivas_jbm_dec_fx.c | 383 +++++++++--------- lib_dec/ivas_masa_dec_fx.c | 20 +- lib_dec/ivas_mc_param_dec_fx.c | 10 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 44 +- lib_dec/ivas_mct_dec_fx.c | 76 ++-- lib_dec/ivas_objectRenderer_internal_fx.c | 12 +- lib_dec/ivas_omasa_dec_fx.c | 25 +- lib_dec/ivas_osba_dec_fx.c | 8 +- lib_dec/ivas_sba_dec_fx.c | 18 +- lib_dec/ivas_spar_decoder_fx.c | 14 +- lib_dec/ivas_stat_dec.h | 29 +- lib_dec/lib_dec_fx.c | 14 +- lib_enc/ivas_enc_fx.c | 2 +- lib_enc/ivas_osba_enc_fx.c | 17 +- lib_rend/ivas_crend_fx.c | 12 +- .../ivas_dirac_dec_binaural_functions_fx.c | 4 +- lib_rend/ivas_output_init_fx.c | 2 +- lib_rend/ivas_prot_rend_fx.h | 6 +- 26 files changed, 477 insertions(+), 443 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e6bb49689..ae44138e8 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -186,12 +186,12 @@ typedef enum #define IVAS_NUM_SUPPORTED_FS 3 /* number of supported sampling-rates in IVAS */ #define CLDFB_SLOT_NS 1250000L /* 1.25ms: CLDFB slot length */ -#define MAX_JBM_SUBFRAMES_5MS 8 -#define DEFAULT_JBM_SUBFRAMES_5MS 4 -#define JBM_CLDFB_SLOTS_IN_SUBFRAME 4 +#define DEFAULT_JBM_SUBFRAMES_5MS 4 /* == IVAS_MAX_PARAM_SPATIAL_SUBFRAMES */ +#define MAX_JBM_SUBFRAMES_5MS ( DEFAULT_JBM_SUBFRAMES_5MS * 2 ) +#define JBM_CLDFB_SLOTS_IN_SUBFRAME 4 /* == IVAS_MAX_PARAM_SPATIAL_SUBFRAMES */ #define JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2 2 /* To be used for shift operation instead of division */ -#define MAX_JBM_CLDFB_TIMESLOTS 32 -#define DEFAULT_JBM_CLDFB_TIMESLOTS 16 +#define DEFAULT_JBM_CLDFB_TIMESLOTS CLDFB_NO_COL_MAX +#define MAX_JBM_CLDFB_TIMESLOTS ( DEFAULT_JBM_CLDFB_TIMESLOTS * 2 ) #define MAX_JBM_L_FRAME48k ( IVAS_MAX_FRAME_SIZE * 2 ) /* 1920: max. time-scaled frame buffer length (per channel) in samples */ #define MAX_JBM_L_FRAME_NS 40000000L /* 40 ms: time-scaled frame size in ns, proportional to MAX_JBM_L_FRAME48k */ #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 85bbcb4b1..7c0e1bc18 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -622,12 +622,6 @@ void ivas_dirac_dec_set_md_map_fx( const Word16 nCldfbTs /* i : number of CLDFB time slots */ ); -void ivas_jbm_dec_get_adapted_subframes_fx( - const Word16 nCldfbTs, /* i : number of time slots in the current frame */ - Word16 *subframe_nbslots, /* i/o: subframe grid */ - Word16 *nb_subframes /* i/o: number of subframes in the frame */ -); - /*! r: number of bits read */ Word16 read_GR0( const UWord16 *bit_stream, /* i : bitstream to be read */ @@ -1039,7 +1033,7 @@ void ivas_ism_render_sf_fx( const Word16 n_samples_to_render /* i : output frame length per channel */ ); -void ivas_omasa_separate_object_render_jbm_fx( +void ivas_omasa_separate_object_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal */ @@ -2447,7 +2441,7 @@ void ivas_fb_mixer_cross_fading_fx( const Word16 cf_offset ); -ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( +ivas_error ivas_omasa_dirac_td_binaural_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of samples requested */ UWord16 *nSamplesRendered, /* o : number of samples rendered */ @@ -2484,7 +2478,7 @@ void ivas_sba_get_spar_hoa_md_flag_fx( Word16 *spar_hoa_dirac2spar_md_flag ); -void ivas_omasa_dirac_rend_jbm_fx( +void ivas_omasa_dirac_rend_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of samples requested */ UWord16 *nSamplesRendered, /* o : number of samples rendered */ @@ -3846,7 +3840,7 @@ ivas_error ivas_osba_data_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); -ivas_error ivas_osba_dirac_td_binaural_jbm_fx( +ivas_error ivas_osba_dirac_td_binaural_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ @@ -5873,12 +5867,6 @@ ivas_error ivas_compute_core_buffers_fx( Word16 *Q_new ); -ivas_error ivas_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 *data, /* i : input signal Q0 */ - const Word16 n_samples /* i : number of input samples */ -); - void reset_metadata_spatial_fx( const IVAS_FORMAT ivas_format, /* i : IVAS format */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ @@ -5929,6 +5917,24 @@ void modify_Rmat_q_fx( * General IVAS prototypes *----------------------------------------------------------------------------------*/ +ivas_error ivas_enc_fx( + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 *data, /* i : input signal Q0 */ + const Word16 n_samples /* i : number of input samples */ +); + +ivas_error ivas_dec_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_dec_render_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const UWord16 nSamplesAsked, /* i : number of samples wanted */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ + Word16 *data /* o : output synthesis signal */ +); + void copy_encoder_config_ivas_fx( Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ Encoder_State *st, /* o : encoder state structure */ @@ -6134,21 +6140,9 @@ Word16 is_DTXrate( /*----------------------------------------------------------------------------------* - * JBM prototypes + * Internal rendering prototypes *----------------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_tc_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_jbm_dec_render_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const UWord16 nSamplesAsked, /* i : number of samples wanted */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - Word16 *data /* o : output synthesis signal */ -); - ivas_error ivas_jbm_dec_flush_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 tc_granularity_new, /* i : new renderer granularity */ @@ -6161,7 +6155,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 *data /* o : output synthesis signal */ ); -void ivas_jbm_dec_feed_tc_to_renderer_fx( +void ivas_dec_feed_tc_to_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ @@ -6175,80 +6169,80 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); -void ivas_jbm_dec_get_adapted_linear_interpolator_fx( +void ivas_dec_get_adapted_linear_interpolator_fx( const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */ const Word16 interp_length, /* i : length of the interpolator to be created */ Word16 *interpolator_fx /* o : the interpolator */ ); -void ivas_jbm_dec_get_adapted_subframes( +void ivas_dec_get_adapted_subframes_fx( const Word16 nCldfbTs, /* i : number of time slots in the current frame */ Word16 *subframe_nbslots, /* i/o: subframe grid */ Word16 *nb_subframes /* i/o: number of subframes in the frame */ ); -void ivas_jbm_dec_get_md_map( +void ivas_dec_get_md_map_fx( const Word16 default_len, /* i : default frame length in metadata slots */ const Word16 len, /* i : length of the modfied frames in metadata slots */ const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the md buffer */ + const Word16 offset, /* i : current read offset into the MD buffer */ const Word16 buf_len, /* i : length of the metadata buffer */ Word16 *map /* o : metadata index map */ ); -Word16 ivas_jbm_dec_get_num_tc_channels_fx( +Word16 ivas_dec_get_num_tc_channels_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -void ivas_jbm_dec_get_md_map_even_spacing( +void ivas_dec_get_md_map_even_spacing_fx( const Word16 len, /* i : length of the modfied frames in metadata slots */ const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the md buffer */ + const Word16 offset, /* i : current read offset into the MD buffer */ const Word16 buf_len, /* i : length of the metadata buffer */ Word16 *map /* o : metadata index map */ ); -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( +TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -Word16 ivas_jbm_dec_get_render_granularity_fx( +Word16 ivas_dec_get_render_granularity_fx( const RENDERER_TYPE renderer_type, /* i : renderer type */ const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ const Word32 output_Fs /* i : sampling rate */ ); -ivas_error ivas_jbm_dec_tc_buffer_open_fx( +ivas_error ivas_dec_tc_buffer_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const Word16 nchan_transport_jbm, /* i : number of real transport channels */ + const Word16 nchan_transport_rend, /* i : number of TCs for rendering */ const Word16 nchan_transport_internal, /* i : number of totally buffered channels */ const Word16 nchan_full, /* i : number of channels to fully store */ const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ ); -ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( +ivas_error ivas_dec_tc_buffer_reconfigure_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const Word16 nchan_transport_jbm, /* i : new number of real transport channels */ + const Word16 nchan_transport_rend, /* i : new number of TCs for rendering */ const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ const Word16 nchan_full, /* i : new number of channels to fully store */ const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ ); -void ivas_jbm_dec_tc_buffer_close_fx( +void ivas_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); -void ivas_jbm_dec_td_renderers_adapt_subframes( +void ivas_dec_td_renderers_adapt_subframes_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -ivas_error ivas_jbm_dec_metadata_open( +ivas_error ivas_jbm_dec_masa_metadata_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -void ivas_jbm_masa_sf_to_sf_map( +void ivas_jbm_masa_sf_to_sf_map_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); @@ -6809,11 +6803,12 @@ void ivas_filters_init_fx( const Word16 order ); + /*----------------------------------------------------------------------------------* * OSBA prototypes *----------------------------------------------------------------------------------*/ -ivas_error ivas_osba_enc_reconfig( +ivas_error ivas_osba_enc_reconfig_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -6830,11 +6825,11 @@ void ivas_set_surplus_brate_dec( Word32 *ism_total_brate /* i : ISM total bitrate */ ); -ivas_error ivas_omasa_separate_object_renderer_open( +ivas_error ivas_omasa_separate_object_renderer_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -void ivas_omasa_separate_object_renderer_close( +void ivas_omasa_separate_object_renderer_close_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 8c4d10499..88748bcec 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -5001,7 +5001,7 @@ void generate_masking_noise_lb_dirac_fx( n_samples_start = add( n_samples_start, hFdCngCom->frameSize ); } - /* move generated noise to the 5ms subframe starts in the tc buffer according to the output sampling frequency to avoid + /* move generated noise to the 5ms subframe starts in the TC buffer according to the output sampling frequency to avoid overwriting it with the synthesis in case of shared tc and synth channel memory, i.e. non-TSM mode */ slot_size_cng = shr( hFdCngCom->frameSize, 4 /* DEFAULT_JBM_CLDFB_TIMESLOTS */ ); /* move start indices forward to the end of the last subframe */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index f43ac5c09..d799df603 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1965,9 +1965,9 @@ void ivas_dirac_dec_set_md_map_fx( hSpatParamRendCom->subframes_rendered = 0; move16(); - ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes ); + ivas_dec_get_adapted_subframes_fx( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes ); - /* copy also to tc buffer */ + /* copy also to TC buffer */ /* only for non-combined formats and combinded formats w/o discrete objects */ test(); test(); @@ -1986,15 +1986,15 @@ void ivas_dirac_dec_set_md_map_fx( test(); IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { - ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); + ivas_dec_get_md_map_even_spacing_fx( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); } ELSE IF( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 ) { - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); + ivas_dec_get_md_map_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); } ELSE { - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); + ivas_dec_get_md_map_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); } test(); @@ -3706,7 +3706,7 @@ void ivas_dirac_dec_render_sf_fx( test(); IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) { - ivas_jbm_dec_get_adapted_linear_interpolator_fx( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx ); + ivas_dec_get_adapted_linear_interpolator_fx( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx ); st_ivas->hIsmRendererData->interp_offset_fx = 0; move16(); } diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index f93b5a69c..fe40f8ca9 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1622,7 +1622,7 @@ ivas_error ivas_init_decoder_fx( Word16 i, n, k; Word16 sce_id, cpe_id; Word16 numCldfbAnalyses, numCldfbSyntheses; - Word16 granularity, n_channels_transport_jbm; + Word16 granularity, n_channels_transport; Word16 nchan_out_buff; Word32 output_Fs, ivas_total_brate, tmp_br, tmp32; Word32 delay_ns; @@ -2859,7 +2859,7 @@ ivas_error ivas_init_decoder_fx( return error; } - IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -3078,16 +3078,16 @@ ivas_error ivas_init_decoder_fx( } /*-----------------------------------------------------------------* - * Allocate and initialize JBM struct + buffer + * Allocate and initialize TC struct + buffer *-----------------------------------------------------------------*/ IF( st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ - granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); - n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); + n_channels_transport = ivas_dec_get_num_tc_channels_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, ivas_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport, n_channels_transport, n_channels_transport, granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -3099,7 +3099,7 @@ ivas_error ivas_init_decoder_fx( { IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - IF( NE_32( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_masa_metadata_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -3356,7 +3356,7 @@ void ivas_initialize_handles_dec( { st_ivas->hTdRendHandles[i] = NULL; } - /* JBM handles */ + st_ivas->hTcBuffer = NULL; st_ivas->hJbmMetadata = NULL; @@ -3588,8 +3588,8 @@ void ivas_destroy_dec_fx( st_ivas->hDecoderConfig = NULL; } - /* JBM TC buffer structure */ - ivas_jbm_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer ); + /* TC buffer structure */ + ivas_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer ); IF( st_ivas->hJbmMetadata != NULL ) { diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 4537b3840..a00a857b6 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -55,9 +55,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Word32 element_brate_tmp[MAX_NUM_OBJECTS]; Word16 nSCE_old, nCPE_old; Word16 numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; - TC_BUFFER_MODE tc_buffer_mode_new; - Word16 tc_nchan_tc_new; - Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; Word16 nchan_out_buff; @@ -124,7 +121,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( test(); test(); - /* transfer subframe info from DirAC or ParamMC to central tc buffer */ + /* transfer subframe info from DirAC or ParamMC to central TC buffer */ /* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */ IF( EQ_32( last_ism_mode, ISM_MODE_PARAM ) && st_ivas->hSpatParamRendCom != NULL && NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { @@ -139,15 +136,15 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } - /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv - render what still fits in the new granularity */ - tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + /* when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv + render what still fits in the new granularity */ + tc_granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { /* flush already done in IVAS_DEC_ReadFormat() */ } - /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + /* when granularity goes up set samples to discard at the beginning of the frame */ ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) @@ -303,18 +300,21 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } /*-----------------------------------------------------------------* - * JBM TC buffers + * TC buffer *-----------------------------------------------------------------*/ Word16 tc_nchan_full_new; + TC_BUFFER_MODE tc_buffer_mode_new; + Word16 tc_nchan_rend_new; + Word16 tc_nchan_allocate_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - tc_nchan_allocate_new = tc_nchan_tc_new; + tc_buffer_mode_new = ivas_dec_get_tc_buffer_mode_fx( st_ivas ); + tc_nchan_rend_new = ivas_dec_get_num_tc_channels_fx( st_ivas ); + tc_nchan_allocate_new = tc_nchan_rend_new; move16(); - tc_nchan_full_new = tc_nchan_tc_new; + tc_nchan_full_new = tc_nchan_rend_new; move16(); test(); @@ -327,32 +327,32 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( move16(); } - /* reconfigure buffer */ + /* reconfigure TC buffer */ test(); test(); test(); - IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) || + IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_rend, tc_nchan_rend_new ) || NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) ) { - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_rend_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) ) { return error; } } - /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ + /* transfer subframe info from central TC buffer to ParamMC or McMASA (DirAC) */ IF( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes; move16(); - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered; move16(); - st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hSpatParamRendCom->num_slots = hTcBuffer->num_slots; move16(); - st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + st_ivas->hSpatParamRendCom->slots_rendered = hTcBuffer->slots_rendered; move16(); - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 83fc9833b..d5257f9ee 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -760,7 +760,7 @@ ivas_error ivas_param_ism_dec_open_fx( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; - granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); test(); IF( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) @@ -807,7 +807,7 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -820,7 +820,7 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -921,7 +921,7 @@ void ivas_ism_dec_digest_tc_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes_fx( st_ivas ); test(); test(); @@ -979,9 +979,10 @@ void ivas_ism_dec_digest_tc_fx( } ELSE { - ivas_jbm_dec_get_adapted_linear_interpolator_fx( extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx ); + ivas_dec_get_adapted_linear_interpolator_fx( extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx ); move16(); } + st_ivas->hIsmRendererData->interp_offset_fx = 0; move16(); @@ -1092,7 +1093,7 @@ void ivas_param_ism_dec_digest_tc_fx( num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; move16(); output_frame = imult1616( nCldfbSlots, st_ivas->hSpatParamRendCom->num_freq_bands ); - n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); + n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_rend, st_ivas->hTcBuffer->nchan_buffer_full ); cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx; cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx; @@ -1226,11 +1227,11 @@ void ivas_param_ism_dec_prepare_renderer_fx( } /* general setup */ - ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx ); + ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx ); ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots ); - /* set buffers to zero */ + /* set buffers to zero */ set_zero_fx( &cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); set16_zero_fx( &exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 2da205364..8b7c773fc 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -173,7 +173,7 @@ void ivas_ism_render_sf_fx( Word32 gain_fx, prev_gain_fx; Word32 tc_local_fx[MAX_NUM_OBJECTS][L_FRAME48k]; Word32 *p_tc_fx[MAX_NUM_OBJECTS]; - Word16 ism_md_subframe_update_jbm, slots_to_render, first_sf, last_sf, subframe_idx; + Word16 ism_md_subframe_update, slots_to_render, first_sf, last_sf, subframe_idx; Word16 n_samples_rendered_loop; /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ @@ -209,11 +209,11 @@ void ivas_ism_render_sf_fx( /* Number of subframes to delay metadata to sync with audio */ IF( st_ivas->hDecoderConfig->Opt_delay_comp ) { - ism_md_subframe_update_jbm = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) ); + ism_md_subframe_update = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) ); } ELSE { - ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); + ism_md_subframe_update = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); } FOR( i = 0; i < num_objects; i++ ) @@ -235,7 +235,7 @@ void ivas_ism_render_sf_fx( test(); IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) ) { - ivas_jbm_dec_get_adapted_linear_interpolator_fx( n_samples_in_subframe, n_samples_in_subframe, st_ivas->hIsmRendererData->interpolator_fx ); + ivas_dec_get_adapted_linear_interpolator_fx( n_samples_in_subframe, n_samples_in_subframe, st_ivas->hIsmRendererData->interpolator_fx ); interp_offset = 0; move16(); } @@ -246,7 +246,7 @@ void ivas_ism_render_sf_fx( test(); IF( st_ivas->hCombinedOrientationData != NULL && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) ) { - if ( GE_16( subframe_idx, ism_md_subframe_update_jbm ) ) + if ( GE_16( subframe_idx, ism_md_subframe_update ) ) { rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); } @@ -405,7 +405,7 @@ void ivas_ism_get_stereo_gains_fx( * Open structures, reserve memory, and init values. *-------------------------------------------------------------------------*/ -ivas_error ivas_omasa_separate_object_renderer_open( +ivas_error ivas_omasa_separate_object_renderer_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -454,7 +454,7 @@ ivas_error ivas_omasa_separate_object_renderer_open( * Close structures, free memory. *-------------------------------------------------------------------------*/ -void ivas_omasa_separate_object_renderer_close( +void ivas_omasa_separate_object_renderer_close_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -485,16 +485,16 @@ void ivas_omasa_separate_object_renderer_close( /*-------------------------------------------------------------------------* - * ivas_omasa_separate_object_render_jbm() + * ivas_omasa_separate_object_render() * - * Rendering separated objects and mixing them to the parametrically rendered signals for JBM + * Rendering separated objects and mixing them to the parametrically rendered signals *-------------------------------------------------------------------------*/ -void ivas_omasa_separate_object_render_jbm_fx( +void ivas_omasa_separate_object_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesRendered, /* i : number of samples rendered */ - Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/ - Word32 *output_fx[], /* o : rendered time signal Q11*/ + Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/ + Word32 *output_fx[], /* o : rendered time signal Q11*/ const Word16 subframes_rendered /* i : number of subframes rendered */ ) { diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ece09b600..093dc841f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -47,11 +47,11 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -static void ivas_jbm_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, Word32 *output_fx[] ); +static void ivas_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, Word32 *output_fx[] ); -static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); +static void ivas_jbm_dec_copy_masa_meta_to_buffer_fx( Decoder_Struct *st_ivas ); -static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const Word16 nCldfbTs ); +static void ivas_jbm_masa_sf_to_slot_map_fx( Decoder_Struct *st_ivas, const Word16 nCldfbTs ); static Word16 ceil_fx16( const Word16 inp, @@ -68,12 +68,12 @@ static Word16 ceil_fx16( } /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc() + * ivas_dec() * - * Principal IVAS JBM decoder routine, decoding of metadata and transport channels + * Principal IVAS decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_tc_fx( +ivas_error ivas_dec_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -91,15 +91,15 @@ ivas_error ivas_jbm_dec_tc_fx( CPE_DEC_HANDLE hCPE; SCE_DEC_HANDLE hSCE; - push_wmops( "ivas_jbm_dec_tc" ); + push_wmops( "ivas_dec" ); /*----------------------------------------------------------------* * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); - nchan_out = st_ivas->hTcBuffer->nchan_transport_jbm; + nchan_out = st_ivas->hTcBuffer->nchan_transport_rend; move16(); output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1510,7 +1510,7 @@ ivas_error ivas_jbm_dec_tc_fx( * + digest TC channels in ParamISM and ParamMC *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_feed_tc_to_renderer_fx( +void ivas_dec_feed_tc_to_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ @@ -1523,7 +1523,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - n_ch_cldfb = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + n_ch_cldfb = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); move16(); hTcBuffer->q_tc_fx = Q11; @@ -1541,18 +1541,18 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( move16(); move16(); move16(); - n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); - n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + n_ch_full_copy = s_min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': - in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffers + in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffer pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */ len_offset = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ); IF( LT_16( len_offset, L_FRAME48k ) ) { offset = 0; move16(); - FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch++ ) + FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch++ ) { hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset]; st_ivas->p_output_fx[ch] = hTcBuffer->tc_fx[ch]; @@ -1571,7 +1571,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( IF( n_ch_res_copy > 0 ) { - FOR( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) + FOR( ; ch < hTcBuffer->nchan_transport_rend; ch++ ) { p_data_fx[ch] = hTcBuffer->tc_fx[ch]; Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); @@ -1591,7 +1591,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( move16(); } - ch = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + ch = s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); FOR( n = 0; n < ch; n++ ) { hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */ @@ -1637,19 +1637,19 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( /*--------------------------------------------------------------------------* * ivas_dec_render() * - * Principal IVAS JBM rendering routine + * Principal IVAS internal rendering routine *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_render_fx( +ivas_error ivas_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesAsked, /* i : number of samples wanted */ UWord16 *nSamplesRendered, /* o : number of samples rendered */ UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - Word16 *data /* o : output synthesis signal Q0*/ + Word16 *data /* o : output synthesis signal Q0*/ ) { Word16 n, nchan_out; - Word16 nchan_transport; + Word16 nchan_transport_rend; Word16 nchan_remapped; Word32 output_Fs; AUDIO_CONFIG output_config; @@ -1671,7 +1671,7 @@ ivas_error ivas_jbm_dec_render_fx( move32(); nchan_out = st_ivas->hDecoderConfig->nchan_out; move16(); - nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm; + nchan_transport_rend = st_ivas->hTcBuffer->nchan_transport_rend; move16(); output_config = st_ivas->hDecoderConfig->output_config; move32(); @@ -1696,9 +1696,6 @@ ivas_error ivas_jbm_dec_render_fx( p_tc_fx[n] = &st_ivas->hTcBuffer->tc_fx[n][st_ivas->hTcBuffer->n_samples_rendered]; } - st_ivas->hTcBuffer->no_channels = st_ivas->hTcBuffer->nchan_buffer_full; - move16(); - /*----------------------------------------------------------------* * Update combined orientation access index *----------------------------------------------------------------*/ @@ -1737,7 +1734,7 @@ ivas_error ivas_jbm_dec_render_fx( tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e ); tmp = shr( tmp, sub( 15, e ) ); #endif - ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); + ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); } ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { @@ -1887,8 +1884,9 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { - nchan_remapped = nchan_transport; + nchan_remapped = nchan_transport_rend; move16(); + test(); test(); /* Loudspeakers, Ambisonics or Binaural rendering */ @@ -1923,7 +1921,7 @@ ivas_error ivas_jbm_dec_render_fx( test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - IF( NE_32( ( error = ivas_omasa_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ) ), IVAS_ERR_OK ) ) { return error; } @@ -1935,18 +1933,19 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) { - ivas_omasa_dirac_rend_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + ivas_omasa_dirac_rend_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) { - ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); + ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, *nSamplesRendered ); } } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - nchan_remapped = nchan_transport; + nchan_remapped = nchan_transport_rend; move16(); + /* Loudspeakers, Ambisonics or Binaural rendering */ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { @@ -1959,7 +1958,7 @@ ivas_error ivas_jbm_dec_render_fx( hSpar->hMdDec->Q_mixer_mat = 30; move16(); - IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) { return error; } @@ -2063,8 +2062,8 @@ ivas_error ivas_jbm_dec_render_fx( } } - test(); /* Rendering */ + test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; @@ -2171,9 +2170,9 @@ ivas_error ivas_jbm_dec_render_fx( { ivas_mc_paramupmix_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc_fx, p_output_fx ); + /* Rendering */ test(); test(); - /* Rendering */ IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { /* handled in CLDFB domain already */ @@ -2439,7 +2438,7 @@ ivas_error ivas_jbm_dec_render_fx( /*--------------------------------------------------------------------------* * ivas_jbm_dec_flush_renderer() * - * Flush samples if renderer granularity changes on a bitrate change + * Flush samples if renderer granularity changes on a bitrate change in JBM *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_flush_renderer_fx( @@ -2458,6 +2457,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 n_samples_still_available; Word16 n_slots_still_available; Word16 n_samples_to_render; + Word16 n_samples_granularity; DECODER_TC_BUFFER_HANDLE hTcBuffer; Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS]; Word16 nchan_in, nchan_out; @@ -2470,6 +2470,8 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( *nSamplesRendered = 0; move16(); hTcBuffer = st_ivas->hTcBuffer; + n_samples_granularity = hTcBuffer->n_samples_granularity; + move16(); /* get number of possible slots in new granularity */ n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); @@ -2493,7 +2495,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 ch_idx; /* render available full slots (with new lower granularity) */ - FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) { /* move it at the beginning of the TC buffer with zero padding */ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); @@ -2506,7 +2508,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( hTcBuffer->subframes_rendered = 0; hTcBuffer->slots_rendered = 0; hTcBuffer->subframe_nbslots[0] = 1; - hTcBuffer->n_samples_buffered = add( hTcBuffer->n_samples_granularity, n_samples_still_available ); + hTcBuffer->n_samples_buffered = add( n_samples_granularity, n_samples_still_available ); hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_flushed = n_samples_to_render; hTcBuffer->n_samples_rendered = 0; @@ -2533,7 +2535,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( /* Binaural rendering */ IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -2541,9 +2543,9 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ - set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15 + set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, n_samples_granularity ); // 32767=1.0f in Q15 - ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, hTcBuffer->n_samples_granularity ); + ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, n_samples_granularity ); st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; @@ -2596,7 +2598,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } Word16 subframe_len, gd_bits; - subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity ); + subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], n_samples_granularity ); gd_bits = find_guarded_bits_fx( subframe_len ); *st_ivas->hCrendWrapper->p_io_qfactor = sub( 13, gd_bits ); FOR( Word16 i = 0; i < nchan_in; i++ ) @@ -2609,7 +2611,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( return error; } - ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, n_samples_granularity, hTcBuffer->tc_fx, p_output_fx ); FOR( Word16 i = 0; i < nchan_in; i++ ) { @@ -2618,12 +2620,12 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; } - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, hTcBuffer->tc_fx, p_output_fx ); } ELSE { @@ -2671,7 +2673,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); - IF( ( error = ivas_omasa_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output_fx ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output_fx ) ) != IVAS_ERR_OK ) { return error; } @@ -2743,7 +2745,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); /* render the last subframe */ - IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) { return error; } @@ -2794,7 +2796,8 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( /*--------------------------------------------------------------------------* * ivas_jbm_dec_set_discard_samples() * - * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change + * Set number of samples to discard in the first subframe + * if the renderer granularity changes on a bitrate change in JBM processing *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_set_discard_samples_fx( @@ -2810,6 +2813,7 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx( temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */ nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); + IF( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->n_samples_discard = imult1616( sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ), st_ivas->hTcBuffer->n_samples_granularity ); @@ -2824,28 +2828,29 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_adapted_linear_interpolator() + * ivas_dec_get_adapted_linear_interpolator() * - * Get an interpolator that is adapted to time scale modified IVAS frame + * Get an interpolator that is adapted to (time scale modified) IVAS frame *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_adapted_linear_interpolator_fx( + +void ivas_dec_get_adapted_linear_interpolator_fx( const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */ const Word16 interp_length, /* i : length of the interpolator to be created */ Word16 *interpolator_fx /* o : the interpolator Q15 */ ) { - Word16 jbm_segment_len, idx; + Word16 segment_len, idx; Word16 dec_fx; Word16 dec_e; - jbm_segment_len = shr( default_interp_length, 1 ); + segment_len = shr( default_interp_length, 1 ); dec_fx = divide1616( 1, default_interp_length ); /*32767 / default_interp_length*/ interpolator_fx[interp_length - 1] = 32767; /* (1.0f in Q15) -1 */ move16(); interpolator_fx[interp_length - 2] = add( sub( 32767, dec_fx ), 1 ); // Use 32768 to maintain precision move16(); - FOR( idx = interp_length - 3; idx >= jbm_segment_len; idx-- ) + FOR( idx = interp_length - 3; idx >= segment_len; idx-- ) { interpolator_fx[idx] = s_max( 0, sub( interpolator_fx[idx + 1], dec_fx ) ); move16(); @@ -2853,7 +2858,7 @@ void ivas_jbm_dec_get_adapted_linear_interpolator_fx( IF( interpolator_fx[idx + 1] > 0 ) { - dec_fx = BASOP_Util_Divide1616_Scale( interpolator_fx[idx + 1], add( jbm_segment_len, 1 ), &dec_e ); + dec_fx = BASOP_Util_Divide1616_Scale( interpolator_fx[idx + 1], add( segment_len, 1 ), &dec_e ); dec_fx = shr( dec_fx, sub( 15, dec_e ) ); // Q0 FOR( ; idx >= 0; idx-- ) { @@ -2871,12 +2876,12 @@ void ivas_jbm_dec_get_adapted_linear_interpolator_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_adapted_subframes() + * ivas_dec_get_adapted_subframes() * - * Get an interpolator that is adapted to time scale modified IVAS frame + * Get an interpolator that is adapted to (time scale modified) IVAS frame *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_adapted_subframes( +void ivas_dec_get_adapted_subframes_fx( const Word16 nCldfbTs, /* i : number of time slots in the current frame */ Word16 *subframe_nbslots, /* i/o: subframe grid */ Word16 *nb_subframes /* i/o: number of subframes in the frame */ @@ -2925,16 +2930,16 @@ void ivas_jbm_dec_get_adapted_subframes( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_adapted_linear_interpolator() + * ivas_dec_get_md_map() * * Get an meta data map adapted to a time scale modified IVAS frame *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_md_map( +void ivas_dec_get_md_map_fx( const Word16 default_len, /* i : default frame length in metadata slots */ - const Word16 len, /* i : length of the modfied frames in metadata slots */ + const Word16 len, /* i : length of the modified frames in metadata slots*/ const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the md buffer */ + const Word16 offset, /* i : current read offset into the MD buffer */ const Word16 buf_len, /* i : length of the metadata buffer */ Word16 *map /* o : metadata index map */ ) @@ -2978,16 +2983,18 @@ void ivas_jbm_dec_get_md_map( return; } + /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_md_map_even_spacing() + * ivas_dec_get_md_map_even_spacing() * - * Get an meta data map adapted to a time scale modified IVAS frame. Distribute slots evenly across the modified frame. + * Get an meta data map adapted to (time scale modified) IVAS frame. + * Distribute slots evenly across the (modified) frame. *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_md_map_even_spacing( - const Word16 len, /* i : length of the modfied frames in metadata slots */ +void ivas_dec_get_md_map_even_spacing_fx( + const Word16 len, /* i : length of the modified frames in metadata slots*/ const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the md buffer */ + const Word16 offset, /* i : current read offset into the MD buffer */ const Word16 buf_len, /* i : length of the metadata buffer */ Word16 *map /* o : metadata index map */ ) @@ -3052,14 +3059,14 @@ void ivas_jbm_dec_get_md_map_even_spacing( return; } + /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_num_tc_channels() + * ivas_dec_get_num_tc_channels() * - * Get the number of transport channels provided by the JBM transport channel decode function + * Get the number of transport channels provided to the renderer *--------------------------------------------------------------------------*/ - -Word16 ivas_jbm_dec_get_num_tc_channels_fx( +Word16 ivas_dec_get_num_tc_channels_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ) { @@ -3132,7 +3139,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->nchan_transport, 2 ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) + IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->nchan_transport, 2 ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { num_tc = CPE_CHANNELS; move16(); @@ -3147,7 +3154,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( } ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { - IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { test(); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) @@ -3162,8 +3169,6 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - - if ( st_ivas->sba_dirac_stereo_flag ) { num_tc = CPE_CHANNELS; @@ -3181,12 +3186,12 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( } ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) { - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { num_tc = 1; move16(); } - ELSE IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { num_tc = 2; move16(); @@ -3222,6 +3227,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( { num_tc = add( num_tc, 1 ); } + test(); test(); test(); @@ -3251,13 +3257,13 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_render_granularity() - * + * ivas_dec_get_render_granularity() * + * Get renderer granularity *--------------------------------------------------------------------------*/ /*! r: render granularity */ -Word16 ivas_jbm_dec_get_render_granularity_fx( +Word16 ivas_dec_get_render_granularity_fx( const RENDERER_TYPE renderer_type, /* i : renderer type */ const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ const Word32 output_Fs /* i : sampling rate */ @@ -3289,13 +3295,13 @@ Word16 ivas_jbm_dec_get_render_granularity_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_audio_allocate() + * ivas_dec_tc_audio_allocate() * * allocate and initialize TC audio buffer *--------------------------------------------------------------------------*/ -static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( - DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM TSM buffer handle */ +static ivas_error ivas_dec_tc_audio_allocate_fx( + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC buffer handle */ const Word32 output_Fs, /* i : output sampling rate */ const Word16 Opt_tsm /* i : TSM option flag */ ) @@ -3316,20 +3322,20 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( move16(); } - nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ), n_samp_full ); + nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ), n_samp_full ); IF( Opt_tsm ) { - /* note: this is stack memory buffer for time-scale modified audio signals */ + /* note: this is stack memory buffer for TC decoded and also time-scale modified audio signals */ IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); } set_zero_fx( hTcBuffer->tc_buffer_fx, nsamp_to_allocate ); offset = 0; move16(); - FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; offset = add( offset, n_samp_full ); @@ -3344,7 +3350,7 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( { IF( ( hTcBuffer->tc_buffer_old_fx[ch_idx] = (Word32 *) malloc( n_samp_residual * sizeof( Word32 ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); } set_zero_fx( hTcBuffer->tc_buffer_old_fx[ch_idx], n_samp_residual ); } @@ -3419,15 +3425,15 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( } /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_open() + * ivas_dec_tc_buffer_open() * - * open and initialize JBM transport channel buffer + * Open and initialize transport channel buffer handle *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_tc_buffer_open_fx( +ivas_error ivas_dec_tc_buffer_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const Word16 nchan_transport_jbm, /* i : number of real transport channels */ + const Word16 nchan_transport_rend, /* i : number of TCs for rendering */ const Word16 nchan_transport_internal, /* i : number of totally buffered channels */ const Word16 nchan_full, /* i : number of channels to fully store */ const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ @@ -3444,12 +3450,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( IF( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); } hTcBuffer->tc_buffer_mode = tc_buffer_mode; move16(); - hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; + hTcBuffer->nchan_transport_rend = nchan_transport_rend; move16(); hTcBuffer->nchan_transport_internal = nchan_transport_internal; move16(); @@ -3485,7 +3491,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); - IF( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } @@ -3497,15 +3503,15 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_reconfigure() + * ivas_dec_tc_buffer_reconfigure() * - * open and initialize JBM transport channel buffer + * Reconfigure transport channel buffer handle *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( +ivas_error ivas_dec_tc_buffer_reconfigure_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const Word16 nchan_transport_jbm, /* i : new number of real transport channels */ + const Word16 nchan_transport_rend, /* i : new number of TCs for rendering */ const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ const Word16 nchan_full, /* i : new number of channels to fully store */ const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ @@ -3568,7 +3574,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( hTcBuffer->tc_buffer_mode = tc_buffer_mode; move16(); - hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; + hTcBuffer->nchan_transport_rend = nchan_transport_rend; move16(); hTcBuffer->nchan_transport_internal = nchan_transport_internal; move16(); @@ -3581,7 +3587,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer ); - IF( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } @@ -3597,12 +3603,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_playout() - * + * ivas_dec_tc_buffer_playout() * + * Get TC buffer playout *--------------------------------------------------------------------------*/ -static void ivas_jbm_dec_tc_buffer_playout_fx( +static void ivas_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, @@ -3610,17 +3616,19 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( ) { Word16 ch_idx, slot_size, slots_to_render, first_sf, last_sf, tmp, e; + DECODER_TC_BUFFER_HANDLE hTcBuffer; - slot_size = st_ivas->hTcBuffer->n_samples_granularity; + hTcBuffer = st_ivas->hTcBuffer; + slot_size = hTcBuffer->n_samples_granularity; move16(); /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e ); tmp = shr( tmp, sub( 15, e ) ); // Q0 - slots_to_render = s_min( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered ), tmp ); - st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, slots_to_render ); // Q0 + slots_to_render = s_min( sub( hTcBuffer->num_slots, hTcBuffer->slots_rendered ), tmp ); + hTcBuffer->slots_rendered = add( hTcBuffer->slots_rendered, slots_to_render ); // Q0 *nSamplesRendered = (UWord16) L_mult0( slots_to_render, slot_size ); - first_sf = st_ivas->hTcBuffer->subframes_rendered; + first_sf = hTcBuffer->subframes_rendered; last_sf = first_sf; move16(); move16(); @@ -3629,20 +3637,20 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( WHILE( slots_to_render > 0 ) { - slots_to_render = sub( slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf] ); + slots_to_render = sub( slots_to_render, hTcBuffer->subframe_nbslots[last_sf] ); last_sf = add( last_sf, 1 ); } #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif - FOR( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_rend; ch_idx++ ) { - output_fx[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered; + output_fx[ch_idx] = hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_rendered; move32(); } - st_ivas->hTcBuffer->subframes_rendered = last_sf; + hTcBuffer->subframes_rendered = last_sf; move16(); return; @@ -3650,12 +3658,12 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_close() + * ivas_dec_tc_buffer_close() * - * Close JBM transport channel buffer + * Close transport channel buffer handle *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_tc_buffer_close_fx( +void ivas_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { @@ -3672,39 +3680,42 @@ void ivas_jbm_dec_tc_buffer_close_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_td_renderers_adapt_subframes() + * ivas_dec_td_renderers_adapt_subframes() * - * Close JBM transport channel buffer + * Adapt subframes for TD renderers *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_td_renderers_adapt_subframes( +void ivas_dec_td_renderers_adapt_subframes_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, tmp_e, tmp1, tmp2, s1, s2; UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; - /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */ + /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; */ tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); - tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e ); + tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ - /* nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e ); + /* nSlotsAvailable = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity; */ + tmp = BASOP_Util_Divide1616_Scale( hTcBuffer->n_samples_available, hTcBuffer->n_samples_granularity, &tmp_e ); nSlotsAvailable = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ - st_ivas->hTcBuffer->num_slots = nSlotsAvailable; + hTcBuffer->num_slots = nSlotsAvailable; move16(); - /* st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; */ - st_ivas->hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, st_ivas->hTcBuffer->n_samples_granularity ); + /* hTcBuffer->n_samples_available = nSlotsAvailable * hTcBuffer->n_samples_granularity; */ + hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, hTcBuffer->n_samples_granularity ); move16(); - nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); - st_ivas->hTcBuffer->nb_subframes = 0; + nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1] ); + hTcBuffer->nb_subframes = 0; move16(); IF( nSlotsInFirstSubframe > 0 ) { - st_ivas->hTcBuffer->nb_subframes = 1; + hTcBuffer->nb_subframes = 1; move16(); nSlotsAvailable = sub( nSlotsAvailable, nSlotsInFirstSubframe ); } @@ -3716,29 +3727,29 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( tmp2 = shl( nMaxSlotsPerSubframe, s2 ); tmp = div_s( tmp1, tmp2 ); - st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16( tmp, sub( 15, sub( s2, s1 ) ) ) ); + hTcBuffer->nb_subframes = add( hTcBuffer->nb_subframes, ceil_fx16( tmp, sub( 15, sub( s2, s1 ) ) ) ); move16(); nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; move16(); - set16_fx( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); - set16_fx( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); + set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); + set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, hTcBuffer->nb_subframes ); if ( nSlotsInFirstSubframe > 0 ) { - st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; + hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; move16(); } if ( nSlotsInLastSubframe > 0 ) { - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; + hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; move16(); } - st_ivas->hTcBuffer->slots_rendered = 0; + hTcBuffer->slots_rendered = 0; move16(); - st_ivas->hTcBuffer->subframes_rendered = 0; + hTcBuffer->subframes_rendered = 0; move16(); return; @@ -3746,12 +3757,12 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_tc_buffer_mode() + * ivas_dec_get_tc_buffer_mode() * * *--------------------------------------------------------------------------*/ -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( +TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -3818,7 +3829,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( } BREAK; case RENDERER_MC: - if ( NE_16( ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) ) + if ( NE_16( ivas_dec_get_num_tc_channels_fx( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) ) { buffer_mode = TC_BUFFER_MODE_RENDERER; move16(); @@ -3861,12 +3872,12 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_metadata_open() + * ivas_jbm_dec_masa_metadata_open() * - * Open structure for metadata buffering in JBM + * Open structure for MASA metadata buffering in JBM processing *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_metadata_open( +ivas_error ivas_jbm_dec_masa_metadata_open_fx( Decoder_Struct *st_ivas ) { JBM_METADATA_HANDLE hJbmMetadata; @@ -3897,10 +3908,10 @@ ivas_error ivas_jbm_dec_metadata_open( /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_masa_meta_to_buffer() * - * Copy decoded MASA metadata to a ring buffer + * Copy decoded MASA metadata to a ring buffer in JBM processing *--------------------------------------------------------------------------*/ -static void ivas_jbm_dec_copy_masa_meta_to_buffer( +static void ivas_jbm_dec_copy_masa_meta_to_buffer_fx( Decoder_Struct *st_ivas ) { Word16 sf, dir, band; @@ -3950,7 +3961,7 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( * Map input MASA metadata subframes to slots in JBM processing *--------------------------------------------------------------------------*/ -static void ivas_jbm_masa_sf_to_slot_map( +static void ivas_jbm_masa_sf_to_slot_map_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nCldfbTs /* i : number of CLDFB time slots */ ) @@ -3961,7 +3972,7 @@ static void ivas_jbm_masa_sf_to_slot_map( Word16 slot_idx; Word16 write_idx, sf_index; - ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); + ivas_jbm_dec_copy_masa_meta_to_buffer_fx( st_ivas ); /* Set values */ hJbmMetadata = st_ivas->hJbmMetadata; @@ -3969,7 +3980,7 @@ static void ivas_jbm_masa_sf_to_slot_map( move16(); /* Map input subframes to slots */ - ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map ); + ivas_dec_get_md_map_even_spacing_fx( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map ); FOR( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ ) { @@ -3996,7 +4007,7 @@ static void ivas_jbm_masa_sf_to_slot_map( * Map input MASA metadata subframes to output subframes in JBM processing *--------------------------------------------------------------------------*/ -void ivas_jbm_masa_sf_to_sf_map( +void ivas_jbm_masa_sf_to_sf_map_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -4077,45 +4088,53 @@ void ivas_jbm_masa_sf_to_sf_map( /*--------------------------------------------------------------------------* * ivas_dec_prepare_renderer() * - * prepare IVAS renderer routine + * Prepare IVAS renderer routine *--------------------------------------------------------------------------*/ void ivas_dec_prepare_renderer_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - Word16 n, n_render_timeslots, tmp, exp, shift; + Word16 n, n_render_timeslots, n_samples_available, tmp, exp, shift; + AUDIO_CONFIG output_config; + DECODER_TC_BUFFER_HANDLE hTcBuffer; push_wmops( "ivas_dec_prepare_renderer" ); - /* n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); + output_config = st_ivas->hDecoderConfig->output_config; + move16(); + hTcBuffer = st_ivas->hTcBuffer; + n_samples_available = hTcBuffer->n_samples_available; + move16(); + + /* n_render_timeslots = n_samples_available / hTcBuffer->n_samples_granularity; */ + tmp = BASOP_Util_Divide1616_Scale( n_samples_available, hTcBuffer->n_samples_granularity, &exp ); n_render_timeslots = shr( tmp, sub( 15, exp ) ); // Q0 test(); - IF( EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) + IF( EQ_16( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes_fx( st_ivas ); test(); test(); test(); - IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm ) + IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm ) { - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + ivas_jbm_masa_sf_to_slot_map_fx( st_ivas, n_render_timeslots ); } /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */ test(); test(); test(); - IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->hMasaIsmData->masa_gain_is_edited, 1 ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->hMasaIsmData->masa_gain_is_edited, 1 ) ) { - ivas_omasa_gain_masa_tc_fx( st_ivas->hTcBuffer->tc_fx, st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available ); + ivas_omasa_gain_masa_tc_fx( hTcBuffer->tc_fx, st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->nchan_ism, n_samples_available ); } } ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) || EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes_fx( st_ivas ); } ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { @@ -4154,7 +4173,7 @@ void ivas_dec_prepare_renderer_fx( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); } - ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available ); } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { @@ -4175,12 +4194,12 @@ void ivas_dec_prepare_renderer_fx( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || - EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) && - ( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) + EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) && + ( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { - delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hSbaIsmData->delayBuffer_size ); + delay_signal32_fx( hTcBuffer->tc_fx[n], n_samples_available, st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hSbaIsmData->delayBuffer_size ); } } @@ -4189,7 +4208,7 @@ void ivas_dec_prepare_renderer_fx( IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { Word16 temp, temp_e; - temp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size, &temp_e ); + temp = BASOP_Util_Divide1616_Scale( hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size, &temp_e ); n_render_timeslots = extract_l( L_shr( L_mult0( n_render_timeslots, temp ), sub( 15, temp_e ) ) ); } @@ -4203,12 +4222,12 @@ void ivas_dec_prepare_renderer_fx( scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift) st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); } - ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available ); } } ELSE { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes_fx( st_ivas ); IF( st_ivas->hSCE[0] ) { @@ -4221,7 +4240,7 @@ void ivas_dec_prepare_renderer_fx( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); } - ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available ); } } ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) @@ -4229,11 +4248,11 @@ void ivas_dec_prepare_renderer_fx( test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes_fx( st_ivas ); IF( st_ivas->hDecoderConfig->Opt_tsm ) { - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + ivas_jbm_masa_sf_to_slot_map_fx( st_ivas, n_render_timeslots ); } /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */ test(); @@ -4241,8 +4260,8 @@ void ivas_dec_prepare_renderer_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); // Q8 - Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 + v_multc_fx_16( hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, hTcBuffer->tc_fx[n], n_samples_available ); // Q8 + Scale_sig32( hTcBuffer->tc_fx[n], n_samples_available, Q3 ); // Q8 -> Q11 } } } @@ -4251,7 +4270,7 @@ void ivas_dec_prepare_renderer_fx( test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - n_render_timeslots = i_mult( n_render_timeslots, idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) ); + n_render_timeslots = i_mult( n_render_timeslots, idiv1616( hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) ); } IF( st_ivas->hSCE[0] ) @@ -4266,7 +4285,7 @@ void ivas_dec_prepare_renderer_fx( move16(); } - ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available ); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { @@ -4305,8 +4324,8 @@ void ivas_dec_prepare_renderer_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); - Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 + v_multc_fx_16( hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, hTcBuffer->tc_fx[n], n_samples_available ); + Scale_sig32( hTcBuffer->tc_fx[n], n_samples_available, Q3 ); // Q8 -> Q11 } } } @@ -4316,19 +4335,19 @@ void ivas_dec_prepare_renderer_fx( test(); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + v_multc_fx_16( hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available ); IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) { - v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); - Scale_sig32( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 + v_multc_fx_16( hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available ); + Scale_sig32( hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available, Q3 ); // Q8 -> Q11 } } test(); - IF( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); + delay_signal32_fx( hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } @@ -4339,8 +4358,8 @@ void ivas_dec_prepare_renderer_fx( { FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { - v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); // Q8 - Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 + v_multc_fx_16( hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, hTcBuffer->tc_fx[n], n_samples_available ); // Q8 + Scale_sig32( hTcBuffer->tc_fx[n], n_samples_available, Q3 ); // Q8 -> Q11 } } } @@ -4350,11 +4369,11 @@ void ivas_dec_prepare_renderer_fx( { IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes_fx( st_ivas ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { - ivas_mc_paramupmix_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_mc_paramupmix_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, n_samples_available ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { @@ -4419,7 +4438,7 @@ void ivas_dec_prepare_renderer_fx( move16(); } - ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available ); } } diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index e24fa019b..31a6c45ee 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -925,7 +925,7 @@ ivas_error ivas_masa_dec_open_fx( move16(); } - nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + nchan_transport = ivas_dec_get_num_tc_channels_fx( st_ivas ); nchan_to_allocate = nchan_transport; move16(); @@ -951,9 +951,9 @@ ivas_error ivas_masa_dec_open_fx( nchan_to_allocate = add( nchan_to_allocate, 1 ); } - granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); - IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -1937,7 +1937,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); /*-----------------------------------------------------------------* - * JBM TC buffers + * TC buffer *-----------------------------------------------------------------*/ { Word16 tc_nchan_to_allocate; @@ -1945,9 +1945,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( TC_BUFFER_MODE buffer_mode_new; Word16 n_samples_granularity; - n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); - buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); - tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + n_samples_granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); + buffer_mode_new = ivas_dec_get_tc_buffer_mode_fx( st_ivas ); + tc_nchan_transport = ivas_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_to_allocate = tc_nchan_transport; move16(); @@ -2007,11 +2007,13 @@ ivas_error ivas_masa_dec_reconfigure_fx( tc_nchan_transport = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); tc_nchan_to_allocate = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); } + + /* reconfigure TC buffer */ test(); test(); - IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) ) + IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_rend ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) ) { - IF( NE_32( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 43937a077..b66cfae01 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -523,9 +523,9 @@ ivas_error ivas_param_mc_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { - granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -1520,7 +1520,7 @@ void ivas_param_mc_dec_digest_tc_fx( /* Initialization */ num_freq_bands = st_ivas->hParamMC->num_freq_bands; move16(); - n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); + n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_rend, st_ivas->hTcBuffer->nchan_buffer_full ); cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx; cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx; @@ -1642,7 +1642,7 @@ void ivas_param_mc_dec_prepare_renderer( move16(); hParamMC->subframes_rendered = 0; move16(); - ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); + ivas_dec_get_adapted_subframes_fx( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; move16(); Copy( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); @@ -2608,7 +2608,7 @@ static void ivas_param_mc_dec_compute_interpolator_fx( } ELSE { - ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator ); + ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator ); } return; diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 833947efd..8eaf0577a 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -216,9 +216,9 @@ void ivas_mc_paramupmix_dec_digest_tc_fx( ivas_param_upmix_dec_decorr_subframes( st_ivas, nSamplesForRendering ); /* adapt subframes */ - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes_fx( st_ivas ); - ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator_fx ); + ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator_fx ); pop_wmops(); return; @@ -399,10 +399,11 @@ ivas_error ivas_mc_paramupmix_dec_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } + hMCParamUpmix->free_param_interpolator = 1; move16(); - ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator_fx ); + ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator_fx ); IF( st_ivas->hTcBuffer == NULL ) { @@ -412,7 +413,7 @@ ivas_error ivas_mc_paramupmix_dec_open( TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; - nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + nchan_tc = ivas_dec_get_num_tc_channels_fx( st_ivas ); nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; move16(); move16(); @@ -435,9 +436,9 @@ ivas_error ivas_mc_paramupmix_dec_open( move16(); } - granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -496,12 +497,12 @@ void ivas_mc_paramupmix_dec_close( /*------------------------------------------------------------------------- - * paramupmix_td_decorr_process_jbm_fx() + * paramupmix_td_decorr_process() * * *------------------------------------------------------------------------*/ -static void paramupmix_td_decorr_process_jbm_fx( +static void paramupmix_td_decorr_process_fx( ivas_td_decorr_state_t *hTdDecorr[], /* i/o: SPAR Covar. decoder handle */ Word32 *pcm_in[], /* i : input audio channels */ Word32 **pp_out_pcm, /* o : output audio channels */ @@ -561,8 +562,9 @@ static void paramupmix_td_decorr_process_jbm_fx( *------------------------------------------------------------------------*/ static void ivas_param_upmix_dec_decorr_subframes( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const Word16 nSamplesForRendering ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const Word16 nSamplesForRendering /* i : number of samples provided */ +) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; Word32 *pPcm_tmp_fx[MC_PARAMUPMIX_COMBINATIONS]; @@ -591,23 +593,21 @@ static void ivas_param_upmix_dec_decorr_subframes( WHILE( nSamplesLeftForTD ) { Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); + Word16 i, q_format[MC_PARAMUPMIX_COMBINATIONS]; + FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { - Word16 i, q_format[MC_PARAMUPMIX_COMBINATIONS]; - - FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) - { - q_format[i] = Q11; - move16(); - } + q_format[i] = Q11; + move16(); + } - paramupmix_td_decorr_process_jbm_fx( hMCParamUpmix->hTdDecorr, p_tc_fx, pPcm_tmp_fx, nSamplesToDecorr, q_format ); + paramupmix_td_decorr_process_fx( hMCParamUpmix->hTdDecorr, p_tc_fx, pPcm_tmp_fx, nSamplesToDecorr, q_format ); - FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) - { - Scale_sig32( pPcm_tmp_fx[i], nSamplesToDecorr, sub( Q11, q_format[i] ) ); // Setting Q to changed q in q_format - } + FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) + { + Scale_sig32( pPcm_tmp_fx[i], nSamplesToDecorr, sub( Q11, q_format[i] ) ); // Setting Q to changed q in q_format } + FOR( ch = 0; ch < nchan_internal; ch++ ) { p_tc_fx[ch] += nSamplesToDecorr; diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 34055e84a..5c5b0ac52 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -899,12 +899,14 @@ static ivas_error ivas_mc_dec_reconfig_fx( Decoder_State *st; ivas_error error; MC_MODE mc_mode, last_mc_mode; + DECODER_TC_BUFFER_HANDLE hTcBuffer; TC_BUFFER_MODE tc_buffer_mode_new; Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; Word16 nchan_out_buff; + hTcBuffer = st_ivas->hTcBuffer; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); nchan_transport_old = st_ivas->nchan_transport; @@ -950,45 +952,45 @@ static ivas_error ivas_mc_dec_reconfig_fx( /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); - /* transfer subframe info from DirAC or ParamMC to central tc buffer */ - IF( NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) + /* transfer subframe info from DirAC or ParamMC to central TC buffer */ + IF( NE_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { test(); IF( EQ_16( last_mc_mode, MC_MODE_PARAMMC ) ) { - st_ivas->hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes; + hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes; move16(); - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered; + hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered; move16(); - st_ivas->hTcBuffer->num_slots = st_ivas->hParamMC->num_slots; + hTcBuffer->num_slots = st_ivas->hParamMC->num_slots; move16(); - st_ivas->hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered; + hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered; move16(); - Copy( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( st_ivas->hParamMC->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } ELSE IF( EQ_16( last_mc_mode, MC_MODE_MCMASA ) && st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; move16(); - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; move16(); - st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; move16(); - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; move16(); - Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } - /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv - render what still fits in the new granularity */ - tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); - IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + /* when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv + render what still fits in the new granularity */ + tc_granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + IF( LT_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) ) { /* flush already done in IVAS_DEC_ReadFormat() */ } - /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ - ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + /* when granularity goes up set samples to discard at the beginning of the frame */ + ELSE IF( GT_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { @@ -1526,16 +1528,13 @@ static ivas_error ivas_mc_dec_reconfig_fx( } /*-----------------------------------------------------------------* - * JBM TC buffers + * TC buffer *-----------------------------------------------------------------*/ - { Word16 tc_nchan_full_new; - DECODER_TC_BUFFER_HANDLE hTcBuffer; - hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + tc_buffer_mode_new = ivas_dec_get_tc_buffer_mode_fx( st_ivas ); + tc_nchan_tc_new = ivas_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; move16(); tc_nchan_full_new = tc_nchan_tc_new; @@ -1593,39 +1592,40 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); test(); test(); - IF( NE_16( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) || + IF( NE_16( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_rend, tc_nchan_tc_new ) || NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) || NE_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) ) { - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) ) { return error; } } - /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ + + /* transfer subframe info from central TC buffer to ParamMC or McMASA (DirAC) */ IF( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes; move16(); - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered; move16(); - st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hSpatParamRendCom->num_slots = hTcBuffer->num_slots; move16(); - st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + st_ivas->hSpatParamRendCom->slots_rendered = hTcBuffer->slots_rendered; move16(); - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } ELSE IF( st_ivas->hParamMC != NULL ) { - st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hParamMC->nb_subframes = hTcBuffer->nb_subframes; move16(); - st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hParamMC->subframes_rendered = hTcBuffer->subframes_rendered; move16(); - st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hParamMC->num_slots = hTcBuffer->num_slots; move16(); - st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + st_ivas->hParamMC->slots_rendered = hTcBuffer->slots_rendered; move16(); - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } @@ -1634,7 +1634,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); - IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, hTcBuffer ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 428c6512e..ac58b9dfd 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -94,7 +94,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( Word16 ch, slot_size, slots_to_render, output_frame, tmp; ivas_error error; - Word16 ism_md_subframe_update_jbm; + Word16 ism_md_subframe_update; Word16 c_indx, nS, i; Word16 nchan_ism_internal, nchan_ism, ch_offset; @@ -136,16 +136,16 @@ ivas_error ivas_td_binaural_renderer_sf_fx( /* Number of subframes to delay metadata to sync with audio */ IF( st_ivas->hDecoderConfig->Opt_delay_comp ) { - ism_md_subframe_update_jbm = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) ); + ism_md_subframe_update = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) ); } ELSE { - ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); + ism_md_subframe_update = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); } IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { - ism_md_subframe_update_jbm = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 2 ) ); + ism_md_subframe_update = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 2 ) ); } FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -206,7 +206,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( } } - IF( EQ_16( subframe_idx, ism_md_subframe_update_jbm ) ) + IF( EQ_16( subframe_idx, ism_md_subframe_update ) ) { test(); test(); @@ -311,7 +311,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( } /* Render subframe */ - /* ism_md_subframe_update_jbm != subframe_idx: trigger update only for ism_md_subframe_update_jbm == subframe_idx, + /* ism_md_subframe_updatem != subframe_idx: trigger update only for ism_md_subframe_update_jbm == subframe_idx, where then the two TDREND_GetMix()-arguments subframe_idx and ism_md_subframe_update are equal, and we want to enforce the update inside TDREND_GetMix to use subframe_idx == 0 */ IF( NE_32( ( error = TDREND_GetMix_fx( st_ivas->hBinRendererTd, output_fx_local, output_frame, 0 ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0021a7b76..8f0785769 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -652,7 +652,7 @@ ivas_error ivas_omasa_dec_config_fx( IF( st_ivas->hMasaIsmData != NULL || st_ivas->hIsmRendererData != NULL ) { /* this calls also ivas_ism_renderer_close() closing st_ivas->hIsmRendererData used by the EXT renderers. also cleans st_ivas->hMasaIsmData */ - ivas_omasa_separate_object_renderer_close( st_ivas ); + ivas_omasa_separate_object_renderer_close_fx( st_ivas ); } test(); @@ -708,7 +708,7 @@ ivas_error ivas_omasa_dec_config_fx( } /* ISM renderer handle + ISM data handle */ - ivas_omasa_separate_object_renderer_close( st_ivas ); + ivas_omasa_separate_object_renderer_close_fx( st_ivas ); } } @@ -729,7 +729,7 @@ ivas_error ivas_omasa_dec_config_fx( return error; } - IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -737,7 +737,7 @@ ivas_error ivas_omasa_dec_config_fx( ELSE { /* ISM renderer handle + ISM data handle */ - ivas_omasa_separate_object_renderer_close( st_ivas ); + ivas_omasa_separate_object_renderer_close_fx( st_ivas ); } IF( EQ_32( old_renderer_type, RENDERER_MONO_DOWNMIX ) ) @@ -1075,19 +1075,20 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( return IVAS_ERR_OK; } + /*--------------------------------------------------------------------------* - * ivas_omasa_dirac_rend_jbm_fx() + * ivas_omasa_dirac_rend() * - * Rendering in OMASA format for JBM + * Rendering in OMASA format *--------------------------------------------------------------------------*/ -void ivas_omasa_dirac_rend_jbm_fx( +void ivas_omasa_dirac_rend_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of samples requested */ UWord16 *nSamplesRendered, /* o : number of samples rendered */ UWord16 *nSamplesAvailable, /* o : number of samples still to render */ const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *output_fx[] /* o : rendered time signal Q11*/ + Word32 *output_fx[] /* o : rendered time signal Q11*/ ) { Word16 subframes_rendered; @@ -1150,7 +1151,7 @@ void ivas_omasa_dirac_rend_jbm_fx( scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, -1 ); // Q30 -> Q29 } - ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered ); + ivas_omasa_separate_object_render_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered ); FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) { @@ -1164,16 +1165,16 @@ void ivas_omasa_dirac_rend_jbm_fx( /*--------------------------------------------------------------------------* * ivas_omasa_dirac_td_binaural_render() * - * Binaural rendering in OMASA format for JBM + * Binaural rendering in OMASA format *--------------------------------------------------------------------------*/ -ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( +ivas_error ivas_omasa_dirac_td_binaural_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of samples requested */ UWord16 *nSamplesRendered, /* o : number of samples rendered */ UWord16 *nSamplesAvailable, /* o : number of samples still to render */ const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *output_fx[] /* o : rendered time signal Q11*/ + Word32 *output_fx[] /* o : rendered time signal Q11*/ ) { Word16 n; diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index c9a6e0d70..c6abf897b 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -119,17 +119,17 @@ void ivas_osba_data_close_fx( /*--------------------------------------------------------------------------* - * ivas_osba_dirac_td_binaural_jbm() + * ivas_osba_dirac_td_binaural() * - * Binaural rendering in JBM OSBA format + * Binaural rendering in OSBA format *--------------------------------------------------------------------------*/ -ivas_error ivas_osba_dirac_td_binaural_jbm_fx( +ivas_error ivas_osba_dirac_td_binaural_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - Word32 *output_fx[] /* o : rendered time signal Q11*/ + Word32 *output_fx[] /* o : rendered time signal Q11*/ ) { Word16 n; diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 90cca6855..8df43f1a4 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -102,7 +102,7 @@ void ivas_sba_set_cna_cng_flag( } /*-------------------------------------------------------------------* - * ivas_sba_dec_reconfigure_fx() + * ivas_sba_dec_reconfigure() * * Reconfigure IVAS SBA decoder *-------------------------------------------------------------------*/ @@ -180,7 +180,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) { /* determine new granularity */ - granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); + granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) @@ -585,9 +585,8 @@ ivas_error ivas_sba_dec_reconfigure_fx( } /*-----------------------------------------------------------------* - * JBM TC buffers + * TC buffer *-----------------------------------------------------------------*/ - { Word16 tc_nchan_to_allocate; Word16 tc_nchan_tc; @@ -595,8 +594,8 @@ ivas_error ivas_sba_dec_reconfigure_fx( tc_buffer_mode = TC_BUFFER_MODE_RENDERER; move16(); - tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/ - tc_nchan_to_allocate = tc_nchan_tc; /*Q0*/ + tc_nchan_tc = ivas_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/ + tc_nchan_to_allocate = tc_nchan_tc; /*Q0*/ move16(); test(); test(); @@ -647,19 +646,20 @@ ivas_error ivas_sba_dec_reconfigure_fx( } } + /* reconfigure TC buffer */ test(); test(); test(); - IF( NE_16( tc_nchan_tc, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( tc_buffer_mode, st_ivas->hTcBuffer->tc_buffer_mode ) || NE_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( NE_16( tc_nchan_tc, st_ivas->hTcBuffer->nchan_transport_rend ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( tc_buffer_mode, st_ivas->hTcBuffer->tc_buffer_mode ) || NE_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - if ( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ), IVAS_ERR_OK ) ) { return error; } } } - /* resync SPAR and DirAC JBM info from TC Buffer */ + /* resync SPAR and DirAC info from TC Buffer */ test(); IF( st_ivas->hSpatParamRendCom != NULL && EQ_16( st_ivas->hSpatParamRendCom->slot_size, st_ivas->hTcBuffer->n_samples_granularity ) ) { diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 7cb1297a7..bea27a067 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -246,8 +246,8 @@ ivas_error ivas_spar_dec_open_fx( buffer_mode = TC_BUFFER_MODE_RENDERER; move32(); - nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/ - nchan_to_allocate = num_channels_internal; /*Q0*/ + nchan_tc = ivas_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/ + nchan_to_allocate = num_channels_internal; /*Q0*/ move16(); test(); @@ -288,9 +288,9 @@ ivas_error ivas_spar_dec_open_fx( move16(); } - granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); + granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -1525,9 +1525,9 @@ void ivas_spar_dec_set_render_map_fx( move16(); set16_fx( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes ); + ivas_dec_get_adapted_subframes_fx( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes ); - /* copy also to tc buffer */ + /* copy also to TC buffer */ /* only for non-combined formats and combinded formats w/o discrete objects */ test(); IF( !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ) @@ -1537,7 +1537,7 @@ void ivas_spar_dec_set_render_map_fx( Copy( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); /*Q0*/ } - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); + ivas_dec_get_md_map_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); return; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 151006225..34c07d1f1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -993,7 +993,7 @@ typedef struct ivas_masa_ism_data_structure /*----------------------------------------------------------------------------------* - * JBM structures + * TC buffer structure, stores decoder and renderer audio samples, and rendering parameters *----------------------------------------------------------------------------------*/ typedef struct decoder_tc_buffer_structure @@ -1001,16 +1001,15 @@ typedef struct decoder_tc_buffer_structure Word32 *tc_buffer_old_fx[MAX_INTERN_CHANNELS]; /* TC audio samples not rendered in the previous frame */ Word32 *tc_buffer_fx; /* the buffer itself */ Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ - Word16 no_channels; /*Stores no of channels in tc_fx with values*/ - Word16 q_tc_fx; - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - Word16 nchan_transport_jbm; /* number of TCs after TC decoding */ - Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - Word16 nchan_buffer_full; /* number of channels to be fully buffered */ - Word16 n_samples_available; /* samples still available for rendering in the current frame */ - Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - Word16 n_samples_rendered; /* samples already rendered in the current frame */ - Word16 n_samples_granularity; /* render granularity */ + Word16 q_tc_fx; /* TC channels Q-factor */ + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + Word16 nchan_transport_rend; /* number of TCs provided to the renderer */ + Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + Word16 nchan_buffer_full; /* number of channels to be fully buffered */ + Word16 n_samples_available; /* samples still available for rendering in the current frame */ + Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + Word16 n_samples_rendered; /* samples already rendered in the current frame */ + Word16 n_samples_granularity; /* render granularity */ Word16 n_samples_flushed; Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; Word16 nb_subframes; @@ -1023,6 +1022,11 @@ typedef struct decoder_tc_buffer_structure } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; + +/*----------------------------------------------------------------------------------* + * JBM metadata structure + *----------------------------------------------------------------------------------*/ + typedef struct jbm_metadata_structure { Word16 sf_write_idx; @@ -1181,8 +1185,7 @@ typedef struct Decoder_Struct ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; /* TD object renderer handles */ - /* JBM module */ - DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ + DECODER_TC_BUFFER_HANDLE hTcBuffer; /* transport channels (TC) structure */ JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */ Word32 last_active_ivas_total_brate; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0bc064d05..376907bab 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1523,7 +1523,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer( } /* render IVAS frames directly to the output buffer */ - IF( ( error = ivas_jbm_dec_render_fx( st_ivas, sub( nSamplesAsked, nSamplesRendered ), &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dec_render_fx( st_ivas, sub( nSamplesAsked, nSamplesRendered ), &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1704,7 +1704,7 @@ static ivas_error ivas_dec_setup_all( } } - *nTransportChannels = (UWord8) st_ivas->hTcBuffer->nchan_transport_jbm; + *nTransportChannels = (UWord8) st_ivas->hTcBuffer->nchan_transport_rend; move16(); /*-----------------------------------------------------------------* @@ -2085,7 +2085,7 @@ ivas_error IVAS_DEC_GetMasaMetadata( IF( getFromJbmBuffer ) { - ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas ); + ivas_jbm_masa_sf_to_sf_map_fx( hIvasDec->st_ivas ); } *hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta; @@ -3813,7 +3813,7 @@ ivas_error IVAS_DEC_ReadFormat( ( NE_32( renderer_type_old, st_ivas->renderer_type ) || NE_32( renderer_type_sec_old, renderer_type_sec_new ) ) ) { - Word16 tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); + Word16 tc_granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); st_ivas->nchan_transport = nchan_transport_old; move16(); @@ -3960,7 +3960,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } ELSE IF( EQ_32( hIvasDec->mode, IVAS_DEC_MODE_IVAS ) ) { - IF( ( error = ivas_jbm_dec_tc_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dec_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -4026,7 +4026,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( * Feed decoded transport channels samples to the renderer *-----------------------------------------------------------------*/ - ivas_jbm_dec_feed_tc_to_renderer_fx( st_ivas, nSamplesTcsScaled, &nResidualSamples ); + ivas_dec_feed_tc_to_renderer_fx( st_ivas, nSamplesTcsScaled, &nResidualSamples ); IF( st_ivas->hDecoderConfig->Opt_tsm ) { @@ -5172,7 +5172,7 @@ ivas_error IVAS_DEC_Flush( test(); IF( GT_16( nSamplesToRender, 0 ) && NE_16( (Word16) hIvasDec->st_ivas->ivas_format, (Word16) MONO_FORMAT ) ) { - error = ivas_jbm_dec_render_fx( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); + error = ivas_dec_render_fx( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); } ELSE { diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index b206d8f8d..fde0d8bd5 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -137,7 +137,7 @@ ivas_error ivas_enc_fx( } ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { - IF( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_osba_enc_reconfig_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 5f0ec3319..044a42c17 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -44,6 +44,7 @@ /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ + static void ivas_osba_render_ism_to_sba_fx( Word32 *data_in_fx[], Word32 data_out_fx[][L_FRAME48k], @@ -54,11 +55,13 @@ static void ivas_osba_render_ism_to_sba_fx( Word32 prev_gains_fx[][MAX_INPUT_CHANNELS], const Word32 interpolator_fx[L_FRAME48k], Word16 *Q_data ); + /*-------------------------------------------------------------------* * ivas_merge_sba_transports() * * Merge SBA transport channels *-------------------------------------------------------------------*/ + static void ivas_merge_sba_transports_fx( Word32 data_in_f1[][L_FRAME48k], // Q_f1 Word32 *data_in_f2[], // Q_f2 @@ -81,13 +84,17 @@ static void ivas_merge_sba_transports_fx( } } *Q_out = sub( Q_f1, 1 ); + return; } + + /*--------------------------------------------------------------------------* * ivas_osba_enc_open() * * Allocate and initialize OMASA handle *--------------------------------------------------------------------------*/ + ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ) @@ -138,11 +145,13 @@ ivas_error ivas_osba_enc_open_fx( return error; } + /*--------------------------------------------------------------------------* * ivas_omasa_enc_close() * * Close OMASA handle *--------------------------------------------------------------------------*/ + void ivas_osba_enc_close_fx( OSBA_ENC_HANDLE *hOSba /* i/o: encoder OSBA handle */ ) @@ -167,12 +176,14 @@ void ivas_osba_enc_close_fx( return; } + /*--------------------------------------------------------------------------* * ivas_osba_enc_reconfig() * * oSBA encoder reconfiguration *--------------------------------------------------------------------------*/ -ivas_error ivas_osba_enc_reconfig( + +ivas_error ivas_osba_enc_reconfig_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) { @@ -386,6 +397,8 @@ ivas_error ivas_osba_enc_reconfig( return error; } + + /*--------------------------------------------------------------------------* * ivas_osba_enc() * @@ -395,7 +408,7 @@ ivas_error ivas_osba_enc_reconfig( void ivas_osba_enc_fx( OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ - Word32 *data_in_fx[], /* i/o: Input / transport audio signals q_data*/ + Word32 *data_in_fx[], /* i/o: Input / transport audio signals q_data*/ const Word16 input_frame, /* i : Input frame size */ const Word16 nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 845976352..fe468b981 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -2046,7 +2046,7 @@ ivas_error ivas_rend_crendProcessSubframe_fx( const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ - DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */ Word32 *input_f[], /* i : transport channels Qx */ Word32 *output[], /* i/o: input/output audio channels Qx */ const Word16 n_samples_to_render, /* i : output frame length per channel */ @@ -2269,15 +2269,15 @@ ivas_error ivas_rend_crendProcessSubframe_fx( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_rend_crendProcessSubframesSplitBin( - const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ - const AUDIO_CONFIG inConfig, /* i : input audio configuration */ - const AUDIO_CONFIG outConfig, /* i : output audio configuration */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ - DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */ Word32 *input_f[], /* i : transport channels */ Word32 *output[], /* i/o: input/output audio channels */ const Word16 n_samples_to_render, /* i : output frame length per channel */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0152bf465..f6fa52c29 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -394,9 +394,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( nchan_to_allocate = add( BINAURAL_CHANNELS, st_ivas->nchan_ism ); } - n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); + n_samples_granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_dec_get_num_tc_channels_fx( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 053cb43c1..95a225aba 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -446,7 +446,7 @@ ivas_error ivas_output_buff_dec_fx( if ( Opt_tsm ) { /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer->tc[]' */ - nchan_tc_jbm = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + nchan_tc_jbm = s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); } test(); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 5f37622a8..24067e682 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -914,7 +914,7 @@ ivas_error ivas_rend_crendProcessSubframe_fx( const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ - DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */ Word32 *input_f[], /* i : transport channels */ Word32 *output[], /* i/o: input/output audio channels */ const Word16 n_samples_to_render, /* i : output frame length per channel */ @@ -1555,12 +1555,12 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ const AUDIO_CONFIG inConfig, /* i : input audio configuration */ const AUDIO_CONFIG outConfig, /* i : output audio configuration */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ - DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */ Word32 *input_f[], /* i : transport channels */ Word32 *output[], /* i/o: input/output audio channels */ const Word16 n_samples_to_render, /* i : output frame length per channel */ -- GitLab From 647937cb88fbe9d01c75de7d2c839565605c22e5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 16 Dec 2025 14:49:05 -0500 Subject: [PATCH 214/750] Removal of unnecessary scaling --- lib_com/options.h | 2 +- lib_com/prot_fx.h | 4 ++++ lib_dec/acelp_core_dec_fx.c | 19 ++++++++++++++++++- lib_dec/ivas_core_dec_fx.c | 13 ++++++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 640bd4a74..f6f59e9e8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,7 +100,7 @@ #define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ - +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bba113ec0..29fce3f6e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10321,7 +10321,11 @@ ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs */ Word16 synth_fx16[], /* o : synthesis */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else Word16 save_hb_synth_fx16[], /* o : HB synthesis */ +#endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ Word16 *voice_factors_fx, /* o : voicing factors */ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index e163662c8..f3b421367 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -55,7 +55,11 @@ ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ Word16 synth_fx16[], /* o : synthesis Q_syn2*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ +#endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE Q_syn2-1*/ @@ -74,7 +78,11 @@ ivas_error acelp_core_dec_fx( const Word16 read_sid_info /* i : read SID info flag */ ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 synth_fx[960]; +#else Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; +#endif Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ Word16 output_frame; /* frame length at output sampling freq. */ @@ -2008,7 +2016,11 @@ ivas_error acelp_core_dec_fx( } } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + IF( save_hb_synth_fx32 != NULL ) +#else IF( save_hb_synth_fx16 != NULL ) +#endif { /* save and then zero-out lowband */ max_real = 0; @@ -2049,8 +2061,11 @@ ivas_error acelp_core_dec_fx( } } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx32, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); +#else cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); - +#endif /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -2333,6 +2348,7 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->element_mode, EVS_MONO ) ) { +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING #ifdef FIX_2252_SCALING_SAVE_HB_SYNTH IF( save_hb_synth_fx16 != NULL ) #else @@ -2345,6 +2361,7 @@ ivas_error acelp_core_dec_fx( Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0 #endif } +#endif Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 690797e20..3377d8321 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -479,6 +479,7 @@ ivas_error ivas_core_dec_fx( { /* ACELP core decoder */ Word16 old_syn_12k8_16k_fx_16[L_FRAME16k]; +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx; IF( save_hb_synth_32_fx ) @@ -489,7 +490,7 @@ ivas_error ivas_core_dec_fx( { save_hb_synth_16_fx = NULL; } - +#endif IF( st->cldfbAna ) { scale_sig32( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, Q11 - Q10 ); // Q11 @@ -529,7 +530,11 @@ ivas_error ivas_core_dec_fx( st->Q_syn_factor = 0; move16(); +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_32_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -555,14 +560,16 @@ ivas_error ivas_core_dec_fx( move16(); } move16(); - IF( save_hb_synth_32_fx ) { +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_16_32_DEPREC( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); // Q11 +#else + Scale_sig32( save_hb_synth_32_fx, output_frame, Q11 ); // Q0 -> Q11 +#endif hSCE->q_save_hb_synth_fx = Q11; move16(); } - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) } -- GitLab From 086f9eee5aeffa7d22fc3ca75274b93458d89591 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 17 Dec 2025 09:22:05 +0100 Subject: [PATCH 215/750] Add USAN fix under FIX_1474_USAN_TRANS_INV --- lib_com/options.h | 1 + lib_com/trans_direct_fx.c | 21 ++++++++++++++++++--- lib_com/trans_inv_fx.c | 22 +++++++++++++++++++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5e8a08b81..e6edb7978 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ +#define FIX_1474_USAN_TRANS_INV /* Eri: Float issue 1474: Fix USAN out-of-bounds warning. No OOB occurs, but the pointer is set to point to uninitialized memory. */ /* #################### End BE switches ################################## */ diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c index 4e259e0cc..f8fe2f03f 100644 --- a/lib_com/trans_direct_fx.c +++ b/lib_com/trans_direct_fx.c @@ -76,15 +76,22 @@ void direct_transform_fx( move32(); } +#ifndef FIX_1474_USAN_TRANS_INV iseg_fx = &in32_r16_fx[-segment_length4]; /*Q*/ - oseg_fx = out32_fx; /*Q*/ +#endif + oseg_fx = out32_fx; /*Q*/ wh_fx = &win_fx[segment_length4]; /*Q15*/ wl_fx = wh_fx - 1; /*Q15*/ +#ifdef FIX_1474_USAN_TRANS_INV + shift = extract_l( L_mult0( 2, segment_length4 ) ); /*Q0*/ + sh_fx = &in32_r16_fx[shift]; /*Q*/ +#else shift = extract_l( L_mult0( 3, segment_length4 ) ); /*Q0*/ sh_fx = &iseg_fx[shift]; /*Q*/ - sl_fx2 = sh_fx - 1; /*Q*/ +#endif + sl_fx2 = sh_fx - 1; /*Q*/ FOR( i = 0; i < segment_length4; i++ ) @@ -94,7 +101,11 @@ void direct_transform_fx( move32(); } - sl_fx2 = &iseg_fx[( segment_length2 - 1 )]; /*Q*/ +#ifdef FIX_1474_USAN_TRANS_INV + sl_fx2 = &in32_r16_fx[( segment_length4 - 1 )]; /*Q*/ +#else + sl_fx2 = &iseg_fx[( segment_length2 - 1 )]; /*Q*/ +#endif FOR( i = segment_length4; i < segment_length2; i++ ) { @@ -107,7 +118,11 @@ void direct_transform_fx( edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[0] ); Qmin = s_min( Qs[0], Qmin ); +#ifdef FIX_1474_USAN_TRANS_INV + iseg_fx = &in32_r16_fx[segment_length4]; +#else iseg_fx += segment_length2; +#endif oseg_fx += segment_length2; FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ ) diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 8bf63fcca..9a0774215 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -1032,7 +1032,11 @@ void Inverse_Transform( } } +#ifdef FIX_1474_USAN_TRANS_INV + out_segment = out_alias; +#else out_segment = out_alias - segment_length_div4; +#endif in_segment = in_mdct_modif; /*Q*/ tmp = *Q; @@ -1051,7 +1055,11 @@ void Inverse_Transform( FOR( ta = segment_length_div4; ta < segment_length_div2; ta++ ) { - out_segment[ta] = L_shr( alias[ta], tmp ); /*q_out*/ +#ifdef FIX_1474_USAN_TRANS_INV + *out_segment++ = L_shr( alias[ta], tmp ); /*q_out*/ +#else + out_segment[ta] = L_shr( alias[ta], tmp ); /*q_out*/ +#endif move32(); } /* This previous loop fills the output buffer from [0..seg_len_div4-1] */ @@ -1059,13 +1067,21 @@ void Inverse_Transform( win2 = &win[segment_length_div2]; /*Q15*/ FOR( ta = segment_length_div2; ta < segment_length; ta++ ) { +#ifdef FIX_1474_USAN_TRANS_INV + *out_segment++ = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/ +#else out_segment[ta] = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/ +#endif move32(); } /* This previous loop fills the output buffer from [seg_len_div4..seg_len-seg_len_div4-1] */ - out_segment += segment_length_div2; /*q_out*/ - in_segment += segment_length_div2; /*Q*/ +#ifdef FIX_1474_USAN_TRANS_INV + out_segment = &out_alias[segment_length_div4]; /*q_out*/ +#else + out_segment += segment_length_div2; /*q_out*/ +#endif + in_segment += segment_length_div2; /*Q*/ FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ ) { -- GitLab From c0b555c43a25bbed7dda8be49b3ff853034b181e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 Dec 2025 11:18:05 +0100 Subject: [PATCH 216/750] introduce FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX --- lib_com/options.h | 1 + lib_dec/ivas_ism_dtx_dec_fx.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 5e8a08b81..b7e24bfb2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ +#define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 162cc42ed..41e3ce466 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -126,6 +126,12 @@ void ivas_ism_dtx_dec_fx( move16(); } } +#ifdef FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX + ELSE + { + set16_fx( nb_bits_metadata, 0, st_ivas->nchan_transport ); + } +#endif IF( !st_ivas->bfi ) { -- GitLab From 610d14d71c7acbbb43db3ace0ae01a924ae54daa Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 17 Dec 2025 11:25:34 +0100 Subject: [PATCH 217/750] Fix in FIX_1474_USAN_TRANS_INV, wrong update of shift variable --- lib_com/trans_direct_fx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c index f8fe2f03f..7598bd422 100644 --- a/lib_com/trans_direct_fx.c +++ b/lib_com/trans_direct_fx.c @@ -84,12 +84,11 @@ void direct_transform_fx( wh_fx = &win_fx[segment_length4]; /*Q15*/ wl_fx = wh_fx - 1; /*Q15*/ + shift = extract_l( L_mult0( 3, segment_length4 ) ); /*Q0*/ #ifdef FIX_1474_USAN_TRANS_INV - shift = extract_l( L_mult0( 2, segment_length4 ) ); /*Q0*/ - sh_fx = &in32_r16_fx[shift]; /*Q*/ + sh_fx = &in32_r16_fx[segment_length2]; /*Q*/ #else - shift = extract_l( L_mult0( 3, segment_length4 ) ); /*Q0*/ - sh_fx = &iseg_fx[shift]; /*Q*/ + sh_fx = &iseg_fx[shift]; /*Q*/ #endif sl_fx2 = sh_fx - 1; /*Q*/ @@ -104,7 +103,7 @@ void direct_transform_fx( #ifdef FIX_1474_USAN_TRANS_INV sl_fx2 = &in32_r16_fx[( segment_length4 - 1 )]; /*Q*/ #else - sl_fx2 = &iseg_fx[( segment_length2 - 1 )]; /*Q*/ + sl_fx2 = &iseg_fx[( segment_length2 - 1 )]; /*Q*/ #endif FOR( i = segment_length4; i < segment_length2; i++ ) -- GitLab From 791742b833821cf63bb0fefafdc609ef2c42f7fb Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 Dec 2025 15:20:06 +0100 Subject: [PATCH 218/750] formatting --- lib_com/options.h | 2 +- lib_enc/pit_enc_fx.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1154cde9a..d7daa9187 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,8 +102,8 @@ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ - #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 9ea54aa4f..5c9a5bdcd 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -765,6 +765,7 @@ Word16 pitch_fr4_fx( #ifdef FIX_2273_OOB_INDEXING_IN_PIT_FR4 Word16 corr_off; #endif + /* initialization */ IF( limit_flag == 0 ) { @@ -807,6 +808,7 @@ Word16 pitch_fr4_fx( t_min = sub( t0_min, L_INTERPOL1 ); t_max = add( t0_max, L_INTERPOL1 ); + #ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 corr = &corr_v[-t_min]; #else @@ -814,6 +816,7 @@ Word16 pitch_fr4_fx( corr_off = -t_min; move16(); #endif + /* corr[t_min..t_max] */ #ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( element_mode > EVS_MONO ) @@ -834,6 +837,7 @@ Word16 pitch_fr4_fx( norm_corr_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr ); } #endif + /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ -- GitLab From a933ba7c2d2f34b537b50b731743e56fe4a0feb2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 17 Dec 2025 09:57:35 -0500 Subject: [PATCH 219/750] Propose fix to silence clang18 (1) on the encoder side, for stereo bitrate --- lib_com/options.h | 2 ++ lib_enc/avq_cod_fx.c | 4 ++++ lib_enc/ext_sig_ana_fx.c | 4 ++++ lib_enc/ivas_core_enc_fx.c | 3 +++ lib_enc/ivas_cpe_enc_fx.c | 8 ++++++++ 5 files changed, 21 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 60447f9d3..037851564 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,8 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ +#define FIX_CLANG_18_ENC /* VA: Fix some encoder clang-18 warnings */ + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 253c05956..3d88315c9 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -609,7 +609,11 @@ void AVQ_cod_lpc_fx( Word16 i, l, pos; Word32 I; Word32 x1[8]; +#ifdef FIX_CLANG_18_ENC + UWord16 I16 = 0; +#else UWord16 I16; +#endif /* quantize all subvector using estimated gain */ diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index c3958e543..4a47f7aec 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1132,7 +1132,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { Word16 Q; +#ifdef FIX_CLANG_18_ENC + Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, L_subframe, 16 ); +#else Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, N_MAX + L_MDCT_OVLP_MAX, 16 ); +#endif Q = add( q_mdstWin, 16 ); move16(); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 2ee800325..812cf31da 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -116,6 +116,9 @@ ivas_error ivas_core_enc_fx( { set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET ); set16_fx( old_syn_12k8_16k_fx[i], 0, L_FRAME16k ); +#ifdef FIX_CLANG_18_ENC + set16_fx( voice_factors_fx[i], 0, NB_SUBFR16k ); +#endif } push_wmops( "ivas_core_enc" ); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index a610d0dfc..caa2a0c51 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -336,6 +336,14 @@ ivas_error ivas_cpe_enc_fx( Word16 q_band_energies_LR; Word16 q_fr_bands[2], q_lf_E[2]; +#ifdef FIX_CLANG_18_ENC + q_band_energies_LR = 0; + q_lf_E[0] = 0; + q_lf_E[1] = 0; + move16(); + move16(); + move16(); +#endif IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx, &q_band_energies_LR, NULL, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ), -- GitLab From bd1c6f2bf11f4cc84b470740cd033bf3006bfc9b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 18 Dec 2025 13:58:02 +0100 Subject: [PATCH 220/750] Add fix FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR to address MSAN error --- lib_com/hvq_pvq_bitalloc_fx.c | 6 ++++++ lib_com/options.h | 1 + 2 files changed, 7 insertions(+) diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c index ea51afe88..58d918abd 100644 --- a/lib_com/hvq_pvq_bitalloc_fx.c +++ b/lib_com/hvq_pvq_bitalloc_fx.c @@ -40,6 +40,10 @@ Word16 hvq_pvq_bitalloc_fx( UWord16 lsb; Word16 num_sfm; +#ifdef FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR + *n_sel_bands = 0; +#endif + IF( EQ_16( bwidth_fx, FB ) ) { num_sfm = SFM_N_HARM_FB; @@ -107,7 +111,9 @@ Word16 hvq_pvq_bitalloc_fx( return 0; } +#ifndef FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR *n_sel_bands = 0; +#endif move16(); envSum = 0; move16(); diff --git a/lib_com/options.h b/lib_com/options.h index d7daa9187..4dbc147a5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR /* Eri: When no PVQ bands are selected in peaq_vq_enc, the number of bands is not initialized. */ /* #################### End BE switches ################################## */ -- GitLab From 55ef90d1cd6bcf5102ccb73f374d261ae423bd9b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 18 Dec 2025 14:34:41 +0100 Subject: [PATCH 221/750] Add FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE to resolve clang-18 MSAN error --- lib_com/options.h | 1 + lib_dec/hq_hr_dec_fx.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index d7daa9187..59d189d63 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE /* Eri: Initializes two variables in HQ decoder. They are not used, but they are passed uninitialized to a function which is caught by clang-18 */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 0d342ba2d..93fd8d63a 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -166,7 +166,12 @@ void ivas_hq_hr_dec_fx( Word16 csw_flag1, csw_flag2; HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; - +#ifdef FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE + SWB_fenv = NULL; /* Init in case HQ_GEN_SWB/HQ_GEN_FB is not used -- eliminates runtime warning when passed to fill_spectrum */ + hq_generic_offset = 0; + move16(); + move16(); +#endif move16(); move16(); -- GitLab From 157aff60581f3fcf74ff41ba98e0d261db491e97 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 18 Dec 2025 15:59:21 +0100 Subject: [PATCH 222/750] Fix wrong init of SWB_fenv --- lib_dec/hq_hr_dec_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 93fd8d63a..975b643a4 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -167,10 +167,8 @@ void ivas_hq_hr_dec_fx( HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; #ifdef FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE - SWB_fenv = NULL; /* Init in case HQ_GEN_SWB/HQ_GEN_FB is not used -- eliminates runtime warning when passed to fill_spectrum */ hq_generic_offset = 0; move16(); - move16(); #endif move16(); move16(); -- GitLab From 03910a9e63cc9a828db9cf11d29d91d5a5e10b23 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 19 Dec 2025 11:51:39 +0100 Subject: [PATCH 223/750] introduce REMOVE_UNUSED_CODE_IVAS_DEC --- lib_com/ivas_prot_fx.h | 10 +- lib_com/options.h | 1 + lib_dec/ivas_ism_dtx_dec_fx.c | 32 +- lib_dec/ivas_jbm_dec_fx.c | 536 +++++++++++++++---------- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 299 +++++++++++++- 5 files changed, 646 insertions(+), 232 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 85bbcb4b1..1f778f497 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1576,8 +1576,11 @@ void decoder_tcx_imdct_fx( void ivas_sba_dirac_stereo_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : output frame length per channel */ + const Word16 output_frame /* i : output frame length per channel */ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC + , const Word16 mcmasa /* i : McMASA flag */ +#endif ); ivas_error ivas_osba_render_sf_fx( @@ -4273,8 +4276,11 @@ void ivas_ism_coh_estim_dtx_enc_fx( void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const Word16 sce_id_dtx, /* i : SCE DTX ID */ - const Word16 nchan_transport, /* i : number of transport channels */ + const Word16 nchan_transport /* i : number of transport channels */ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC + , Word16 *Q_cngNoiseLevel +#endif ); ivas_error stereo_dft_enc_create_fx( diff --git a/lib_com/options.h b/lib_com/options.h index b2bc73dd9..e85fcf443 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ +#define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */() /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 162cc42ed..8d635cbc4 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -152,16 +152,40 @@ void ivas_ism_dtx_dec_fx( * for DTX frames where the energy of the sent noise estimate of the dominant object * is near silence, limit the other objects CNG energies to the same level *-------------------------------------------------------------------*/ + void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ - const Word16 sce_id_dtx, /* i : SCE DTX ID */ - const Word16 nchan_transport, /* i : number of transport channels */ - Word16 *Q_cngNoiseLevel /* i : stores Q factor of hFdCngCom->cngNoiseLevel for various channels*/ + SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ + const Word16 sce_id_dtx, /* i : SCE DTX ID */ + const Word16 nchan_transport /* i : number of transport channels */ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC + , + Word16 *Q_cngNoiseLevel /* i : stores Q factor of hFdCngCom->cngNoiseLevel for various channels*/ +#endif ) { Word32 fac_fx, cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx; Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant, exp; HANDLE_FD_CNG_COM hFdCngCom; +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Word16 Q_cngNoiseLevel[MAX_SCE]; + + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + IF( hSCE[ch] != NULL ) + { + Word16 shift = getScaleFactor32( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + } + scale_sig32( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-(cngNoiseLevelExp -shift) ) + hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + Q_cngNoiseLevel[ch] = sub( 31, hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); + move16(); + move16(); + } + } +#endif hFdCngCom = hSCE[sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom; cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ece09b600..6504dc923 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -77,7 +77,11 @@ ivas_error ivas_jbm_dec_tc_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Word16 ch, n, output_frame, nchan_out, i, s; +#else Word16 ch, n, output_frame, nchan_out, i, ii; +#endif Decoder_State *st; /* used for bitstream handling */ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */ Word16 nchan_remapped; @@ -87,10 +91,12 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_error error; Word16 num_md_sub_frames; Word32 ism_total_brate; +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 s; - CPE_DEC_HANDLE hCPE; SCE_DEC_HANDLE hSCE; +#endif + push_wmops( "ivas_jbm_dec_tc" ); /*----------------------------------------------------------------* @@ -111,7 +117,6 @@ ivas_error ivas_jbm_dec_tc_fx( FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { p_output_fx[n] = st_ivas->p_output_fx[n]; - IF( p_output_fx[n] != NULL ) { set32_fx( p_output_fx[n], 0, L_FRAME48k ); @@ -123,6 +128,7 @@ ivas_error ivas_jbm_dec_tc_fx( *----------------------------------------------------------------*/ test(); +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC test(); IF( st_ivas->bfi != 0 && st_ivas->ini_frame == 0 ) { @@ -132,26 +138,31 @@ ivas_error ivas_jbm_dec_tc_fx( set32_fx( p_output_fx[n], 0, output_frame ); } } - ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + ELSE +#endif + IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + { st_ivas->hCPE[0]->element_brate = ivas_total_brate; move32(); +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 q_output = 11; move16(); set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); - +#endif IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_16( q_output, Q11 ) ) { Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11 Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11 } - +#endif /* HP filtering */ FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ ) { @@ -165,13 +176,16 @@ ivas_error ivas_jbm_dec_tc_fx( IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); - +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC set32_fx( p_output_fx[st_ivas->hISMDTX.sce_id_dtx], 0, L_FRAME48k ); +#endif IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) { return error; } + +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 Q_cngNoiseLevel[MAX_SCE]; FOR( ch = 0; ch < 4; ch++ ) { @@ -191,6 +205,9 @@ ivas_error ivas_jbm_dec_tc_fx( } ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); +#else + ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); +#endif ivas_param_ism_dec_dequant_md_fx( st_ivas ); } @@ -218,8 +235,9 @@ ivas_error ivas_jbm_dec_tc_fx( test(); IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) ) { +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC set32_fx( p_output_fx[n], 0, L_FRAME48k ); - +#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) ) { return error; @@ -237,7 +255,11 @@ ivas_error ivas_jbm_dec_tc_fx( { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); +#else Scale_sig32( p_output_fx[0], L_FRAME48k, 3 ); +#endif } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) { @@ -254,13 +276,11 @@ ivas_error ivas_jbm_dec_tc_fx( { set16_fx( nb_bits_metadata, 0, MAX_SCE ); - /* read parameters from the bitstream */ test(); IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hQMetaData != NULL ) { // st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - IF( st_ivas->nSCE > 0 ) { st = st_ivas->hSCE[0]->hCoreCoder[0]; @@ -293,12 +313,15 @@ ivas_error ivas_jbm_dec_tc_fx( } /* core-decoding of transport channels */ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 q_output = Q11; move16(); +#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC set32_fx( p_output_fx[0], 0, L_FRAME48k ); - +#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -306,19 +329,21 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); - +#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } - +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_16( q_output, Q11 ) ) { Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11 Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11 } +#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -354,6 +379,7 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); nchan_out = nchan_transport; move16(); + ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); IF( st_ivas->hSpar->hPCA != NULL ) @@ -363,6 +389,10 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + + ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); +#else { Word16 q; hCPE = st_ivas->hCPE[0]; @@ -370,11 +400,11 @@ ivas_error ivas_jbm_dec_tc_fx( s = 0; move16(); - FOR( i = 0; i < 2; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) { s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ } - FOR( i = 0; i < 2; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) { Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) } @@ -387,6 +417,7 @@ ivas_error ivas_jbm_dec_tc_fx( hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; move16(); } + q = hCPE->hStereoDft->q_dft; move16(); scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft @@ -451,6 +482,7 @@ ivas_error ivas_jbm_dec_tc_fx( } } } + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; move16(); @@ -478,13 +510,14 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); - FOR( i = 0; i < 2; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) { Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 + Scale_sig32( hCPE->prev_synth_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); @@ -562,6 +595,7 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); } } +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) { @@ -639,7 +673,7 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); - FOR( i = 0; i < 2; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } @@ -692,10 +726,11 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); } - +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC /* set ISM parameters and decode ISM metadata in OMASA format */ Word16 q_output = 11; move16(); + // NOTE: the following is done to calculate the number of hIsmMetaData indices Word16 tmp_nchan_ism; IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) @@ -718,7 +753,7 @@ ivas_error ivas_jbm_dec_tc_fx( { set32_fx( p_output_fx[n], 0, L_FRAME48k ); } - +#endif /* MASA metadata decoding */ IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { @@ -749,6 +784,7 @@ ivas_error ivas_jbm_dec_tc_fx( return error; } +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC /* shifting both the channels from variable q_output to constant Q-factor (Q11) */ FOR( Word16 k = 0; k < output_frame; k++ ) { @@ -757,7 +793,7 @@ ivas_error ivas_jbm_dec_tc_fx( p_output_fx[1][k] = L_shr( p_output_fx[1][k], sub( Q11, q_output ) ); move32(); } - +#endif IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) { Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ @@ -768,13 +804,13 @@ ivas_error ivas_jbm_dec_tc_fx( hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } - Word16 output_q = 11; + Word16 output_q = Q11; move16(); IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); - output_q = 8; + output_q = Q8; move16(); } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) @@ -794,6 +830,7 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q ); } } + IF( NE_16( output_q, Q11 ) ) { FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) @@ -843,31 +880,40 @@ ivas_error ivas_jbm_dec_tc_fx( } /* core-decoding of transport channels */ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 q_output = 11; move16(); - +#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC set32_fx( p_output_fx[0], 0, L_FRAME48k ); - +#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } } +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) { return error; } - +#else + ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ){ + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ){ + return error; + } +#endif +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_16( q_output, Q11 ) ) { Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 } +#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -895,107 +941,119 @@ ivas_error ivas_jbm_dec_tc_fx( { ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] ); } + ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); - { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s) - } - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - move16(); - } - q = hCPE->hStereoDft->q_dft; - move16(); - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); +#else + { + Word16 q; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; + s = 0; + move16(); + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s) + } + hCPE->hStereoDft->q_dft = add( Q11, s ); + move16(); + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) + { + hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; + hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; + move16(); + move16(); + } - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); - } + q = hCPE->hStereoDft->q_dft; + move16(); + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); + FOR( i = 0; i < CPE_CHANNELS; ++i ) + { + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + } + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; + move16(); + } + IF( hCPE->hStereoDft != NULL ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft + hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + move16(); + } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 + IF( hSCE != NULL ) + { + Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft + hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + move16(); + Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft + hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; + move16(); + } + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + { + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; + move16(); + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx + } - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } + ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - move16(); - } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); + } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 + } + + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + FOR( i = 0; i < CPE_CHANNELS; ++i ) + { + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } + + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda + } + IF( hCPE->hStereoDft != NULL ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + move16(); + } + + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + { + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + hCPE->q_output_mem_fx[ii] = Q11; + move16(); + } + } +#endif } /* HP filtering */ @@ -1077,7 +1135,11 @@ ivas_error ivas_jbm_dec_tc_fx( { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); - Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); // Q11 +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); // Q11 +#else + Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); // Q11 +#endif /* add W */ FOR( n = 0; n < nchan_out; n++ ) @@ -1102,7 +1164,12 @@ ivas_error ivas_jbm_dec_tc_fx( /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 +#else + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 +#endif + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; @@ -1158,7 +1225,11 @@ ivas_error ivas_jbm_dec_tc_fx( /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 +#else + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 +#endif ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); @@ -1199,7 +1270,9 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[i], output_frame, s ); } + ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); @@ -1214,18 +1287,21 @@ ivas_error ivas_jbm_dec_tc_fx( IF( EQ_16( st_ivas->nCPE, 1 ) ) { +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 q_output = 11; move16(); - +#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_16( q_output, Q11 ) ) { Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 } +#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -1264,25 +1340,30 @@ ivas_error ivas_jbm_dec_tc_fx( IF( st_ivas->hOutSetup.separateChannelEnabled ) { /* Decode the transport audio signals */ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 q_output = 11; move16(); - +#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_16( q_output, Q11 ) ) { Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 } +#endif /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ n = LFE_CHANNEL - 1; move16(); /* Decode the separated channel to output[n] to be combined with the synthesized channels */ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC set32_fx( p_output_fx[n], 0, L_FRAME48k ); +#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; @@ -1309,12 +1390,15 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE { +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC Word16 q_output = 11; move16(); +#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC set32_fx( p_output_fx[0], 0, L_FRAME48k ); - +#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -1326,124 +1410,136 @@ ivas_error ivas_jbm_dec_tc_fx( { return error; } +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_16( q_output, Q11 ) ) { Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 } +#endif } } IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) - } +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); +#else + Word16 q; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; + s = 0; + move16(); + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) + } + + hCPE->hStereoDft->q_dft = add( Q11, s ); + move16(); + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) + { + hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; + hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_dft = add( Q11, s ); move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; + move16(); + } - move16(); - move16(); - } + q = hCPE->hStereoDft->q_dft; + move16(); - q = hCPE->hStereoDft->q_dft; + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); + FOR( i = 0; i < CPE_CHANNELS; ++i ) + { + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + } + + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; + move16(); + } + IF( hCPE->hStereoDft != NULL ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft + hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; move16(); + } + IF( st_ivas->hSpar != NULL ) + { + st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; + move16(); + } - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } + IF( hSCE != NULL ) + { + Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft + hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + move16(); + Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft + hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; + move16(); + } + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + { + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft + hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; + move16(); + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx + } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - IF( st_ivas->hSpar != NULL ) - { - st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - move16(); - } + ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 + } - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); + FOR( i = 0; i < CPE_CHANNELS; ++i ) + { + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda + } + IF( hCPE->hStereoDft != NULL ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + move16(); + } + IF( st_ivas->hSpar != NULL ) + { + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + hCPE->q_output_mem_fx[ii] = Q11; move16(); } - IF( st_ivas->hSpar != NULL ) - { - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } + } +#endif } /* HP filtering */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 0c380ea5c..85be85159 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1231,8 +1231,11 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( void ivas_sba_dirac_stereo_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : output frame length per channel Q0*/ - const Word16 mcmasa /* i : McMASA flag Q0*/ + const Word16 output_frame /* i : output frame length per channel Q0*/ +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC + , + const Word16 mcmasa /* i : McMASA flag Q0*/ +#endif ) { Word16 dtx_flag, fd_cng_flag; @@ -1250,27 +1253,199 @@ void ivas_sba_dirac_stereo_dec_fx( SCE_DEC_HANDLE hSCE; CPE_DEC_HANDLE hCPE; STEREO_DFT_DEC_DATA_HANDLE hStereoDft; +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Word16 mcmasa; + mcmasa = 0; + move16(); + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) + { + mcmasa = 1; + move16(); + } +#endif + +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; + hStereoDft = hCPE->hStereoDft; + + /*----------------------------------------------------------------* + * Adjust scaling of buffers + *----------------------------------------------------------------*/ + + Decoder_State *st; + Word16 i, ii, s; + + s = 0; + move16(); + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + s = s_min( s, L_norm_arr( output[i], output_frame ) - Q11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ +#else + s = s_min( s, L_norm_arr( output[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ +#endif + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Scale_sig32( output[i], output_frame, s ); // Q(11+s) +#else + Scale_sig32( output[i], L_FRAME48k, s ); // Q(11+s) +#endif + } + hStereoDft->q_dft = add( Q11, s ); + move16(); + IF( EQ_16( hStereoDft->first_frame, 1 ) ) + { + hStereoDft->q_smoothed_nrg = Q6; // hStereoDft->q_dft; + move16(); + hStereoDft->q_ap_delay_mem_fx = hStereoDft->q_dft; + move16(); + } + + q = hStereoDft->q_dft; + move16(); + + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hStereoDft->q_dft, Q11 ) ); // q_dft + FOR( i = 0; i < CPE_CHANNELS; ++i ) + { + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft + } + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, output_frame, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#else + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#endif + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; + move16(); + } + IF( hStereoDft != NULL ) + { + IF( LE_16( st_ivas->nchan_transport, 1 ) ) + { + st = hCPE->hCoreCoder[0]; + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && ( st->last_core == ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ + { + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft + } + ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ + { + IF( !st->tcxonly ) + { + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft + } + } + } + ELSE /* ACELP core */ + { + test(); + test(); + IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ + { + test(); + test(); + test(); + test(); + IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) + { + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + } + } + } + } + +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + IF( NE_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft + } +#endif + scale_sig32( hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hStereoDft->q_dft, hStereoDft->q_ap_fade_mem_fx ) ); // q_dft + hStereoDft->q_ap_fade_mem_fx = hStereoDft->q_dft; + move16(); + } + +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + test(); + if ( st_ivas->hSpar != NULL && EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30; + move16(); + } +#endif + + IF( hSCE != NULL ) + { + Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); // q_dft + hSCE->q_save_hb_synth_fx = hStereoDft->q_dft; + move16(); + Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); // q_dft + hSCE->q_save_synth_fx = hStereoDft->q_dft; + move16(); + } + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + { + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + hCPE->q_output_mem_fx[ii] = hStereoDft->q_dft; + move16(); + } + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + { + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx + } + + /*----------------------------------------------------------------* + * Processing + *----------------------------------------------------------------*/ +#endif + +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + FOR( i = 0; i < CPE_CHANNELS; i++ ) +#else FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) +#endif { set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX ); } +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC hSCE = st_ivas->hSCE[0]; hCPE = st_ivas->hCPE[0]; hStereoDft = hCPE->hStereoDft; - q = hCPE->hStereoDft->q_dft; +#endif + q = hStereoDft->q_dft; move16(); - q_dft[0] = hCPE->hStereoDft->q_dft; + q_dft[0] = hStereoDft->q_dft; move16(); - q_dft[1] = hCPE->hStereoDft->q_dft; + q_dft[1] = hStereoDft->q_dft; move16(); Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ IF( hSCE != NULL ) { Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ - hSCE->q_prev_hb_synth_fx = hCPE->hStereoDft->q_dft; + hSCE->q_prev_hb_synth_fx = hStereoDft->q_dft; move16(); } @@ -1407,5 +1582,117 @@ void ivas_sba_dirac_stereo_dec_fx( move16(); } +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + /*----------------------------------------------------------------* + * Adjust scaling of buffers + *----------------------------------------------------------------*/ + + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Scale_sig32( output[i], output_frame, negate( s ) ); +#else + Scale_sig32( output[i], L_FRAME48k, negate( s ) ); +#endif + } + + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + { + Scale_sig32( hCPE->prev_synth_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 + } + + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); + FOR( i = 0; i < CPE_CHANNELS; ++i ) + { + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } + + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, output_frame, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB +#else + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB +#endif + } + IF( hCPE->hStereoDft != NULL ) + { + IF( LE_16( st_ivas->nchan_transport, 1 ) ) + { + st = hCPE->hCoreCoder[0]; + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && st->core == ACELP_CORE && EQ_16( st->con_tcx, 1 ) ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } + ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ + { + IF( !st->tcxonly ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } + } + } + ELSE /* ACELP core */ + { + test(); + test(); + IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ + { + test(); + test(); + test(); + test(); + IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } + } + } + } + +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + IF( NE_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } +#endif + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + test(); + } + +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + if ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) +#endif + { + st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30; + move16(); + } + + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + { + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + hCPE->q_output_mem_fx[ii] = Q11; + move16(); + } +#endif + return; } -- GitLab From b231f50a7c10ad1d568f9cbe64028ce2d63c1fb0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 19 Dec 2025 13:23:40 +0100 Subject: [PATCH 224/750] fix --- lib_dec/ivas_jbm_dec_fx.c | 4 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 62 +++++++++++++++----------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 6504dc923..040fb59cb 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -128,7 +128,7 @@ ivas_error ivas_jbm_dec_tc_fx( *----------------------------------------------------------------*/ test(); -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC +#ifndef REMOVE_UNUSED_CODE_IVAS_DECaa test(); IF( st_ivas->bfi != 0 && st_ivas->ini_frame == 0 ) { @@ -894,7 +894,7 @@ ivas_error ivas_jbm_dec_tc_fx( return error; } } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC // this is just to keep formatting correct (clang-format otherwise brekas the indentation) ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 85be85159..5cb208bce 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1241,6 +1241,7 @@ void ivas_sba_dirac_stereo_dec_fx( Word16 dtx_flag, fd_cng_flag; Word16 sba_mono_flag; Word16 memOffset; + Word32 output_Fs; Word32 tmp_buf[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; Word32 tmp_synth[L_FRAME16k]; Word32 hb_gain[NB_DIV]; @@ -1265,6 +1266,9 @@ void ivas_sba_dirac_stereo_dec_fx( } #endif + output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); + #ifdef REMOVE_UNUSED_CODE_IVAS_DEC hCPE = st_ivas->hCPE[0]; hSCE = st_ivas->hSCE[0]; @@ -1311,8 +1315,8 @@ void ivas_sba_dirac_stereo_dec_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hStereoDft->q_dft, Q11 ) ); // q_dft FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft } IF( hCPE->hCoreCoder[0] != NULL ) { @@ -1327,7 +1331,11 @@ void ivas_sba_dirac_stereo_dec_fx( } IF( hStereoDft != NULL ) { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + IF( LE_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) +#else IF( LE_16( st_ivas->nchan_transport, 1 ) ) +#endif { st = hCPE->hCoreCoder[0]; test(); @@ -1369,7 +1377,7 @@ void ivas_sba_dirac_stereo_dec_fx( test(); IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { - scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft } } } @@ -1397,22 +1405,22 @@ void ivas_sba_dirac_stereo_dec_fx( IF( hSCE != NULL ) { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); // q_dft + Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); // q_dft hSCE->q_save_hb_synth_fx = hStereoDft->q_dft; move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); // q_dft + Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); // q_dft hSCE->q_save_synth_fx = hStereoDft->q_dft; move16(); } FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[ii] = hStereoDft->q_dft; move16(); } FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx } /*----------------------------------------------------------------* @@ -1441,10 +1449,10 @@ void ivas_sba_dirac_stereo_dec_fx( q_dft[1] = hStereoDft->q_dft; move16(); - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ IF( hSCE != NULL ) { - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ hSCE->q_prev_hb_synth_fx = hStereoDft->q_dft; move16(); } @@ -1474,7 +1482,7 @@ void ivas_sba_dirac_stereo_dec_fx( ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); test(); test(); - hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); + hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); stereo_dft_dec_update_fx( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); IF( GT_16( st_ivas->nchan_transport, 1 ) ) { @@ -1516,7 +1524,7 @@ void ivas_sba_dirac_stereo_dec_fx( /* DFT Stereo upmix */ stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); /* DFT synthesis */ stereo_dft_dec_synthesize_fx( hCPE, DFT, 0, output[0], output_frame ); @@ -1574,10 +1582,10 @@ void ivas_sba_dirac_stereo_dec_fx( set32_fx( output[ch], 0, output_frame ); } - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ IF( hSCE != NULL ) { - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ hSCE->q_prev_hb_synth_fx = Q11; move16(); } @@ -1598,14 +1606,14 @@ void ivas_sba_dirac_stereo_dec_fx( FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( hCPE->prev_synth_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 + Scale_sig32( hCPE->prev_synth_fx[ii], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hStereoDft->q_dft ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11 } IF( hCPE->hCoreCoder[0] != NULL ) @@ -1617,9 +1625,13 @@ void ivas_sba_dirac_stereo_dec_fx( Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB #endif } - IF( hCPE->hStereoDft != NULL ) + IF( hStereoDft != NULL ) { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC + IF( LE_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) +#else IF( LE_16( st_ivas->nchan_transport, 1 ) ) +#endif { st = hCPE->hCoreCoder[0]; test(); @@ -1639,13 +1651,13 @@ void ivas_sba_dirac_stereo_dec_fx( test(); IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11 } ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ { IF( !st->tcxonly ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11 } } } @@ -1661,7 +1673,7 @@ void ivas_sba_dirac_stereo_dec_fx( test(); IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11 } } } @@ -1670,11 +1682,11 @@ void ivas_sba_dirac_stereo_dec_fx( #ifdef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_32( st_ivas->ivas_format, SBA_FORMAT ) ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11 } #endif - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + scale_sig32( hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_ap_fade_mem_fx ) ); // Q11 + hStereoDft->q_ap_fade_mem_fx = Q11; test(); } @@ -1688,7 +1700,7 @@ void ivas_sba_dirac_stereo_dec_fx( FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[ii] = Q11; move16(); } -- GitLab From 1c9a6de3be1c1903c447a287800db2b97cedb302 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 19 Dec 2025 14:15:04 +0100 Subject: [PATCH 225/750] update to keep BE --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 5cb208bce..2e1a778f6 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1285,7 +1285,7 @@ void ivas_sba_dirac_stereo_dec_fx( move16(); FOR( i = 0; i < CPE_CHANNELS; i++ ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC +#if 0 // ToDo: this is a bug for output_Fs = 16 or 32 -> deactivated for the moment to keep BE s = s_min( s, L_norm_arr( output[i], output_frame ) - Q11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ #else s = s_min( s, L_norm_arr( output[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ @@ -1597,7 +1597,7 @@ void ivas_sba_dirac_stereo_dec_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC +#ifdef REMOVE_UNUSED_CODE_IVAS_DECaa Scale_sig32( output[i], output_frame, negate( s ) ); #else Scale_sig32( output[i], L_FRAME48k, negate( s ) ); @@ -1619,7 +1619,7 @@ void ivas_sba_dirac_stereo_dec_fx( IF( hCPE->hCoreCoder[0] != NULL ) { Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC +#ifdef REMOVE_UNUSED_CODE_IVAS_DECaa Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, output_frame, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB #else Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB -- GitLab From 5fe04cf30ab26191ff71c0e39774f9ada335d8f7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 19 Dec 2025 14:26:37 +0100 Subject: [PATCH 226/750] fix FIX_2297_SBA_SCALING_32KHZ --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec_fx.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..7c7c5bc93 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,6 +119,7 @@ #define FIX_1466_EXTREND /* FhG: float issue 1466: enable rendering of mono/stereo to other formats in the external renderer */ #define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ +#define FIX_2297_SBA_SCALING_32KHZ /* basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ece09b600..4433fc5d7 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -372,7 +372,11 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); FOR( i = 0; i < 2; i++ ) { +#ifdef FIX_2297_SBA_SCALING_32KHZ + s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ +#else s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ +#endif } FOR( i = 0; i < 2; i++ ) { @@ -904,7 +908,11 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); FOR( i = 0; i < 2; i++ ) { +#ifdef FIX_2297_SBA_SCALING_32KHZ + s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], output_frame ) - 11 /* Guard bits */ ); +#else s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); +#endif } FOR( i = 0; i < 2; i++ ) { @@ -1343,7 +1351,11 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); FOR( i = 0; i < 2; i++ ) { +#ifdef FIX_2297_SBA_SCALING_32KHZ + s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 /* Guard bits */ ); +#else s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); +#endif } FOR( i = 0; i < 2; i++ ) { -- GitLab From fbeb193334498951e46378c957ed9f3a61eb75ee Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 19 Dec 2025 16:46:54 +0100 Subject: [PATCH 227/750] comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7c7c5bc93..41376545e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,7 @@ #define FIX_1466_EXTREND /* FhG: float issue 1466: enable rendering of mono/stereo to other formats in the external renderer */ #define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ -#define FIX_2297_SBA_SCALING_32KHZ /* basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ +#define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ /* ##################### End NON-BE switches ########################### */ -- GitLab From fe2752a5e37cb0a7e1e4b0942e1030e48092ca89 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 19 Dec 2025 16:53:35 +0100 Subject: [PATCH 228/750] editorial changes --- lib_dec/ivas_jbm_dec_fx.c | 23 ++++++++++++----------- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 040fb59cb..95fba4083 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -128,7 +128,7 @@ ivas_error ivas_jbm_dec_tc_fx( *----------------------------------------------------------------*/ test(); -#ifndef REMOVE_UNUSED_CODE_IVAS_DECaa +#ifndef REMOVE_UNUSED_CODE_IVAS_DEC test(); IF( st_ivas->bfi != 0 && st_ivas->ini_frame == 0 ) { @@ -400,11 +400,11 @@ ivas_error ivas_jbm_dec_tc_fx( s = 0; move16(); - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ } - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) } @@ -510,14 +510,14 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( hCPE->prev_synth_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); @@ -673,6 +673,7 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); + FOR( i = 0; i < CPE_CHANNELS; i++ ) { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); @@ -953,11 +954,11 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE = st_ivas->hSCE[0]; s = 0; move16(); - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); } - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s) } @@ -1016,7 +1017,7 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); } @@ -1430,11 +1431,11 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE = st_ivas->hSCE[0]; s = 0; move16(); - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); } - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) } @@ -1502,7 +1503,7 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 2e1a778f6..e34edea7b 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1597,7 +1597,7 @@ void ivas_sba_dirac_stereo_dec_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DECaa +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( output[i], output_frame, negate( s ) ); #else Scale_sig32( output[i], L_FRAME48k, negate( s ) ); @@ -1619,7 +1619,7 @@ void ivas_sba_dirac_stereo_dec_fx( IF( hCPE->hCoreCoder[0] != NULL ) { Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB -#ifdef REMOVE_UNUSED_CODE_IVAS_DECaa +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, output_frame, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB #else Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB -- GitLab From 337c4839c7b60a51642ce06e5d457d38e009020f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 19 Dec 2025 21:20:02 +0100 Subject: [PATCH 229/750] clang-format --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 95fba4083..0c75d3f76 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -673,7 +673,7 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); - + FOR( i = 0; i < CPE_CHANNELS; i++ ) { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); -- GitLab From 8567e996b8dcfb71e765e317476443ef830109e9 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Tue, 30 Dec 2025 19:16:54 +0100 Subject: [PATCH 230/750] perform now division by 128 in non EVS mode --- lib_com/swb_tbe_com_fx.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index c9d307ef2..751bfc1ff 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6129,34 +6129,35 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + j = abs_s( shr( Random( &seed[0] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ } else { L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + j = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ -#endif - + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ j = extract_l( L_shr( L_tmp, 23 ) ); +#endif j = s_and( j, 0xff ); #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = abs_s( shr( Random( &seed[1] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ } else { L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = extract_l( L_shr( L_tmp, 23 ) ); #endif - k = extract_l( L_shr( L_tmp, 23 ) ); k = s_and( k, 0xff ); WHILE( EQ_16( k, j ) ) @@ -6164,17 +6165,18 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = abs_s( shr( Random( &seed[1] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ } else { L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = extract_l( L_shr( L_tmp, 23 ) ); } #else L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = extract_l( L_shr( L_tmp, 23 ) ); #endif - k = extract_l( L_shr( L_tmp, 23 ) ); k = s_and( k, 0xff ); } -- GitLab From d5579c20d32e40413a02fd5631526eebe703f52c Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 09:25:19 +0100 Subject: [PATCH 231/750] cleaning under CLEANUP_VBR_CAM_ENC --- lib_com/lsf_tools_fx.c | 5 ++- lib_com/options.h | 1 + lib_com/prot_fx.h | 9 +++-- lib_enc/acelp_core_enc_fx.c | 67 +++++++++++++++++++++++++++++++------ lib_enc/cng_enc_fx.c | 1 + lib_enc/enc_nelp_fx.c | 2 ++ lib_enc/enc_ppp_fx.c | 2 ++ lib_enc/nelp_enc_fx.c | 2 ++ lib_enc/prot_fx_enc.h | 6 ++-- 9 files changed, 78 insertions(+), 17 deletions(-) diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index e4dbd7e2a..7893d9b79 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -2962,7 +2962,7 @@ void lsf_syn_mem_backup_fx( return; } - +#ifndef CLEANUP_VBR_CAM_ENC /*-------------------------------------------------------------------* * lsf_syn_mem_backup_fx() * @@ -3046,6 +3046,7 @@ void lsf_syn_mem_backup_ivas_fx( return; } +#endif void lsf_update_memory( Word16 narrowband, /* i : narrowband flag */ @@ -3190,6 +3191,7 @@ void lsf_syn_mem_restore_fx( return; } +#ifndef CLEANUP_VBR_CAM_ENC void lsf_syn_mem_restore_ivas_fx( Encoder_State *st_fx, /* o: state structure */ Word16 btilt_code_fx, /* i: Q15 */ @@ -3267,6 +3269,7 @@ void lsf_syn_mem_restore_ivas_fx( return; } +#endif /* Returns: codebook index */ Word16 tcxlpc_get_cdk( diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..43a990288 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 577451b04..4a36c9ea7 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -927,6 +927,7 @@ void lsf_syn_mem_restore_fx( Word16 pstreaklen /* i:LSF quantizer */ ); +#ifndef CLEANUP_VBR_CAM_ENC void lsf_syn_mem_restore_ivas_fx( Encoder_State *st_fx, /* o: state structure */ Word16 btilt_code_fx, /* i: Q15 */ @@ -947,7 +948,7 @@ void lsf_syn_mem_restore_ivas_fx( Word16 streaklimit, /* i:LSF quantizer Q15 */ Word16 pstreaklen /* i:LSF quantizer */ ); - +#endif void lsf_update_memory( Word16 narrowband, /* i : narrowband flag */ const Word16 qisf[], /* i : quantized xSF coefficients */ @@ -3848,13 +3849,14 @@ void nelp_encoder_fx( Word16 *qIn1, Word16 reduce_gains ); +#ifndef CLEANUP_VBR_CAM_ENC void nelp_encoder_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state */ Word16 *in_fx, /* i : residual signal */ Word16 *exc_fx, /* o : NELP quantized excitation signal */ Word16 *qIn1, Word16 reduce_gains ); - +#endif void swb_bwe_enc_lr_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 L_m_core[], /* i : lowband synthesis */ @@ -10664,6 +10666,7 @@ Word16 ari_decode_14bits_sign_ivas( Word16 *res, Tastat *s ); +#ifndef CLEANUP_VBR_CAM_ENC void lsf_syn_mem_backup_ivas_fx( Encoder_State *st_fx, /* i: state structure */ Word16 *btilt_code_fx, /* i: tilt code Q15 */ @@ -10683,7 +10686,7 @@ void lsf_syn_mem_backup_ivas_fx( Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ Word16 *streaklimit, /* Q15 */ Word16 *pstreaklen ); - +#endif ivas_error config_acelp1_fx( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 0596b2f2d..36ab219dc 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -694,11 +694,13 @@ ivas_error acelp_core_enc_fx( return error; } + /*-------------------------------------------------------------------* * acelp_core_enc_ivas_fx() * * ACELP core encoder *--------------------------------------------------------------------*/ + ivas_error acelp_core_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 inp[], /* i : input signal of the current frame Q_new*/ @@ -726,14 +728,20 @@ ivas_error acelp_core_enc_ivas_fx( Word32 int_fs; Word16 nb_bits; /* parameters handling */ +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */ Word16 pstreaklen; +#endif Word16 sid_bw = -1; move16(); +#ifndef CLEANUP_VBR_CAM_ENC Word16 next_force_sf_bck; +#endif Word16 uc_two_stage_flag; Word16 position; +#ifndef CLEANUP_VBR_CAM_ENC Word16 ppp_mode, nelp_mode; +#endif Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; /* bitstream */ @@ -748,18 +756,22 @@ ivas_error acelp_core_enc_ivas_fx( Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/ Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */ Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */ +#ifndef CLEANUP_VBR_CAM_ENC Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M]; Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2]; Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx; +#endif set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ); set16_fx( old_exc_fx, 0, L_EXC ); set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) ); set16_fx( syn_fx, 0, L_FRAME16k ); +#ifndef CLEANUP_VBR_CAM_ENC Word16 tilt_code_bck_fx; Word32 gc_threshold_bck_fx; Word16 clip_var_bck_fx[6]; +#endif Word32 q_env_fx[NUM_ENV_CNG]; set32_fx( q_env_fx, 0, NUM_ENV_CNG ); set16_fx( exc2_fx, 0, L_FRAME16k ); @@ -882,6 +894,7 @@ ivas_error acelp_core_enc_ivas_fx( position = -1; move16(); +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR temporary variables */ pstreaklen = 0; move16(); @@ -908,10 +921,10 @@ ivas_error acelp_core_enc_ivas_fx( } move16(); move16(); +#endif test(); /* TD stereo */ - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) { tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; // Q0 @@ -1008,6 +1021,7 @@ ivas_error acelp_core_enc_ivas_fx( /*----------------------------------------------------------------* * Encoding of CNG frames *----------------------------------------------------------------*/ + test(); IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) { @@ -1099,11 +1113,13 @@ ivas_error acelp_core_enc_ivas_fx( move16(); st->hLPDmem->q_mem_syn = st->Q_syn; move16(); - // Scaling Aq to Q12 + + /* Scaling Aq to Q12 */ FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) { Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); } + /* synthesis at 12.8kHz sampling rate */ syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn ); @@ -1144,17 +1160,18 @@ ivas_error acelp_core_enc_ivas_fx( /*----------------------------------------------------------------* * Encoding of all other frames *----------------------------------------------------------------*/ + ELSE { + Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k ); + Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */ + st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp ); + move16(); /*-----------------------------------------------------------------* * Configure ACELP bit allocation *-----------------------------------------------------------------*/ - Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k ); - Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */ - st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp ); - move16(); nb_bits = 0; move16(); st->acelp_cfg.FEC_mode = 0; @@ -1162,11 +1179,15 @@ ivas_error acelp_core_enc_ivas_fx( uc_two_stage_flag = 0; move16(); +#ifndef CLEANUP_VBR_CAM_ENC test(); IF( !nelp_mode && !ppp_mode ) { +#endif config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#ifndef CLEANUP_VBR_CAM_ENC } +#endif /*-----------------------------------------------------------------* * After inactive period, use the most up-to-date ISPs @@ -1203,9 +1224,10 @@ ivas_error acelp_core_enc_ivas_fx( * A[z] calculation *-----------------------------------------------------------------*/ +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */ lsf_syn_mem_backup_ivas_fx( st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen ); - +#endif IF( !tdm_lp_reuse_flag ) { lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); @@ -1244,11 +1266,13 @@ ivas_error acelp_core_enc_ivas_fx( st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15 move16(); } - // Scaling Aq to Q12 + + /* Scaling Aq to Q12 */ FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) { Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); } + test(); IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { @@ -1325,12 +1349,13 @@ ivas_error acelp_core_enc_ivas_fx( encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); } } +#ifndef CLEANUP_VBR_CAM_ENC ELSE IF( nelp_mode ) { /* SC-VBR - NELP frames */ encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); } - +#endif ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ @@ -1340,6 +1365,7 @@ ivas_error acelp_core_enc_ivas_fx( { encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); } +#ifndef CLEANUP_VBR_CAM_ENC ELSE IF( ppp_mode ) { /* SC-VBR - PPP frames */ @@ -1368,6 +1394,7 @@ ivas_error acelp_core_enc_ivas_fx( encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); } } +#endif 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) */ @@ -1388,8 +1415,8 @@ ivas_error acelp_core_enc_ivas_fx( /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // hLPDmem->q_mem_syn - // st->Q_syn = Q_new - 1; - Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn + Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn + /* save and delay synthesis to be used by SWB BWE */ IF( st->hBWE_FD != NULL ) { @@ -1429,11 +1456,16 @@ ivas_error acelp_core_enc_ivas_fx( /*--------------------------------------------------------------------------------------* * Modify the excitation signal when the noise is stationary *--------------------------------------------------------------------------------------*/ + test(); test(); test(); +#ifdef CLEANUP_VBR_CAM_ENC + IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) +#else test(); IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) +#endif { /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */ Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new @@ -1464,9 +1496,11 @@ ivas_error acelp_core_enc_ivas_fx( } /* end of active inp coding */ + /*-----------------------------------------------------------------* * Write ACELP unused bits *-----------------------------------------------------------------*/ + test(); test(); IF( NE_32( st->core_brate, SID_2k40 ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, PPP_NELP_2k80 ) ) @@ -1495,9 +1529,13 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); +#ifdef CLEANUP_VBR_CAM_ENC + IF( ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) +#else test(); test(); IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) +#endif { st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); @@ -1508,8 +1546,12 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); +#ifdef CLEANUP_VBR_CAM_ENC + IF( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) +#else test(); IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) +#endif { /* Apply a non linearity to the SHB excitation */ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc @@ -1580,6 +1622,7 @@ ivas_error acelp_core_enc_ivas_fx( st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 1; } move16(); + /* efficient DTX hangover control */ IF( GT_16( st->hTdCngEnc->burst_ho_cnt, 1 ) ) { @@ -1587,6 +1630,7 @@ ivas_error acelp_core_enc_ivas_fx( } } +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR update of average data rate */ IF( EQ_16( st->vad_flag, 1 ) ) { @@ -1596,6 +1640,7 @@ ivas_error acelp_core_enc_ivas_fx( update_average_rate_fx( st->hSC_VBR, st->core_brate ); } } +#endif pop_wmops(); return error; diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index e51dd4884..cf4c06203 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1501,6 +1501,7 @@ void CNG_enc_ivas_fx( { lsf_enc_ivas_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); } + /* Reset CNG history if CNG frame length is changed */ test(); test(); diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index 30756d19d..60bbab86c 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -171,6 +171,7 @@ void encod_nelp_fx( return; } +#ifndef CLEANUP_VBR_CAM_ENC void encod_nelp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -311,3 +312,4 @@ void encod_nelp_ivas_fx( return; } +#endif diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 70360f9d2..cff514493 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -233,6 +233,7 @@ ivas_error encod_ppp_fx( return error; } +#ifndef CLEANUP_VBR_CAM_ENC ivas_error encod_ppp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -415,3 +416,4 @@ ivas_error encod_ppp_ivas_fx( return error; } +#endif diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 9122be431..60e2b29fe 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -1032,6 +1032,7 @@ void nelp_encoder_fx( return; } +#ifndef CLEANUP_VBR_CAM_ENC void nelp_encoder_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state */ @@ -1766,3 +1767,4 @@ void nelp_encoder_ivas_fx( return; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 13d11e72b..8d97027b2 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1863,6 +1863,7 @@ void encod_nelp_fx( Word16 Q_new, Word16 shift ); +#ifndef CLEANUP_VBR_CAM_ENC void encod_nelp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : input speech Q_new-1 */ @@ -1878,7 +1879,7 @@ void encod_nelp_ivas_fx( Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new */ Word16 Q_new, Word16 shift ); - +#endif Word16 encod_tran_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ @@ -2056,6 +2057,7 @@ ivas_error encod_ppp_fx( Word16 Q_new, Word16 shift ); +#ifndef CLEANUP_VBR_CAM_ENC ivas_error encod_ppp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q_new*/ @@ -2070,7 +2072,7 @@ ivas_error encod_ppp_ivas_fx( Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ Word16 Q_new, Word16 shift ); - +#endif void encod_gen_voic_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : i speech Q0*/ -- GitLab From b86d13879c171a7f0c85d424d77966ec9f6d7a02 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 09:43:21 +0100 Subject: [PATCH 232/750] cleaning under CLEANUP_HQ_CORE --- lib_com/hq2_core_com_fx.c | 3 ++- lib_com/options.h | 1 + lib_com/prot_fx.h | 6 ++++-- lib_dec/hq_core_dec_fx.c | 22 +++++++++++++++++++--- lib_enc/hq_core_enc_fx.c | 5 ++++- lib_enc/hq_lr_enc_fx.c | 29 +++++++++++++++++++---------- lib_enc/prot_fx_enc.h | 6 ++++-- lib_enc/swb_bwe_enc_lr_fx.c | 5 +++++ lib_enc/tcq_core_enc_fx.c | 2 ++ 9 files changed, 60 insertions(+), 19 deletions(-) diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index 78f60d465..3cf943725 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -208,7 +208,7 @@ void mdct_spectrum_denorm_fx( return; } - +#ifndef CLEANUP_HQ_CORE void mdct_spectrum_denorm_ivas_fx( const Word32 inp_vector[], /* i : Q0 : */ Word32 L_y2[], /* i/o : Qs : decoded spectrum */ @@ -373,6 +373,7 @@ void mdct_spectrum_denorm_ivas_fx( return; } +#endif /*==========================================================================*/ /* FUNCTION : void hq2_core_configure_fx() */ diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..57d738fe4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define CLEANUP_HQ_CORE /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 577451b04..5445fb53a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2277,6 +2277,7 @@ void mdct_spectrum_denorm_fx( const Word16 pd_thresh_fx /* i : Q15 : */ ); +#ifndef CLEANUP_HQ_CORE void mdct_spectrum_denorm_ivas_fx( const Word32 inp_vector[], /* i : Q0 : */ Word32 L_y2[], /* i/o : Qs : decoded spectrum */ @@ -2289,7 +2290,7 @@ void mdct_spectrum_denorm_ivas_fx( const Word16 ld_slope_fx, /* i : Q15 : */ const Word16 pd_thresh_fx /* i : Q15 : */ ); - +#endif void hq2_core_configure_fx( const Word16 frame_length, /* Q0 */ const Word16 num_bits, /* Q0 */ @@ -3880,6 +3881,7 @@ void swb_bwe_enc_lr_fx( Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ ); +#ifndef CLEANUP_HQ_CORE void swb_bwe_enc_lr_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 L_m_core[], /* i : lowband synthesis */ @@ -3904,7 +3906,7 @@ void swb_bwe_enc_lr_ivas_fx( const Word32 L_y2_ni[], /* i : band_width information */ Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ ); - +#endif void isf_enc_amr_wb_fx( Encoder_State *st, /* i/o: state structure */ Word16 *isf_new, /* i/o: quantized ISF vector */ diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 6be36bd1a..1dd462cf2 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -565,6 +565,9 @@ void ivas_hq_core_dec_fx( } ELSE { +#ifdef CLEANUP_HQ_CORE + /* this cannot happen in IVAS */ +#else core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame ); /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ @@ -573,6 +576,7 @@ void ivas_hq_core_dec_fx( num_bits = (Word16) ( HQ_48k / 50 ); move16(); } +#endif } } IF( hq_recovery_flag ) @@ -625,11 +629,12 @@ void ivas_hq_core_dec_fx( } } +#ifndef CLEANUP_HQ_CORE IF( EQ_16( output_frame, L_FRAME8k ) ) { hq_configure_bfi_fx( &nb_sfm, &num_Sb, num_bands_p, &sfmsize, &sfm_start, &sfm_end ); } - +#endif /*-------------------------------------------------------------------------- * transform-domain decoding *--------------------------------------------------------------------------*/ @@ -645,11 +650,13 @@ void ivas_hq_core_dec_fx( &hHQ_core->last_fec, hHQ_core->ph_ecu_HqVoicing, &hHQ_core->ph_ecu_active, gapsynth_fx, st_fx->prev_bfi, hHQ_core->old_is_transient, hHQ_core->mag_chg_1st_fx, hHQ_core->Xavg_fx, &hHQ_core->beta_mute_fx, output_frame, st_fx ); } +#ifndef CLEANUP_HQ_CORE ELSE { HQ_FEC_processing_fx( st_fx, t_audio_q, is_transient, hHQ_nbfec->ynrm_values_fx, hHQ_nbfec->r_p_values_fx, num_Sb, nb_sfm, num_bands_p, output_frame, sfm_start, sfm_end ); } +#endif hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1]; /* Q0 */ move16(); @@ -675,6 +682,10 @@ void ivas_hq_core_dec_fx( { IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) { +#ifdef CLEANUP_HQ_CORE + /* this cannot happen in IVAS */ + +#else IF( EQ_16( st_fx->prev_bfi, 1 ) ) { set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); @@ -685,6 +696,7 @@ void ivas_hq_core_dec_fx( /* HQ low rate decoder */ hq_lr_dec_fx( st_fx, t_audio_q, inner_frame, num_bits, &is_transient ); +#endif hqswb_clas = is_transient; /* Q0 */ move16(); Q_audio = 12; @@ -914,6 +926,7 @@ void ivas_hq_core_dec_fx( move16(); } +#ifndef CLEANUP_HQ_CORE IF( EQ_16( output_frame, L_FRAME8k ) ) { test(); @@ -951,6 +964,7 @@ void ivas_hq_core_dec_fx( } } ELSE +#endif { test(); IF( EQ_16( st_fx->bfi, 1 ) && GE_16( output_frame, L_FRAME16k ) ) @@ -986,6 +1000,7 @@ void ivas_hq_core_dec_fx( } } +#ifndef CLEANUP_HQ_CORE test(); test(); test(); @@ -1007,7 +1022,7 @@ void ivas_hq_core_dec_fx( } waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth, 0, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi ); } - +#endif IF( GE_16( output_frame, L_FRAME16k ) ) { IF( EQ_16( hHQ_core->ph_ecu_HqVoicing, 1 ) ) @@ -1034,13 +1049,14 @@ void ivas_hq_core_dec_fx( move16(); } +#ifndef CLEANUP_HQ_CORE IF( EQ_16( output_frame, L_FRAME8k ) ) { Copy32( wtda_audio, hHQ_nbfec->oldIMDCTout_fx, L_FRAME8k / 2 ); /* q_wtda */ Copy( &hHQ_nbfec->old_auOut_2fr_fx[output_frame], hHQ_nbfec->old_auOut_2fr_fx, output_frame ); /* Q_old_auOut */ Copy_Scale_sig( synth, &hHQ_nbfec->old_auOut_2fr_fx[output_frame], output_frame, negate( *Q_synth ) ); /* Q0 */ } - +#endif /* prepare synthesis output buffer (as recent as possible) for HQ FEC */ { diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index 1966a4256..46f8546fd 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -505,8 +505,11 @@ void hq_core_enc_ivas_fx( move16(); IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) { - +#ifdef CLEANUP_HQ_CORE + /* this cannot happen in IVAS */ +#else hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient ); +#endif } ELSE { diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 48b3edc38..8111d21c3 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -22,7 +22,7 @@ static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_a static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[] /*Q12*/, Word32 L_y2[] /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint /*Q29*/, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits ); - +#ifndef CLEANUP_HQ_CORE static Word16 p2a_threshold_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th /*Q11*/, Word16 *p2a_flags ); static void mdct_spectrum_fine_gain_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -48,6 +48,8 @@ static Word16 band_energy_quant_ivas_fx( const Word32 L_qint, /* Q29 */ const Word16 eref_fx, /* Q10 */ const Word16 is_transient /* Q0 */ ); +#endif + /*--------------------------------------------------------------------------* * spt_shorten_domain_set() @@ -126,6 +128,7 @@ static void spt_shorten_domain_set_fx( return; } +#ifndef CLEANUP_HQ_CORE static void spt_shorten_domain_set_ivas_fx( Encoder_State *st_fx, /* i: encoder state structure */ const Word32 L_t_audio[], /* i: input spectrum Q12*/ @@ -196,7 +199,7 @@ static void spt_shorten_domain_set_ivas_fx( return; } - +#endif /*--------------------------------------------------------------------------* * hq_lr_enc_fx() @@ -1097,6 +1100,7 @@ void hq_lr_enc_fx( return; } +#ifndef CLEANUP_HQ_CORE void hq_lr_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word32 L_t_audio[], /* i/o: transform-domain coefs. Q12*/ @@ -2032,7 +2036,7 @@ void hq_lr_enc_ivas_fx( return; } - +#endif /*--------------------------------------------------------------------------* * small_symbol_enc_tran() @@ -2086,7 +2090,7 @@ static Word16 small_symbol_enc_tran_fx( /* o : bits return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } - +#ifndef CLEANUP_HQ_CORE static Word16 small_symbol_enc_tran_ivas_fx( /* o : bits */ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ @@ -2130,7 +2134,7 @@ static Word16 small_symbol_enc_tran_ivas_fx( /* o : bit return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } - +#endif /*--------------------------------------------------------------------------* * small_symbol_enc() @@ -2209,6 +2213,7 @@ static Word16 small_symbol_enc_fx( return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } +#ifndef CLEANUP_HQ_CORE static Word16 small_symbol_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ @@ -2276,7 +2281,7 @@ static Word16 small_symbol_enc_ivas_fx( return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } - +#endif /* o : bits Q0 */ static Word16 large_symbol_enc_fx( @@ -2615,7 +2620,7 @@ static Word16 large_symbol_enc_fx( return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } - +#ifndef CLEANUP_HQ_CORE static Word16 large_symbol_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ @@ -2952,6 +2957,7 @@ static Word16 large_symbol_enc_ivas_fx( return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } +#endif /*-------------------------------------------------------------------* * band_energy_quant() @@ -3153,7 +3159,7 @@ static Word16 band_energy_quant_fx( return ( deng_bits ); /* Q0 */ } - +#ifndef CLEANUP_HQ_CORE static Word16 band_energy_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ @@ -3349,7 +3355,7 @@ static Word16 band_energy_quant_ivas_fx( return ( deng_bits ); /* Q0 */ } - +#endif /*-------------------------------------------------------------------* * p2a_threshold_quant() @@ -3473,6 +3479,7 @@ static Word16 p2a_threshold_quant_fx( return ( j ); /* Q0 */ } +#ifndef CLEANUP_HQ_CORE static Word16 p2a_threshold_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: : bit stream */ const Word32 *L_t_audio, /* i : Q12 : input spectrum */ @@ -3587,7 +3594,7 @@ static Word16 p2a_threshold_quant_ivas_fx( return ( j ); /* Q0 */ } - +#endif /*-------------------------------------------------------------------* * mdct_spectrum_fine_gain_enc() @@ -3752,6 +3759,7 @@ static void mdct_spectrum_fine_gain_enc_fx( return; } +#ifndef CLEANUP_HQ_CORE static void mdct_spectrum_fine_gain_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -3910,3 +3918,4 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( return; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 13d11e72b..2aea7f842 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4102,6 +4102,7 @@ void hq_lr_enc_fx( const Word16 is_transient_fx /* i : Q0 : transient flag */ ); +#ifndef CLEANUP_HQ_CORE void hq_lr_enc_ivas_fx( Encoder_State *st_fx, /* i/o: : encoder state structure */ Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ @@ -4109,7 +4110,7 @@ void hq_lr_enc_ivas_fx( Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ const Word16 is_transient_fx /* i : Q0 : transient flag */ ); - +#endif void hq_hr_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure fx */ Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ @@ -4285,6 +4286,7 @@ ivas_error tcq_core_LR_enc_fx( const Word16 adjustFlag, const Word16 is_transient ); +#ifndef CLEANUP_HQ_CORE ivas_error tcq_core_LR_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word32 inp_vector[], @@ -4304,7 +4306,7 @@ ivas_error tcq_core_LR_enc_ivas_fx( const Word16 input_frame, const Word16 adjustFlag, const Word16 is_transient ); - +#endif /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ Word16 encode_envelope_indices_fx( BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 7d31b8532..4c0061c60 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -1024,6 +1024,7 @@ static void EncodeSWBSubbands_fx( return; } +#ifndef CLEANUP_HQ_CORE static void EncodeSWBSubbands_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *L_spectra, /* i/o: MDCT domain spectrum */ @@ -1221,6 +1222,8 @@ static void EncodeSWBSubbands_ivas_fx( return; } +#endif + /*--------------------------------------------------------------------------* * swb_bwe_enc_lr() * @@ -1309,6 +1312,7 @@ void swb_bwe_enc_lr_fx( return; } +#ifndef CLEANUP_HQ_CORE void swb_bwe_enc_lr_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -1393,3 +1397,4 @@ void swb_bwe_enc_lr_ivas_fx( return; } +#endif diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index a3d355a2d..ffe9b86f7 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -493,6 +493,7 @@ ivas_error tcq_core_LR_enc_fx( return error; } +#ifndef CLEANUP_HQ_CORE ivas_error tcq_core_LR_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -977,3 +978,4 @@ ivas_error tcq_core_LR_enc_ivas_fx( return error; } +#endif -- GitLab From 5f19b217b5ad0fe65d350a9d7424b6e380918e8a Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 09:53:36 +0100 Subject: [PATCH 233/750] harmonization under HARM_LSF_ENC --- lib_com/int_lsp_fx.c | 8 + lib_com/options.h | 1 + lib_com/prot_fx.h | 3 +- lib_com/stat_noise_uv_mod_fx.c | 4 + lib_dec/acelp_core_dec_fx.c | 4 + lib_dec/dec_LPD_fx.c | 4 + lib_dec/lsf_dec_fx.c | 9 + lib_enc/acelp_core_enc_fx.c | 24 +++ lib_enc/analy_lp_fx.c | 8 + lib_enc/cng_enc_fx.c | 9 + lib_enc/ivas_tcx_core_enc_fx.c | 5 + lib_enc/lsf_enc_fx.c | 307 +++++++++++++++++++++++++++++---- lib_enc/prot_fx_enc.h | 21 ++- lib_enc/qlpc_stoch_fx.c | 29 +++- 14 files changed, 393 insertions(+), 43 deletions(-) diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c index 08ab6ba85..7b7f93c14 100644 --- a/lib_com/int_lsp_fx.c +++ b/lib_com/int_lsp_fx.c @@ -132,6 +132,12 @@ void int_lsp4_fx( { pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/ } +#ifdef HARM_LSF_ENC + ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) ) + { + pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/ + } +#endif ELSE { pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/ @@ -177,6 +183,7 @@ void int_lsp4_fx( return; } +#ifdef HARM_LSF_ENC void int_lsp4_ivas_fx( const Word16 L_frame, /* i : length of the frame */ @@ -257,3 +264,4 @@ void int_lsp4_ivas_fx( return; } +#endif diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..556676259 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 577451b04..a692a1649 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1669,6 +1669,7 @@ void int_lsp4_fx( Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ ); +#ifndef HARM_LSF_ENC void int_lsp4_ivas_fx( const Word16 L_frame, /* i : length of the frame */ const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ @@ -1678,7 +1679,7 @@ void int_lsp4_ivas_fx( const Word16 m, /* i : order of LP filter */ Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ ); - +#endif void de_interleave_spectrum_fx( Word32 *coefs, /* i/o: i and output coefficients Q? */ const Word16 length /* i : length of spectrum Q0 */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index ad87695e8..f117f11e4 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -614,7 +614,11 @@ void stat_noise_uv_mod_ivas_fx( mult( sub( 32767, beta ), lspnew_s[i] ) ); } +#ifdef HARM_LSF_ENC + int_lsp4_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 ); +#else int_lsp4_ivas_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 ); +#endif Copy( lspnew_s, lspold_s, M ); } ELSE /* (unvoiced_vad != 0) */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index e163662c8..8015f5cda 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1035,7 +1035,11 @@ ivas_error acelp_core_dec_fx( test(); IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) ) { +#ifdef HARM_LSF_ENC + int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); +#else int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); +#endif } /*---------------------------------------------------------------* diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index 9515aefe8..6a610063c 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -556,7 +556,11 @@ void decoder_LPD_fx( move16(); } +#ifdef HARM_LSF_ENC + int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); +#else int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); +#endif } ELSE { diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 3af2e35ed..03595e6d5 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -298,13 +298,22 @@ void lsf_dec_fx( } /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ +#ifdef HARM_LSF_ENC + int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); +#else int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); +#endif } ELSE { /* LSP interpolation and conversion of LSPs to A(z) */ +#ifdef HARM_LSF_ENC + int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp ); +#else int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp ); +#endif } + /*------------------------------------------------------------------* * Check LSF stability (distance between old LSFs and current LSFs) *------------------------------------------------------------------*/ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 0596b2f2d..a88bd6c16 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -436,7 +436,11 @@ ivas_error acelp_core_enc_fx( if ( !tdm_lp_reuse_flag ) { +#ifdef HARM_LSF_ENC + lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, NULL, Q_new ); +#else lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); +#endif } /*---------------------------------------------------------------* @@ -510,7 +514,11 @@ ivas_error acelp_core_enc_fx( config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, st_fx->idchan, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ +#ifdef HARM_LSF_ENC + lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, 0, -1, NULL, Q_new ); +#else lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); +#endif /* recalculation of LP residual (filtering through A[z] filter) */ calc_residu_fx( st_fx, inp_fx, res_fx, Aq_fx ); @@ -976,11 +984,19 @@ ivas_error acelp_core_enc_ivas_fx( IF( st->rate_switching_reset ) { /*extrapolation in case of unstable LSP*/ +#ifdef HARM_LSF_ENC + int_lsp4_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 ); +#else int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 ); +#endif } ELSE { +#ifdef HARM_LSF_ENC + int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 ); +#else int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 ); +#endif } /* Reset LPC mem */ @@ -1208,7 +1224,11 @@ ivas_error acelp_core_enc_ivas_fx( IF( !tdm_lp_reuse_flag ) { +#ifdef HARM_LSF_ENC + lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); +#else lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); +#endif } ELSE { @@ -1357,7 +1377,11 @@ ivas_error acelp_core_enc_ivas_fx( config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); /* redo LSF quantization */ +#ifdef HARM_LSF_ENC + lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new ); +#else lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new ); +#endif /* recalculation of LP residual (filtering through A[z] filter) */ calc_residu_fx( st, inp, res_fx, Aq ); diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index 873966116..7ce8f4cb0 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -115,12 +115,20 @@ void analy_lp_fx( IF( EQ_16( sec_chan_low_rate, 1 ) ) { /* LSP interpolation */ +#ifdef HARM_LSF_ENC + int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); +#else int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); +#endif } ELSE { /* LSP interpolation */ +#ifdef HARM_LSF_ENC + int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); +#else int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); +#endif } Copy( lsp_new, lsp_old, M ); /* Q15 */ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */ diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index e51dd4884..8d3a731de 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -331,8 +331,13 @@ void CNG_enc_fx( } ELSE { +#ifdef HARM_LSF_ENC + lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); +#else lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, Q_new ); +#endif } + /* Reset CNG history if CNG frame length is changed */ test(); test(); @@ -1499,7 +1504,11 @@ void CNG_enc_ivas_fx( } ELSE { +#ifdef HARM_LSF_ENC + lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); +#else lsf_enc_ivas_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); +#endif } /* Reset CNG history if CNG frame length is changed */ test(); diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 95e52bc69..18d79f26d 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -420,8 +420,13 @@ void stereo_tcx_core_enc( move16(); } +#ifdef HARM_LSF_ENC + lpc_quantization_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, NULL, st->clip_var_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/ + param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener ); +#else lpc_quantization_ivas_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/ param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener ); +#endif /*--------------------------------------------------------------* * Rate switching diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index d62b97f1d..f075d4cb7 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -24,15 +24,23 @@ * Local function prototypes *---------------------------------------------------------------------*/ +#ifdef HARM_LSF_ENC +static void lsfq_CNG_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ); +#else static void lsfq_CNG_fx( BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ); +#endif static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word32 p_offset_scale1[][MAX_NO_SCALES + 1], Word32 p_offset_scale2[][MAX_NO_SCALES + 1], Word16 p_no_scales[][2], Word16 *resq, Word16 *lsfq ); static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word16 *resq, Word16 *lsfq ); +#ifdef HARM_LSF_ENC +static void lsf_mid_enc_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); +#else static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); +#endif /*===========================================================================*/ @@ -62,15 +70,21 @@ static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Wo /* RETURN ARGUMENTS : */ /* _ None */ /*===========================================================================*/ + void lsf_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ Word16 *lsf_new, /* o : quantized LSF vector */ Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ Word16 *Aq, /* o : quantized A(z) for 4 subframes */ +#ifndef HARM_LSF_ENC const Word16 Nb_ACELP_frames, +#endif const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ +#ifdef HARM_LSF_ENC + const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ +#endif const Word16 Q_new ) { Word16 nBits = 0; @@ -78,6 +92,10 @@ void lsf_enc_fx( Word16 int_fs; Word16 force_sf = 0; move16(); +#ifdef HARM_LSF_ENC + Word16 no_param_lpc; + Word16 param_lpc[NPRM_LPC_NEW]; +#endif Word16 fec_lsf[M], stab, i; Word32 L_tmp; Word16 coder_type, ppp_mode, nelp_mode; @@ -101,6 +119,9 @@ void lsf_enc_fx( move16(); } +#ifdef HARM_LSF_ENC + no_param_lpc = 0; +#endif move16(); IF( st_fx->Opt_SC_VBR ) @@ -122,6 +143,7 @@ void lsf_enc_fx( assert( st_fx->sr_core <= 32000 ); int_fs = extract_l( st_fx->sr_core ); move32(); + /* convert LSPs to LSFs */ lsp2lsf_fx( lsp_new, lsf_new, M, int_fs ); @@ -161,12 +183,17 @@ void lsf_enc_fx( move16(); } } + force_sf = 0; move16(); - /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */ test(); +#ifdef HARM_LSF_ENC + if ( LT_16( st_fx->Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) ) +#else if ( LT_16( Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) ) +#endif { + /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */ force_sf = 1; move16(); } @@ -184,8 +211,13 @@ void lsf_enc_fx( * Frame end LSF quantization *-------------------------------------------------------------------------------------*/ +#ifdef HARM_LSF_ENC + lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, + force_sf, param_lpc, &no_param_lpc, NULL, st_fx->coder_type_raw, tdm_lsfQ_PCh ); +#else lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, force_sf, NULL, NULL, NULL, st_fx->coder_type_raw ); +#endif /* convert quantized LSFs back to LSPs */ lsf2lsp_fx( lsf_new, lsp_new, M, int_fs ); @@ -196,7 +228,23 @@ void lsf_enc_fx( /* don't use old LSF values if this is the first ACELP frame after HQ frames */ Copy( lsf_new, st_fx->lsf_old_fx, M ); } + /* set seed_acelp used in UC mode */ +#ifdef HARM_LSF_ENC + test(); + IF( EQ_16( coder_type, UNVOICED ) && ( st_fx->element_mode > EVS_MONO ) ) + { + st_fx->seed_acelp = 0; + move16(); + FOR( i = no_param_lpc - 1; i >= 0; i-- ) + { + /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ + st_fx->seed_acelp = add( i_mult( add( shr( st_fx->seed_acelp, 1 ), param_lpc[i] ), 31821 ), 13849 ); + move16(); + } + } +#endif + IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) { /* return if SID frame (conversion to A(z) done in the calling function) */ @@ -218,7 +266,18 @@ void lsf_enc_fx( FEC_lsf_estim_enc_fx( st_fx, fec_lsf ); /* in case of FEC in decoder - calculate LSF stability */ +#ifdef HARM_LSF_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 + } + ELSE + { + stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 + } +#else stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 +#endif test(); test(); @@ -249,19 +308,24 @@ void lsf_enc_fx( Copy( st_fx->lsfoldbfi0_fx, st_fx->lsfoldbfi1_fx, M ); Copy( lsf_new, st_fx->lsfoldbfi0_fx, M ); - /*-------------------------------------------------------------------------------------* * Mid-frame LSF encoding * LSP interpolation and conversion of LSPs to A(z) *-------------------------------------------------------------------------------------*/ - if ( st_fx->rate_switching_reset ) + + IF( st_fx->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ Copy( lsp_new, st_fx->lsp_old_fx, M ); // Q15 Copy( lsf_new, st_fx->lsf_old_fx, M ); // Q15 } + /* Mid-frame LSF encoding */ +#ifdef HARM_LSF_ENC + lsf_mid_enc_fx( st_fx->element_mode, st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); +#else lsf_mid_enc_fx( st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); +#endif test(); IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) @@ -296,12 +360,24 @@ void lsf_enc_fx( IF( NE_32( st_fx->core_brate, SID_2k40 ) ) { +#ifdef HARM_LSF_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); + } + ELSE + { + st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); // Q15 + } +#else st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); +#endif } return; } +#ifndef HARM_LSF_ENC void lsf_enc_ivas_fx( Encoder_State *st, /* i/o: state structure */ Word16 *lsf_new, /* o : quantized LSF vector Q(x2.56)*/ @@ -439,8 +515,8 @@ void lsf_enc_ivas_fx( /* don't use old LSF values if this is the first ACELP frame after HQ frames */ Copy( lsf_new, st->lsf_old_fx, M ); } - /* set seed_acelp used in UC mode */ + /* set seed_acelp used in UC mode */ test(); IF( EQ_16( coder_type, UNVOICED ) && ( st->element_mode > EVS_MONO ) ) { @@ -540,21 +616,34 @@ void lsf_enc_ivas_fx( } /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ +#ifdef HARM_LSF_ENC + int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); +#else int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); +#endif } ELSE { +#ifdef HARM_LSF_ENC + int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); +#else int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); +#endif } + /*------------------------------------------------------------------* * Check LSF stability (distance between old LSFs and current LSFs) *------------------------------------------------------------------*/ + IF( NE_32( st->core_brate, SID_2k40 ) ) { st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); // Q15 } + return; } +#endif + /*-------------------------------------------------------------------* * lsfq_CNG_fx() * @@ -567,7 +656,10 @@ void lsf_enc_ivas_fx( *-------------------------------------------------------------------*/ static void lsfq_CNG_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ +#ifdef HARM_LSF_ENC + const Word16 element_mode, /* i : element mode */ +#endif + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/ const Word16 *lsf, /*x2.56 unquantized LSF vector */ const Word16 *wghts, /*Q10 LSF weights */ Word16 *qlsf, /*x2.56 quantized LSF vecotor */ @@ -610,7 +702,6 @@ static void lsfq_CNG_fx( move16(); } - min_dist = L_add( MAXINT32, 0 ); FOR( i = first_cb; i < last_cb; i++ ) { @@ -643,10 +734,27 @@ static void lsfq_CNG_fx( /* quantize the difference with LVQ */ /* MSVQ_ROM to be updated */ +#ifdef HARM_LSF_ENC + IF( element_mode == EVS_MONO ) + { + mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales ); + + index_lvq_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG + idx_cv, idx_lvq, + p_offset_scale1, p_offset_scale2, p_no_scales ); + } + ELSE + { + mslvq_cng_ivas_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts ); + + index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 ); + } +#else mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales ); index_lvq_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG + idx_cv, idx_lvq, p_offset_scale1, p_offset_scale2, p_no_scales ); +#endif + Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M ); /* write the VQ index to the bitstream */ @@ -659,6 +767,7 @@ static void lsfq_CNG_fx( return; } +#ifndef HARM_LSF_ENC static void lsfq_CNG_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *lsf, /*x2.56 unquantized LSF vector */ @@ -748,13 +857,14 @@ static void lsfq_CNG_ivas_fx( return; } +#endif + /*-------------------------------------------------------------------* * qlsf_Mode_Select_fx() * * Mode selection for LSF quantizer *-------------------------------------------------------------------*/ - static Word16 qlsf_Mode_Select_fx( const Word16 *w, /* i : weighting vector Q8 */ const Word16 *pred1, /* i : prediction vector x2.56 */ @@ -847,6 +957,7 @@ static Word16 qlsf_Mode_Select_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*========================================================================*/ +#ifndef HARM_LSF_ENC void lsf_end_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ @@ -1352,28 +1463,32 @@ void lsf_end_enc_fx( return; } +#endif - +#ifdef HARM_LSF_ENC +void lsf_end_enc_fx( +#else void lsf_end_enc_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ - Word16 *qlsf, /* o : quantized LSF x2.56*/ + const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ + Word16 *qlsf, /* o : quantized LSF x2.56*/ const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ - const Word16 coder_type_org, /* i : coding type */ - Word16 Q_ener, /* i : Q valuen for Bin_Ener */ - Word16 force_sf, /* i : Force safety-net usage if coding type supports */ + const Word16 coder_type_org, /* i : coding type */ + const Word16 Q_ener, /* i : Q value for Bin_Ener */ + const Word16 force_sf, /* i : Force safety-net usage if coding type supports */ Word16 *lpc_param, Word16 *no_indices, Word16 *bits_param_lpc, - Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases) */ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { Word16 i; Word16 Idx0[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for safety-net quantizer */ Word16 Idx1[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for predictive quantizer */ Word16 indice[MAX_VQ_STAGES + 3]; /* Temp. array of indice for vector de-quantizer */ - Word16 mode_lvq = 0, mode_lvq_p = 0; /* LVQ mode and predictive LVQ mode */ + Word16 mode_lvq = 0, mode_lvq_p = 0; /* LVQ mode and predictive LVQ mode */ Word16 bits0[MAX_VQ_STAGES], bits1[MAX_VQ_STAGES]; const Word16 *Bit_alloc1 = NULL; Word32 Err[2]; /* Quantization error for safety-net(0) and predictive(1) quantizers */ @@ -1403,15 +1518,25 @@ void lsf_end_enc_ivas_fx( Word16 pred3[M]; Word16 dummy, dummy_v[5]; +#ifdef HARM_LSF_ENC + flag_1bit_gran = 0; + move16(); + if ( GT_16( st->element_mode, EVS_MONO ) ) + { + flag_1bit_gran = 1; + move16(); + } +#else flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO ); +#endif nBits = nBits_in; move16(); + /* Update LSF coder_type for LSF quantizer for some special cases */ test(); test(); test(); - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) && ( st->idchan == 0 ) ) /* this bit is used only for primary channel or mono */ { IF( EQ_16( coder_type_raw, VOICED ) ) @@ -1443,14 +1568,25 @@ void lsf_end_enc_ivas_fx( IF( st->bwidth == NB ) { +#ifdef HARM_LSF_ENC + abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); +#else abs_threshold = SFNETLOWLIMIT_NB / 2; +#endif move32(); } ELSE { abs_threshold = SFNETLOWLIMIT_WB / 2; move32(); +#ifdef HARM_LSF_ENC + if ( flag_1bit_gran == 0 ) + { + abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); + } +#endif } + /* Calculate LSF weighting coefficients */ Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], Q_ener, lsf, wghts, (Word16) EQ_16( st->bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), st->sr_core, M ); @@ -1460,12 +1596,17 @@ void lsf_end_enc_ivas_fx( IF( EQ_32( st->core_brate, SID_2k40 ) ) { +#ifdef HARM_LSF_ENC + lsfq_CNG_fx( st->element_mode, hBstr, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] ); +#else lsfq_CNG_ivas_fx( hBstr, lsf, wghts, qlsf ); +#endif sort_fx( qlsf, 0, M - 1 ); reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core ); return; } + /* Find allowed predictor mode for current coder_type. (SN only (0), SN/AR switched (2) or MA predictive (1) */ find_pred_mode( &predmode, coder_type, st->bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); @@ -1510,7 +1651,18 @@ void lsf_end_enc_ivas_fx( Vr_subt( lsf, pred0, Tmp, M ); /* LVQ quantization (safety-net only) */ - Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); +#ifdef HARM_LSF_ENC + IF( flag_1bit_gran == 0 ) + { + Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, + st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); + } + ELSE +#endif + { + Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); + } + safety_net = 1; move16(); st->pstreaklen = 0; @@ -1519,12 +1671,23 @@ void lsf_end_enc_ivas_fx( ELSE IF( EQ_16( predmode, 1 ) ) /* only MA prediction */ { Vr_subt( lsf, pred1, Tmp1, M ); - Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, resq, lsfq ); + +#ifdef HARM_LSF_ENC + IF( flag_1bit_gran == 0 ) + { + Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, + st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, resq, lsfq ); + } + ELSE +#endif + { + Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, resq, lsfq ); + } safety_net = 0; move16(); } - ELSE + ELSE /* Switched Safety-Net/AR prediction */ { IF( EQ_16( predmode, 2 ) ) { @@ -1590,15 +1753,35 @@ void lsf_end_enc_ivas_fx( /* all other frames (not VOICED@16kHz) */ ELSE { - /* safety-net */ + /* Switched Safety-Net/AR prediction */ +#ifdef HARM_LSF_ENC + IF( flag_1bit_gran == 0 ) + { + Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); + } + ELSE +#endif + { + Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); + } - Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); /* Predictive quantizer is calculated only if it can be selected */ test(); IF( !force_sf || GT_32( Err[0], abs_threshold ) ) { - Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, &resq[M], &lsfq[M] ); +#ifdef HARM_LSF_ENC + IF( flag_1bit_gran == 0 ) + { + Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, + st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); + } + ELSE +#endif + { + Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, &resq[M], &lsfq[M] ); + } } + test(); test(); /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following: @@ -1899,7 +2082,19 @@ void lsf_end_enc_ivas_fx( } ELSE { - vq_dec_lvq_ivas_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1] ); +#ifdef HARM_LSF_ENC + IF( flag_1bit_gran == 0 ) + { + vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1], + &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], + &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); + } + ELSE +#endif + { + vq_dec_lvq_ivas_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1] ); + } + Vr_add( qlsf, pred0, qlsf, M ); Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); } @@ -1917,7 +2112,19 @@ void lsf_end_enc_ivas_fx( ELSE { /* LVQ */ - vq_dec_lvq_ivas_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1] ); +#ifdef HARM_LSF_ENC + IF( flag_1bit_gran == 0 ) + { + vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1], + &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], + &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); + } + ELSE +#endif + { + vq_dec_lvq_ivas_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1] ); + } + IF( EQ_16( predmode, 1 ) ) { Copy( qlsf, st->mem_MA_fx, M ); @@ -2476,14 +2683,13 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( IF( pred_flag == 0 ) /* safety net*/ { cb = &Quantizers_fx[CB_lsf[mode]]; + move16(); IF( LT_16( mode, 6 ) ) { - move16(); mode_glb = add( offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][( levels[stagesVQ] - min_lat_bits_SN[mode] )] ); } ELSE { - move16(); mode_glb = add( offset_lvq_modes_SN[mode], levels[stagesVQ] - min_lat_bits_SN[mode] ); } } @@ -3460,8 +3666,11 @@ static void FFT_Mid_Interpol_16k_fx( static void lsf_mid_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 nb_bits, /* i : number of bits */ +#ifdef HARM_LSF_ENC + const Word16 element_mode, /* i : element mode */ +#endif + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 nb_bits, /* i : number of bits */ const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/ const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/ const Word16 qlsp1[], /* i : quantized LSPs from frame end */ @@ -3487,12 +3696,30 @@ static void lsf_mid_enc_fx( lsp2lsf_fx( qlsp0, qlsf0, M, int_fs ); lsp2lsf_fx( qlsp1, qlsf1, M, int_fs ); +#ifdef HARM_LSF_ENC + IF( element_mode == EVS_MONO ) + { + /* calculate weights */ + FFT_Mid_Interpol_16k_fx( Bin_Ener_old, &Bin_Ener[L_FFT / 2], Bin_Ener_mid ); + + /* LSF weighting */ + Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); + move16(); + } + ELSE + { + Unified_weighting_fx( Bin_Ener_old, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); + move16(); + } +#else /* calculate weights */ FFT_Mid_Interpol_16k_fx( Bin_Ener_old, &Bin_Ener[L_FFT / 2], Bin_Ener_mid ); /* LSF weighting */ Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); move16(); +#endif + /* codebook selection, number of bits, size of the codebook */ test(); IF( ppp_mode == 0 && nelp_mode == 0 ) @@ -3514,6 +3741,14 @@ static void lsf_mid_enc_fx( move16(); BREAK; } +#ifdef HARM_LSF_ENC + case 1: + { + ratio = tbl_mid_voi_wb_1b_fx; // Q13 + move16(); + BREAK; + } +#endif } } ELSE IF( EQ_16( coder_type, UNVOICED ) ) @@ -3531,6 +3766,14 @@ static void lsf_mid_enc_fx( move16(); BREAK; } +#ifdef HARM_LSF_ENC + case 4: + { + ratio = tbl_mid_gen_wb_4b_fx; // Q13 + move16(); + BREAK; + } +#endif case 2: { ratio = tbl_mid_gen_wb_2b_fx; @@ -3576,7 +3819,7 @@ static void lsf_mid_enc_fx( FOR( j = 0; j < M; j++ ) { /* qlsf[j] = (1.0f - ratio[k*M+j]) * qlsf0[j] + ratio[k*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000, ratio[k1 + j] ), qlsf0[j] ); + L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[k1 + j] ), qlsf0[j] ); L_tmp = L_mac( L_tmp, ratio[k1 + j], qlsf1[j] ); qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); @@ -3613,7 +3856,7 @@ static void lsf_mid_enc_fx( FOR( j = 0; j < M; j++ ) { /* qlsf[j] = (1.0f - ratio[idx*M+j]) * qlsf0[j] + ratio[idx*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000, ratio[idx * M + j] ), qlsf0[j] ); + L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[idx * M + j] ), qlsf0[j] ); L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); @@ -3634,6 +3877,7 @@ static void lsf_mid_enc_fx( return; } +#ifndef HARM_LSF_ENC static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -3817,3 +4061,4 @@ static void lsf_mid_enc_ivas_fx( return; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 13d11e72b..d9ebe8b47 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -890,6 +890,7 @@ void LPDmem_enc_init_fx( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); +#ifndef HARM_LSF_ENC void lsf_end_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ @@ -905,17 +906,20 @@ void lsf_end_enc_fx( ); void lsf_end_enc_ivas_fx( +#else +void lsf_end_enc_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ Word16 *qlsf, /* o : quantized LSF */ const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ const Word16 coder_type_org, /* i : coding type */ - Word16 Q_ener, /* i : Q valuen for Bin_Ener */ - Word16 force_sf, /* i : Force safety-net usage if coding type supports */ + const Word16 Q_ener, /* i : Q value for Bin_Ener */ + const Word16 force_sf, /* i : Force safety-net usage if coding type supports */ Word16 *lpc_param, Word16 *no_indices, Word16 *bits_param_lpc, - Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/ + const Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); @@ -1530,6 +1534,7 @@ void lpc_quantization_fx( Word16 *no_param_lpc, /* Q0 */ const Word16 Q_ener ); +#ifndef HARM_LSF_ENC void lpc_quantization_ivas_fx( Encoder_State *st, const Word16 lsp[], /* Q15 */ @@ -1544,7 +1549,7 @@ void lpc_quantization_ivas_fx( Word16 *bits_param_lpc, /* Q0 */ Word16 *no_param_lpc, /* Q0 */ const Word16 Q_ener ); - +#endif void Mode2_pit_encode_fx( const Word16 coder_type, /* i : coding model */ const Word16 i_subfr, /* i : subframe index */ @@ -1820,11 +1825,17 @@ void lsf_enc_fx( Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ Word16 *Aq, /* o : quantized A(z) for 4 subframes */ +#ifndef HARM_LSF_ENC const Word16 Nb_ACELP_frames, +#endif const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ +#ifdef HARM_LSF_ENC + const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ +#endif const Word16 Q_new ); +#ifndef HARM_LSF_ENC void lsf_enc_ivas_fx( Encoder_State *st, /* i/o: state structure */ Word16 *lsf_new, /* o : quantized LSF vector */ @@ -1835,7 +1846,7 @@ void lsf_enc_ivas_fx( const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ); - +#endif void Es_pred_enc_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ Word16 *indice, /* o : indice of quantization Q0*/ diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 0964d7421..0e0672abd 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -25,6 +25,7 @@ * * *--------------------------------------------------------------------*/ + void lpc_quantization_fx( Encoder_State *st, const Word16 lsp[], /* Q15 */ @@ -116,28 +117,36 @@ void lpc_quantization_fx( test(); IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) ) { +#ifdef HARM_LSF_ENC + lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, + force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); +#else lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC ); +#endif nb_indices = *no_param_lpc; // Q0 move16(); } ELSE { +#ifdef HARM_LSF_ENC + lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, + force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); +#else lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type ); +#endif nb_indices = *no_param_lpc; // Q0 move16(); } - FEC_lsf_estim_enc_fx( st, fec_lsf ); /* FEC - calculate LSF stability */ stab = lsf_stab_fx( lsf_q, fec_lsf, 0, st->L_frame ); /*Q15*/ - test(); test(); test(); @@ -172,11 +181,9 @@ void lpc_quantization_fx( } /* Mid-frame LPC quantization */ - test(); IF( st->lpcQuantization && acelp_midLpc ) { - IF( st->rate_switching_reset == 0 ) { lsp2lsf_fx( lspmid, lsfmid, M, extract_l( st->sr_core ) ); @@ -196,10 +203,10 @@ void lpc_quantization_fx( } } - return; } +#ifndef HARM_LSF_ENC void lpc_quantization_ivas_fx( Encoder_State *st, const Word16 lsp[], /* Q15 */ @@ -281,16 +288,26 @@ void lpc_quantization_ivas_fx( test(); IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) ) { +#ifdef HARM_LSF_ENC + lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, + force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); +#else lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); +#endif nb_indices = *no_param_lpc; // Q0 move16(); } ELSE { +#ifdef HARM_LSF_ENC + lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, + force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); +#else lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); +#endif nb_indices = *no_param_lpc; // Q0 move16(); @@ -361,7 +378,7 @@ void lpc_quantization_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * Unified_weighting() -- GitLab From 01be39f296de620df122620d500d1b905f5261e0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 10:06:11 +0100 Subject: [PATCH 234/750] remove ivas_HQ_FEC_Mem_update_fx() --- lib_com/ivas_prot_fx.h | 3 ++- lib_dec/FEC_HQ_core_fx.c | 3 ++- lib_dec/hq_core_dec_fx.c | 22 ++++++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 85bbcb4b1..6fa412a54 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1599,6 +1599,7 @@ void ivas_hq_core_dec_fx( Word16 *Q_output ); +#ifdef CLEANUP_HQ_CORE void ivas_HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ @@ -1614,7 +1615,7 @@ void ivas_HQ_FEC_Mem_update_fx( Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ Word16 output_frame ); - +#endif /* o : Consumed bits Q0 */ Word16 ivas_hq_classifier_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 43d1e2627..3eeffcdd4 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -399,6 +399,7 @@ void HQ_FEC_processing_fx( return; } +#ifndef CLEANUP_HQ_CORE void ivas_HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ @@ -677,7 +678,7 @@ void ivas_HQ_FEC_Mem_update_fx( return; } - +#endif void HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 1dd462cf2..5c65e6a58 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -484,15 +484,22 @@ void ivas_hq_core_dec_fx( Word32 normq_fx[NB_SFM]; Word16 mean_en_high_fx; Word16 SWB_fenv_fx[SWB_FENV + DIM_FB]; +#ifndef CLEANUP_HQ_CORE const Word16 *sfmsize, *sfm_start, *sfm_end; +#endif Word16 gapsynth_fx[L_FRAME48k]; Word16 tmp, tmp_loop; Word32 L_tmp; UWord16 lsb; Word16 L_spec; +#ifndef CLEANUP_HQ_CORE HQ_NBFEC_HANDLE hHQ_nbfec; +#endif HQ_DEC_HANDLE hHQ_core; + +#ifndef CLEANUP_HQ_CORE hHQ_nbfec = st_fx->hHQ_nbfec; +#endif hHQ_core = st_fx->hHQ_core; TCX_DEC_HANDLE hTcxDec; @@ -519,11 +526,13 @@ void ivas_hq_core_dec_fx( set16_fx( wtda_audio_16, 0, 2 * L_FRAME48k ); mean_en_high_fx = 0; move16(); - Q_audio = 12; + Q_audio = Q12; move16(); - Q_G_audio = 12; + Q_G_audio = Q12; move16(); +#ifndef CLEANUP_HQ_CORE sfm_start = sfm_end = NULL; +#endif num_Sb = nb_sfm = 0; move16(); move16(); @@ -697,6 +706,8 @@ void ivas_hq_core_dec_fx( /* HQ low rate decoder */ hq_lr_dec_fx( st_fx, t_audio_q, inner_frame, num_bits, &is_transient ); #endif + is_transient = 0; + move16(); hqswb_clas = is_transient; /* Q0 */ move16(); Q_audio = 12; @@ -742,9 +753,16 @@ void ivas_hq_core_dec_fx( } } } + +#ifdef CLEANUP_HQ_CORE + HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, + core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); +#else ivas_HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); +#endif } + /*-------------------------------------------------------------------------- * Attenuate HFs in case of band-width switching (from higher BW to lower BW) *--------------------------------------------------------------------------*/ -- GitLab From dbb7b4823d25e17a5789cf01120c4525168e2189 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 10:18:21 +0100 Subject: [PATCH 235/750] clang-format --- lib_dec/hq_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 5c65e6a58..50dd36f09 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -756,7 +756,7 @@ void ivas_hq_core_dec_fx( #ifdef CLEANUP_HQ_CORE HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, - core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); + core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); #else ivas_HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); -- GitLab From 3d9bd5f47beba4d87e518ae996becdae3adfd2f2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 10:27:34 +0100 Subject: [PATCH 236/750] fix compilation warning --- lib_com/int_lsp_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c index 7b7f93c14..81c57c60f 100644 --- a/lib_com/int_lsp_fx.c +++ b/lib_com/int_lsp_fx.c @@ -43,13 +43,13 @@ void int_lsp_fx( - const Word16 L_frame, /* i : length of the frame */ + const Word16 L_frame, /* i : length of the frame */ const Word16 lsp_old[], /* i : Q15 LSPs from past frame */ const Word16 lsp_new[], /* i : Q15 LSPs from present frame */ Word16 *Aq, /* o : Q12 LP coefficients in both subframes */ - const Word16 m, /* i : order of LP filter */ + const Word16 m, /* i : order of LP filter */ const Word16 *int_coeffs, /* i : Q15 interpolation coefficients */ - const Word16 Opt_AMR_WB /* i : Q0 flag indicating AMR-WB IO mode */ + const Word16 Opt_AMR_WB /* i : Q0 flag indicating AMR-WB IO mode */ ) { Word16 lsp[M], fnew, fold; @@ -183,7 +183,7 @@ void int_lsp4_fx( return; } -#ifdef HARM_LSF_ENC +#ifndef HARM_LSF_ENC void int_lsp4_ivas_fx( const Word16 L_frame, /* i : length of the frame */ -- GitLab From 0d74cb1c45727fe5b9798198ee17996bb127f6ea Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 15:59:18 +0100 Subject: [PATCH 237/750] removal of duplicated code, under CLEANUP_ACELP_ENC --- lib_com/options.h | 1 + lib_com/prot_fx.h | 10 ++- lib_enc/acelp_core_enc_fx.c | 3 +- lib_enc/acelp_core_switch_enc_fx.c | 46 ++++++---- lib_enc/analy_lp_fx.c | 4 +- lib_enc/cod_tcx_fx.c | 4 +- lib_enc/core_switching_enc_fx.c | 9 +- lib_enc/enc_amr_wb_fx.c | 9 +- lib_enc/enc_gen_voic_fx.c | 15 ++++ lib_enc/enc_higher_acelp_fx.c | 18 +++- lib_enc/enc_pit_exc_fx.c | 15 +++- lib_enc/enc_tran_fx.c | 15 ++++ lib_enc/gs_enc_fx.c | 4 +- lib_enc/inov_enc_fx.c | 89 ++++++++++++++----- lib_enc/ivas_core_enc_fx.c | 4 + lib_enc/nois_est_fx.c | 2 +- lib_enc/prot_fx_enc.h | 45 +++++----- lib_enc/transition_enc_fx.c | 135 ++++++++++++++++++++++++----- 18 files changed, 328 insertions(+), 100 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..0363ea893 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 577451b04..90bba96d6 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10898,11 +10898,15 @@ ivas_error IGF_Reconfig_fx( ); void core_switching_post_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ + Encoder_State *st /* i/o: encoder state structure */ +#ifndef CLEANUP_ACELP_ENC + , Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new ); + Word16 Q_new +#endif +); void residu_ivas_fx( const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ @@ -11194,7 +11198,7 @@ ivas_error acelp_core_enc_ivas_fx( Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - Word16 Q_new ); + const Word16 Q_new ); void flip_and_downmix_generic_fx32( Word32 input[], /* i : input spectrum Qx*/ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 0596b2f2d..b21bc566b 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -699,6 +699,7 @@ ivas_error acelp_core_enc_fx( * * ACELP core encoder *--------------------------------------------------------------------*/ + ivas_error acelp_core_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 inp[], /* i : input signal of the current frame Q_new*/ @@ -717,7 +718,7 @@ ivas_error acelp_core_enc_ivas_fx( Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - Word16 Q_new ) + const Word16 Q_new ) { Word16 i, nBits; /* reserved bits */ LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */ diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 2f51be28e..db2c27344 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -15,15 +15,18 @@ * Local function prototypes *---------------------------------------------------------------------*/ -static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); - -static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); +static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, const Word16 shift, const Word16 Q_new ); +#ifndef CLEANUP_ACELP_ENC +static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, const Word16 shift, const Word16 Q_new ); +#endif static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech ); +#ifndef CLEANUP_ACELP_ENC static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech ); +#endif +static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, const Word16 qx, const Word16 qy, Word16 *qo, const Word16 len, const Word16 delta ); -static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta ); /*-------------------------------------------------------------------* * acelp_core_switch_enc_fx() @@ -36,8 +39,8 @@ void acelp_core_switch_enc_fx( const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */ const Word16 inp16k[], /* i : input signal @16 kHz Q0 */ const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 i, j, T_op[2]; Word16 old_exc[L_EXC], *exc; /* excitation signal buffer Qexc */ @@ -163,7 +166,7 @@ void acelp_core_switch_enc_fx( return; } - +#ifndef CLEANUP_ACELP_ENC void acelp_core_switch_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */ @@ -273,7 +276,7 @@ void acelp_core_switch_enc_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * encod_gen_voic_core_switch() @@ -290,8 +293,8 @@ static void encod_gen_voic_core_switch_fx( const Word16 T_op[], /* i : open loop pitch Q0*/ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 res[L_SUBFR]; /* residual signal Qexc */ Word16 Ap[M + 1]; /* A(z) with spectral expansion Q12 */ @@ -431,8 +434,13 @@ static void encod_gen_voic_core_switch_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, + h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); +#endif /*-----------------------------------------------------------------* * Gain encoding @@ -489,6 +497,7 @@ static void encod_gen_voic_core_switch_fx( return; } +#ifndef CLEANUP_ACELP_ENC static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -498,8 +507,8 @@ static void encod_gen_voic_core_switch_ivas_fx( const Word16 T_op[], /* i : open loop pitch Q0*/ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 res[L_SUBFR]; /* residual signal Qexc */ Word16 Ap[M + 1]; /* A(z) with spectral expansion Q12 */ @@ -699,6 +708,7 @@ static void encod_gen_voic_core_switch_ivas_fx( return; } +#endif /*-------------------------------------------------------------------* * bwe_switch_enc() @@ -849,7 +859,7 @@ static void bwe_switch_enc_fx( return; } - +#ifndef CLEANUP_ACELP_ENC static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *new_speech_fx /* i : original input signal Q0 */ @@ -989,16 +999,16 @@ static void bwe_switch_enc_ivas_fx( return; } - +#endif static Word16 dotprod_satcont( const Word16 *x, /* qx */ const Word16 *y, /* qy */ - Word16 qx, - Word16 qy, + const Word16 qx, + const Word16 qy, Word16 *qo, - Word16 len, /* Q0 */ - Word16 delta /* Q0 */ + const Word16 len, /* Q0 */ + const Word16 delta /* Q0 */ ) { Word16 tmp_tabx[L_FRAME48k], tmp_taby[L_FRAME48k]; diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index 873966116..ee8b57c6b 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -39,7 +39,7 @@ void analy_lp_fx( const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ const Word16 element_mode, /* i : element mode */ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ - Word16 Q_new, /* i : stores Q for speech */ + const Word16 Q_new, /* i : stores Q for speech */ Word16 *Q_r /*stores q for ener*/ ) { @@ -152,7 +152,7 @@ void analy_lp_AMR_WB_fx( Word16 isf_new[], /* o : current frame ISPs Q15*/ Word16 Top, /* i : open loop pitch lag Q0*/ Word16 Tnc, /* i : open loop pitch gain Qx*/ - Word16 Q_new, + const Word16 Q_new, Word16 *Q_r ) { Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 5d54b9729..e1a246817 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3908,8 +3908,8 @@ void coder_tcx_post_fx( const Word16 *A, const Word16 *Ai, Word16 *wsig, - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, + const Word16 shift ) { Word16 xn_buf[L_FRAME_MAX]; diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index aa06b12d2..2d44ba36a 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -1052,16 +1052,22 @@ void core_switching_pre_enc_ivas_fx( *---------------------------------------------------------------------*/ void core_switching_post_enc_ivas_fx( +#ifdef CLEANUP_ACELP_ENC + Encoder_State *st /* i/o: encoder state structure */ +#else Encoder_State *st, /* i/o: encoder state structure */ Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */ Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */ Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */ - Word16 Q_new ) + Word16 Q_new +#endif +) { IF( EQ_16( st->core, HQ_CORE ) ) { st->use_acelp_preq = 0; move16(); +#ifndef CLEANUP_ACELP_ENC test(); test(); IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */ @@ -1079,6 +1085,7 @@ void core_switching_post_enc_ivas_fx( acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) ); } +#endif st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index f68b94daf..9bb9d3a6f 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -29,8 +29,8 @@ void encod_amr_wb_fx( Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ const Word16 *speech16k_fx, /* i : input speech @16kHz Qx*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 xn[L_SUBFR]; /* Target vector for pitch search */ Word16 xn2[L_SUBFR]; /* Target vector for codebook search */ @@ -174,8 +174,13 @@ void encod_amr_wb_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, + exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); +#endif /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index bfe50a588..ee075c134 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -292,9 +292,14 @@ void encod_gen_voic_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift ); +#endif /*-----------------------------------------------------------------* * Gain encoding @@ -652,8 +657,13 @@ void encod_gen_voic_ivas_fx( test(); IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) ) { +#ifdef CLEANUP_ACELP_ENC + transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, + xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#else transf_cdbk_enc_ivas_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#endif } /*-----------------------------------------------------------------* @@ -708,8 +718,13 @@ void encod_gen_voic_ivas_fx( test(); IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) ) { +#ifdef CLEANUP_ACELP_ENC + transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, + Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#else transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 82296aa4a..a7afd750c 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -22,6 +22,7 @@ static void find_cn_fx( const Word16 xn[], const Word16 Ap[], const Word16 *p_Aq *-----------------------------------------------------------------*/ #define Q_MINUS 4 +#ifndef CLEANUP_ACELP_ENC void transf_cdbk_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ @@ -375,9 +376,13 @@ void transf_cdbk_enc_fx( return; } +#endif - +#ifdef CLEANUP_ACELP_ENC +void transf_cdbk_enc_fx( +#else void transf_cdbk_enc_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -490,7 +495,16 @@ void transf_cdbk_enc_ivas_fx( * Split algebraic vector quantizer based on RE8 lattice *--------------------------------------------------------------*/ - AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 ); + } + ELSE +#endif + { + AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct ); + } /*--------------------------------------------------------------* * Find prequantizer excitation gain diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 2d5902bc3..a69175aa7 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -63,8 +63,8 @@ void enc_pit_exc_fx( Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, + const Word16 shift ) { Word16 xn[PIT_EXC_L_SUBFR]; /* Target vector for pitch search */ Word16 xn2[PIT_EXC_L_SUBFR]; /* Target vector for codebook search */ @@ -387,8 +387,13 @@ void enc_pit_exc_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + 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, 0 ); +#else 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 ); +#endif } /*-----------------------------------------------------------------* @@ -402,6 +407,7 @@ void enc_pit_exc_fx( /*-----------------------------------------------------------------* * Innovation & gain encoding *-----------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -411,8 +417,13 @@ void enc_pit_exc_fx( ELSE #endif { +#ifdef CLEANUP_ACELP_ENC + 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, 0 ); +#else 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 ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 879ed6dd0..43e0b8759 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -187,8 +187,13 @@ Word16 encod_tran_fx( * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); +#endif test(); test(); @@ -564,8 +569,13 @@ Word16 encod_tran_ivas_fx( * adaptive/glottal part of excitation construction *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + transition_enc_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1, + h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift ); +#else transition_enc_ivas_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1, h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift ); +#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames @@ -573,8 +583,13 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { +#ifdef CLEANUP_ACELP_ENC + transf_cdbk_enc_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, + &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); +#else transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index b2800da5b..23a9a84fa 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -39,8 +39,8 @@ void encod_audio_fx( Word16 *tmp_noise, /* o : noise energy Q2 */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0 */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6 */ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, + const Word16 shift ) { const Word16 *p_Aq; Word16 i, i_subfr, nb_subfr, last_pit_bin; diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 81b9ba49e..624988941 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -54,7 +54,7 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*==============================================================================*/ - +#ifndef CLEANUP_ACELP_ENC Word16 inov_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -340,9 +340,13 @@ Word16 inov_encode_fx( return stack_pulses; } +#endif - +#ifdef CLEANUP_ACELP_ENCaa +Word16 inov_encode_fx( +#else Word16 inov_encode_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -365,8 +369,8 @@ Word16 inov_encode_ivas_fx( Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/ Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2; Word16 nBits, cmpl_flag; @@ -395,16 +399,35 @@ Word16 inov_encode_ivas_fx( move16(); } - maximum_abs_16_fx( xn2, L_subfr, &max_xn2 ); - IF( max_xn2 ) +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) +#endif { - Qxn = add( sub( Q_new, 1 ), shift ); + maximum_abs_16_fx( xn2, L_subfr, &max_xn2 ); + IF( max_xn2 ) + { + Qxn = add( sub( Q_new, 1 ), shift ); + } + ELSE + { + Qxn = 0; + move16(); + } +#ifdef CLEANUP_ACELP_ENC + + Qcn = Q_new; + move16(); +#endif } +#ifdef CLEANUP_ACELP_ENC ELSE { Qxn = 0; move16(); + Qcn = 0; + move16(); } +#endif /*----------------------------------------------------------------* * Update target vector for codebook search in residual domain @@ -414,8 +437,10 @@ Word16 inov_encode_ivas_fx( test(); test(); +#ifndef CLEANUP_ACELP_ENC Qcn = Q_new; move16(); +#endif IF( GT_32( core_brate, ACELP_13k20 ) && !Opt_AMR_WB && EQ_16( L_subfr, L_SUBFR ) ) { acelpautoc = 1; @@ -436,23 +461,42 @@ Word16 inov_encode_ivas_fx( acelpautoc = 0; move16(); updt_tar_fx( cn, cn, &exc[i_subfr], gain_pit, L_subfr ); + /* scaling of cn[] to limit dynamic at 12 bits */ Scale_sig( cn, L_subfr, shift ); - Word16 q_h1 = sub( 14, norm_s( h2[0] ) ); - Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/ - cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); - corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1 - IF( LT_16( Qdn, Qcn ) ) + +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) { - scale_sig( cn, L_subfr, sub( Qdn, Qcn ) ); - Qcn = Qdn; + cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); + + corr_xh_fx( xn2, dn, h2 ); + + Qdn = 0; move16(); } ELSE +#endif { - scale_sig( dn, L_subfr, sub( Qcn, Qdn ) ); - Qdn = Qcn; - move16(); + Word16 q_h1 = sub( 14, norm_s( h2[0] ) ); + Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/ + + cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); + + corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1 + + IF( LT_16( Qdn, Qcn ) ) + { + scale_sig( cn, L_subfr, sub( Qdn, Qcn ) ); + Qcn = Qdn; + move16(); + } + ELSE + { + scale_sig( dn, L_subfr, sub( Qcn, Qdn ) ); + Qdn = Qcn; + move16(); + } } } @@ -584,8 +628,13 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); - Qh2 = sub( 14, norm_s( h2[0] ) ); - Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) +#endif + { + Qh2 = sub( 14, norm_s( h2[0] ) ); + Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); + } IF( !Opt_AMR_WB ) { @@ -683,7 +732,7 @@ Word16 inov_encode_ivas_fx( } ELSE { - nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr >> 6]; + nBits = st_fx->acelp_cfg.fixed_cdk_index[shr( i_subfr, 6 )]; move16(); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 2ee800325..c19ec47db 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -647,7 +647,11 @@ ivas_error ivas_core_enc_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + core_switching_post_enc_ivas_fx( st ); +#else core_switching_post_enc_ivas_fx( st, old_inp_12k8_fx[n], old_inp_16k_fx[n], A_fx[n], Q_new[n] ); +#endif /*---------------------------------------------------------------------* * WB TBE encoding diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 41078054c..756ee4ac3 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -650,7 +650,7 @@ void noise_est_down_fx( Word16 Etot, /* i : Energy of current frame */ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ Word16 *Etot_v_h2, /* i/o: Energy variations of noise frames Q8 */ - Word16 Q_new, + const Word16 Q_new, const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */ ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 13d11e72b..a32d7efd3 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -78,7 +78,7 @@ void analy_lp_fx( const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ const Word16 element_mode, /* i : element mode */ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ - Word16 Q_new, /* i : stores Q for speech */ + const Word16 Q_new, /* i : stores Q for speech */ Word16 *Q_r /*stores q for ener*/ ); @@ -322,7 +322,7 @@ void noise_est_down_fx( Word16 Etot, /* i : Energy of current frame */ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ Word16 *Etot_v_h2, /* i/o: Energy variations of noise frames Q8 */ - Word16 Q_new, + const Word16 Q_new, const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */ ); @@ -2125,9 +2125,10 @@ void encod_audio_fx( Word16 *tmp_noise, /* o : noise energy */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ - Word16 Q_new, - Word16 shift ); + const Word16 Q_new, + const Word16 shift ); +#ifndef CLEANUP_ACELP_ENC void encod_audio_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 speech[], /* i : input speech Q_new */ @@ -2146,7 +2147,7 @@ void encod_audio_ivas_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ Word16 Q_new, Word16 shift ); - +#endif void stat_noise_uv_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors */ @@ -2558,8 +2559,8 @@ void coder_tcx_post_fx( const Word16 *A, const Word16 *Ai, Word16 *wsig, - Word16 Q_new, - Word16 shift ); + const Word16 Q_new, + const Word16 shift ); void coder_tcx_post_ivas_fx( Encoder_State *st, @@ -3512,6 +3513,7 @@ Word16 lp_filt_exc_enc_fx( Word16 *lp_flag /* i/o: mode selection Q0 */ ); +#ifndef CLEANUP_ACELP_ENC Word16 inov_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -3536,7 +3538,7 @@ Word16 inov_encode_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ Word16 shift ); - +#endif Word16 inov_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -3560,8 +3562,8 @@ Word16 inov_encode_ivas_fx( Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/ Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ - Word16 shift, - Word16 Q_new ); + const Word16 shift, + const Word16 Q_new ); void gain_enc_mless_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -3608,7 +3610,7 @@ void analy_lp_AMR_WB_fx( Word16 isf_new[], /* o : current frame ISPs Q15*/ Word16 Top, /* i : open loop pitch lag Q0*/ Word16 Tnc, /* i : open loop pitch gain Qx*/ - Word16 Q_new, + const Word16 Q_new, Word16 *Q_r ); void encod_amr_wb_fx( @@ -3623,8 +3625,8 @@ void encod_amr_wb_fx( Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ - Word16 shift, - Word16 Q_new ); + const Word16 shift, + const Word16 Q_new ); void re8_cod_fx( Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ @@ -3644,9 +3646,10 @@ void acelp_core_switch_enc_fx( const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - Word16 shift, - Word16 Q_new ); + const Word16 shift, + const Word16 Q_new ); +#ifndef CLEANUP_ACELP_ENC void acelp_core_switch_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ @@ -3654,7 +3657,7 @@ void acelp_core_switch_enc_ivas_fx( const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ Word16 shift, Word16 Q_new ); - +#endif void gain_enc_amr_wb_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *xn, /* i : target vector Q_xn*/ @@ -3714,6 +3717,7 @@ void transf_cdbk_enc_fx( const Word16 shift /* i : shifting applied to y1, xn,... */ ); +#ifndef CLEANUP_ACELP_ENC void transf_cdbk_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ @@ -3738,7 +3742,7 @@ void transf_cdbk_enc_ivas_fx( const Word16 Q_new, /* i : Current frame scaling */ const Word16 shift /* i : shifting applied to y1, xn,... */ ); - +#endif void gain_enc_lbr_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3848,6 +3852,7 @@ void transition_enc_fx( Word16 shift /* i : downscaling needs for 12 bits convolutions */ ); +#ifndef CLEANUP_ACELP_ENC void transition_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index */ @@ -3873,7 +3878,7 @@ void transition_enc_ivas_fx( Word16 Q_new, /* i : Current scaling */ Word16 shift /* i : downscaling needs for 12 bits convolutions */ ); - +#endif void gain_enc_tc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -4010,8 +4015,8 @@ void enc_pit_exc_fx( Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ); + const Word16 Q_new, + const Word16 shift ); #ifndef FIX_1904_HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 547502eab..fce2df6c5 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -16,8 +16,9 @@ static void gain_trans_enc_fx( Word32 gain_trans32, Word16 exc[], Word16 *quant_index, Word16 *quant_sign, Word16 Q_new ); static void tc_enc_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); +#ifndef CLEANUP_ACELP_ENC static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); - +#endif /*==========================================================================*/ /* FUNCTION : void transition_enc_fx () */ @@ -163,14 +164,29 @@ void transition_enc_fx( move16(); *clip_gain = 0; move16(); - g_corr_fx[0] = 16384; - move16(); - g_corr_fx[1] = add( shl( sub( shift_wsp, 1 ), 1 ), 1 ); - move16(); - g_corr_fx[2] = -16384; - move16(); - g_corr_fx[3] = shl( sub( shift_wsp, 1 ), 1 ); - move16(); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + g_corr_fx[0] = MAX16B /* 1.0f in Q15 */; + move16(); + g_corr_fx[1] = 0; + move16(); + g_corr_fx[2] = MAX16B /* 1.0f in Q15 */; + move16(); + g_corr_fx[3] = 0; + } + ELSE +#endif + { + g_corr_fx[0] = 16384; + move16(); + g_corr_fx[1] = add( shl( sub( shift_wsp, 1 ), 1 ), 1 ); + move16(); + g_corr_fx[2] = -16384; + move16(); + g_corr_fx[3] = shl( sub( shift_wsp, 1 ), 1 ); + move16(); + } set16_fx( &exc_fx[i_subfr], 0, L_SUBFR ); /* set excitation for current subrame to 0 */ @@ -197,6 +213,7 @@ void transition_enc_fx( /*-----------------------------------------------------------------* * glottal codebook contribution construction *-----------------------------------------------------------------*/ + ELSE IF( EQ_16( *tc_subfr, i_subfr ) ) { IF( EQ_16( st_fx->L_frame, L_FRAME ) ) @@ -395,7 +412,16 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -443,11 +469,19 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; @@ -508,7 +542,16 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -533,11 +576,19 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; @@ -571,7 +622,16 @@ void transition_enc_fx( pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -807,10 +867,26 @@ void transition_enc_fx( move16(); *clip_gain = 0; move16(); - g_corr_fx[0] = 0; - move16(); - g_corr_fx[1] = 0; - move16(); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + g_corr_fx[0] = 328 /* 0.01f in Q15 */; + move16(); + g_corr_fx[1] = 0; + move16(); + g_corr_fx[2] = 328 /* 0.01f in Q15 */; + move16(); + g_corr_fx[3] = 0; + move16(); + } + ELSE +#endif + { + g_corr_fx[0] = 0; + move16(); + g_corr_fx[1] = 0; + move16(); + } *Jopt_flag = 0; move16(); @@ -824,7 +900,17 @@ void transition_enc_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + offset = L_deposit_l( 0 ); tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ @@ -889,6 +975,7 @@ void transition_enc_fx( return; } +#ifndef CLEANUP_ACELP_ENC void transition_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index */ @@ -1717,7 +1804,7 @@ void transition_enc_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------------------------------* * tc_enc() @@ -1959,7 +2046,7 @@ static void tc_enc_fx( return; } - +#ifndef CLEANUP_ACELP_ENC static void tc_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subrame index */ @@ -2180,7 +2267,7 @@ static void tc_enc_ivas_fx( move16(); return; } - +#endif /*-----------------------------------------------------------------* * gain_trans_enc() -- GitLab From 4342d7e98271d36b519fffff757d10ba39d34598 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 16:29:04 +0100 Subject: [PATCH 238/750] removal of duplicated code, under CLEANUP_ACELP_ENC --- lib_enc/acelp_core_switch_enc_fx.c | 2 +- lib_enc/enc_amr_wb_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 9 +- lib_enc/enc_pit_exc_fx.c | 14 +- lib_enc/enc_tran_fx.c | 9 +- lib_enc/enc_uv_fx.c | 5 + lib_enc/inov_enc_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 7 +- lib_enc/prot_fx_enc.h | 2435 ++++++++++++++-------------- 9 files changed, 1257 insertions(+), 1228 deletions(-) diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index db2c27344..977bc099b 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -435,7 +435,7 @@ static void encod_gen_voic_core_switch_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, + inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 9bb9d3a6f..d3f0636ae 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -175,7 +175,7 @@ void encod_amr_wb_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, + inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index ee075c134..591c6e9bb 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -293,8 +293,8 @@ void encod_gen_voic_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, @@ -670,9 +670,14 @@ void encod_gen_voic_ivas_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); +#endif /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index a69175aa7..7cc932164 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -377,8 +377,13 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + 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, Q_new ); +#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 } ELSE #endif @@ -388,7 +393,7 @@ void enc_pit_exc_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - 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, + 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, 0 ); #else 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, @@ -411,14 +416,19 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + 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, Q_new ); +#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 } ELSE #endif { #ifdef CLEANUP_ACELP_ENC - 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, + 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, 0 ); #else 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, diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 43e0b8759..639d34048 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -188,8 +188,8 @@ Word16 encod_tran_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); @@ -596,8 +596,13 @@ Word16 encod_tran_ivas_fx( * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); +#endif test(); test(); diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index eb6149359..86215f5b8 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -373,9 +373,14 @@ void encod_unvoiced_ivas_fx( * Encode the algebraic innovation * *----------------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); +#endif E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 624988941..4a9ba19fc 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -342,7 +342,7 @@ Word16 inov_encode_fx( } #endif -#ifdef CLEANUP_ACELP_ENCaa +#ifdef CLEANUP_ACELP_ENC Word16 inov_encode_fx( #else Word16 inov_encode_ivas_fx( diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index ef28b3c0a..6773a8839 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -322,14 +322,17 @@ void encod_gen_2sbfr( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new ); +#endif /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, - st->element_mode ); + gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode ); IF( st->Opt_SC_VBR ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index a32d7efd3..f33abae3f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3513,8 +3513,8 @@ Word16 lp_filt_exc_enc_fx( Word16 *lp_flag /* i/o: mode selection Q0 */ ); -#ifndef CLEANUP_ACELP_ENC Word16 inov_encode_fx( +#ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -3538,8 +3538,9 @@ Word16 inov_encode_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ Word16 shift ); + +Word16 inov_encode_fx( #endif -Word16 inov_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -3565,1236 +3566,1236 @@ Word16 inov_encode_ivas_fx( const Word16 shift, const Word16 Q_new ); -void gain_enc_mless_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ -); - -void updt_IO_switch_enc_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 input_frame /* i : i frame length */ -); - -void hf_cod_init_fx( - Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ - Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ - Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ - Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ - Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ -); - -void analy_lp_AMR_WB_fx( - const Word16 speech[], /* i : pointer to the speech frame Q_new*/ - Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ - Word16 A[], /* o : A(z) filter coefficients Q14*/ - Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 isp_new[], /* o : current frame ISPs Q15*/ - Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ - Word16 isf_new[], /* o : current frame ISPs Q15*/ - Word16 Top, /* i : open loop pitch lag Q0*/ - Word16 Tnc, /* i : open loop pitch gain Qx*/ - const Word16 Q_new, - Word16 *Q_r ); - -void encod_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 speech[], /* i : i speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *syn, /* i/o: core synthesis st->Q_syn*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ - Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ - const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ - const Word16 shift, - const Word16 Q_new ); - -void re8_cod_fx( - Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ - UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ - Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ -); - -void TBEreset_enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 last_core, /* i : last core */ - Word16 bandwidth /* i : bandwidth mode */ -); - -void acelp_core_switch_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - const Word16 shift, - const Word16 Q_new ); + void gain_enc_mless_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 scaling */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ + ); + + void updt_IO_switch_enc_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 input_frame /* i : i frame length */ + ); + + void hf_cod_init_fx( + Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ + Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ + Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ + Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ + Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ + ); + + void analy_lp_AMR_WB_fx( + const Word16 speech[], /* i : pointer to the speech frame Q_new*/ + Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ + Word16 A[], /* o : A(z) filter coefficients Q14*/ + Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 isp_new[], /* o : current frame ISPs Q15*/ + Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ + Word16 isf_new[], /* o : current frame ISPs Q15*/ + Word16 Top, /* i : open loop pitch lag Q0*/ + Word16 Tnc, /* i : open loop pitch gain Qx*/ + const Word16 Q_new, + Word16 *Q_r ); + + void encod_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 speech[], /* i : i speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *syn, /* i/o: core synthesis st->Q_syn*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ + const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ + const Word16 shift, + const Word16 Q_new ); + + void re8_cod_fx( + Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ + UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ + Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ + ); + + void TBEreset_enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ + ); + + void acelp_core_switch_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + const Word16 shift, + const Word16 Q_new ); #ifndef CLEANUP_ACELP_ENC -void acelp_core_switch_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - Word16 shift, - Word16 Q_new ); + void acelp_core_switch_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + Word16 shift, + Word16 Q_new ); #endif -void gain_enc_amr_wb_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 Q_xn, /* i : xn and yy1 format */ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ -); - -void hf_cod_fx( - const Word32 core_brate_fx, /* i : core bitrate */ - const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ - const Word16 Aq_fx[], /* i : quantized Aq */ - const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ - Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ - Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ - Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ - Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ - Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ - Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ - const Word16 dtxHangoverCount_fx, - Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ - Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ - Word16 Q_exc, - Word16 Q_syn ); - -void transf_cdbk_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ -); + void gain_enc_amr_wb_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 Q_xn, /* i : xn and yy1 format */ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ + ); + + void hf_cod_fx( + const Word32 core_brate_fx, /* i : core bitrate */ + const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ + const Word16 Aq_fx[], /* i : quantized Aq */ + const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ + Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ + Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ + Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ + Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ + Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ + Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ + const Word16 dtxHangoverCount_fx, + Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ + Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ + Word16 Q_exc, + Word16 Q_syn ); + + void transf_cdbk_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ + ); #ifndef CLEANUP_ACELP_ENC -void transf_cdbk_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ -); + void transf_cdbk_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ + ); #endif -void gain_enc_lbr_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 format */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 L_subfr, /* i : subframe length Q0*/ - const Word16 element_mode /* i : mode element Q0*/ -); - -void gain_enc_SQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); - -void updt_tar_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 L /* i : subframe size */ -); - -void updt_tar_HR_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 Qx, /* i : Scaling factor to adapt output to i */ - const Word16 L /* i : subframe size */ -); - -Flag conv_fx( - const Word16 x[], /* i : i vector Q_new*/ - const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ - Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ - const Word16 L /* i : vector size */ -); - -ivas_error ppp_voiced_encoder_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - SC_VBR_ENC_HANDLE hSC_VBR, - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 last_coder_type_raw, /* i : raw last_coder_type */ - const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ - Word16 *in_fx, /* i : residual signal */ - Word16 *out_fx, /* o : Quantized residual signal */ - Word16 delay_fx, /* i : open loop pitch */ - Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ - Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ - Word16 *exc_fx, /* i: previous frame quantized excitation */ - Word16 *pitch_fx, /* o: floating pitch values for each subframe */ - Word16 Qres ); - -void signalling_enc_fx( - Encoder_State *st_fx /* i : encoder state structure */ -); - -void transition_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ -); + void gain_enc_lbr_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 format */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 L_subfr, /* i : subframe length Q0*/ + const Word16 element_mode /* i : mode element Q0*/ + ); + + void gain_enc_SQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 Q_xn /* i : xn and y1 scaling */ + ); + + void updt_tar_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 L /* i : subframe size */ + ); + + void updt_tar_HR_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 Qx, /* i : Scaling factor to adapt output to i */ + const Word16 L /* i : subframe size */ + ); + + Flag conv_fx( + const Word16 x[], /* i : i vector Q_new*/ + const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ + Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ + const Word16 L /* i : vector size */ + ); + + ivas_error ppp_voiced_encoder_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + SC_VBR_ENC_HANDLE hSC_VBR, + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 last_coder_type_raw, /* i : raw last_coder_type */ + const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ + Word16 *in_fx, /* i : residual signal */ + Word16 *out_fx, /* o : Quantized residual signal */ + Word16 delay_fx, /* i : open loop pitch */ + Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ + Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ + Word16 *exc_fx, /* i: previous frame quantized excitation */ + Word16 *pitch_fx, /* o: floating pitch values for each subframe */ + Word16 Qres ); + + void signalling_enc_fx( + Encoder_State *st_fx /* i : encoder state structure */ + ); + + void transition_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ + ); #ifndef CLEANUP_ACELP_ENC -void transition_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ -); + void transition_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ + ); #endif -void gain_enc_tc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); - -void gain_enc_tc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); - -Word16 gaus_encode_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ -); - -Word16 gaus_encode_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ -); - -void pre_proc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_frame, /* i : frame length */ - Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ - Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ - Word16 **inp, /* o : ptr. to inp. signal in the current frame */ - Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ - Word16 *Etot, /* o : total energy */ - Word32 *ener, /* o : residual energy from Levinson-Durbin */ + void gain_enc_tc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + const Word16 Q_xn /* i : xn and y1 scaling */ + ); + + void gain_enc_tc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ + const Word16 Q_xn /* i : xn and y1 scaling */ + ); + + Word16 gaus_encode_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ + ); + + Word16 gaus_encode_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ + ); + + void pre_proc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_frame, /* i : frame length */ + Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ + Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ + Word16 **inp, /* o : ptr. to inp. signal in the current frame */ + Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ + Word16 *Etot, /* o : total energy */ + Word32 *ener, /* o : residual energy from Levinson-Durbin */ #ifndef FIX_I4_OL_PITCH - Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ + Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ #endif - Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - Word16 epsP_h[M + 1], /* o : LP prediction errors */ - Word16 epsP_l[M + 1], /* o : LP prediction errors */ - Word32 epsP[M + 1], /* o : LP prediction errors */ - Word16 lsp_new[M], /* o : LSPs at the end of the frame */ - Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ - Word16 *vad_hover_flag, - Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ - Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ - CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ - Word16 *old_exc, /* i/o: static excitation memory */ - Word16 *hq_core_type, /* o : HQ core type */ - Word16 *Q_new, - Word16 *shift, - Word16 *Q_r ); - -void swb_bwe_enc_hr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *new_input_fx, /* i : i signal */ - Word16 new_input_fx_exp, /* i : Exponent of i signal */ - const Word16 input_frame, /* i : frame length */ - const Word16 unbits /* i : number of core unused bits */ -); - -/* o : Return index of quantization */ -Word16 gain_enc_gaus_fx( - Word32 *gain, /* i/o: Code gain to quantize Q16*/ - const Word16 bits, /* i : number of bits to quantize Q0*/ - const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ - const Word16 stepSize, /* i : Step size choice Q14*/ - const Word16 inv_stepSize /* i : Step size choice Q15*/ -); - -void enc_pit_exc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *speech, /* i : Input speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - const Word16 Q_new, - const Word16 shift ); + Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ + Word16 epsP_h[M + 1], /* o : LP prediction errors */ + Word16 epsP_l[M + 1], /* o : LP prediction errors */ + Word32 epsP[M + 1], /* o : LP prediction errors */ + Word16 lsp_new[M], /* o : LSPs at the end of the frame */ + Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ + Word16 *vad_hover_flag, + Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ + Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ + CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ + Word16 *old_exc, /* i/o: static excitation memory */ + Word16 *hq_core_type, /* o : HQ core type */ + Word16 *Q_new, + Word16 *shift, + Word16 *Q_r ); + + void swb_bwe_enc_hr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *new_input_fx, /* i : i signal */ + Word16 new_input_fx_exp, /* i : Exponent of i signal */ + const Word16 input_frame, /* i : frame length */ + const Word16 unbits /* i : number of core unused bits */ + ); + + /* o : Return index of quantization */ + Word16 gain_enc_gaus_fx( + Word32 *gain, /* i/o: Code gain to quantize Q16*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ + const Word16 stepSize, /* i : Step size choice Q14*/ + const Word16 inv_stepSize /* i : Step size choice Q15*/ + ); + + void enc_pit_exc_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + const Word16 Q_new, + const Word16 shift ); #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*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ); + void enc_pit_exc_ivas_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + 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 */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); + /* o : bin where pitch contribution is significant */ + Word16 Pit_exc_contribution_len_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); #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 */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); + /* o : bin where pitch contribution is significant */ + Word16 Pit_exc_contribution_len_ivas_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + 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 */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ -); - -Word16 pvq_core_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ -); -void core_switching_hq_prepare_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ - const Word16 *audio /*q_audio*/ ); - -void hq_lr_enc_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ -); - -void hq_lr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ -); - -void hq_hr_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ -); - -void hq_hr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ -); - -void reordernorm_fx( - const Word16 *ynrm, /* i : quantization indices for norms Q0 */ - const Word16 *normqlg2, /* i : quantized norms Q0 */ - Word16 *idxbuf, /* o : reordered quantization indices Q0 */ - Word16 *normbuf, /* o : reordered quantized norms Q0 */ - const Word16 nb_sfm /* i : number of bands Q0 */ -); - -void diffcod_fx( - const Word16 N, /* (i) number of sub-vectors Q0*/ - Word16 *y, /* (i/o) indices of quantized norms Q0*/ - Word16 *difidx /* (o) differential code Q0*/ -); - -/* o : Consumed bits Q0 */ -Word16 hq_classifier_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ -); - -/* o : Consumed bits Q0 */ -Word16 hq_classifier_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ -); - -void diff_envelope_coding_fx( - const Word16 is_transient, /* i : transient indicator Q0 */ - const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ - const Word16 start_norm, /* i : start of envelope coding Q0 */ - Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ - Word16 *normqlg2, /* i/o: quantized norms Q0 */ - Word16 *difidx /* o : differential code Q0 */ -); - -/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ -Word16 encode_envelope_indices_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ -); - -void hq_generic_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas /* o : bwe excitation class */ -); - -void normalizecoefs_fx( - Word32 *coefs, /* i : Input vector (Q12) */ - const Word16 *ynrm, /* i : quantization indices for norms */ - const Word16 num_bands, /* i : Number of bands */ - const Word16 *band_start, /* i : Start of bands */ - const Word16 *band_end, /* i : End of bands */ - Word16 *coefs_norm /* o : Normalized output vector (Q12) */ -); - -/* o : Consumed bits */ -Word16 hvq_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 brate, /* i : Total bit rate */ - const Word16 hvq_bits, /* i : HVQ bit budget */ - const Word16 Npeaks, /* i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ - Word16 *noise_level, /* o : Quantized noise level */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q14 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ -); - -/* o : Consumed bits */ -Word16 hvq_enc_ivas_fx( - Encoder_State *st_fx, /*i/o: encoder state structure */ - const Word32 core_brate, /*i : Total bit rate */ - const Word16 hvq_bits, /*i : HVQ bit budget */ - const Word16 Npeaks, /*i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ - Word16 *noise_level, /* o : Quantized noise level Q15 */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q12 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ -); - -Word16 pvq_core_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ -); - -/* o : index of noise attenuation Q0 */ -Word16 noise_adjust_fx( - const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ - const Word16 qx, /* i : Q value of coeffs_norm */ - const Word16 *bitalloc, /* i : bit allocation Q0 */ - const Word16 *sfm_start, /* i : band start Q0 */ - const Word16 *sfm_end, /* i : band end Q0 */ - const Word16 core_sfm /* i : index of the end band for core Q0 */ -); - -ivas_error tcq_core_LR_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 inp_vector_fx[], /* x5 */ - const Word32 coefs_norm_fx[], /* Q12 */ - Word32 coefs_quant_fx[], /* Q12 */ - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *R_fx, /* Q16 */ - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - -ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector[], - const Word32 coefs_norm_fx[], - Word32 coefs_quant_fx[], - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *Rk_fx, - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - -/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ -Word16 encode_envelope_indices_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ -); - -void diffcod_lrmdct_fx( - const Word16 N, /* i : number of sub-vectors Q0*/ - const Word16 be_ref, /* i : band energy reference Q0*/ - Word16 *y, /* i/o: indices of quantized norms Q0*/ - Word16 *difidx, /* o : differential code Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ -); - -Word16 peak_vq_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 core_brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ -); - -Word16 peak_vq_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ -); - -void wb_vad_init_fx( - VAD_HANDLE hVAD /* i/o: VAD data handle */ -); - -void noise_est_init_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ -); - -void noise_est_init_ivas_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ -); - -void InitSWBencBuffer_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void InitSWBencBuffer_ivas_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void ResetSHBbuffer_Enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); - -Word16 E_ACELP_hh_corr( - Word16 *x /*Q11*/, - Word16 *y /*Qy*/, - Word16 L_subfr /*Q0*/, - Word16 bits /*Q0*/ -); - -void acelp_1t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[], /* o : filtered fixed codebook excitation */ - const Word16 L_subfr /* i : subframe length */ -); - -void acelp_2t32_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[] /* o : filtered fixed codebook excitation */ -); - -Word16 acelp_4t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 cn[], /* i : residual after long term prediction Q_new*/ - const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ - Word16 R[], /* i : autocorrelation values */ - const Word16 acelpautoc, /* i : autocorrealtion flag */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - Word16 y[], /* o : filtered fixed codebook excitation Q9*/ - Word16 nbbits, /* i : number of bits per codebook */ - const Word16 cmpl_flag, /* i : coomplexity reduction flag */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 element_mode ); - -ivas_error evs_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *data, /* i : input signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of input samples Q0*/ -); - -/* o: Qx y(n) */ -/* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ -Word16 noise_est_AR1_Qx( - Word16 x, /* i : Qx x(n) */ - Word16 y, /* i : Qx y(n-1) */ - Word16 alpha /* i : Q15 scaling of driving x(n) */ -); - -/*o : Qx y( n ) */ -Word32 noise_est_AR1_Qx_32( - Word32 x, /* i : Qx x(n) */ - Word32 y, /* i : Qx y(n-1) */ - Word32 alpha /* i : Q15 scaling of driving x(n) */ -); - -void FEC_lsf_estim_enc_fx( - Encoder_State *st_fx, /* i : Encoder static memory */ - Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ -); - -Word32 mslvq_cng_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w, /* i : weights for LSF quantization Q10*/ - Word16 *no_scales ); - -Word32 mslvq_cng_ivas_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w /* i : weights for LSF quantization Q10*/ -); - -void Unified_weighting_fx( - const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ - Word16 Q_ener, - const Word16 lsf_fx[], /* i : LSF vector x2.56 */ - Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ - const Word16 narrowBand, /* i : flag for Narrowband Q0*/ - const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ - const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ - const Word16 order /* i : LP order Q0*/ -); - -Word32 qlsf_ARSN_tcvq_Enc_16k_fx( - const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ - Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ - Word16 *indice, /* o : Indices */ - const Word16 *w_fx, /* i : LSF Weights Q10 */ - const Word16 nBits, /* i : number of bits */ - Word16 safety_net /* i : safety_net flag */ -); - -Word32 mslvq_fx( - Word16 *pTmp, /* i : M-dimensional i vector */ - Word16 *quant, /* o : quantized vector */ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - Word16 *w, /* i : weights for LSF quantization */ - Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ - Word16 mode_glb, /* i : LVQ coding mode */ - Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ - Word16 no_scales[][2] ); - -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ -Word16 multi_harm_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ -); - -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ -Word16 multi_harm_ivas_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ -); - -void pvq_encode_frame_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ -); - -void pvq_encode_frame_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ -); - -/*Qx o : interpolated value */ -Word16 Interpol_4( - Word16 *x, /*Qx i : i vector */ - Word16 frac /* i : fraction (-4..+3) */ -); - -void set_ppp_mode_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ - const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ - const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ - const Word16 localVAD_he /* i : HE-SAD flag without hangover */ -); - -void decision_matrix_enc_fx( - Encoder_State *st_fx, /* i : encoder state structure */ - Word16 *hq_core_type /* o : HQ core_fx type Q0*/ -); - -void pvq_encode_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ -); - -void pvq_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ -); - -void rc_enc_init_fx( - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - Word16 tot_bits /* i : Total bit budget Q0*/ -); - -void rc_enc_finish_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ -); - -void rc_enc_finish_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ - -); - -void rc_encode_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ -); - -void rc_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ -); - -void rc_enc_uniform_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ -); - -void rc_enc_uniform_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ -); - -void rc_enc_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ -); - -void rc_enc_bits_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ -); - -void re8_compute_base_index_fx( - const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ - const Word16 ka, /* i : Identifier of the absolute leader related to x */ - UWord16 *I /* o : index */ -); - -void tfaCalcEnv_fx( - const Word16 *shb_speech, - Word32 *enr ); - -/* o : pitch index */ -Word16 delta_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac, /* i : pitch fraction */ - const Word16 T0_min /* i : delta search min */ -); - -void set_impulse_fx( - const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ - const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ - Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ - Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ - Word16 *imp_shape, /* o : adaptive codebook index Q0*/ - Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ - Word32 *gain_trans_fx, /* o : transition gain Q7*/ - Word16 Q_new /* i : Current scaling */ -); - -/* o : pitch index */ -Word16 abs_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac /* i : pitch fraction */ -); - -ivas_error ppp_quarter_encoder_fx( - Word16 *returnFlag, /* o : return value */ - DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ - DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ - Word16 prevCW_lag, /* i : previous lag */ - DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ - const Word16 *curr_lpc_fx, /* i : LPCS */ - Word16 *lastLgainE_fx, /* i/o: last low band gain */ - Word16 *lastHgainE_fx, /* i/o: last high band gain */ - Word16 *lasterbE_fx, /* i/o: last ERB vector */ - DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ - Word16 *S_fx, /* i : sin table, Q15 */ - Word16 *C_fx, /* i : cos table, Q15 */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void index_lvq_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - -void index_lvq_ivas_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - const Word16 prediction_flag ); - -void copy_encoder_config_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ -); - -void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_sp[], /* i : i signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of i samples Q0*/ -); - -void writeLPCparam_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ -); - -Word16 cng_energy_ivas_fx( - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidh */ - const Word16 CNG_mode, /* i : mode for DTX configuration */ - const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ - const Word16 *exc, /* i : input signal */ - const Word16 len, /* i : vector length */ - const Word16 Q_new /* i : Input scaling */ -); - -void generate_comfort_noise_enc_ivas_fx( - Encoder_State *stcod, - Word16 Q_new, - Word16 gen_exc ); - -void SynthesisSTFT_enc_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -ivas_error write_indices_ivas_fx( - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - UWord16 *bit_stream, /* i/o: output bitstream */ - UWord16 *num_bits /* i : number of indices written to output */ -); + Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ + ); + + Word16 pvq_core_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ + ); + void core_switching_hq_prepare_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ + const Word16 *audio /*q_audio*/ ); + + void hq_lr_enc_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ + ); + + void hq_lr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ + ); + + void hq_hr_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ + ); + + void hq_hr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ + ); + + void reordernorm_fx( + const Word16 *ynrm, /* i : quantization indices for norms Q0 */ + const Word16 *normqlg2, /* i : quantized norms Q0 */ + Word16 *idxbuf, /* o : reordered quantization indices Q0 */ + Word16 *normbuf, /* o : reordered quantized norms Q0 */ + const Word16 nb_sfm /* i : number of bands Q0 */ + ); + + void diffcod_fx( + const Word16 N, /* (i) number of sub-vectors Q0*/ + Word16 *y, /* (i/o) indices of quantized norms Q0*/ + Word16 *difidx /* (o) differential code Q0*/ + ); + + /* o : Consumed bits Q0 */ + Word16 hq_classifier_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ + ); + + /* o : Consumed bits Q0 */ + Word16 hq_classifier_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ + ); + + void diff_envelope_coding_fx( + const Word16 is_transient, /* i : transient indicator Q0 */ + const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ + const Word16 start_norm, /* i : start of envelope coding Q0 */ + Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ + Word16 *normqlg2, /* i/o: quantized norms Q0 */ + Word16 *difidx /* o : differential code Q0 */ + ); + + /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ + Word16 encode_envelope_indices_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ + ); + + void hq_generic_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas /* o : bwe excitation class */ + ); + + void normalizecoefs_fx( + Word32 *coefs, /* i : Input vector (Q12) */ + const Word16 *ynrm, /* i : quantization indices for norms */ + const Word16 num_bands, /* i : Number of bands */ + const Word16 *band_start, /* i : Start of bands */ + const Word16 *band_end, /* i : End of bands */ + Word16 *coefs_norm /* o : Normalized output vector (Q12) */ + ); + + /* o : Consumed bits */ + Word16 hvq_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 brate, /* i : Total bit rate */ + const Word16 hvq_bits, /* i : HVQ bit budget */ + const Word16 Npeaks, /* i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ + Word16 *noise_level, /* o : Quantized noise level */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q14 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ + ); + + /* o : Consumed bits */ + Word16 hvq_enc_ivas_fx( + Encoder_State *st_fx, /*i/o: encoder state structure */ + const Word32 core_brate, /*i : Total bit rate */ + const Word16 hvq_bits, /*i : HVQ bit budget */ + const Word16 Npeaks, /*i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ + Word16 *noise_level, /* o : Quantized noise level Q15 */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q12 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ + ); + + Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ + ); + + /* o : index of noise attenuation Q0 */ + Word16 noise_adjust_fx( + const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ + const Word16 qx, /* i : Q value of coeffs_norm */ + const Word16 *bitalloc, /* i : bit allocation Q0 */ + const Word16 *sfm_start, /* i : band start Q0 */ + const Word16 *sfm_end, /* i : band end Q0 */ + const Word16 core_sfm /* i : index of the end band for core Q0 */ + ); + + ivas_error tcq_core_LR_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 inp_vector_fx[], /* x5 */ + const Word32 coefs_norm_fx[], /* Q12 */ + Word32 coefs_quant_fx[], /* Q12 */ + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *R_fx, /* Q16 */ + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + + ivas_error tcq_core_LR_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word32 inp_vector[], + const Word32 coefs_norm_fx[], + Word32 coefs_quant_fx[], + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *Rk_fx, + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + + /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ + Word16 encode_envelope_indices_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ + ); + + void diffcod_lrmdct_fx( + const Word16 N, /* i : number of sub-vectors Q0*/ + const Word16 be_ref, /* i : band energy reference Q0*/ + Word16 *y, /* i/o: indices of quantized norms Q0*/ + Word16 *difidx, /* o : differential code Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ + ); + + Word16 peak_vq_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 core_brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ + ); + + Word16 peak_vq_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ + ); + + void wb_vad_init_fx( + VAD_HANDLE hVAD /* i/o: VAD data handle */ + ); + + void noise_est_init_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ + ); + + void noise_est_init_ivas_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ + ); + + void InitSWBencBuffer_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ + ); + + void InitSWBencBuffer_ivas_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ + ); + + void ResetSHBbuffer_Enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ + ); + + Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); + + Word16 E_ACELP_hh_corr( + Word16 *x /*Q11*/, + Word16 *y /*Qy*/, + Word16 L_subfr /*Q0*/, + Word16 bits /*Q0*/ + ); + + void acelp_1t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[], /* o : filtered fixed codebook excitation */ + const Word16 L_subfr /* i : subframe length */ + ); + + void acelp_2t32_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[] /* o : filtered fixed codebook excitation */ + ); + + Word16 acelp_4t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 cn[], /* i : residual after long term prediction Q_new*/ + const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ + Word16 R[], /* i : autocorrelation values */ + const Word16 acelpautoc, /* i : autocorrealtion flag */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + Word16 y[], /* o : filtered fixed codebook excitation Q9*/ + Word16 nbbits, /* i : number of bits per codebook */ + const Word16 cmpl_flag, /* i : coomplexity reduction flag */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 element_mode ); + + ivas_error evs_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *data, /* i : input signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of input samples Q0*/ + ); + + /* o: Qx y(n) */ + /* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ + Word16 noise_est_AR1_Qx( + Word16 x, /* i : Qx x(n) */ + Word16 y, /* i : Qx y(n-1) */ + Word16 alpha /* i : Q15 scaling of driving x(n) */ + ); + + /*o : Qx y( n ) */ + Word32 noise_est_AR1_Qx_32( + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /* i : Q15 scaling of driving x(n) */ + ); + + void FEC_lsf_estim_enc_fx( + Encoder_State *st_fx, /* i : Encoder static memory */ + Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ + ); + + Word32 mslvq_cng_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w, /* i : weights for LSF quantization Q10*/ + Word16 *no_scales ); + + Word32 mslvq_cng_ivas_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w /* i : weights for LSF quantization Q10*/ + ); + + void Unified_weighting_fx( + const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ + Word16 Q_ener, + const Word16 lsf_fx[], /* i : LSF vector x2.56 */ + Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ + const Word16 narrowBand, /* i : flag for Narrowband Q0*/ + const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ + const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ + const Word16 order /* i : LP order Q0*/ + ); + + Word32 qlsf_ARSN_tcvq_Enc_16k_fx( + const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ + Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ + Word16 *indice, /* o : Indices */ + const Word16 *w_fx, /* i : LSF Weights Q10 */ + const Word16 nBits, /* i : number of bits */ + Word16 safety_net /* i : safety_net flag */ + ); + + Word32 mslvq_fx( + Word16 *pTmp, /* i : M-dimensional i vector */ + Word16 *quant, /* o : quantized vector */ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + Word16 *w, /* i : weights for LSF quantization */ + Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ + Word16 mode_glb, /* i : LVQ coding mode */ + Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ + Word16 no_scales[][2] ); + + /* o : frame multi-harmonicity (1-harmonic, 0-not) */ + Word16 multi_harm_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ + ); + + /* o : frame multi-harmonicity (1-harmonic, 0-not) */ + Word16 multi_harm_ivas_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ + ); + + void pvq_encode_frame_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ + ); + + void pvq_encode_frame_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ + ); + + /*Qx o : interpolated value */ + Word16 Interpol_4( + Word16 *x, /*Qx i : i vector */ + Word16 frac /* i : fraction (-4..+3) */ + ); + + void set_ppp_mode_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ + const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ + const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ + const Word16 localVAD_he /* i : HE-SAD flag without hangover */ + ); + + void decision_matrix_enc_fx( + Encoder_State *st_fx, /* i : encoder state structure */ + Word16 *hq_core_type /* o : HQ core_fx type Q0*/ + ); + + void pvq_encode_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ + ); + + void pvq_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ + ); + + void rc_enc_init_fx( + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + Word16 tot_bits /* i : Total bit budget Q0*/ + ); + + void rc_enc_finish_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ + ); + + void rc_enc_finish_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ + + ); + + void rc_encode_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ + ); + + void rc_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ + ); + + void rc_enc_uniform_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ + ); + + void rc_enc_uniform_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ + ); + + void rc_enc_bits_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ + ); + + void rc_enc_bits_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ + ); + + void re8_compute_base_index_fx( + const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ + const Word16 ka, /* i : Identifier of the absolute leader related to x */ + UWord16 *I /* o : index */ + ); + + void tfaCalcEnv_fx( + const Word16 *shb_speech, + Word32 *enr ); + + /* o : pitch index */ + Word16 delta_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac, /* i : pitch fraction */ + const Word16 T0_min /* i : delta search min */ + ); + + void set_impulse_fx( + const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ + const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ + Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ + Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ + Word16 *imp_shape, /* o : adaptive codebook index Q0*/ + Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ + Word32 *gain_trans_fx, /* o : transition gain Q7*/ + Word16 Q_new /* i : Current scaling */ + ); + + /* o : pitch index */ + Word16 abs_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac /* i : pitch fraction */ + ); + + ivas_error ppp_quarter_encoder_fx( + Word16 *returnFlag, /* o : return value */ + DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ + DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ + Word16 prevCW_lag, /* i : previous lag */ + DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ + const Word16 *curr_lpc_fx, /* i : LPCS */ + Word16 *lastLgainE_fx, /* i/o: last low band gain */ + Word16 *lastHgainE_fx, /* i/o: last high band gain */ + Word16 *lasterbE_fx, /* i/o: last ERB vector */ + DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ + Word16 *S_fx, /* i : sin table, Q15 */ + Word16 *C_fx, /* i : cos table, Q15 */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + ); + + void index_lvq_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + + void index_lvq_ivas_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + const Word16 prediction_flag ); + + void copy_encoder_config_fx( + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_State *st, /* o : encoder state structure */ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ + ); + + void amr_wb_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_sp[], /* i : i signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of i samples Q0*/ + ); + + void writeLPCparam_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ + ); + + Word16 cng_energy_ivas_fx( + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidh */ + const Word16 CNG_mode, /* i : mode for DTX configuration */ + const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ + const Word16 *exc, /* i : input signal */ + const Word16 len, /* i : vector length */ + const Word16 Q_new /* i : Input scaling */ + ); + + void generate_comfort_noise_enc_ivas_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc ); + + void SynthesisSTFT_enc_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + ivas_error write_indices_ivas_fx( + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + UWord16 *bit_stream, /* i/o: output bitstream */ + UWord16 *num_bits /* i : number of indices written to output */ + ); #endif -- GitLab From 3113ee2527e7cc96f44c04a4cd27d52b83d10dc9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 16:52:06 +0100 Subject: [PATCH 239/750] harmonize est_tilt_ivas_fx(), under CLEANUP_ACELP_ENC --- lib_com/est_tilt_fx.c | 9 ++++++++- lib_com/prot_fx.h | 7 +++++-- lib_dec/dec_gen_voic_fx.c | 10 ++++++++-- lib_dec/dec_pit_exc_fx.c | 10 +++++++++- lib_dec/dec_tran_fx.c | 10 ++++++++++ lib_dec/dec_uv_fx.c | 9 +++++++-- lib_dec/ivas_td_low_rate_dec_fx.c | 9 ++++++--- lib_enc/acelp_core_switch_enc_fx.c | 7 ++++++- lib_enc/enc_gen_voic_fx.c | 4 ++++ lib_enc/enc_pit_exc_fx.c | 10 +++++++--- lib_enc/enc_tran_fx.c | 8 +++++++- lib_enc/ivas_td_low_rate_enc_fx.c | 5 +++++ 12 files changed, 82 insertions(+), 16 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 4ad2a85a1..bbcc22e69 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -120,8 +120,11 @@ Word16 est_tilt_ivas_fx( const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr, /* i : Sub frame length */ + const Word16 L_subfr /* i : Sub frame length */ +#ifndef CLEANUP_ACELP_ENC + , const Word16 flag_tilt /* i : flag for special tilt */ +#endif ) { Word16 i, tmp, exp, ener1, exp1, ener2, exp2; @@ -161,6 +164,9 @@ Word16 est_tilt_ivas_fx( *voice_fac = exp; move16(); +#ifdef CLEANUP_ACELP_ENC + tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */ +#else IF( flag_tilt == 0 ) { /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */ @@ -180,6 +186,7 @@ Word16 est_tilt_ivas_fx( // tilt_code = (float)(0.28f + (*voice_fac + 1.0f) * 0.14f); tilt_code = mac_r( 13763L /*0.42.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4588 /*0.14.Q15*/ ); /*Q15 */ } +#endif return tilt_code; } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 90bba96d6..dc9c59896 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4851,8 +4851,11 @@ Word16 est_tilt_ivas_fx( const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr, /* i : Sub frame length */ - const Word16 flag_tilt /* i : flag for special tilt */ + const Word16 L_subfr /* i : Sub frame length */ +#ifndef CLEANUP_ACELP_ENC + , + const Word16 flag_tilt /* i : flag for special tilt */ +#endif ); /* o : tilt of the code */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index f7640abe7..3a5bc119b 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -173,13 +173,14 @@ ivas_error decod_gen_voic_fx( pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } - // tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx); tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); /*--------------------------------------------------------------* * LP filtering of the adaptive excitation *--------------------------------------------------------------*/ + lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx ); + /*-----------------------------------------------------------------* * Transform-domain contribution decoding (active frames) *-----------------------------------------------------------------*/ @@ -215,12 +216,18 @@ ivas_error decod_gen_voic_fx( { gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } + +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15 +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); // Q15 +#endif move16(); /*-----------------------------------------------------------------* * Transform domain contribution decoding *-----------------------------------------------------------------*/ + test(); IF( !st_fx->inactive_coder_type_flag && st_fx->coder_type == INACTIVE ) { @@ -368,7 +375,6 @@ ivas_error decod_gen_voic_fx( } /* FEC fast recovery */ - IF( do_WI_fx ) { /* shft_prev = L_EXC_MEM - rint_new_fx(st_fx->bfi_pitch_fx);*/ diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 645444e7d..fee0328ca 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -202,12 +202,15 @@ void dec_pit_exc_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); +#endif move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ { - /*inov_decode_fx(st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx);*/ inov_decode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, 0, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); /*--------------------------------------------------------------* @@ -217,7 +220,11 @@ void dec_pit_exc_fx( gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); +#endif move16(); } ELSE @@ -250,6 +257,7 @@ void dec_pit_exc_fx( /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ + Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx, L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type ); diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index b00b445d7..294b67ff3 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -87,6 +87,7 @@ void decod_tran_fx( move16(); set16_fx( code_preQ_fx, 0, L_SUBFR ); // Q10 + /*----------------------------------------------------------------* * ACELP subframe loop *----------------------------------------------------------------*/ @@ -118,9 +119,11 @@ void decod_tran_fx( transition_dec_fx( st_fx, 0, L_frame_fx, i_subfr, tc_subfr_fx, &Jopt_flag, exc_fx, &T0, &T0_frac, &T0_min, &T0_max, &pt_pitch_fx, &position, bwe_exc_fx, &st_fx->Q_exc ); + /*-----------------------------------------------------------------* * Transform domain contribution decoding - active frames *-----------------------------------------------------------------*/ + IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { gain_code_fx = 0; @@ -176,13 +179,18 @@ void decod_tran_fx( { lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); +#endif move16(); } /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ + test(); test(); test(); @@ -219,6 +227,7 @@ void decod_tran_fx( /*-----------------------------------------------------------------* * Add the ACELP pre-quantizer contribution *-----------------------------------------------------------------*/ + IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { IF( ( st_fx->element_mode == EVS_MONO ) ) @@ -244,6 +253,7 @@ void decod_tran_fx( /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ + Word16 tmp_idx_2; tmp_idx_2 = 0; move16(); diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index b5c10232c..f941af18c 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -5,6 +5,8 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ + + static void gain_dec_gacelp_uv_fx( Word16 index, /* i : Quantization index vector Q0 */ Word16 *code, /* i : algebraic code excitation Q9 */ @@ -90,19 +92,18 @@ void decod_unvoiced_fx( * Innovation decoding *--------------------------------------------------------------*/ - // inov_decode(st, st->core_brate, 0, L_FRAME, 1, i_subfr, p_Aq, st->tilt_code, *pt_pitch, code, L_SUBFR); inov_decode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_SUBFR ); /*-------------------------------------------------------* * Generate Gaussian excitation * *-------------------------------------------------------*/ - // gaus_L2_dec_flt(code2, st->tilt_code, p_Aq, FORMANT_SHARPENING_G1_FLT, &(st->seed_acelp)); gaus_L2_dec( code2_fx, st_fx->tilt_code_fx, p_Aq_fx, FORMANT_SHARPENING_G1, &( st_fx->seed_acelp ) ); /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ + Word16 tmp_idx_1; tmp_idx_1 = 0; move16(); @@ -115,7 +116,11 @@ void decod_unvoiced_fx( gain_dec_gacelp_uv_fx( index, code_fx, code2_fx, Es_pred_fx, L_SUBFR, &gain_pit_fx, &gain_code_fx, &gain_code2_fx, &( st_fx->past_gpit ), &norm_gain_code_fx, &gain_inov_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); +#endif move16(); /* update LP filtered gains for the case of frame erasures */ diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 8c2893934..d7d3908a0 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -248,9 +248,6 @@ void decod_gen_2sbfr_fx( error = 0; move16(); - move16(); - move16(); - move16(); /*------------------------------------------------------------------* * ACELP subframe loop *------------------------------------------------------------------*/ @@ -276,6 +273,7 @@ void decod_gen_2sbfr_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ + IF( st->element_mode != EVS_MONO ) { pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -303,7 +301,12 @@ void decod_gen_2sbfr_fx( *--------------------------------------------------------------*/ gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); + +#ifdef CLEANUP_ACELP_ENC + st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */ +#else st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */ +#endif move16(); /* update LP filtered gains for the case of frame erasures */ diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 977bc099b..62cefe5e6 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -436,7 +436,7 @@ static void encod_gen_voic_core_switch_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, - h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); + h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); @@ -671,8 +671,13 @@ static void encod_gen_voic_core_switch_ivas_fx( // hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift ); // Q_new or shift ?? ->Qexc +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */ +#endif move16(); + /*-----------------------------------------------------------------* * Construct adaptive part of the excitation *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 591c6e9bb..80c2e61d3 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -713,7 +713,11 @@ void encod_gen_voic_ivas_fx( Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */ +#endif move16(); /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 7cc932164..180d9d4d5 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -394,7 +394,7 @@ void enc_pit_exc_fx( #ifdef CLEANUP_ACELP_ENC 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, 0 ); + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, 0 ); #else 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 ); @@ -418,7 +418,7 @@ void enc_pit_exc_fx( { #ifdef CLEANUP_ACELP_ENC 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, Q_new ); + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); #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 ); @@ -429,7 +429,7 @@ void enc_pit_exc_fx( { #ifdef CLEANUP_ACELP_ENC 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, 0 ); + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); #else 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 ); @@ -458,7 +458,11 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ +#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 } ELSE #endif diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 639d34048..f0e9ff18e 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -598,7 +598,7 @@ Word16 encod_tran_ivas_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); @@ -644,7 +644,13 @@ Word16 encod_tran_ivas_fx( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); + +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + move16(); +#else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 +#endif /*-----------------------------------------------------------------* * Update memory of the weighting filter diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 6773a8839..8c60c2a2c 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -352,7 +352,12 @@ void encod_gen_2sbfr( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ +#endif move16(); /*-----------------------------------------------------------------* -- GitLab From 1df39a6ba749fdede66c328c1de00b9b3e01829e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 17:12:46 +0100 Subject: [PATCH 240/750] harmonize est_tilt_ivas_fx(), under CLEANUP_ACELP_ENC --- lib_com/est_tilt_fx.c | 10 ++++++++-- lib_com/prot_fx.h | 10 ++++++++-- lib_dec/acelp_core_switch_dec_fx.c | 4 ++++ lib_dec/dec_amr_wb_fx.c | 5 +++++ lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/dec_pit_exc_fx.c | 4 ++-- lib_dec/dec_tran_fx.c | 17 ++++++++++------- lib_dec/dec_uv_fx.c | 2 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 +- lib_enc/acelp_core_switch_enc_fx.c | 4 ---- lib_enc/enc_pit_exc_fx.c | 9 +++++---- lib_enc/enc_tran_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- 13 files changed, 47 insertions(+), 26 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index bbcc22e69..71a82089a 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -33,6 +33,7 @@ /* RETURN ARGUMENTS : */ /* _ (Word16) tolt_code : tilt of the code Q15 */ /*=======================================================================*/ +#ifndef CLEANUP_ACELP_ENC Word16 est_tilt_fx( /* o : tilt of the code Q15 */ const Word16 *exc, /* i : adaptive excitation vector Qx */ const Word16 gain_pit, /* i : adaptive gain Q14 */ @@ -111,19 +112,24 @@ Word16 est_tilt_fx( /* o : tilt of the code /* RETURN ARGUMENTS : */ /* _ (Word16) tolt_code : tilt of the code Q15 */ /*=======================================================================*/ +#endif /* o : tilt of the code Q15 */ +#ifdef CLEANUP_ACELP_ENC +Word16 est_tilt_fx( +#else Word16 est_tilt_ivas_fx( +#endif const Word16 *exc, /* i : adaptive excitation vector Qx */ const Word16 gain_pit, /* i : adaptive gain Q14 */ const Word16 *code, /* i : algebraic excitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 L_subfr /* i : Sub frame length */ #ifndef CLEANUP_ACELP_ENC , - const Word16 flag_tilt /* i : flag for special tilt */ + const Word16 flag_tilt /* i : flag for special tilt */ #endif ) { diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index dc9c59896..0af0e093e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4840,9 +4840,15 @@ Word16 est_tilt_fx( const Word16 *code, /* i : algebraic exctitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ +#ifdef CLEANUP_ACELP_ENC + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ +#else + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ +#endif ); +#ifndef CLEANUP_ACELP_ENC /* o : tilt of the code Q15 */ Word16 est_tilt_ivas_fx( const Word16 *exc, /* i : adaptive excitation vector Qx */ @@ -4857,7 +4863,7 @@ Word16 est_tilt_ivas_fx( const Word16 flag_tilt /* i : flag for special tilt */ #endif ); - +#endif /* o : tilt of the code */ Word16 Est_tilt2( const Word16 *exc, /* i : adaptive excitation vector Qx */ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 2df489cc1..9a4c5536e 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -940,7 +940,11 @@ static void decod_gen_voic_core_switch_fx( /* _ (Word32*) gain_code : quantized codebook gain (Q16) */ /* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */ /* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */ +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc, L_SUBFR ); /*Q15*/ +#else st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc ); /*Q15*/ +#endif move16(); /*----------------------------------------------------------------------* diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index c65162afc..2fad171fd 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -84,6 +84,7 @@ void decod_amr_wb_fx( *--------------------------------------------------------------*/ lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr, L_SUBFR, L_FRAME, lp_flag, exc_fx ); + /*--------------------------------------------------------------* * Innovation decoding *--------------------------------------------------------------*/ @@ -100,7 +101,11 @@ void decod_amr_wb_fx( /* update LP filtered gains for the case of frame erasures */ lp_gain_updt_fx( i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); +#else st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); +#endif move16(); Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_SUBFR, 0, diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 3a5bc119b..d1e4a564d 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -218,7 +218,7 @@ ivas_error decod_gen_voic_fx( } #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15 + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15 #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); // Q15 #endif diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index fee0328ca..067db4fcd 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -203,7 +203,7 @@ void dec_pit_exc_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); #endif @@ -221,7 +221,7 @@ void dec_pit_exc_fx( gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); #endif diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 294b67ff3..d9dfd9505 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -119,7 +119,7 @@ void decod_tran_fx( transition_dec_fx( st_fx, 0, L_frame_fx, i_subfr, tc_subfr_fx, &Jopt_flag, exc_fx, &T0, &T0_frac, &T0_min, &T0_max, &pt_pitch_fx, &position, bwe_exc_fx, &st_fx->Q_exc ); - + /*-----------------------------------------------------------------* * Transform domain contribution decoding - active frames *-----------------------------------------------------------------*/ @@ -171,22 +171,25 @@ void decod_tran_fx( IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); - +#ifndef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); move16(); +#endif } ELSE { lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); - -#ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); -#else +#ifndef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); -#endif move16(); +#endif } +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); + move16(); +#endif + /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index f941af18c..a0dd73994 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -117,7 +117,7 @@ void decod_unvoiced_fx( gain_dec_gacelp_uv_fx( index, code_fx, code2_fx, Es_pred_fx, L_SUBFR, &gain_pit_fx, &gain_code_fx, &gain_code2_fx, &( st_fx->past_gpit ), &norm_gain_code_fx, &gain_inov_fx ); #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); #endif diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index d7d3908a0..377160d06 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -303,7 +303,7 @@ void decod_gen_2sbfr_fx( gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); #ifdef CLEANUP_ACELP_ENC - st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */ + st->tilt_code_fx = est_tilt_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */ #else st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */ #endif diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 62cefe5e6..5e9dc4cd8 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -671,11 +671,7 @@ static void encod_gen_voic_core_switch_ivas_fx( // hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift ); // Q_new or shift ?? ->Qexc -#ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); /* Q15 */ -#else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */ -#endif move16(); /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 180d9d4d5..7dd7d0e4b 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -453,22 +453,23 @@ void enc_pit_exc_fx( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); + IF( use_fcb != 0 ) { +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ +#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ -#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 } ELSE #endif { hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ } +#endif move16(); } ELSE diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index f0e9ff18e..9a371b5a0 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -646,7 +646,7 @@ Word16 encod_tran_ivas_fx( gcode16 = round_fx_sat( Lgcode ); #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 move16(); #else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 8c60c2a2c..98a526b06 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -354,7 +354,7 @@ void encod_gen_2sbfr( gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ + hLPDmem->tilt_code = est_tilt_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ #else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ #endif -- GitLab From 63c48a8376c2f03a05eb3a5b34d1f65729f27012 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 17:30:45 +0100 Subject: [PATCH 241/750] clang-format --- lib_com/prot_fx.h | 4 +- lib_dec/dec_gen_voic_fx.c | 2 +- lib_enc/enc_amr_wb_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_uv_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 6 +- lib_enc/prot_fx_enc.h | 2430 ++++++++++++++--------------- 7 files changed, 1224 insertions(+), 1224 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0af0e093e..0396634e9 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4841,8 +4841,8 @@ Word16 est_tilt_fx( const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ #ifdef CLEANUP_ACELP_ENC - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #else const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ #endif diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index d1e4a564d..d92e66a94 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -180,7 +180,7 @@ ivas_error decod_gen_voic_fx( *--------------------------------------------------------------*/ lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx ); - + /*-----------------------------------------------------------------* * Transform-domain contribution decoding (active frames) *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index d3f0636ae..022483f82 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -176,7 +176,7 @@ void encod_amr_wb_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, - exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); + exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 80c2e61d3..b7ceb81bc 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -672,7 +672,7 @@ void encod_gen_voic_ivas_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 86215f5b8..2b0bd02ba 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -374,7 +374,7 @@ void encod_unvoiced_ivas_fx( *----------------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_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 98a526b06..5290ecd22 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -332,7 +332,7 @@ void encod_gen_2sbfr( * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode ); + gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode ); IF( st->Opt_SC_VBR ) { @@ -350,8 +350,8 @@ void encod_gen_2sbfr( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #ifdef CLEANUP_ACELP_ENC hLPDmem->tilt_code = est_tilt_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index f33abae3f..2792fbdcf 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3566,1236 +3566,1236 @@ Word16 inov_encode_fx( const Word16 shift, const Word16 Q_new ); - void gain_enc_mless_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ - ); - - void updt_IO_switch_enc_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 input_frame /* i : i frame length */ - ); - - void hf_cod_init_fx( - Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ - Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ - Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ - Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ - Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ - ); - - void analy_lp_AMR_WB_fx( - const Word16 speech[], /* i : pointer to the speech frame Q_new*/ - Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ - Word16 A[], /* o : A(z) filter coefficients Q14*/ - Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 isp_new[], /* o : current frame ISPs Q15*/ - Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ - Word16 isf_new[], /* o : current frame ISPs Q15*/ - Word16 Top, /* i : open loop pitch lag Q0*/ - Word16 Tnc, /* i : open loop pitch gain Qx*/ - const Word16 Q_new, - Word16 *Q_r ); - - void encod_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 speech[], /* i : i speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *syn, /* i/o: core synthesis st->Q_syn*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ - Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ - const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ - const Word16 shift, - const Word16 Q_new ); - - void re8_cod_fx( - Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ - UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ - Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ - ); - - void TBEreset_enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 last_core, /* i : last core */ - Word16 bandwidth /* i : bandwidth mode */ - ); - - void acelp_core_switch_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - const Word16 shift, - const Word16 Q_new ); +void gain_enc_mless_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 scaling */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ +); + +void updt_IO_switch_enc_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 input_frame /* i : i frame length */ +); + +void hf_cod_init_fx( + Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ + Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ + Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ + Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ + Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ +); + +void analy_lp_AMR_WB_fx( + const Word16 speech[], /* i : pointer to the speech frame Q_new*/ + Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ + Word16 A[], /* o : A(z) filter coefficients Q14*/ + Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 isp_new[], /* o : current frame ISPs Q15*/ + Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ + Word16 isf_new[], /* o : current frame ISPs Q15*/ + Word16 Top, /* i : open loop pitch lag Q0*/ + Word16 Tnc, /* i : open loop pitch gain Qx*/ + const Word16 Q_new, + Word16 *Q_r ); + +void encod_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 speech[], /* i : i speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *syn, /* i/o: core synthesis st->Q_syn*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ + const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ + const Word16 shift, + const Word16 Q_new ); + +void re8_cod_fx( + Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ + UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ + Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ +); + +void TBEreset_enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ +); + +void acelp_core_switch_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + const Word16 shift, + const Word16 Q_new ); #ifndef CLEANUP_ACELP_ENC - void acelp_core_switch_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - Word16 shift, - Word16 Q_new ); +void acelp_core_switch_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + Word16 shift, + Word16 Q_new ); #endif - void gain_enc_amr_wb_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 Q_xn, /* i : xn and yy1 format */ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ - ); - - void hf_cod_fx( - const Word32 core_brate_fx, /* i : core bitrate */ - const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ - const Word16 Aq_fx[], /* i : quantized Aq */ - const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ - Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ - Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ - Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ - Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ - Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ - Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ - const Word16 dtxHangoverCount_fx, - Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ - Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ - Word16 Q_exc, - Word16 Q_syn ); - - void transf_cdbk_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ - ); +void gain_enc_amr_wb_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 Q_xn, /* i : xn and yy1 format */ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ +); + +void hf_cod_fx( + const Word32 core_brate_fx, /* i : core bitrate */ + const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ + const Word16 Aq_fx[], /* i : quantized Aq */ + const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ + Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ + Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ + Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ + Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ + Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ + Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ + const Word16 dtxHangoverCount_fx, + Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ + Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ + Word16 Q_exc, + Word16 Q_syn ); + +void transf_cdbk_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ +); #ifndef CLEANUP_ACELP_ENC - void transf_cdbk_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ - ); +void transf_cdbk_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ +); #endif - void gain_enc_lbr_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 format */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 L_subfr, /* i : subframe length Q0*/ - const Word16 element_mode /* i : mode element Q0*/ - ); - - void gain_enc_SQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 Q_xn /* i : xn and y1 scaling */ - ); - - void updt_tar_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 L /* i : subframe size */ - ); - - void updt_tar_HR_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 Qx, /* i : Scaling factor to adapt output to i */ - const Word16 L /* i : subframe size */ - ); - - Flag conv_fx( - const Word16 x[], /* i : i vector Q_new*/ - const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ - Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ - const Word16 L /* i : vector size */ - ); - - ivas_error ppp_voiced_encoder_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - SC_VBR_ENC_HANDLE hSC_VBR, - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 last_coder_type_raw, /* i : raw last_coder_type */ - const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ - Word16 *in_fx, /* i : residual signal */ - Word16 *out_fx, /* o : Quantized residual signal */ - Word16 delay_fx, /* i : open loop pitch */ - Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ - Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ - Word16 *exc_fx, /* i: previous frame quantized excitation */ - Word16 *pitch_fx, /* o: floating pitch values for each subframe */ - Word16 Qres ); - - void signalling_enc_fx( - Encoder_State *st_fx /* i : encoder state structure */ - ); - - void transition_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ - ); +void gain_enc_lbr_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 format */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 L_subfr, /* i : subframe length Q0*/ + const Word16 element_mode /* i : mode element Q0*/ +); + +void gain_enc_SQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 Q_xn /* i : xn and y1 scaling */ +); + +void updt_tar_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 L /* i : subframe size */ +); + +void updt_tar_HR_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 Qx, /* i : Scaling factor to adapt output to i */ + const Word16 L /* i : subframe size */ +); + +Flag conv_fx( + const Word16 x[], /* i : i vector Q_new*/ + const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ + Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ + const Word16 L /* i : vector size */ +); + +ivas_error ppp_voiced_encoder_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + SC_VBR_ENC_HANDLE hSC_VBR, + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 last_coder_type_raw, /* i : raw last_coder_type */ + const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ + Word16 *in_fx, /* i : residual signal */ + Word16 *out_fx, /* o : Quantized residual signal */ + Word16 delay_fx, /* i : open loop pitch */ + Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ + Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ + Word16 *exc_fx, /* i: previous frame quantized excitation */ + Word16 *pitch_fx, /* o: floating pitch values for each subframe */ + Word16 Qres ); + +void signalling_enc_fx( + Encoder_State *st_fx /* i : encoder state structure */ +); + +void transition_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ +); #ifndef CLEANUP_ACELP_ENC - void transition_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ - ); +void transition_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ +); #endif - void gain_enc_tc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - const Word16 Q_xn /* i : xn and y1 scaling */ - ); - - void gain_enc_tc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ - const Word16 Q_xn /* i : xn and y1 scaling */ - ); - - Word16 gaus_encode_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ - ); - - Word16 gaus_encode_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ - ); - - void pre_proc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_frame, /* i : frame length */ - Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ - Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ - Word16 **inp, /* o : ptr. to inp. signal in the current frame */ - Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ - Word16 *Etot, /* o : total energy */ - Word32 *ener, /* o : residual energy from Levinson-Durbin */ +void gain_enc_tc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + const Word16 Q_xn /* i : xn and y1 scaling */ +); + +void gain_enc_tc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ + const Word16 Q_xn /* i : xn and y1 scaling */ +); + +Word16 gaus_encode_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ +); + +Word16 gaus_encode_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ +); + +void pre_proc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_frame, /* i : frame length */ + Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ + Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ + Word16 **inp, /* o : ptr. to inp. signal in the current frame */ + Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ + Word16 *Etot, /* o : total energy */ + Word32 *ener, /* o : residual energy from Levinson-Durbin */ #ifndef FIX_I4_OL_PITCH - Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ + Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ #endif - Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - Word16 epsP_h[M + 1], /* o : LP prediction errors */ - Word16 epsP_l[M + 1], /* o : LP prediction errors */ - Word32 epsP[M + 1], /* o : LP prediction errors */ - Word16 lsp_new[M], /* o : LSPs at the end of the frame */ - Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ - Word16 *vad_hover_flag, - Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ - Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ - CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ - Word16 *old_exc, /* i/o: static excitation memory */ - Word16 *hq_core_type, /* o : HQ core type */ - Word16 *Q_new, - Word16 *shift, - Word16 *Q_r ); - - void swb_bwe_enc_hr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *new_input_fx, /* i : i signal */ - Word16 new_input_fx_exp, /* i : Exponent of i signal */ - const Word16 input_frame, /* i : frame length */ - const Word16 unbits /* i : number of core unused bits */ - ); - - /* o : Return index of quantization */ - Word16 gain_enc_gaus_fx( - Word32 *gain, /* i/o: Code gain to quantize Q16*/ - const Word16 bits, /* i : number of bits to quantize Q0*/ - const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ - const Word16 stepSize, /* i : Step size choice Q14*/ - const Word16 inv_stepSize /* i : Step size choice Q15*/ - ); - - void enc_pit_exc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *speech, /* i : Input speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - const Word16 Q_new, - const Word16 shift ); + Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ + Word16 epsP_h[M + 1], /* o : LP prediction errors */ + Word16 epsP_l[M + 1], /* o : LP prediction errors */ + Word32 epsP[M + 1], /* o : LP prediction errors */ + Word16 lsp_new[M], /* o : LSPs at the end of the frame */ + Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ + Word16 *vad_hover_flag, + Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ + Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ + CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ + Word16 *old_exc, /* i/o: static excitation memory */ + Word16 *hq_core_type, /* o : HQ core type */ + Word16 *Q_new, + Word16 *shift, + Word16 *Q_r ); + +void swb_bwe_enc_hr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *new_input_fx, /* i : i signal */ + Word16 new_input_fx_exp, /* i : Exponent of i signal */ + const Word16 input_frame, /* i : frame length */ + const Word16 unbits /* i : number of core unused bits */ +); + +/* o : Return index of quantization */ +Word16 gain_enc_gaus_fx( + Word32 *gain, /* i/o: Code gain to quantize Q16*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ + const Word16 stepSize, /* i : Step size choice Q14*/ + const Word16 inv_stepSize /* i : Step size choice Q15*/ +); + +void enc_pit_exc_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + const Word16 Q_new, + const Word16 shift ); #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*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ); +void enc_pit_exc_ivas_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + 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 */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); +/* o : bin where pitch contribution is significant */ +Word16 Pit_exc_contribution_len_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); #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 */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); +/* o : bin where pitch contribution is significant */ +Word16 Pit_exc_contribution_len_ivas_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + 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 */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ - ); - - Word16 pvq_core_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ - ); - void core_switching_hq_prepare_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ - const Word16 *audio /*q_audio*/ ); - - void hq_lr_enc_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ - ); - - void hq_lr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ - ); - - void hq_hr_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ - ); - - void hq_hr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ - ); - - void reordernorm_fx( - const Word16 *ynrm, /* i : quantization indices for norms Q0 */ - const Word16 *normqlg2, /* i : quantized norms Q0 */ - Word16 *idxbuf, /* o : reordered quantization indices Q0 */ - Word16 *normbuf, /* o : reordered quantized norms Q0 */ - const Word16 nb_sfm /* i : number of bands Q0 */ - ); - - void diffcod_fx( - const Word16 N, /* (i) number of sub-vectors Q0*/ - Word16 *y, /* (i/o) indices of quantized norms Q0*/ - Word16 *difidx /* (o) differential code Q0*/ - ); - - /* o : Consumed bits Q0 */ - Word16 hq_classifier_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ - ); - - /* o : Consumed bits Q0 */ - Word16 hq_classifier_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ - ); - - void diff_envelope_coding_fx( - const Word16 is_transient, /* i : transient indicator Q0 */ - const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ - const Word16 start_norm, /* i : start of envelope coding Q0 */ - Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ - Word16 *normqlg2, /* i/o: quantized norms Q0 */ - Word16 *difidx /* o : differential code Q0 */ - ); - - /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ - Word16 encode_envelope_indices_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ - ); - - void hq_generic_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas /* o : bwe excitation class */ - ); - - void normalizecoefs_fx( - Word32 *coefs, /* i : Input vector (Q12) */ - const Word16 *ynrm, /* i : quantization indices for norms */ - const Word16 num_bands, /* i : Number of bands */ - const Word16 *band_start, /* i : Start of bands */ - const Word16 *band_end, /* i : End of bands */ - Word16 *coefs_norm /* o : Normalized output vector (Q12) */ - ); - - /* o : Consumed bits */ - Word16 hvq_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 brate, /* i : Total bit rate */ - const Word16 hvq_bits, /* i : HVQ bit budget */ - const Word16 Npeaks, /* i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ - Word16 *noise_level, /* o : Quantized noise level */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q14 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ - ); - - /* o : Consumed bits */ - Word16 hvq_enc_ivas_fx( - Encoder_State *st_fx, /*i/o: encoder state structure */ - const Word32 core_brate, /*i : Total bit rate */ - const Word16 hvq_bits, /*i : HVQ bit budget */ - const Word16 Npeaks, /*i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ - Word16 *noise_level, /* o : Quantized noise level Q15 */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q12 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ - ); - - Word16 pvq_core_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ - ); - - /* o : index of noise attenuation Q0 */ - Word16 noise_adjust_fx( - const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ - const Word16 qx, /* i : Q value of coeffs_norm */ - const Word16 *bitalloc, /* i : bit allocation Q0 */ - const Word16 *sfm_start, /* i : band start Q0 */ - const Word16 *sfm_end, /* i : band end Q0 */ - const Word16 core_sfm /* i : index of the end band for core Q0 */ - ); - - ivas_error tcq_core_LR_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 inp_vector_fx[], /* x5 */ - const Word32 coefs_norm_fx[], /* Q12 */ - Word32 coefs_quant_fx[], /* Q12 */ - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *R_fx, /* Q16 */ - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - - ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector[], - const Word32 coefs_norm_fx[], - Word32 coefs_quant_fx[], - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *Rk_fx, - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - - /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ - Word16 encode_envelope_indices_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ - ); - - void diffcod_lrmdct_fx( - const Word16 N, /* i : number of sub-vectors Q0*/ - const Word16 be_ref, /* i : band energy reference Q0*/ - Word16 *y, /* i/o: indices of quantized norms Q0*/ - Word16 *difidx, /* o : differential code Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ - ); - - Word16 peak_vq_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 core_brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ - ); - - Word16 peak_vq_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ - ); - - void wb_vad_init_fx( - VAD_HANDLE hVAD /* i/o: VAD data handle */ - ); - - void noise_est_init_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ - ); - - void noise_est_init_ivas_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ - ); - - void InitSWBencBuffer_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ - ); - - void InitSWBencBuffer_ivas_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ - ); - - void ResetSHBbuffer_Enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ - ); - - Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); - - Word16 E_ACELP_hh_corr( - Word16 *x /*Q11*/, - Word16 *y /*Qy*/, - Word16 L_subfr /*Q0*/, - Word16 bits /*Q0*/ - ); - - void acelp_1t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[], /* o : filtered fixed codebook excitation */ - const Word16 L_subfr /* i : subframe length */ - ); - - void acelp_2t32_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[] /* o : filtered fixed codebook excitation */ - ); - - Word16 acelp_4t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 cn[], /* i : residual after long term prediction Q_new*/ - const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ - Word16 R[], /* i : autocorrelation values */ - const Word16 acelpautoc, /* i : autocorrealtion flag */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - Word16 y[], /* o : filtered fixed codebook excitation Q9*/ - Word16 nbbits, /* i : number of bits per codebook */ - const Word16 cmpl_flag, /* i : coomplexity reduction flag */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 element_mode ); - - ivas_error evs_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *data, /* i : input signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of input samples Q0*/ - ); - - /* o: Qx y(n) */ - /* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ - Word16 noise_est_AR1_Qx( - Word16 x, /* i : Qx x(n) */ - Word16 y, /* i : Qx y(n-1) */ - Word16 alpha /* i : Q15 scaling of driving x(n) */ - ); - - /*o : Qx y( n ) */ - Word32 noise_est_AR1_Qx_32( - Word32 x, /* i : Qx x(n) */ - Word32 y, /* i : Qx y(n-1) */ - Word32 alpha /* i : Q15 scaling of driving x(n) */ - ); - - void FEC_lsf_estim_enc_fx( - Encoder_State *st_fx, /* i : Encoder static memory */ - Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ - ); - - Word32 mslvq_cng_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w, /* i : weights for LSF quantization Q10*/ - Word16 *no_scales ); - - Word32 mslvq_cng_ivas_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w /* i : weights for LSF quantization Q10*/ - ); - - void Unified_weighting_fx( - const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ - Word16 Q_ener, - const Word16 lsf_fx[], /* i : LSF vector x2.56 */ - Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ - const Word16 narrowBand, /* i : flag for Narrowband Q0*/ - const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ - const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ - const Word16 order /* i : LP order Q0*/ - ); - - Word32 qlsf_ARSN_tcvq_Enc_16k_fx( - const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ - Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ - Word16 *indice, /* o : Indices */ - const Word16 *w_fx, /* i : LSF Weights Q10 */ - const Word16 nBits, /* i : number of bits */ - Word16 safety_net /* i : safety_net flag */ - ); - - Word32 mslvq_fx( - Word16 *pTmp, /* i : M-dimensional i vector */ - Word16 *quant, /* o : quantized vector */ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - Word16 *w, /* i : weights for LSF quantization */ - Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ - Word16 mode_glb, /* i : LVQ coding mode */ - Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ - Word16 no_scales[][2] ); - - /* o : frame multi-harmonicity (1-harmonic, 0-not) */ - Word16 multi_harm_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ - ); - - /* o : frame multi-harmonicity (1-harmonic, 0-not) */ - Word16 multi_harm_ivas_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ - ); - - void pvq_encode_frame_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ - ); - - void pvq_encode_frame_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ - ); - - /*Qx o : interpolated value */ - Word16 Interpol_4( - Word16 *x, /*Qx i : i vector */ - Word16 frac /* i : fraction (-4..+3) */ - ); - - void set_ppp_mode_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ - const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ - const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ - const Word16 localVAD_he /* i : HE-SAD flag without hangover */ - ); - - void decision_matrix_enc_fx( - Encoder_State *st_fx, /* i : encoder state structure */ - Word16 *hq_core_type /* o : HQ core_fx type Q0*/ - ); - - void pvq_encode_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ - ); - - void pvq_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ - ); - - void rc_enc_init_fx( - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - Word16 tot_bits /* i : Total bit budget Q0*/ - ); - - void rc_enc_finish_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ - ); - - void rc_enc_finish_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ - - ); - - void rc_encode_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ - ); - - void rc_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ - ); - - void rc_enc_uniform_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ - ); - - void rc_enc_uniform_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ - ); - - void rc_enc_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ - ); - - void rc_enc_bits_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ - ); - - void re8_compute_base_index_fx( - const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ - const Word16 ka, /* i : Identifier of the absolute leader related to x */ - UWord16 *I /* o : index */ - ); - - void tfaCalcEnv_fx( - const Word16 *shb_speech, - Word32 *enr ); - - /* o : pitch index */ - Word16 delta_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac, /* i : pitch fraction */ - const Word16 T0_min /* i : delta search min */ - ); - - void set_impulse_fx( - const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ - const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ - Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ - Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ - Word16 *imp_shape, /* o : adaptive codebook index Q0*/ - Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ - Word32 *gain_trans_fx, /* o : transition gain Q7*/ - Word16 Q_new /* i : Current scaling */ - ); - - /* o : pitch index */ - Word16 abs_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac /* i : pitch fraction */ - ); - - ivas_error ppp_quarter_encoder_fx( - Word16 *returnFlag, /* o : return value */ - DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ - DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ - Word16 prevCW_lag, /* i : previous lag */ - DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ - const Word16 *curr_lpc_fx, /* i : LPCS */ - Word16 *lastLgainE_fx, /* i/o: last low band gain */ - Word16 *lastHgainE_fx, /* i/o: last high band gain */ - Word16 *lasterbE_fx, /* i/o: last ERB vector */ - DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ - Word16 *S_fx, /* i : sin table, Q15 */ - Word16 *C_fx, /* i : cos table, Q15 */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ - ); - - void index_lvq_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - - void index_lvq_ivas_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - const Word16 prediction_flag ); - - void copy_encoder_config_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ - ); - - void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_sp[], /* i : i signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of i samples Q0*/ - ); - - void writeLPCparam_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ - ); - - Word16 cng_energy_ivas_fx( - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidh */ - const Word16 CNG_mode, /* i : mode for DTX configuration */ - const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ - const Word16 *exc, /* i : input signal */ - const Word16 len, /* i : vector length */ - const Word16 Q_new /* i : Input scaling */ - ); - - void generate_comfort_noise_enc_ivas_fx( - Encoder_State *stcod, - Word16 Q_new, - Word16 gen_exc ); - - void SynthesisSTFT_enc_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - ivas_error write_indices_ivas_fx( - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - UWord16 *bit_stream, /* i/o: output bitstream */ - UWord16 *num_bits /* i : number of indices written to output */ - ); +Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ +); + +Word16 pvq_core_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ +); +void core_switching_hq_prepare_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ + const Word16 *audio /*q_audio*/ ); + +void hq_lr_enc_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ +); + +void hq_lr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ +); + +void hq_hr_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ +); + +void hq_hr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ +); + +void reordernorm_fx( + const Word16 *ynrm, /* i : quantization indices for norms Q0 */ + const Word16 *normqlg2, /* i : quantized norms Q0 */ + Word16 *idxbuf, /* o : reordered quantization indices Q0 */ + Word16 *normbuf, /* o : reordered quantized norms Q0 */ + const Word16 nb_sfm /* i : number of bands Q0 */ +); + +void diffcod_fx( + const Word16 N, /* (i) number of sub-vectors Q0*/ + Word16 *y, /* (i/o) indices of quantized norms Q0*/ + Word16 *difidx /* (o) differential code Q0*/ +); + +/* o : Consumed bits Q0 */ +Word16 hq_classifier_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ +); + +/* o : Consumed bits Q0 */ +Word16 hq_classifier_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ +); + +void diff_envelope_coding_fx( + const Word16 is_transient, /* i : transient indicator Q0 */ + const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ + const Word16 start_norm, /* i : start of envelope coding Q0 */ + Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ + Word16 *normqlg2, /* i/o: quantized norms Q0 */ + Word16 *difidx /* o : differential code Q0 */ +); + +/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ +Word16 encode_envelope_indices_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ +); + +void hq_generic_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas /* o : bwe excitation class */ +); + +void normalizecoefs_fx( + Word32 *coefs, /* i : Input vector (Q12) */ + const Word16 *ynrm, /* i : quantization indices for norms */ + const Word16 num_bands, /* i : Number of bands */ + const Word16 *band_start, /* i : Start of bands */ + const Word16 *band_end, /* i : End of bands */ + Word16 *coefs_norm /* o : Normalized output vector (Q12) */ +); + +/* o : Consumed bits */ +Word16 hvq_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 brate, /* i : Total bit rate */ + const Word16 hvq_bits, /* i : HVQ bit budget */ + const Word16 Npeaks, /* i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ + Word16 *noise_level, /* o : Quantized noise level */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q14 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ +); + +/* o : Consumed bits */ +Word16 hvq_enc_ivas_fx( + Encoder_State *st_fx, /*i/o: encoder state structure */ + const Word32 core_brate, /*i : Total bit rate */ + const Word16 hvq_bits, /*i : HVQ bit budget */ + const Word16 Npeaks, /*i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ + Word16 *noise_level, /* o : Quantized noise level Q15 */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q12 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ +); + +Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ +); + +/* o : index of noise attenuation Q0 */ +Word16 noise_adjust_fx( + const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ + const Word16 qx, /* i : Q value of coeffs_norm */ + const Word16 *bitalloc, /* i : bit allocation Q0 */ + const Word16 *sfm_start, /* i : band start Q0 */ + const Word16 *sfm_end, /* i : band end Q0 */ + const Word16 core_sfm /* i : index of the end band for core Q0 */ +); + +ivas_error tcq_core_LR_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 inp_vector_fx[], /* x5 */ + const Word32 coefs_norm_fx[], /* Q12 */ + Word32 coefs_quant_fx[], /* Q12 */ + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *R_fx, /* Q16 */ + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + +ivas_error tcq_core_LR_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word32 inp_vector[], + const Word32 coefs_norm_fx[], + Word32 coefs_quant_fx[], + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *Rk_fx, + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + +/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ +Word16 encode_envelope_indices_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ +); + +void diffcod_lrmdct_fx( + const Word16 N, /* i : number of sub-vectors Q0*/ + const Word16 be_ref, /* i : band energy reference Q0*/ + Word16 *y, /* i/o: indices of quantized norms Q0*/ + Word16 *difidx, /* o : differential code Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ +); + +Word16 peak_vq_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 core_brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ +); + +Word16 peak_vq_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ +); + +void wb_vad_init_fx( + VAD_HANDLE hVAD /* i/o: VAD data handle */ +); + +void noise_est_init_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ +); + +void noise_est_init_ivas_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ +); + +void InitSWBencBuffer_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ +); + +void InitSWBencBuffer_ivas_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ +); + +void ResetSHBbuffer_Enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ +); + +Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); + +Word16 E_ACELP_hh_corr( + Word16 *x /*Q11*/, + Word16 *y /*Qy*/, + Word16 L_subfr /*Q0*/, + Word16 bits /*Q0*/ +); + +void acelp_1t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[], /* o : filtered fixed codebook excitation */ + const Word16 L_subfr /* i : subframe length */ +); + +void acelp_2t32_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[] /* o : filtered fixed codebook excitation */ +); + +Word16 acelp_4t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 cn[], /* i : residual after long term prediction Q_new*/ + const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ + Word16 R[], /* i : autocorrelation values */ + const Word16 acelpautoc, /* i : autocorrealtion flag */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + Word16 y[], /* o : filtered fixed codebook excitation Q9*/ + Word16 nbbits, /* i : number of bits per codebook */ + const Word16 cmpl_flag, /* i : coomplexity reduction flag */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 element_mode ); + +ivas_error evs_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *data, /* i : input signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of input samples Q0*/ +); + +/* o: Qx y(n) */ +/* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ +Word16 noise_est_AR1_Qx( + Word16 x, /* i : Qx x(n) */ + Word16 y, /* i : Qx y(n-1) */ + Word16 alpha /* i : Q15 scaling of driving x(n) */ +); + +/*o : Qx y( n ) */ +Word32 noise_est_AR1_Qx_32( + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /* i : Q15 scaling of driving x(n) */ +); + +void FEC_lsf_estim_enc_fx( + Encoder_State *st_fx, /* i : Encoder static memory */ + Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ +); + +Word32 mslvq_cng_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w, /* i : weights for LSF quantization Q10*/ + Word16 *no_scales ); + +Word32 mslvq_cng_ivas_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w /* i : weights for LSF quantization Q10*/ +); + +void Unified_weighting_fx( + const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ + Word16 Q_ener, + const Word16 lsf_fx[], /* i : LSF vector x2.56 */ + Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ + const Word16 narrowBand, /* i : flag for Narrowband Q0*/ + const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ + const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ + const Word16 order /* i : LP order Q0*/ +); + +Word32 qlsf_ARSN_tcvq_Enc_16k_fx( + const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ + Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ + Word16 *indice, /* o : Indices */ + const Word16 *w_fx, /* i : LSF Weights Q10 */ + const Word16 nBits, /* i : number of bits */ + Word16 safety_net /* i : safety_net flag */ +); + +Word32 mslvq_fx( + Word16 *pTmp, /* i : M-dimensional i vector */ + Word16 *quant, /* o : quantized vector */ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + Word16 *w, /* i : weights for LSF quantization */ + Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ + Word16 mode_glb, /* i : LVQ coding mode */ + Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ + Word16 no_scales[][2] ); + +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +Word16 multi_harm_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ +); + +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +Word16 multi_harm_ivas_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ +); + +void pvq_encode_frame_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ +); + +void pvq_encode_frame_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ +); + +/*Qx o : interpolated value */ +Word16 Interpol_4( + Word16 *x, /*Qx i : i vector */ + Word16 frac /* i : fraction (-4..+3) */ +); + +void set_ppp_mode_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ + const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ + const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ + const Word16 localVAD_he /* i : HE-SAD flag without hangover */ +); + +void decision_matrix_enc_fx( + Encoder_State *st_fx, /* i : encoder state structure */ + Word16 *hq_core_type /* o : HQ core_fx type Q0*/ +); + +void pvq_encode_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ +); + +void pvq_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ +); + +void rc_enc_init_fx( + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + Word16 tot_bits /* i : Total bit budget Q0*/ +); + +void rc_enc_finish_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ +); + +void rc_enc_finish_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ + +); + +void rc_encode_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ +); + +void rc_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ +); + +void rc_enc_uniform_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ +); + +void rc_enc_uniform_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ +); + +void rc_enc_bits_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ +); + +void rc_enc_bits_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ +); + +void re8_compute_base_index_fx( + const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ + const Word16 ka, /* i : Identifier of the absolute leader related to x */ + UWord16 *I /* o : index */ +); + +void tfaCalcEnv_fx( + const Word16 *shb_speech, + Word32 *enr ); + +/* o : pitch index */ +Word16 delta_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac, /* i : pitch fraction */ + const Word16 T0_min /* i : delta search min */ +); + +void set_impulse_fx( + const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ + const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ + Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ + Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ + Word16 *imp_shape, /* o : adaptive codebook index Q0*/ + Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ + Word32 *gain_trans_fx, /* o : transition gain Q7*/ + Word16 Q_new /* i : Current scaling */ +); + +/* o : pitch index */ +Word16 abs_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac /* i : pitch fraction */ +); + +ivas_error ppp_quarter_encoder_fx( + Word16 *returnFlag, /* o : return value */ + DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ + DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ + Word16 prevCW_lag, /* i : previous lag */ + DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ + const Word16 *curr_lpc_fx, /* i : LPCS */ + Word16 *lastLgainE_fx, /* i/o: last low band gain */ + Word16 *lastHgainE_fx, /* i/o: last high band gain */ + Word16 *lasterbE_fx, /* i/o: last ERB vector */ + DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ + Word16 *S_fx, /* i : sin table, Q15 */ + Word16 *C_fx, /* i : cos table, Q15 */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +); + +void index_lvq_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + +void index_lvq_ivas_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + const Word16 prediction_flag ); + +void copy_encoder_config_fx( + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_State *st, /* o : encoder state structure */ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ +); + +void amr_wb_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_sp[], /* i : i signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of i samples Q0*/ +); + +void writeLPCparam_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ +); + +Word16 cng_energy_ivas_fx( + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidh */ + const Word16 CNG_mode, /* i : mode for DTX configuration */ + const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ + const Word16 *exc, /* i : input signal */ + const Word16 len, /* i : vector length */ + const Word16 Q_new /* i : Input scaling */ +); + +void generate_comfort_noise_enc_ivas_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc ); + +void SynthesisSTFT_enc_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +ivas_error write_indices_ivas_fx( + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + UWord16 *bit_stream, /* i/o: output bitstream */ + UWord16 *num_bits /* i : number of indices written to output */ +); #endif -- GitLab From a0501b1d2400927c129fbad118cfc268760800e6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 18:43:33 +0100 Subject: [PATCH 242/750] harmonize encod_unvoiced_fx(), under CLEANUP_ACELP_ENC --- lib_enc/acelp_core_enc_fx.c | 21 ++++++++++- lib_enc/enc_uv_fx.c | 69 +++++++++++++++++++++++++++++-------- lib_enc/prot_fx_enc.h | 4 +-- 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index b21bc566b..716313065 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -95,12 +95,17 @@ ivas_error acelp_core_enc_fx( ivas_error error; error = IVAS_ERR_OK; + +#ifdef CLEANUP_ACELP_ENC + (void) hStereoTD; +#else test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && LE_32( st_fx->core_brate, SID_2k40 ) ) { /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */ return error; } +#endif /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -196,6 +201,7 @@ ivas_error acelp_core_enc_fx( move16(); } +#ifndef CLEANUP_ACELP_ENC /* TD stereo */ test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) @@ -206,21 +212,25 @@ ivas_error acelp_core_enc_fx( tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf_fx; } ELSE +#endif { tdm_lp_reuse_flag = 0; tdm_low_rate_mode = 0; move16(); move16(); +#ifndef CLEANUP_ACELP_ENC if ( EQ_16( st_fx->element_mode, IVAS_SCE ) && st_fx->low_rate_mode ) { tdm_low_rate_mode = 1; move16(); } +#endif tdm_Pitch_reuse_flag = 0; tdm_Pri_pitch_buf = NULL; move16(); move16(); } + /*-----------------------------------------------------------------* * ACELP@12k8 / ACELP@16k switching *-----------------------------------------------------------------*/ @@ -551,21 +561,26 @@ ivas_error acelp_core_enc_fx( E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &hLPDmem->syn[M] ); Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn +#ifndef CLEANUP_ACELP_ENC test(); IF( st_fx->element_mode > EVS_MONO && st_fx->hTcxEnc != NULL ) { Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 ); // Q_syn } - +#endif /*--------------------------------------------------------------------------------------* * Modify the excitation signal when the noise is stationary *--------------------------------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + IF( NE_16( nelp_mode, 1 ) ) +#else test(); test(); test(); test(); IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) +#endif { L_epsP[0] = L_Comp( epsP_h_fx[2], epsP_l_fx[2] ); move32(); @@ -1335,7 +1350,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ +#ifdef CLEANUP_ACELP_ENC + encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); +#else encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); +#endif } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 2b0bd02ba..3b81f4f5d 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -16,7 +16,7 @@ * * Encode unvoiced (UC) frames *-------------------------------------------------------------------*/ - +#ifndef CLEANUP_ACELP_ENC void encod_unvoiced_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ @@ -247,22 +247,26 @@ void encod_unvoiced_fx( return; } +#endif - +#ifdef CLEANUP_ACELP_ENC +void encod_unvoiced_fx( +#else void encod_unvoiced_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ + const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/ const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* o : core synthesis Q_new*/ + Word16 *syn_fx, /* o : core synthesis Q_new-1 (EVS) / Qnew*/ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ) { @@ -280,7 +284,7 @@ void encod_unvoiced_ivas_fx( Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */ Word16 code2[L_SUBFR]; /* Gaussian excitation */ Word16 y22[L_SUBFR]; /* Filtered Gaussian excitation */ - // Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; + Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */ Word32 norm_gain_code_fx; ACELP_config *acelp_cfg; @@ -329,12 +333,25 @@ void encod_unvoiced_ivas_fx( i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + + /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ + Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + } + ELSE +#endif + { + find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - q_h1 = sub( 14, norm_s( h1_fx[0] ) ); - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); - Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); + q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); + Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); + } /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift @@ -366,16 +383,31 @@ void encod_unvoiced_ivas_fx( *-----------------------------------------------------------------*/ Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn ); + *pt_pitch_fx = L_SUBFR << 6; move16(); +#ifdef CLEANUP_ACELP_ENC + if ( st_fx->element_mode == EVS_MONO ) + { + *pt_pitch_fx = L_SUBFR; + move16(); + } +#endif /*----------------------------------------------------------------------* * Encode the algebraic innovation * *----------------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); + IF( st_fx->element_mode == EVS_MONO ) + { + E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate ); + } + ELSE + { + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); + } #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, @@ -394,7 +426,16 @@ void encod_unvoiced_ivas_fx( move16(); assert( gain_pit_fx == 0 ); - gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); + } + ELSE +#endif + { + gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); + } /*----------------------------------------------------------* * - Compute the fixed codebook gain * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2792fbdcf..bfc2228b9 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2010,7 +2010,7 @@ void encod_unvoiced_fx( Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ); - +#ifndef CLEANUP_ACELP_ENC void encod_unvoiced_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ @@ -2027,7 +2027,7 @@ void encod_unvoiced_ivas_fx( Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ); - +#endif void enc_acelp_tcx_main_fx( const Word16 new_samples[], /* i : new samples Q15*/ Encoder_State *st, /* i/o: encoder state structure */ -- GitLab From 762921911564a020ab74bea1bf9680c3b5f5a0a0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 19:00:23 +0100 Subject: [PATCH 243/750] harmonize lp_gain_updt_fx(), under CLEANUP_ACELP_ENC --- lib_com/prot_fx.h | 8 +++++++- lib_dec/core_switching_dec_fx.c | 1 - lib_dec/dec_amr_wb_fx.c | 4 ++++ lib_dec/dec_gen_voic_fx.c | 4 ++++ lib_dec/dec_pit_exc_fx.c | 4 ++++ lib_dec/dec_tran_fx.c | 4 ++++ lib_dec/dec_uv_fx.c | 4 ++++ lib_dec/gain_dec_fx.c | 20 +++++++++++++++++--- lib_dec/gaus_dec_fx.c | 4 ++++ lib_dec/ivas_td_low_rate_dec_fx.c | 5 +++++ 10 files changed, 53 insertions(+), 5 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0396634e9..04007faf3 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6855,6 +6855,7 @@ void gain_dec_lbr_fx( const Word16 L_subfr /* i : subfr lenght */ ); +#ifndef CLEANUP_ACELP_ENC void lp_gain_updt_fx( const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ @@ -6863,8 +6864,13 @@ void lp_gain_updt_fx( Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ const Word16 L_frame /* i : length of the frame */ ); - +#endif +#ifdef CLEANUP_ACELP_ENC +void lp_gain_updt_fx( + const Word16 element_mode, /* i : element mode */ +#else void lp_gain_updt_ivas_fx( +#endif const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 8bab0d061..d1040cb80 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1302,7 +1302,6 @@ ivas_error core_switching_post_dec_ivas_fx( test(); IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { - /*needed to be converted to fixed curretnly using evs implementation not in line*/ if ( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 2fad171fd..2a977033d 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -99,7 +99,11 @@ void decod_amr_wb_fx( gain_dec_amr_wb_fx( st_fx, st_fx->core_brate, &gain_pit_fx, &L_gain_code_fx, hAmrwb_IO->past_qua_en_fx, &gain_inov_fx, code_fx, &L_norm_gain_code_fx ); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( EVS_MONO, i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#else lp_gain_updt_fx( i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#endif #ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index d92e66a94..f08c5e767 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -235,6 +235,9 @@ ivas_error decod_gen_voic_fx( } /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); +#else IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); @@ -243,6 +246,7 @@ ivas_error decod_gen_voic_fx( { lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); } +#endif /*----------------------------------------------------------------------* * Find the total excitation diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 067db4fcd..41fcb64c7 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -426,7 +426,11 @@ void dec_pit_exc_fx( move16(); pt_gain++; +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame ); +#else lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame ); +#endif } } diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index d9dfd9505..f2764e6e3 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -168,6 +168,9 @@ void decod_tran_fx( } /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); +#else IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); @@ -184,6 +187,7 @@ void decod_tran_fx( move16(); #endif } +#endif #ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index a0dd73994..9ced61d68 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -124,6 +124,9 @@ void decod_unvoiced_fx( move16(); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#else IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); @@ -132,6 +135,7 @@ void decod_unvoiced_fx( { lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); } +#endif /*-------------------------------------------------------* * - Find the total excitation. * diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 0848104af..fffead087 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -989,8 +989,7 @@ void gain_dec_lbr_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*=======================================================================*/ - - +#ifndef CLEANUP_ACELP_ENC void lp_gain_updt_fx( const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ @@ -1101,9 +1100,14 @@ void lp_gain_updt_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*=======================================================================*/ +#endif - +#ifdef CLEANUP_ACELP_ENC +void lp_gain_updt_fx( + const Word16 element_mode, /* i : element mode */ +#else void lp_gain_updt_ivas_fx( +#endif const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ @@ -1117,7 +1121,12 @@ void lp_gain_updt_ivas_fx( tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ /* To handle extremely low values */ test(); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( element_mode != EVS_MONO && norm_gain_code != 0 && tmp == 0 ) +#else if ( norm_gain_code != 0 && tmp == 0 ) +#endif { tmp = 1; move16(); @@ -1195,7 +1204,12 @@ void lp_gain_updt_ivas_fx( /* To handle extremely low values */ test(); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( element_mode != EVS_MONO && tmp != 0 && *lp_gainc == 0 ) +#else if ( tmp != 0 && *lp_gainc == 0 ) +#endif { *lp_gainc = 1; move16(); diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index d49ecb5b7..456a7a902 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -87,6 +87,9 @@ void gaus_dec_fx( move32(); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ +#else IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ @@ -95,6 +98,7 @@ void gaus_dec_fx( { lp_gain_updt_ivas_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ } +#endif /*------------------------------------------------------------------------------------------* * Updates diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 377160d06..d897b116e 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -310,8 +310,13 @@ void decod_gen_2sbfr_fx( move16(); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st->element_mode, i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); + lp_gain_updt_fx( st->element_mode, add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); +#else lp_gain_updt_ivas_fx( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); lp_gain_updt_ivas_fx( add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); +#endif /*----------------------------------------------------------------------* * Find the total excitation -- GitLab From 602321e1cb77a9de597acfb25cc7b3b4e9f8ecb7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 19:21:22 +0100 Subject: [PATCH 244/750] fix --- lib_enc/enc_pit_exc_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 7dd7d0e4b..b40bab692 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -456,20 +456,20 @@ void enc_pit_exc_fx( IF( use_fcb != 0 ) { -#ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ -#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ +#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 } ELSE #endif { hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ } -#endif move16(); } ELSE -- GitLab From 374d8c89505fe72ea3850b2133429cd290896da2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 20:50:37 +0100 Subject: [PATCH 245/750] harmonize tbe_celp_exc(), under CLEANUP_ACELP_ENC --- lib_com/prot_fx.h | 16951 ++++++++++++++-------------- lib_com/swb_tbe_com_fx.c | 49 +- lib_dec/dec_ace_fx.c | 4 + lib_dec/dec_gen_voic_fx.c | 5 + lib_dec/ivas_td_low_rate_dec_fx.c | 4 + lib_enc/cod_ace_fx.c | 4 + lib_enc/enc_gen_voic_fx.c | 9 +- lib_enc/ivas_td_low_rate_enc_fx.c | 4 + 8 files changed, 8549 insertions(+), 8481 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 04007faf3..f78f12025 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2910,6 +2910,7 @@ Word16 tbe_celp_exc_offset( const Word16 L_frame /* i : frame lenght */ ); +#ifndef CLEANUP_ACELP_ENC void tbe_celp_exc( const Word16 L_frame_fx, /* i : Frame lenght */ const Word16 i_subfr_fx, /* i : sub frame */ @@ -2918,8 +2919,12 @@ void tbe_celp_exc( Word16 *error_fx, /* i/o: Error */ Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */ ); - +#endif +#ifdef CLEANUP_ACELP_ENC +void tbe_celp_exc( +#else void tbe_celp_exc_ivas( +#endif const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 L_frame_fx, /* i : Frame lenght */ @@ -2932,2163 +2937,2195 @@ void tbe_celp_exc_ivas( const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ ); -void flip_and_downmix_generic_fx( - Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); - -void Calc_rc0_h( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ -); - -void Calc_rc0_h_ivas_enc_fx( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ -); - -void PostShortTerm_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ -); - -void PostShortTerm_ivas_enc_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ -); - -void PostShortTerm_ivas_dec_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ -); - -void flip_spectrum_and_decimby4_fx( - const Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : vector length */ - Word16 mem1[], /* i/o : memory */ - Word16 mem2[], /* i/o : memory */ - const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ -); - -void GenShapedWBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb exctiation */ - const Word16 *lpc_shb, /* i : lpc coefficients */ - Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ - Word32 *mem_csfilt, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ - Word16 *state_lpc_syn, /* i/o : memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_bwe_exc, - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor */ - const Word16 signal_type, - const Word16 igf_flag ); - -void GenWBSynth_fx( - const Word16 *input_synspeech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_16k, /* o : output highband compnent */ - Word16 *state_lsyn_filt_shb1, /* i/o: memory */ - Word16 *state_lsyn_filt_shb2 /* i/o: memory */ -); - -void GenShapedSHBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi ); - -void GenShapedSHBExcitation_ivas_enc_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word16 Q_EnvSHBres_4k, - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -); - -void GenShapedSHBExcitation_ivas_dec_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -); - -void GenSHBSynth_fx( - const Word16 *shb_target_speech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP Frame length */ - Word16 *syn_dm_phase ); - -void GenSHBSynth_fx32( - const Word32 *input_synspeech, /* i : input synthesized speech */ - Word32 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP frame length */ - Word16 *syn_dm_phase ); - -void ScaleShapedSHB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o: synthesized shb signal */ - Word16 *overlap, /* i/o: buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - Word16 *Q_bwe_exc, - Word16 *Qx, - Word16 n_mem3, - Word16 prev_Q_bwe_syn2 ); - -void ScaleShapedSHB_fx32( - const Word16 length, /* i : SHB overlap length */ - Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ - Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ - const Word16 *subgain_fx, /* i : subframe gain Q15 */ - const Word32 frame_gain_fx, /* i : frame gain */ - const Word16 *win_fx, /* i : window Q15 */ - const Word16 *subwin_fx, /* i : subframes window Q15 */ - Word16 *Q_inp, - Word16 *Q_new ); - -void ScaleShapedWB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o : synthesized shb signal */ - Word16 *overlap, /* i/o : buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - const Word16 Q_bwe_exc, - Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ - Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ - Word16 *Qx, /* o : newly computed Q factor for synSHB */ - Word16 prev_Qx, /* i : prev_Qx for memory scaling */ - Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ -); - -void non_linearity_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ -); - -void non_linearity_ivas_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ -); - -void interp_code_5over2_fx( - const Word16 inp_code[], /* i : i vector */ - Word16 interp_code[], /* o : output vector */ - const Word16 inp_length /* i : length of i vector */ -); - -void interp_code_4over2_fx( - const Word16 inp_code_fx[], /* i : i vector Qx */ - Word16 interp_code_fx[], /* o : output vector Qx */ - const Word16 inp_length /* i : length of i vector */ -); - -void wb_tbe_extras_reset_synth_fx( - Word16 state_lsyn_filt_shb[], - Word16 state_lsyn_filt_dwn_shb[], - Word16 state_32and48k_WB_upsample[], - Word16 state_resamp_HB[] ); - -void elliptic_bpf_48k_generic_fx( - const Word16 element_mode, - Word16 IsUpsampled3, - Word16 input_fx[], /* i : input signal Q_input_fx*/ - Word16 *Q_input_fx, - Word16 output_fx[], /* o : output signal */ - Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ - Word16 memory_fx_Q[], - const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ -); - -void synthesise_fb_high_band_fx( - const Word16 excitation_in[], /* i : full band excitation */ - Word16 Q_fb_exc, - Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ - const Word32 fb_exc_energy, /* i : full band excitation energy */ - const Word16 ratio, /* i : energy ratio */ - const Word16 L_frame, /* i : ACELP frame length */ - const Word16 bfi, /* i : fec flag */ - Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ - Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ - Word16 bpf_memory_Q[], - Word16 Qout, - Word16 element_mode ); - -void prep_tbe_exc_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - const Word16 T0, /* i : integer pitch variables Q0 */ - const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ -); - -/*! r: Formant filter strength [0,1] */ -Word16 swb_formant_fac_fx( - const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ - Word16 *tilt_mem /* i/o: Tilt smoothing memory */ -); - -void wb_tbe_extras_reset_fx( - Word16 mem_genSHBexc_filt_down_wb2[], - Word16 mem_genSHBexc_filt_down_wb3[] ); - -Word16 get_tbe_bits_fx( - const Word32 total_brate, /* o : TBE bit consumption per frame */ - const Word16 bwidth, /* i : overall bitrate */ - const Word16 rf_mode /* i : bandwidht mode */ -); - -UWord32 intLimCDivPos_fx( - UWord32 NUM, /* Qx */ - Word16 DEN /* Q0 */ -); - -Word16 shrtCDivSignedApprox( - const Word16 num, /* Q0 */ - const Word16 den /* Q0 */ -); - -void obtainEnergyQuantizerDensity_fx( - const Word16 L, /* i : left vector energy Q0*/ - const Word16 R, /* i : right vector energy Q0*/ - Word16 *Density /* o : quantizer density Q0*/ -); - -void dsDirac2Dirac_fx( - const Word16 dsDiracIndex, /* Q0 */ - Word16 *diracs /* Q0 */ -); - -void dsDiracPerQuanta_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ - const Word16 dsm, /* i : Conservative rounding flag Q0*/ - const unsigned char *const *frQuanta, /* i : Quanta lookup table */ - Word16 *DsIdx /* o : Lookup table index Q0*/ -); - -void QuantaPerDsDirac_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ - const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ - Word16 *Quanta /* i : Quanta Q0*/ -); - -void conservativeL1Norm_fx( - const Word16 L, /* i : Length of vector segment Q0*/ - const Word16 Qvec, /* i : Assigned number of quanta Q0*/ - const Word16 Fcons, /* i : Conservative rounding flag Q0*/ - const Word16 Qavail, /* i : Input quanta remaining Q0*/ - const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ - const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ - Word16 *Dvec, /* o : actual number of diracs Q0*/ - Word16 *Qspare, /* o : Output quanta remaining Q0*/ - Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ - Word16 *Dspecplus /* o : Output number of diracs Q0*/ -); - -void bandBitsAdjustment_fx( - const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ - const UWord32 INTrc, /* i : Range coder state Q0*/ - const Word16 Bavail, /* i : Available number of quanta Q3*/ - const Word16 Nbands, /* i : Number of bands Q0*/ - const Word16 D, /* i : Remaining number of bands to encode Q0*/ - const Word16 L, /* i : Size of current band Q0*/ - const Word16 Bband, /* i : Quanta allocation for current band Q0*/ - const Word16 Breserv, /* i : Quanta reservoir Q0*/ - Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ - Word16 *Brem, /* o : Quanta remaining Q0*/ - Word16 *Breservplus /* o : Quanta pool size Q0*/ -); - -void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density Q0*/ - const Word16 indexphi, /* i : decoded index from AR dec Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ -); - -void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density Q0*/ - const Word16 phiQ14uq, /* i : angle Q14*/ - Word16 *indexphi, /* o : index Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ -); - -void NearOppSplitAdjustment_fx( - const Word16 qband, /* i : quanta for current band Q0*/ - const Word16 qzero, /* i : range coder finalization quanta Q0*/ - const Word16 Qac, /* i : range coder current quanta Q0*/ - const UWord32 INTac, /* i : range coder state Q0*/ - const Word16 qglobal, /* i : quanta input Q0*/ - const Word16 FlagCons, /* i : conservative rounding flag Q0*/ - const Word16 Np, /* i : number of parts Q0*/ - const Word16 Nhead, /* i : first part Q0*/ - const Word16 Ntail, /* i : remaining parts Q0*/ - const Word16 Nnear, /* i : length of near component Q0*/ - const Word16 Nopp, /* i : length of opposite component Q0*/ - Word16 oppRQ3, /* i : ratio Q0*/ - Word16 *qnear, /* o : quantized near Q0*/ - Word16 *qopp, /* o : quantized opposite Q0*/ - Word16 *qglobalupd /* o : quanta remaining Q0*/ -); - -void apply_gain_fx( - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 *band_start, /* i : Sub band start indices Q0 */ - const Word16 *band_end, /* i : Sub band end indices Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gains, /* i : Band gain vector Q12 */ - Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ -); - -void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ -); - -void srt_vec_ind16_fx( - const Word16 *linear, /* linear input Q3*/ - Word16 *srt, /* sorted output Q3*/ - Word16 *I, /* index for sorted output Q0*/ - Word16 length /* Q0 */ -); - -/* o: Angle between 0 and PI/2 radian (Q14) */ -Word16 atan2_fx( - const Word32 y, /* i : near side (Argument must be positive) (Q15) */ - const Word32 x /* i : opposite side (Q15) */ -); - -/* o: Number of bits needed Q0*/ -Word16 rc_get_bits2_fx( - const Word16 N, /* i: Number of bits currently used Q0*/ - const UWord32 range /* i: Range of range coder Q0*/ -); - -void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits Q0*/ - UWord32 INTrc, /* i : Range coder state Q0*/ - Word16 *FBits /* i : Fractional finalization bits Q0*/ -); - -ivas_error DTFS_new_fx( - DTFS_STRUCTURE **dtfs_out ); - -void DTFS_copy_fx( - DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ - DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ -); - -void DTFS_sub_fx( - DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ - DTFS_STRUCTURE X1, /* i: DTFS i 1 */ - DTFS_STRUCTURE X2 /* i: DTFS i 2 */ -); - -Word16 DTFS_alignment_full_fx( - DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ - DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ - Word16 ph_offset_fx, /* i : resolution */ - Word16 *S_fx, - Word16 *C_fx, - Word16 FR_flag ); - -void DTFS_phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - -void Q2phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - -void DTFS_zeroPadd_fx( - Word16 N_fx, - DTFS_STRUCTURE *X_fx ); - -void DTFS_to_fs_fx( - const Word16 *x, /* i : time domain signal */ - Word16 N, /* i : Length of i vector */ - DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ - const Word16 Fs, /* i : sampling rate */ - const Word16 FR_flag, /* i : FR flag */ - Word16 *S_fx, - Word16 *C_fx ); - -void DTFS_zeroFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - -void DTFS_poleFilter_fx_9( - DTFS_STRUCTURE *X_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - -void DTFS_adjustLag_fx( - DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ - Word16 N_fx /* i : Target lag */ -); - -Word32 DTFS_getEngy_fx( - DTFS_STRUCTURE *X_fx ); - -Word32 DTFS_getEngy_P2A_fx( - DTFS_STRUCTURE *X_fx ); - -void DTFS_car2pol_fx( - DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ -); - -Word32 DTFS_setEngyHarm_fx( - Word16 f1_fx, /* i : lower band freq of i to control energy */ - Word16 f2_fx, /* i : upper band freq of i to control energy */ - Word16 g1_fx, /* i : lower band freq of output to control energy */ - Word16 g2_fx, /* i : upper band freq of output to control energy */ - Word32 en2_fx, /* i : Target Energy to set the DTFS to */ - Word16 Qen2_fx, /* i : Input Q format for en2 */ - Word16 *Qa_fx, /* i : Output Q format for x->a */ - DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ -); - -void DTFS_to_erb_fx( - const DTFS_STRUCTURE X_fx, /* i : DTFS i */ - Word16 *out_fx /* o : ERB output */ -); - -void erb_slot_fx( - Word16 lag_fx, /* i : i lag */ - Word16 *out_fx, /* o : ERB slots */ - Word16 *mfreq_fx, /* i : ERB frequencies */ - Word16 num_erb_fx /* i : number of ERBs */ -); - -void DTFS_erb_inv_fx( - Word16 *in_fx, /* i : ERB inpt */ - Word16 *slot_fx, /* i : ERB slots filled based on lag */ - Word16 *mfreq_fx, /* i : erb frequence edges */ - DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ - Word16 num_erb_fx /* i : Number of ERB bands */ -); - -void erb_add_fx( - Word16 *curr_erb_fx, /* i/o: current ERB */ - Word16 l_fx, /* i : current lag */ - const Word16 *prev_erb_fx, /* i : previous ERB */ - Word16 pl_fx, /* i : previous lag */ - const Word16 *index_fx, /* i : ERB index */ - Word16 num_erb_fx /* i : number of ERBs */ -); - -void quant_target_fx( - DTFS_STRUCTURE *X_fx, - const Word16 *curr_lpc, - Word16 *w, - Word16 *target, - Word16 *sin_tab, - Word16 *cos_tab ); - -ivas_error WIsyn_fx( - DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ - DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ - const Word16 *curr_lpc_fx, /* i : LPC */ - Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ - Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ - const Word16 N, /* i : Number of output samples to generate */ - const Word16 FR_flag, /* i : called for post-smoothing in FR */ - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2 ); - -Word16 ppp_extract_pitch_period_fx( - const Word16 *in, /* i : i residual */ - Word16 *out, /* o : output residual */ - Word16 l, /* i : lag */ - Word16 *out_of_bound, /* o : out of bound flag */ - Word16 Qres ); - -void DTFS_peaktoaverage_fx( - DTFS_STRUCTURE X_fx, /* i : DTFS */ - Word32 *pos_fx, /* o : positive peak to ave */ - Word16 *Qpos, /* o : positive peak to ave Q format */ - Word32 *neg_fx, /* o : negative peak to ave */ - Word16 *Qneg /* o : negative peak to ave Q format */ -); - -void rshiftHarmBand_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband_fx, - Word16 hband_fx, - Word16 shift_fx ); - -void GetSinCosTab_fx( - Word16 L, - Word16 *sinTab, - Word16 *cosTab ); - -void r_fft_4_fx( - Word16 *farray_ptr_fx, - Word16 size, - Word16 stage, - Word16 isign ); - -void copy_phase_fx( - DTFS_STRUCTURE *X1_fx, - DTFS_STRUCTURE X2_fx, - DTFS_STRUCTURE *retX_fx ); - -Word32 getSpEngyFromResAmp_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband, - Word16 hband, - const Word16 *curr_lpc, - Word16 *sin_tab, - Word16 *cos_tab ); - -void DTFS_poleFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - -void poleFilter_setup_fx( - const Word16 *LPC, - Word16 N, - DTFS_STRUCTURE X_fx, - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - -Word32 DTFS_getEngy_band_wb_fx( - DTFS_STRUCTURE X_fx, - Word16 lband, - Word16 hband ); - -void InitTnsConfiguration( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void InitTnsConfiguration_ivas_fx( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void ApplyTnsFilter( - STnsConfig const *pTnsConfig, - STnsData const *pTnsData, - Word32 spectrum[], - const Word8 fIsAnalysis ); - -Word16 ITF_Detect_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); - -Word16 ITF_Detect_ivas_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); - -void ITF_Apply_fx( - Word32 spectrum[], - Word16 startLine, - Word16 stopLine, - const Word16 *A, - Word16 Q_A, - Word16 curr_order ); - -void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); - -Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - -Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - -Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); - -Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); - -Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - -Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - -Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - -void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); - -Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); - -Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); - -Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); - -Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); - -Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); - -Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); - -Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); - -void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); - -void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); - -void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); - -void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); - -void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); -void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); - -void ResetTnsData( STnsData *pTnsData ); - -void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); - -/*========================================================================================================/ -gp_clips_fx.c -/========================================================================================================*/ - -void init_gp_clip_fx( - Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ -); - -Word16 gp_clip_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 coder_type, /* i : type of coder Q0*/ - const Word16 xn[], /* i : target vector Q_new*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Q_new /* i : scaling factor */ -); - -void gp_clip_test_isf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ -); - -void gp_clip_test_gain_pit_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ - Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ -); - -Word16 Mode2_gp_clip_fx( - const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 coder_type, /* i : type of coder Q0 */ - const Word16 xn[], /* i : target vector Q_xn */ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ - /* mem[0]: Q0 */ - /* mem[1]: 1Q14 */ - /* mem[2]: 8Q7 */ - /* mem[3]: Q0 (integer) */ - /* mem[4]: Q14 */ - /* mem[5]: Q14 */ - const Word16 L_subfr, /* Q0 */ - const Word16 Q_xn /* i : scaling factor of vector xn[] */ -); - -void gp_clip_test_lsf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 m /* i : dimension of lsf Q0*/ -); - -void gp_clip_test_lsf_ivas_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ -); - -/*========================================================================================================/ -nelp_enc_fx.c -/========================================================================================================*/ - -void quantize_uvg_fx( - Word16 *G, - Word16 *iG1, - Word16 *iG2, - Word16 *quantG, - Word16 bandwidth ); - -void nelp_encoder_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - -void nelp_encoder_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - -void swb_bwe_enc_lr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -); - -void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -); - -void isf_enc_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *isf_new, /* i/o: quantized ISF vector */ - Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ - Word16 *Aq /* o : quantized A(z) for 4 subframes */ -); - -Word16 detect_transient_fx( - const Word16 *in_fx, /*Q_new */ - const Word16 L, /*Q0*/ - Word16 Q_new, - Encoder_State *st_fx ); - -Word16 tcxGetNoiseFillingTilt( - const Word16 A[], - const Word16 lpcorder, - const Word16 L_frame, - const Word16 mode, - Word16 *noiseTiltFactor ); - -void tcxFormantEnhancement( - Word16 xn_buf[], - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - -void tcxFormantEnhancement_with_shift( - Word16 xn_buf[], - Word16 *xn_buf_e, - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - -void tcxInvertWindowGrouping( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word32 xn_buf[], - Word32 spectrum[], - const Word16 L_frame, - const Word8 fUseTns, - const Word16 last_core, - const Word16 index, - const Word16 frame_cnt, - const Word16 bfi ); - -void permute_fx( - Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ - const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ -); - -void init_lvq_fx( - Word32 offset_scale1[][MAX_NO_SCALES + 1], - Word32 offset_scale2[][MAX_NO_SCALES + 1], - Word32 offset_scale1_p[][MAX_NO_SCALES + 1], - Word32 offset_scale2_p[][MAX_NO_SCALES + 1], - Word16 no_scales[][2], - Word16 no_scales_p[][2] ); - -Word16 deindex_lvq_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ - Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, /* i : offset for first subvector */ - Word32 *p_offset_scale2, /* i : offset for the second subvector */ - Word16 *p_no_scales ); - -Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ -); - -Word16 deindex_lvq_cng_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q9*/ - Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - -Word16 deindex_lvq_cng_ivas_fx( - Word16 *index, /* i: index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o: decoded codevector Q9 */ - Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ - Word16 no_bits /* i: number of bits for lattice */ -); - -Word16 lsp_convert_poly_fx( - Word16 w[], /* i/o: LSP or ISP parameters */ - const Word16 L_frame, /* i : flag for up or down conversion */ - const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ -); - -void CNG_exc_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 L_frame, /* i : length of the frame */ - Word32 *Enew, /* i/o: decoded SID energy Q6 */ - Word16 *seed, /* i/o: random generator seed */ - Word16 exc[], /* o : current non-enhanced excitation Q_new */ - Word16 exc2[], /* o : current enhanced excitation Q_new */ - Word32 *lp_ener, /* i/o: LP filtered E */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ - Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ - Word16 bwe_exc[], /* o : excitation for SWB TBE */ - const Word16 allow_cn_step, /* i : allow CN step */ - Word16 *last_allow_cn_step, /* i/o: last allow step */ - const Word16 OldQ_exc, /* i : Old excitation scaling */ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 num_ho, /* i : number of selected hangover frames */ - Word32 q_env[], - Word32 *lp_env, - Word32 *old_env, - Word16 *exc_mem, - Word16 *exc_mem1, - Word16 *sid_bw, - Word16 *cng_ener_seed1, - Word16 exc3[], - Word16 Opt_AMR_WB, - const Word16 element_mode /* i : IVAS Element mode */ -); - -void cng_params_postupd_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer */ -); - -void cng_params_postupd_ivas_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ -); - -void cng_params_upd_fx( - const Word16 lsp_new[], /* i : LSP parameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ -); - -void cng_params_upd_ivas_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate, /* i : Last active bit rate Q0 */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ -); - -Word16 get_cng_mode( - const Word32 last_active_brate /* i : last active bitrate */ -); - -/*! r: codec mode */ -Word16 get_codec_mode( - const Word32 total_brate /* i : total bitrate */ -); - -Word16 getTcxonly( - const Word32 total_brate /* i : total bitrate */ -); - -Word16 getTcxonly_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ -); - -Word16 getCtxHm( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_flag /* i : flag to signal the RF mode */ -); - -Word16 getResq( - const Word32 total_brate /* i : total bitrate */ -); - -Word16 getTnsAllowed( - const Word32 total_brate, /* i : total bitrate */ - const Word16 igf, /* i : flag indicating IGF activity*/ - const Word16 element_mode /* i : IVAS element mode */ -); - -Word16 getRestrictedMode( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - -Word16 getMdctWindowLength_fx( - const Word16 fscale ); - -Word16 sr2fscale_fx( - const Word32 sr_core /* i : internal sampling rate */ -); - -Word32 getCoreSamplerateMode2( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ -); - -Word16 getTcxBandwidth( - const Word16 bandwidth ); - -Word16 getIgfPresent_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -Word16 getCnaPresent_fx( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth /* i : audio bandwidth */ -); - -Word16 getTcxLtp( - const Word32 sr_core /* i : internal sampling rate */ -); - -Word16 initPitchLagParameters( - const Word32 sr_core, - Word16 *pit_min, - Word16 *pit_fr1, - Word16 *pit_fr1b, - Word16 *pit_fr2, - Word16 *pit_max ); - -Word16 getNumTcxCodedLines( - const Word16 bwidth ); - -Word16 getTcxLpcShapedAri( - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const Word16 element_mode /* i : IVAS element mode */ -); - -void mdct_window_sine( - PWord16 *window, /* Qx */ - Word16 n /* Q0 */ -); - -void mdct_window_sine_IVAS_updated( - PWord16 *window, /* Qx */ - const Word32 Fs, /* Q0 */ - const Word16 n, /* Q0 */ - const Word16 window_type, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void mdct_window_aldo( - Word16 *window1, /* Q15 */ - PWord16 *window1_trunc, /* Q15 */ - PWord16 *window2, /* Q15 */ - Word16 n /* Q0 */ -); - -Word16 getInvFrameLen( - const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ - -void tcx_get_windows( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const Word16 left_mode, /* i: overlap mode of left window half */ - const Word16 right_mode, /* i: overlap mode of right window half */ - Word16 *left_overlap, /* o: left overlap length */ - const PWord16 **left_win, /* o: left overlap window */ - Word16 *right_overlap, /* o: right overlap length */ - const PWord16 **right_win, /* o: right overlap window */ - const Word8 fullband /* i: fullband flag */ -); - -void WindowSignal( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 offset, /* i : left folding point offset relative to the i signal pointer */ - const Word16 left_overlap_mode, /* i : overlap mode of left window half */ - Word16 right_overlap_mode, /* i : overlap mode of right window half */ - Word16 *left_overlap_length, /* o : TCX window left overlap length */ - Word16 *right_overlap_length, /* o : TCX window right overlap length */ - const Word16 in[], /* i : i signal */ - Word16 *L_frame, /* i/o: frame length */ - Word16 out[], /* o : output windowed signal */ - const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const Word8 fullband /* i : fullband flag */ -); - -void tcx_windowing_synthesis_current_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 left_rect, /* i: left part is rectangular */ - const Word16 left_mode, /* i: overlap mode of left window half */ - Word16 *acelp_zir, /* i: acelp ZIR */ - const Word16 *old_syn, - const Word16 *syn_overl, - const Word16 *A_zir, - const PWord16 *window_trans, - Word16 acelp_zir_len, - const Word16 acelp_mem_len, - const Word16 last_core_bfi, /* i : last core */ - const Word8 last_is_cng, - const Word16 fullbandScale ); - -void tcx_windowing_synthesis_past_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ -); - -void lpc2mdct( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 *mdct_gains, - Word16 *mdct_gains_exp, - Word16 *mdct_inv_gains, - Word16 *mdct_inv_gains_exp, - const Word16 length, - const Word16 noInverse ); - -void lpc2mdct_2( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 mdct_gains_fx[], - Word16 mdct_gains_e[], - Word16 mdct_inv_gains_fx[], - Word16 mdct_inv_gains_e[], - const Word16 length ); - -void mdct_shaping( - Word32 x[], - const Word16 lg, - const Word16 gains[], - const Word16 gains_exp[] ); - -void mdct_shaping_16( - const Word16 x[], - const Word16 lg, - const Word16 lg_total, - const Word16 gains[], - const Word16 gains_exp[], - Word16 gains_max_exp, - Word32 y[] ); - -void mdct_noiseShaping_ivas_fx( - Word32 x_fx[], - Word16 *x_e, - const Word16 lg, - const Word16 gains_fx[], - const Word16 gains_exp[] ); - -void mdct_noiseShaping_interp( - Word32 x[], - const Word16 lg, - Word16 gains[], - Word16 gains_exp[] ); - -void PsychAdaptLowFreqDeemph( - Word32 x[], - const Word16 lpcGains[], - const Word16 lpcGains_e[], - Word16 lf_deemph_factors[] ); - -void AdaptLowFreqDeemph( - Word32 x[], - Word16 x_e, - Word16 tcx_lpc_shaped_ari, - Word16 lpcGains[], - Word16 lpcGains_e[], - const Word16 lg, - Word16 lf_deemph_factors[] ); - -void tcx_noise_filling( - Word32 *Q, - Word16 Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ -); - -void tcx_noise_filling_with_shift( - Word32 *Q, - Word16 *Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ -); - -void InitTnsConfigs( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void InitTnsConfigs_ivas_fx( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void SetAllowTnsOnWhite( - STnsConfig tnsConfig[2][2], - const Word8 allowTnsOnWhite ); - -void SetTnsConfig( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const Word16 isTCX20, - const Word16 isAfterACELP ); - -void tcx_get_gain( - Word32 *x, /* i: spectrum 1 */ - Word16 x_e, /* i: spectrum 1 exponent */ - Word32 *y, /* i: spectrum 2 */ - Word16 y_e, /* i: spectrum 2 exponent */ - Word16 n, /* i: length */ - Word16 *gain, /* o: gain */ - Word16 *gain_e, /* o: gain exponent */ - Word32 *en_y, /* o: energy of y (optional) */ - Word16 *en_y_e /* o: energy of y exponent (optional) */ -); - -void init_TCX_config( - TCX_CONFIG_HANDLE hTcxCfg, - Word16 L_frame, - Word16 fscale, - Word16 L_frameTCX, - Word16 fscaleFB ); - -void resetTecDec_Fx( - TEC_DEC_HANDLE hTecDec ); - -void resetTecEnc_Fx( - TEC_ENC_HANDLE hTECEnc, - Word16 flag ); - -void calcGainTemp_TBE_Fx( - Word32 **pCldfbRealSrc_Fx, - Word32 **pCldfbImagSrc_Fx, - Word16 cldfb_exp, - Word16 *loBuffer_Fx, - const Word16 startPos, /*!< Start position of the current envelope. */ - const Word16 stopPos, /*!< Stop position of the current envelope. */ - const Word16 lowSubband, /* lowSubband */ - Word16 *pGainTemp_m, - Word16 *pGainTemp_e, - const Word16 code ); - -Word16 procTecTfa_TBE_Fx( - Word16 *hb_synth_Fx, - Word16 hb_synth_fx_exp, - Word16 *gain_m, - Word16 *gain_e, - Word16 flat_flag, - Word16 last_core, - Word16 l_subfr, - Word16 code ); - -void calcHiEnvLoBuff_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - const Word16 nSfb, /*!< Number of scalefactors. */ - Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 pCldfbPow_FixScale ); - -void calcLoEnvCheckCorrHiLo_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, - Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 *corrFlag /*int* corrFlag*/ -); - -void tecEnc_TBE_fx( - Word16 *corrFlag, - const Word16 *voicing, - const Word16 coder_type ); - -void set_TEC_TFA_code_fx( - const Word16 corrFlag, - Word16 *tec_flag, - Word16 *tfa_flag ); - -void TCX_MDCT( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void TCX_MDST( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void TCX_MDCT_Inverse( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qy */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void TCX_MDST_Inverse_fx( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r /* Q0 */ -); - -void TCX_MDXT_Inverse_fx( - const Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const UWord16 kernel_type /* Q0 */ -); - -void edct_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ -); - -void edct_ivas_fx( - const Word32 *x, /* i : input signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length Q0*/ - Word16 *q /* i : Q value of input signal */ -); - -void edst_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ -); - -void edct_16fx( - const Word16 *x, /* i : i signal Qx */ - Word16 *y, /* o : output transform Qx */ - Word16 length, /* i : length */ - Word16 bh, /* bit-headroom */ - const Word16 element_mode ); - -void iedct_short_fx( - const Word32 *in, /* i : i vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 segment_length /* i : length */ -); - -void edxt_fx( - const Word32 *x, /* i : input signal */ - Word32 *y, /* o : output transform */ - const Word16 length, /* i : length */ - const UWord16 kernelType, /* i : kernel type (0 - 3) */ - const UWord16 synthesis /* i : nonzero for inverse */ -); - -void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); -void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); -void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); - -void DoRTFTn_fx( - Word32 *x, /* i/o : real part of i and output data */ - Word32 *y, /* i/o : imaginary part of i and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ -); - -void DoRTFT480_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT320_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT160_fx( - Word32 x[], /* i/o: real part of input and output data */ - Word32 y[] /* i/o: imaginary part of input and output data */ -); - -void DoRTFT128_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT120_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT80_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT40_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT20_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -Word16 RFFTN_fx( - Word32 *data, - const Word16 *sine_table, - const Word16 len, - const Word16 sign ); - -void DoFFT_fx( - Word32 *re2, - Word32 *im2, - const Word16 length ); - -void fft_fx( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - const Word16 length, /* i : length of fft */ - const Word16 s /* i : sign */ -); - -void rfft_fx( - Word32 *x, /* i/o: values */ - const Word16 *w, /* i : window */ - const Word16 length, /* i : length of fft */ - const Word16 isign /* i : sign */ -); - -void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ -); - - -Word16 find_guarded_bits_fx( const Word32 n ); + void flip_and_downmix_generic_fx( + Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ + ); + + void Calc_rc0_h( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ + ); + + void Calc_rc0_h_ivas_enc_fx( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ + ); + + void PostShortTerm_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ + ); + + void PostShortTerm_ivas_enc_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ + ); + + void PostShortTerm_ivas_dec_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ + ); + + void flip_spectrum_and_decimby4_fx( + const Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : vector length */ + Word16 mem1[], /* i/o : memory */ + Word16 mem2[], /* i/o : memory */ + const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ + ); + + void GenShapedWBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb exctiation */ + const Word16 *lpc_shb, /* i : lpc coefficients */ + Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ + Word32 *mem_csfilt, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ + Word16 *state_lpc_syn, /* i/o : memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_bwe_exc, + Word16 bwe_seed[], /* i/o : random number generator seed */ + const Word16 voice_factors[], /* i : voicing factor */ + const Word16 signal_type, + const Word16 igf_flag ); + + void GenWBSynth_fx( + const Word16 *input_synspeech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_16k, /* o : output highband compnent */ + Word16 *state_lsyn_filt_shb1, /* i/o: memory */ + Word16 *state_lsyn_filt_shb2 /* i/o: memory */ + ); + + void GenShapedSHBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi ); + + void GenShapedSHBExcitation_ivas_enc_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 Q_EnvSHBres_4k, + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ + ); + + void GenShapedSHBExcitation_ivas_dec_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, /* i : previous frame was concealed */ + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ + ); + + void GenSHBSynth_fx( + const Word16 *shb_target_speech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP Frame length */ + Word16 *syn_dm_phase ); + + void GenSHBSynth_fx32( + const Word32 *input_synspeech, /* i : input synthesized speech */ + Word32 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP frame length */ + Word16 *syn_dm_phase ); + + void ScaleShapedSHB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o: synthesized shb signal */ + Word16 *overlap, /* i/o: buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + Word16 *Q_bwe_exc, + Word16 *Qx, + Word16 n_mem3, + Word16 prev_Q_bwe_syn2 ); + + void ScaleShapedSHB_fx32( + const Word16 length, /* i : SHB overlap length */ + Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ + Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ + const Word16 *subgain_fx, /* i : subframe gain Q15 */ + const Word32 frame_gain_fx, /* i : frame gain */ + const Word16 *win_fx, /* i : window Q15 */ + const Word16 *subwin_fx, /* i : subframes window Q15 */ + Word16 *Q_inp, + Word16 *Q_new ); + + void ScaleShapedWB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o : synthesized shb signal */ + Word16 *overlap, /* i/o : buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + const Word16 Q_bwe_exc, + Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ + Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ + Word16 *Qx, /* o : newly computed Q factor for synSHB */ + Word16 prev_Qx, /* i : prev_Qx for memory scaling */ + Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ + ); + + void non_linearity_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ + ); + + void non_linearity_ivas_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ + ); + + void interp_code_5over2_fx( + const Word16 inp_code[], /* i : i vector */ + Word16 interp_code[], /* o : output vector */ + const Word16 inp_length /* i : length of i vector */ + ); + + void interp_code_4over2_fx( + const Word16 inp_code_fx[], /* i : i vector Qx */ + Word16 interp_code_fx[], /* o : output vector Qx */ + const Word16 inp_length /* i : length of i vector */ + ); + + void wb_tbe_extras_reset_synth_fx( + Word16 state_lsyn_filt_shb[], + Word16 state_lsyn_filt_dwn_shb[], + Word16 state_32and48k_WB_upsample[], + Word16 state_resamp_HB[] ); + + void elliptic_bpf_48k_generic_fx( + const Word16 element_mode, + Word16 IsUpsampled3, + Word16 input_fx[], /* i : input signal Q_input_fx*/ + Word16 *Q_input_fx, + Word16 output_fx[], /* o : output signal */ + Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ + Word16 memory_fx_Q[], + const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ + ); + + void synthesise_fb_high_band_fx( + const Word16 excitation_in[], /* i : full band excitation */ + Word16 Q_fb_exc, + Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ + const Word32 fb_exc_energy, /* i : full band excitation energy */ + const Word16 ratio, /* i : energy ratio */ + const Word16 L_frame, /* i : ACELP frame length */ + const Word16 bfi, /* i : fec flag */ + Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ + Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ + Word16 bpf_memory_Q[], + Word16 Qout, + Word16 element_mode ); + + void prep_tbe_exc_fx( + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 i_subfr_fx, /* i : subframe index */ + const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ + const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 voice_fac_fx, /* i : voicing factor Q15*/ + Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ + Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ + const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ + const Word16 code_preQ_fx[], /* i : prequantizer excitation */ + const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ + const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ + const Word16 T0, /* i : integer pitch variables Q0 */ + const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ + const Word16 coder_type, /* i : coding type */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ + const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ + const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ + ); + + /*! r: Formant filter strength [0,1] */ + Word16 swb_formant_fac_fx( + const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ + Word16 *tilt_mem /* i/o: Tilt smoothing memory */ + ); + + void wb_tbe_extras_reset_fx( + Word16 mem_genSHBexc_filt_down_wb2[], + Word16 mem_genSHBexc_filt_down_wb3[] ); + + Word16 get_tbe_bits_fx( + const Word32 total_brate, /* o : TBE bit consumption per frame */ + const Word16 bwidth, /* i : overall bitrate */ + const Word16 rf_mode /* i : bandwidht mode */ + ); + + UWord32 intLimCDivPos_fx( + UWord32 NUM, /* Qx */ + Word16 DEN /* Q0 */ + ); + + Word16 shrtCDivSignedApprox( + const Word16 num, /* Q0 */ + const Word16 den /* Q0 */ + ); + + void obtainEnergyQuantizerDensity_fx( + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ + ); + + void dsDirac2Dirac_fx( + const Word16 dsDiracIndex, /* Q0 */ + Word16 *diracs /* Q0 */ + ); + + void dsDiracPerQuanta_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ + ); + + void QuantaPerDsDirac_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ + const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ + Word16 *Quanta /* i : Quanta Q0*/ + ); + + void conservativeL1Norm_fx( + const Word16 L, /* i : Length of vector segment Q0*/ + const Word16 Qvec, /* i : Assigned number of quanta Q0*/ + const Word16 Fcons, /* i : Conservative rounding flag Q0*/ + const Word16 Qavail, /* i : Input quanta remaining Q0*/ + const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ + const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ + Word16 *Dvec, /* o : actual number of diracs Q0*/ + Word16 *Qspare, /* o : Output quanta remaining Q0*/ + Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ + Word16 *Dspecplus /* o : Output number of diracs Q0*/ + ); + + void bandBitsAdjustment_fx( + const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ + const UWord32 INTrc, /* i : Range coder state Q0*/ + const Word16 Bavail, /* i : Available number of quanta Q3*/ + const Word16 Nbands, /* i : Number of bands Q0*/ + const Word16 D, /* i : Remaining number of bands to encode Q0*/ + const Word16 L, /* i : Size of current band Q0*/ + const Word16 Bband, /* i : Quanta allocation for current band Q0*/ + const Word16 Breserv, /* i : Quanta reservoir Q0*/ + Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ + Word16 *Brem, /* o : Quanta remaining Q0*/ + Word16 *Breservplus /* o : Quanta pool size Q0*/ + ); + + void densityAngle2RmsProjDec_fx( + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ + ); + + void densityAngle2RmsProjEnc_fx( + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ + ); + + void NearOppSplitAdjustment_fx( + const Word16 qband, /* i : quanta for current band Q0*/ + const Word16 qzero, /* i : range coder finalization quanta Q0*/ + const Word16 Qac, /* i : range coder current quanta Q0*/ + const UWord32 INTac, /* i : range coder state Q0*/ + const Word16 qglobal, /* i : quanta input Q0*/ + const Word16 FlagCons, /* i : conservative rounding flag Q0*/ + const Word16 Np, /* i : number of parts Q0*/ + const Word16 Nhead, /* i : first part Q0*/ + const Word16 Ntail, /* i : remaining parts Q0*/ + const Word16 Nnear, /* i : length of near component Q0*/ + const Word16 Nopp, /* i : length of opposite component Q0*/ + Word16 oppRQ3, /* i : ratio Q0*/ + Word16 *qnear, /* o : quantized near Q0*/ + Word16 *qopp, /* o : quantized opposite Q0*/ + Word16 *qglobalupd /* o : quanta remaining Q0*/ + ); + + void apply_gain_fx( + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 *band_start, /* i : Sub band start indices Q0 */ + const Word16 *band_end, /* i : Sub band end indices Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gains, /* i : Band gain vector Q12 */ + Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ + ); + + void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ + ); + + void srt_vec_ind16_fx( + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ + Word16 length /* Q0 */ + ); + + /* o: Angle between 0 and PI/2 radian (Q14) */ + Word16 atan2_fx( + const Word32 y, /* i : near side (Argument must be positive) (Q15) */ + const Word32 x /* i : opposite side (Q15) */ + ); + + /* o: Number of bits needed Q0*/ + Word16 rc_get_bits2_fx( + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ + ); + + void rangeCoderFinalizationFBits_fx( + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ + ); + + ivas_error DTFS_new_fx( + DTFS_STRUCTURE **dtfs_out ); + + void DTFS_copy_fx( + DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ + DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ + ); + + void DTFS_sub_fx( + DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ + DTFS_STRUCTURE X1, /* i: DTFS i 1 */ + DTFS_STRUCTURE X2 /* i: DTFS i 2 */ + ); + + Word16 DTFS_alignment_full_fx( + DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ + DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ + Word16 ph_offset_fx, /* i : resolution */ + Word16 *S_fx, + Word16 *C_fx, + Word16 FR_flag ); + + void DTFS_phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + + void Q2phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + + void DTFS_zeroPadd_fx( + Word16 N_fx, + DTFS_STRUCTURE *X_fx ); + + void DTFS_to_fs_fx( + const Word16 *x, /* i : time domain signal */ + Word16 N, /* i : Length of i vector */ + DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ + const Word16 Fs, /* i : sampling rate */ + const Word16 FR_flag, /* i : FR flag */ + Word16 *S_fx, + Word16 *C_fx ); + + void DTFS_zeroFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + + void DTFS_poleFilter_fx_9( + DTFS_STRUCTURE *X_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + + void DTFS_adjustLag_fx( + DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ + Word16 N_fx /* i : Target lag */ + ); + + Word32 DTFS_getEngy_fx( + DTFS_STRUCTURE *X_fx ); + + Word32 DTFS_getEngy_P2A_fx( + DTFS_STRUCTURE *X_fx ); + + void DTFS_car2pol_fx( + DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ + ); + + Word32 DTFS_setEngyHarm_fx( + Word16 f1_fx, /* i : lower band freq of i to control energy */ + Word16 f2_fx, /* i : upper band freq of i to control energy */ + Word16 g1_fx, /* i : lower band freq of output to control energy */ + Word16 g2_fx, /* i : upper band freq of output to control energy */ + Word32 en2_fx, /* i : Target Energy to set the DTFS to */ + Word16 Qen2_fx, /* i : Input Q format for en2 */ + Word16 *Qa_fx, /* i : Output Q format for x->a */ + DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ + ); + + void DTFS_to_erb_fx( + const DTFS_STRUCTURE X_fx, /* i : DTFS i */ + Word16 *out_fx /* o : ERB output */ + ); + + void erb_slot_fx( + Word16 lag_fx, /* i : i lag */ + Word16 *out_fx, /* o : ERB slots */ + Word16 *mfreq_fx, /* i : ERB frequencies */ + Word16 num_erb_fx /* i : number of ERBs */ + ); + + void DTFS_erb_inv_fx( + Word16 *in_fx, /* i : ERB inpt */ + Word16 *slot_fx, /* i : ERB slots filled based on lag */ + Word16 *mfreq_fx, /* i : erb frequence edges */ + DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ + Word16 num_erb_fx /* i : Number of ERB bands */ + ); + + void erb_add_fx( + Word16 *curr_erb_fx, /* i/o: current ERB */ + Word16 l_fx, /* i : current lag */ + const Word16 *prev_erb_fx, /* i : previous ERB */ + Word16 pl_fx, /* i : previous lag */ + const Word16 *index_fx, /* i : ERB index */ + Word16 num_erb_fx /* i : number of ERBs */ + ); + + void quant_target_fx( + DTFS_STRUCTURE *X_fx, + const Word16 *curr_lpc, + Word16 *w, + Word16 *target, + Word16 *sin_tab, + Word16 *cos_tab ); + + ivas_error WIsyn_fx( + DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ + DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ + const Word16 *curr_lpc_fx, /* i : LPC */ + Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ + Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ + const Word16 N, /* i : Number of output samples to generate */ + const Word16 FR_flag, /* i : called for post-smoothing in FR */ + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2 ); + + Word16 ppp_extract_pitch_period_fx( + const Word16 *in, /* i : i residual */ + Word16 *out, /* o : output residual */ + Word16 l, /* i : lag */ + Word16 *out_of_bound, /* o : out of bound flag */ + Word16 Qres ); + + void DTFS_peaktoaverage_fx( + DTFS_STRUCTURE X_fx, /* i : DTFS */ + Word32 *pos_fx, /* o : positive peak to ave */ + Word16 *Qpos, /* o : positive peak to ave Q format */ + Word32 *neg_fx, /* o : negative peak to ave */ + Word16 *Qneg /* o : negative peak to ave Q format */ + ); + + void rshiftHarmBand_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband_fx, + Word16 hband_fx, + Word16 shift_fx ); + + void GetSinCosTab_fx( + Word16 L, + Word16 *sinTab, + Word16 *cosTab ); + + void r_fft_4_fx( + Word16 *farray_ptr_fx, + Word16 size, + Word16 stage, + Word16 isign ); + + void copy_phase_fx( + DTFS_STRUCTURE *X1_fx, + DTFS_STRUCTURE X2_fx, + DTFS_STRUCTURE *retX_fx ); + + Word32 getSpEngyFromResAmp_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband, + Word16 hband, + const Word16 *curr_lpc, + Word16 *sin_tab, + Word16 *cos_tab ); + + void DTFS_poleFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + + void poleFilter_setup_fx( + const Word16 *LPC, + Word16 N, + DTFS_STRUCTURE X_fx, + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + + Word32 DTFS_getEngy_band_wb_fx( + DTFS_STRUCTURE X_fx, + Word16 lband, + Word16 hband ); + + void InitTnsConfiguration( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void InitTnsConfiguration_ivas_fx( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void ApplyTnsFilter( + STnsConfig const *pTnsConfig, + STnsData const *pTnsData, + Word32 spectrum[], + const Word8 fIsAnalysis ); + + Word16 ITF_Detect_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); + + Word16 ITF_Detect_ivas_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); -Word16 L_norm_arr( const Word32 *arr, Word16 size ); -Word16 norm_arr( Word16 *arr, Word16 size ); -Word16 W_norm_arr( Word64 *arr, Word16 size ); - -Word16 get_min_scalefactor( Word32 x, Word32 y ); - -Flag is_zero_arr( Word32 *arr, Word16 size ); -Flag is_zero_arr16( Word16 *arr, Word16 size ); -Flag is_zero_arr64( Word64 *arr, Word16 size ); - -void edct2_fx_ivas( - const Word16 n, - const Word16 isgn, - Word32 *in, - Word32 *a, - const Word16 *ip, - const Word16 *w ); - -void edct2_fx( - Word16 n, - Word16 isgn, - Word16 *in, - Word32 *a, - Word16 *q, - const Word16 *ip, - const Word16 *w ); - -void DoRTFT160_16fx( - Word16 x[], /* i/o : real part of i and output data */ - Word16 y[] /* i/o : imaginary part of i and output data */ -); - -void DoRTFT320_16fx( - Word16 *x, /* i/o : real part of i and output data */ - Word16 *y /* i/o : imaginary part of i and output data */ -); - -void DoRTFT128_16fx( - Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ - Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ -); - -void fft3_fx( - const Word16[], - Word16[], - const Word16 ); - -void ifft3_fx( - const Word16[], - Word16[], - const Word16 ); - -void fft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); -void ifft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); - -void r_fft_fx_lc( - const Word16 *phs_tbl, /* i : Table of phase */ - const Word16 SIZE, /* i : Size of the FFT */ - const Word16 SIZE2, /* i : Size / 2 */ - const Word16 NUM_STAGE, /* i : Number of stage */ - const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - const Word16 isign /* i : 1=fft, otherwize it's ifft */ -); - -void cldfbAnalysis_fx( - HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ - Word32 **cldfbReal, /*!< Pointer to real subband slots */ - Word32 **cldfbImag, /*!< Pointer to imag subband slots */ - CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - const Word16 *timeIn, /*!< Time signal */ - const Word16 timeIn_e, /*!< Time signal */ - const Word16 nTimeSlots, /*!< Time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ -); - -void cldfbSynthesis_fx( - HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ - Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ - Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ - const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - Word16 *timeOut, /*!< Time signal */ - const Word16 timeOut_e, /*!< Target exponent for output signal */ - const Word16 nTimeSlots, /*!< number of time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ -); - -void configureCldfb( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - -ivas_error openCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ - const Word16 type, /* i : analysis or synthesis */ - const Word32 sampling_rate /* i : sampling rate */ -); - -void resampleCldfb( - HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word16 frameSize, /*!< FrameSize */ - const Word8 firstFrame ); - -Word16 AnalysisPostSpectrumScaling_Fx( - HANDLE_CLDFB_FILTER_BANK cldfbBank, - Word32 **rSubband32, - Word32 **iSubband32, - Word16 **rSubband16, - Word16 **iSubband16, - Word16 *cldfbScale ); - -void analysisCldfbEncoder_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *timeIn, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - -void GetEnergyCldfb( - Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ - Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ - const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ - Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ - Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ - Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ - Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ - Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ - Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ - Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ - Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ - Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ - TEC_ENC_HANDLE hTECEnc ); - -void deleteCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ - -ivas_error cldfb_save_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - -void cldfb_restore_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - -void cldfb_reset_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - -void BITS_ALLOC_init_config_acelp( - const Word32 bit_rate, - const Word16 narrowBand, - const Word16 nb_subfr, - ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ -); - -Word16 BITS_ALLOC_config_acelp( - const Word16 bits_frame, /*i: remaining bit budget for the frame */ - const Word16 coder_type, /*i: coder type */ - ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ - const Word16 narrowband, - const Word16 nb_subfr ); - -Word16 set_ACELP_flag( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate per channel */ - const Word16 idchan, /* i : Channel id */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 cng_type /* i : CNG type */ -); - -void syn_12k8_fx( - Word16 L_frame, - const Word16 *Aq, /* i : LP filter coefficients Q12 */ - const Word16 *exc, /* i : i signal Q_exc */ - Word16 *synth, /* o : output signal Q_syn */ - Word16 *mem, /* i/o: initial filter states Q_syn */ - const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ - /* 1 --> update of memory */ - const Word16 Q_exc, /* i : Excitation scaling Q0 */ - const Word16 Q_syn /* i : Synthesis scaling Q0 */ -); - -/* o : tilt of the code Q15 */ -Word16 est_tilt_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ + void ITF_Apply_fx( + Word32 spectrum[], + Word16 startLine, + Word16 stopLine, + const Word16 *A, + Word16 Q_A, + Word16 curr_order ); + + void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); + + Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + + Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + + Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); + + Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); + + Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + + Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + + Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + + void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); + + Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); + + Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); + + Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); + + Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); + + Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); + + Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); + + Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); + + void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); + + void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); + + void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); + + void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); + + void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); + void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); + + void ResetTnsData( STnsData *pTnsData ); + + void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); + + /*========================================================================================================/ + gp_clips_fx.c + /========================================================================================================*/ + + void init_gp_clip_fx( + Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + ); + + Word16 gp_clip_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 coder_type, /* i : type of coder Q0*/ + const Word16 xn[], /* i : target vector Q_new*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Q_new /* i : scaling factor */ + ); + + void gp_clip_test_isf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ + ); + + void gp_clip_test_gain_pit_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ + Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ + ); + + Word16 Mode2_gp_clip_fx( + const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 coder_type, /* i : type of coder Q0 */ + const Word16 xn[], /* i : target vector Q_xn */ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ + /* mem[0]: Q0 */ + /* mem[1]: 1Q14 */ + /* mem[2]: 8Q7 */ + /* mem[3]: Q0 (integer) */ + /* mem[4]: Q14 */ + /* mem[5]: Q14 */ + const Word16 L_subfr, /* Q0 */ + const Word16 Q_xn /* i : scaling factor of vector xn[] */ + ); + + void gp_clip_test_lsf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 m /* i : dimension of lsf Q0*/ + ); + + void gp_clip_test_lsf_ivas_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ + ); + + /*========================================================================================================/ + nelp_enc_fx.c + /========================================================================================================*/ + + void quantize_uvg_fx( + Word16 *G, + Word16 *iG1, + Word16 *iG2, + Word16 *quantG, + Word16 bandwidth ); + + void nelp_encoder_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + + void nelp_encoder_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + + void swb_bwe_enc_lr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ + ); + + void swb_bwe_enc_lr_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ + ); + + void isf_enc_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + Word16 *isf_new, /* i/o: quantized ISF vector */ + Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ + Word16 *Aq /* o : quantized A(z) for 4 subframes */ + ); + + Word16 detect_transient_fx( + const Word16 *in_fx, /*Q_new */ + const Word16 L, /*Q0*/ + Word16 Q_new, + Encoder_State *st_fx ); + + Word16 tcxGetNoiseFillingTilt( + const Word16 A[], + const Word16 lpcorder, + const Word16 L_frame, + const Word16 mode, + Word16 *noiseTiltFactor ); + + void tcxFormantEnhancement( + Word16 xn_buf[], + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + + void tcxFormantEnhancement_with_shift( + Word16 xn_buf[], + Word16 *xn_buf_e, + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + + void tcxInvertWindowGrouping( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word32 xn_buf[], + Word32 spectrum[], + const Word16 L_frame, + const Word8 fUseTns, + const Word16 last_core, + const Word16 index, + const Word16 frame_cnt, + const Word16 bfi ); + + void permute_fx( + Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ + const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ + ); + + void init_lvq_fx( + Word32 offset_scale1[][MAX_NO_SCALES + 1], + Word32 offset_scale2[][MAX_NO_SCALES + 1], + Word32 offset_scale1_p[][MAX_NO_SCALES + 1], + Word32 offset_scale2_p[][MAX_NO_SCALES + 1], + Word16 no_scales[][2], + Word16 no_scales_p[][2] ); + + Word16 deindex_lvq_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ + Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, /* i : offset for first subvector */ + Word32 *p_offset_scale2, /* i : offset for the second subvector */ + Word16 *p_no_scales ); + + Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ + ); + + Word16 deindex_lvq_cng_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q9*/ + Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + + Word16 deindex_lvq_cng_ivas_fx( + Word16 *index, /* i: index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o: decoded codevector Q9 */ + Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ + Word16 no_bits /* i: number of bits for lattice */ + ); + + Word16 lsp_convert_poly_fx( + Word16 w[], /* i/o: LSP or ISP parameters */ + const Word16 L_frame, /* i : flag for up or down conversion */ + const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ + ); + + void CNG_exc_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 L_frame, /* i : length of the frame */ + Word32 *Enew, /* i/o: decoded SID energy Q6 */ + Word16 *seed, /* i/o: random generator seed */ + Word16 exc[], /* o : current non-enhanced excitation Q_new */ + Word16 exc2[], /* o : current enhanced excitation Q_new */ + Word32 *lp_ener, /* i/o: LP filtered E */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ + Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ + Word16 bwe_exc[], /* o : excitation for SWB TBE */ + const Word16 allow_cn_step, /* i : allow CN step */ + Word16 *last_allow_cn_step, /* i/o: last allow step */ + const Word16 OldQ_exc, /* i : Old excitation scaling */ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 num_ho, /* i : number of selected hangover frames */ + Word32 q_env[], + Word32 *lp_env, + Word32 *old_env, + Word16 *exc_mem, + Word16 *exc_mem1, + Word16 *sid_bw, + Word16 *cng_ener_seed1, + Word16 exc3[], + Word16 Opt_AMR_WB, + const Word16 element_mode /* i : IVAS Element mode */ + ); + + void cng_params_postupd_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[] /* i/o: Envelope buffer */ + ); + + void cng_params_postupd_ivas_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ + ); + + void cng_params_upd_fx( + const Word16 lsp_new[], /* i : LSP parameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate /* i : Last active bit rate Q0 */ + ); + + void cng_params_upd_ivas_fx( + const Word16 lsp_new[], /* i : LSP aprameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate, /* i : Last active bit rate Q0 */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ + ); + + Word16 get_cng_mode( + const Word32 last_active_brate /* i : last active bitrate */ + ); + + /*! r: codec mode */ + Word16 get_codec_mode( + const Word32 total_brate /* i : total bitrate */ + ); + + Word16 getTcxonly( + const Word32 total_brate /* i : total bitrate */ + ); + + Word16 getTcxonly_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ + ); + + Word16 getCtxHm( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_flag /* i : flag to signal the RF mode */ + ); + + Word16 getResq( + const Word32 total_brate /* i : total bitrate */ + ); + + Word16 getTnsAllowed( + const Word32 total_brate, /* i : total bitrate */ + const Word16 igf, /* i : flag indicating IGF activity*/ + const Word16 element_mode /* i : IVAS element mode */ + ); + + Word16 getRestrictedMode( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ + ); + + Word16 getMdctWindowLength_fx( + const Word16 fscale ); + + Word16 sr2fscale_fx( + const Word32 sr_core /* i : internal sampling rate */ + ); + + Word32 getCoreSamplerateMode2( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ + ); + + Word16 getTcxBandwidth( + const Word16 bandwidth ); + + Word16 getIgfPresent_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + Word16 getCnaPresent_fx( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth /* i : audio bandwidth */ + ); + + Word16 getTcxLtp( + const Word32 sr_core /* i : internal sampling rate */ + ); + + Word16 initPitchLagParameters( + const Word32 sr_core, + Word16 *pit_min, + Word16 *pit_fr1, + Word16 *pit_fr1b, + Word16 *pit_fr2, + Word16 *pit_max ); + + Word16 getNumTcxCodedLines( + const Word16 bwidth ); + + Word16 getTcxLpcShapedAri( + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const Word16 element_mode /* i : IVAS element mode */ + ); + + void mdct_window_sine( + PWord16 *window, /* Qx */ + Word16 n /* Q0 */ + ); + + void mdct_window_sine_IVAS_updated( + PWord16 *window, /* Qx */ + const Word32 Fs, /* Q0 */ + const Word16 n, /* Q0 */ + const Word16 window_type, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void mdct_window_aldo( + Word16 *window1, /* Q15 */ + PWord16 *window1_trunc, /* Q15 */ + PWord16 *window2, /* Q15 */ + Word16 n /* Q0 */ + ); + + Word16 getInvFrameLen( + const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ + + void tcx_get_windows( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ + const Word16 left_mode, /* i: overlap mode of left window half */ + const Word16 right_mode, /* i: overlap mode of right window half */ + Word16 *left_overlap, /* o: left overlap length */ + const PWord16 **left_win, /* o: left overlap window */ + Word16 *right_overlap, /* o: right overlap length */ + const PWord16 **right_win, /* o: right overlap window */ + const Word8 fullband /* i: fullband flag */ + ); + + void WindowSignal( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word16 offset, /* i : left folding point offset relative to the i signal pointer */ + const Word16 left_overlap_mode, /* i : overlap mode of left window half */ + Word16 right_overlap_mode, /* i : overlap mode of right window half */ + Word16 *left_overlap_length, /* o : TCX window left overlap length */ + Word16 *right_overlap_length, /* o : TCX window right overlap length */ + const Word16 in[], /* i : i signal */ + Word16 *L_frame, /* i/o: frame length */ + Word16 out[], /* o : output windowed signal */ + const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ + const Word8 fullband /* i : fullband flag */ + ); + + void tcx_windowing_synthesis_current_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 left_rect, /* i: left part is rectangular */ + const Word16 left_mode, /* i: overlap mode of left window half */ + Word16 *acelp_zir, /* i: acelp ZIR */ + const Word16 *old_syn, + const Word16 *syn_overl, + const Word16 *A_zir, + const PWord16 *window_trans, + Word16 acelp_zir_len, + const Word16 acelp_mem_len, + const Word16 last_core_bfi, /* i : last core */ + const Word8 last_is_cng, + const Word16 fullbandScale ); + + void tcx_windowing_synthesis_past_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ + ); + + void lpc2mdct( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 *mdct_gains, + Word16 *mdct_gains_exp, + Word16 *mdct_inv_gains, + Word16 *mdct_inv_gains_exp, + const Word16 length, + const Word16 noInverse ); + + void lpc2mdct_2( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 mdct_gains_fx[], + Word16 mdct_gains_e[], + Word16 mdct_inv_gains_fx[], + Word16 mdct_inv_gains_e[], + const Word16 length ); + + void mdct_shaping( + Word32 x[], + const Word16 lg, + const Word16 gains[], + const Word16 gains_exp[] ); + + void mdct_shaping_16( + const Word16 x[], + const Word16 lg, + const Word16 lg_total, + const Word16 gains[], + const Word16 gains_exp[], + Word16 gains_max_exp, + Word32 y[] ); + + void mdct_noiseShaping_ivas_fx( + Word32 x_fx[], + Word16 *x_e, + const Word16 lg, + const Word16 gains_fx[], + const Word16 gains_exp[] ); + + void mdct_noiseShaping_interp( + Word32 x[], + const Word16 lg, + Word16 gains[], + Word16 gains_exp[] ); + + void PsychAdaptLowFreqDeemph( + Word32 x[], + const Word16 lpcGains[], + const Word16 lpcGains_e[], + Word16 lf_deemph_factors[] ); + + void AdaptLowFreqDeemph( + Word32 x[], + Word16 x_e, + Word16 tcx_lpc_shaped_ari, + Word16 lpcGains[], + Word16 lpcGains_e[], + const Word16 lg, + Word16 lf_deemph_factors[] ); + + void tcx_noise_filling( + Word32 *Q, + Word16 Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ + ); + + void tcx_noise_filling_with_shift( + Word32 *Q, + Word16 *Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ + ); + + void InitTnsConfigs( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void InitTnsConfigs_ivas_fx( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void SetAllowTnsOnWhite( + STnsConfig tnsConfig[2][2], + const Word8 allowTnsOnWhite ); + + void SetTnsConfig( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + const Word16 isTCX20, + const Word16 isAfterACELP ); + + void tcx_get_gain( + Word32 *x, /* i: spectrum 1 */ + Word16 x_e, /* i: spectrum 1 exponent */ + Word32 *y, /* i: spectrum 2 */ + Word16 y_e, /* i: spectrum 2 exponent */ + Word16 n, /* i: length */ + Word16 *gain, /* o: gain */ + Word16 *gain_e, /* o: gain exponent */ + Word32 *en_y, /* o: energy of y (optional) */ + Word16 *en_y_e /* o: energy of y exponent (optional) */ + ); + + void init_TCX_config( + TCX_CONFIG_HANDLE hTcxCfg, + Word16 L_frame, + Word16 fscale, + Word16 L_frameTCX, + Word16 fscaleFB ); + + void resetTecDec_Fx( + TEC_DEC_HANDLE hTecDec ); + + void resetTecEnc_Fx( + TEC_ENC_HANDLE hTECEnc, + Word16 flag ); + + void calcGainTemp_TBE_Fx( + Word32 **pCldfbRealSrc_Fx, + Word32 **pCldfbImagSrc_Fx, + Word16 cldfb_exp, + Word16 *loBuffer_Fx, + const Word16 startPos, /*!< Start position of the current envelope. */ + const Word16 stopPos, /*!< Stop position of the current envelope. */ + const Word16 lowSubband, /* lowSubband */ + Word16 *pGainTemp_m, + Word16 *pGainTemp_e, + const Word16 code ); + + Word16 procTecTfa_TBE_Fx( + Word16 *hb_synth_Fx, + Word16 hb_synth_fx_exp, + Word16 *gain_m, + Word16 *gain_e, + Word16 flat_flag, + Word16 last_core, + Word16 l_subfr, + Word16 code ); + + void calcHiEnvLoBuff_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + const Word16 nSfb, /*!< Number of scalefactors. */ + Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 pCldfbPow_FixScale ); + + void calcLoEnvCheckCorrHiLo_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, + Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 *corrFlag /*int* corrFlag*/ + ); + + void tecEnc_TBE_fx( + Word16 *corrFlag, + const Word16 *voicing, + const Word16 coder_type ); + + void set_TEC_TFA_code_fx( + const Word16 corrFlag, + Word16 *tec_flag, + Word16 *tfa_flag ); + + void TCX_MDCT( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void TCX_MDST( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void TCX_MDCT_Inverse( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void TCX_MDST_Inverse_fx( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r /* Q0 */ + ); + + void TCX_MDXT_Inverse_fx( + const Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type /* Q0 */ + ); + + void edct_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ + ); + + void edct_ivas_fx( + const Word32 *x, /* i : input signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length Q0*/ + Word16 *q /* i : Q value of input signal */ + ); + + void edst_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ + ); + + void edct_16fx( + const Word16 *x, /* i : i signal Qx */ + Word16 *y, /* o : output transform Qx */ + Word16 length, /* i : length */ + Word16 bh, /* bit-headroom */ + const Word16 element_mode ); + + void iedct_short_fx( + const Word32 *in, /* i : i vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 segment_length /* i : length */ + ); + + void edxt_fx( + const Word32 *x, /* i : input signal */ + Word32 *y, /* o : output transform */ + const Word16 length, /* i : length */ + const UWord16 kernelType, /* i : kernel type (0 - 3) */ + const UWord16 synthesis /* i : nonzero for inverse */ + ); + + void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); + void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); + void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); + + void DoRTFTn_fx( + Word32 *x, /* i/o : real part of i and output data */ + Word32 *y, /* i/o : imaginary part of i and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ + ); + + void DoRTFT480_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT320_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT160_fx( + Word32 x[], /* i/o: real part of input and output data */ + Word32 y[] /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT128_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT120_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT80_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT40_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT20_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + Word16 RFFTN_fx( + Word32 *data, + const Word16 *sine_table, + const Word16 len, + const Word16 sign ); + + void DoFFT_fx( + Word32 *re2, + Word32 *im2, + const Word16 length ); + + void fft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const Word16 length, /* i : length of fft */ + const Word16 s /* i : sign */ + ); + + void rfft_fx( + Word32 *x, /* i/o: values */ + const Word16 *w, /* i : window */ + const Word16 length, /* i : length of fft */ + const Word16 isign /* i : sign */ + ); + + void DoRTFTn_fx_ivas( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ + ); + + + Word16 find_guarded_bits_fx( const Word32 n ); + + Word16 L_norm_arr( const Word32 *arr, Word16 size ); + Word16 norm_arr( Word16 *arr, Word16 size ); + Word16 W_norm_arr( Word64 *arr, Word16 size ); + + Word16 get_min_scalefactor( Word32 x, Word32 y ); + + Flag is_zero_arr( Word32 *arr, Word16 size ); + Flag is_zero_arr16( Word16 *arr, Word16 size ); + Flag is_zero_arr64( Word64 *arr, Word16 size ); + + void edct2_fx_ivas( + const Word16 n, + const Word16 isgn, + Word32 *in, + Word32 *a, + const Word16 *ip, + const Word16 *w ); + + void edct2_fx( + Word16 n, + Word16 isgn, + Word16 *in, + Word32 *a, + Word16 *q, + const Word16 *ip, + const Word16 *w ); + + void DoRTFT160_16fx( + Word16 x[], /* i/o : real part of i and output data */ + Word16 y[] /* i/o : imaginary part of i and output data */ + ); + + void DoRTFT320_16fx( + Word16 *x, /* i/o : real part of i and output data */ + Word16 *y /* i/o : imaginary part of i and output data */ + ); + + void DoRTFT128_16fx( + Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ + Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ + ); + + void fft3_fx( + const Word16[], + Word16[], + const Word16 ); + + void ifft3_fx( + const Word16[], + Word16[], + const Word16 ); + + void fft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); + void ifft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); + + void r_fft_fx_lc( + const Word16 *phs_tbl, /* i : Table of phase */ + const Word16 SIZE, /* i : Size of the FFT */ + const Word16 SIZE2, /* i : Size / 2 */ + const Word16 NUM_STAGE, /* i : Number of stage */ + const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + const Word16 isign /* i : 1=fft, otherwize it's ifft */ + ); + + void cldfbAnalysis_fx( + HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ + Word32 **cldfbReal, /*!< Pointer to real subband slots */ + Word32 **cldfbImag, /*!< Pointer to imag subband slots */ + CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + const Word16 *timeIn, /*!< Time signal */ + const Word16 timeIn_e, /*!< Time signal */ + const Word16 nTimeSlots, /*!< Time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ + ); + + void cldfbSynthesis_fx( + HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ + Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ + Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ + const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + Word16 *timeOut, /*!< Time signal */ + const Word16 timeOut_e, /*!< Target exponent for output signal */ + const Word16 nTimeSlots, /*!< number of time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ + ); + + void configureCldfb( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ + const Word32 sampling_rate /* i : sampling rate */ + ); + + ivas_error openCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ + const Word16 type, /* i : analysis or synthesis */ + const Word32 sampling_rate /* i : sampling rate */ + ); + + void resampleCldfb( + HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 frameSize, /*!< FrameSize */ + const Word8 firstFrame ); + + Word16 AnalysisPostSpectrumScaling_Fx( + HANDLE_CLDFB_FILTER_BANK cldfbBank, + Word32 **rSubband32, + Word32 **iSubband32, + Word16 **rSubband16, + Word16 **iSubband16, + Word16 *cldfbScale ); + + void analysisCldfbEncoder_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *timeIn, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + + void GetEnergyCldfb( + Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ + Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ + const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ + Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ + Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ + Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ + Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ + Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ + Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ + Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ + Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ + Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ + TEC_ENC_HANDLE hTECEnc ); + + void deleteCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ + + ivas_error cldfb_save_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + + void cldfb_restore_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + + void cldfb_reset_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + + void BITS_ALLOC_init_config_acelp( + const Word32 bit_rate, + const Word16 narrowBand, + const Word16 nb_subfr, + ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ + ); + + Word16 BITS_ALLOC_config_acelp( + const Word16 bits_frame, /*i: remaining bit budget for the frame */ + const Word16 coder_type, /*i: coder type */ + ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ + const Word16 narrowband, + const Word16 nb_subfr ); + + Word16 set_ACELP_flag( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate per channel */ + const Word16 idchan, /* i : Channel id */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 cng_type /* i : CNG type */ + ); + + void syn_12k8_fx( + Word16 L_frame, + const Word16 *Aq, /* i : LP filter coefficients Q12 */ + const Word16 *exc, /* i : i signal Q_exc */ + Word16 *synth, /* o : output signal Q_syn */ + Word16 *mem, /* i/o: initial filter states Q_syn */ + const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ + /* 1 --> update of memory */ + const Word16 Q_exc, /* i : Excitation scaling Q0 */ + const Word16 Q_syn /* i : Synthesis scaling Q0 */ + ); + + /* o : tilt of the code Q15 */ + Word16 est_tilt_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ #ifdef CLEANUP_ACELP_ENC - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #else - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ #endif -); + ); #ifndef CLEANUP_ACELP_ENC -/* o : tilt of the code Q15 */ -Word16 est_tilt_ivas_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + /* o : tilt of the code Q15 */ + Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #ifndef CLEANUP_ACELP_ENC - , - const Word16 flag_tilt /* i : flag for special tilt */ + , + const Word16 flag_tilt /* i : flag for special tilt */ #endif -); + ); #endif -/* o : tilt of the code */ -Word16 Est_tilt2( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -); - -void E_UTIL_voice_factor( - Word16 *exc, /* i : pointer to the excitation frame Q_new */ - Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* i : innovative codebook Q9 */ - Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ - Word16 *tilt_code, /* o : tilt factor Q15 */ - Word16 L_subfr, /* i : subframe length */ - Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ - Word16 Q_new, /* i : excitation buffer format */ - Word16 shift /* i : scaling to get 12bit */ -); - -void sinq_fx( - const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ - const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ - const Word16 N, /* i : size of output */ - Word16 x[] /* o : output vector Q15*/ -); - -void window_ola_fx( - Word32 *ImdctOut, - Word16 *auOut, - Word16 *Q_sig, - Word16 *OldauOut, - Word16 *Q_old, - const Word16 L, - const Word16 right_mode, - const Word16 left_mode, - const Word16 old_bfi, - const Word16 oldHqVoicing, - Word16 *oldgapsynth ); - -void core_switching_OLA_fx( - Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ - const Word16 last_L_frame, /* i : last L_frame lengthture */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ - Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ - Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ - const Word16 output_frame, /* i : output frame length */ - const Word16 bwidth, /* i : output bandwidth */ - Word16 *Qsynth, - Word16 *Qsubfr ); - -void window_ola_ext_fx( - const Word32 *ImdstOut, /* i : input */ - Word32 *auOut, /* o : output audio */ - Word32 *OldauOut, /* i/o: audio from previous frame */ - const Word16 L, /* i : length */ - const Word16 right_mode, - const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const UWord16 kernel_type /* i : transform kernel type */ -); - -void cb_shape_fx( - const Word16 preemphFlag, /* i : flag for pre-emphasis */ - const Word16 pitchFlag, /* i : flag for pitch sharpening */ - const Word16 scramblingFlag, /* i : flag for phase scrambling */ - const Word16 sharpFlag, /* i : flag for formant sharpening */ - const Word16 formantTiltFlag, /* i : flag for formant tilt */ - const Word16 g1, /* i : formant sharpening numerator weighting */ - const Word16 g2, /* i : formant sharpening denominator weighting */ - const Word16 *p_Aq, /* i : LP filter coefficients */ - Word16 *code, /* i/o: signal to shape */ - const Word16 tilt_code, /* i : tilt of code */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ - const Word16 shift, - const Word16 L_subfr /* i : subframe lenght */ -); - -void longadd( - UWord16 a[], /* i/o: vector of the length lena */ - const UWord16 b[], /* i/o: vector of the length lenb */ - const Word16 lena, /* i/o: length of vector a[] */ - const Word16 lenb /* i/o: length of vector b[] */ -); - -void longshiftright( - UWord16 a[], /* i : vector of the length lena */ - const Word16 b, /* i : number of bit positions to shift right */ - UWord16 d[], /* o : vector of the length lend */ - Word16 lena, /* i : length of vector a[] */ - const Word16 lend /* i : length of vector d[] */ -); - -void longshiftleft( - const UWord16 a[], /* i : vector of the length len */ - const Word16 b, /* i : number of bit positions to shift left */ - UWord16 d[], /* o : vector of the length len */ - const Word16 len /* i : length of vector a[] and d[] */ -); - -void longshr( - UWord32 a[], - Word16 bits, - Word16 len ); - -void bands_and_bit_alloc_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : i signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); - -void fine_gain_pred_fx( - const Word16 *sfm_start, /* i : Sub band start indices */ - const Word16 *sfm_end, /* i : Sub band end indices */ - const Word16 *sfm_size, /* i : Sub band bandwidths */ - const Word16 *i_sort, /* i : Energy sorting indices */ - const Word16 *K, /* i : Number of pulses per band */ - const Word16 *maxpulse, /* i : Maximum pulse per band */ - const Word16 *R, /* i : Bits per sub band Q3 */ - const Word16 num_sfm, /* i : Number of sub bands */ - Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ - Word16 *y, /* i/o: Quantized vector (int) */ - Word16 *fg_pred, /* o : Predicted fine gains Q12 */ - const Word16 core /* i : Core */ -); - -void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ -); - -void get_max_pulses_fx( - const Word16 *band_start, /* i : Sub band start indices */ - const Word16 *band_end, /* i : Sub band end indices */ - const Word16 *k_sort, /* i : Indices for sorting by energy */ - const Word16 *npulses, /* i : Pulses per sub band */ - const Word16 BANDS, /* i : Number of bands */ - Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ - Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ -); - -void fine_gain_dec_fx( - Decoder_State *st, - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ -); - -/* o : Number of assigned gain bits */ -Word16 assign_gain_bits_fx( - const Word16 core, /* i : HQ core */ - const Word16 BANDS, /* i : Number of bands */ - const Word16 *band_width, /* i : Sub band bandwidth */ - Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *gain_bits_array, /* o : Assigned gain bits */ - Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ -); - -void freq_dnw_scaling_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 coder_type, /* i : coder type */ - const Word16 noise_lev, /* i : Noise level */ - const Word32 core_brate, /* i : Core bitrate */ - Word16 fy_norm[], /* i/o: Frequency quantized parameter */ - Word16 Qx, /* Q format of fy_norm*/ - const Word16 L_frame /* i : frame length */ -); + /* o : tilt of the code */ + Word16 Est_tilt2( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ + ); + + void E_UTIL_voice_factor( + Word16 *exc, /* i : pointer to the excitation frame Q_new */ + Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* i : innovative codebook Q9 */ + Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ + Word16 *tilt_code, /* o : tilt factor Q15 */ + Word16 L_subfr, /* i : subframe length */ + Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ + Word16 Q_new, /* i : excitation buffer format */ + Word16 shift /* i : scaling to get 12bit */ + ); + + void sinq_fx( + const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ + const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ + const Word16 N, /* i : size of output */ + Word16 x[] /* o : output vector Q15*/ + ); + + void window_ola_fx( + Word32 *ImdctOut, + Word16 *auOut, + Word16 *Q_sig, + Word16 *OldauOut, + Word16 *Q_old, + const Word16 L, + const Word16 right_mode, + const Word16 left_mode, + const Word16 old_bfi, + const Word16 oldHqVoicing, + Word16 *oldgapsynth ); + + void core_switching_OLA_fx( + Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ + const Word16 last_L_frame, /* i : last L_frame lengthture */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ + Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ + Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ + const Word16 output_frame, /* i : output frame length */ + const Word16 bwidth, /* i : output bandwidth */ + Word16 *Qsynth, + Word16 *Qsubfr ); + + void window_ola_ext_fx( + const Word32 *ImdstOut, /* i : input */ + Word32 *auOut, /* o : output audio */ + Word32 *OldauOut, /* i/o: audio from previous frame */ + const Word16 L, /* i : length */ + const Word16 right_mode, + const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const UWord16 kernel_type /* i : transform kernel type */ + ); + + void cb_shape_fx( + const Word16 preemphFlag, /* i : flag for pre-emphasis */ + const Word16 pitchFlag, /* i : flag for pitch sharpening */ + const Word16 scramblingFlag, /* i : flag for phase scrambling */ + const Word16 sharpFlag, /* i : flag for formant sharpening */ + const Word16 formantTiltFlag, /* i : flag for formant tilt */ + const Word16 g1, /* i : formant sharpening numerator weighting */ + const Word16 g2, /* i : formant sharpening denominator weighting */ + const Word16 *p_Aq, /* i : LP filter coefficients */ + Word16 *code, /* i/o: signal to shape */ + const Word16 tilt_code, /* i : tilt of code */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ + const Word16 shift, + const Word16 L_subfr /* i : subframe lenght */ + ); + + void longadd( + UWord16 a[], /* i/o: vector of the length lena */ + const UWord16 b[], /* i/o: vector of the length lenb */ + const Word16 lena, /* i/o: length of vector a[] */ + const Word16 lenb /* i/o: length of vector b[] */ + ); + + void longshiftright( + UWord16 a[], /* i : vector of the length lena */ + const Word16 b, /* i : number of bit positions to shift right */ + UWord16 d[], /* o : vector of the length lend */ + Word16 lena, /* i : length of vector a[] */ + const Word16 lend /* i : length of vector d[] */ + ); + + void longshiftleft( + const UWord16 a[], /* i : vector of the length len */ + const Word16 b, /* i : number of bit positions to shift left */ + UWord16 d[], /* o : vector of the length len */ + const Word16 len /* i : length of vector a[] and d[] */ + ); + + void longshr( + UWord32 a[], + Word16 bits, + Word16 len ); + + void bands_and_bit_alloc_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : i signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); + + void fine_gain_pred_fx( + const Word16 *sfm_start, /* i : Sub band start indices */ + const Word16 *sfm_end, /* i : Sub band end indices */ + const Word16 *sfm_size, /* i : Sub band bandwidths */ + const Word16 *i_sort, /* i : Energy sorting indices */ + const Word16 *K, /* i : Number of pulses per band */ + const Word16 *maxpulse, /* i : Maximum pulse per band */ + const Word16 *R, /* i : Bits per sub band Q3 */ + const Word16 num_sfm, /* i : Number of sub bands */ + Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ + Word16 *y, /* i/o: Quantized vector (int) */ + Word16 *fg_pred, /* o : Predicted fine gains Q12 */ + const Word16 core /* i : Core */ + ); + + void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ + ); + + void get_max_pulses_fx( + const Word16 *band_start, /* i : Sub band start indices */ + const Word16 *band_end, /* i : Sub band end indices */ + const Word16 *k_sort, /* i : Indices for sorting by energy */ + const Word16 *npulses, /* i : Pulses per sub band */ + const Word16 BANDS, /* i : Number of bands */ + Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ + Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ + ); + + void fine_gain_dec_fx( + Decoder_State *st, + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ + ); + + /* o : Number of assigned gain bits */ + Word16 assign_gain_bits_fx( + const Word16 core, /* i : HQ core */ + const Word16 BANDS, /* i : Number of bands */ + const Word16 *band_width, /* i : Sub band bandwidth */ + Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *gain_bits_array, /* o : Assigned gain bits */ + Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ + ); + + void freq_dnw_scaling_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 coder_type, /* i : coder type */ + const Word16 noise_lev, /* i : Noise level */ + const Word32 core_brate, /* i : Core bitrate */ + Word16 fy_norm[], /* i/o: Frequency quantized parameter */ + 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 */ + 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 */ + ); + void highband_exc_dct_in_ivas_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 */ + ); +#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 */ -); -void highband_exc_dct_in_ivas_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 */ @@ -5119,5612 +5156,5580 @@ 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 */ + Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ + const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ + Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ + const Word16 lsfBase[], /* i : base for differential lsf coding */ + Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ + const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ + Word16 L_frame, + const Word16 last_good, /*!< i : last good received frame */ + const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ + const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ + Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ + Word16 *lsf_cng, /* Q2.56 */ + Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ + const Word16 Last_GSC_pit_band_idx, + const Word16 Opt_AMR_WB, /* i : IO flag */ + const Word8 tcxonly, + const short bwidth /* i: coded bandwidth */ + ); + + Word16 const *PlcGetLsfBase( + Word16 const lpcQuantization, + Word16 const narrowBand, + Word32 const sr_core ); + + /* Create an instance of type FD_CNG */ + ivas_error createFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + + void initFdCngCom( + HANDLE_FD_CNG_COM hFdCngCom, + Word16 scale ); + + /* Delete the instance of type FD_CNG */ + void deleteFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + + /* Initialize the spectral partitioning */ + void initPartitions( + const Word16 *part_in, + const Word16 npart_in, + const Word16 startBand, + const Word16 stopBand, + Word16 *part_out, + Word16 *npart_out, + Word16 *midband, + Word16 *psize, + Word16 *psize_norm, + Word16 *psize_norm_exp, + Word16 *psize_inv, + const Word16 stopBandFR ); + + /* Noise estimation using Minimum Statistics (MS) */ + void compress_range( + Word32 *in, + Word16 in_exp, + Word16 *out, + const Word16 len ); + + void expand_range( + Word16 *in, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + + void expand_range_fx( + Word32 *in, // Q25 + Word32 *out, // exp:out_exp + Word16 *out_exp, + const Word16 len ); + + void expand_range_var_exp( + Word16 *in, + Word16 in_exp, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + + void minimum_statistics( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ + Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ + ); + + void minimum_statistics_fx( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ + Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 enc_dec, /* i : encoder/decoder indicator */ + const Word16 element_mode /* i : IVAS element mode type */ + ); + + /* Apply bitrate-dependant scale */ + void apply_scale( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ + ); + + Word16 apply_scale_ind( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ + ); + void apply_scale_ivas_fx( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize, /* i : Size of scale table */ + Word16 *index ); + + /* Compute the power for each partition */ + void bandcombinepow( + const Word32 *bandpow, /* i : Power for each band */ + const Word16 exp_bandpow, /* i : exponent of bandpow */ + const Word16 nband, /* i : Number of bands */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + const Word16 *psize_inv, /* i : Inverse partition sizes */ + Word32 *partpow, /* o : Power for each partition */ + Word16 *exp_partpow ); + + /* Scale partitions (with smoothing) */ + void scalebands( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + + void scalebands_fx( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + + /* STFT analysis filterbank */ + void AnalysisSTFT( + const Word16 *timeDomainInput, /* i : pointer to time signal */ + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + void AnalysisSTFT_fx( + const Word16 *timeDomainInput, + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + /* STFT synthesis filterbank */ + void SynthesisSTFT( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void SynthesisSTFT_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + Word32 sign_l( + const Word32 x /* i : input value of x */ + ); + + void ivas_updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word32 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ + ); + + /* Random generator with Gaussian distribution with mean 0 and std 1 */ + Word32 rand_gauss( + Word16 *seed ); + + Word16 rand_gauss_fix( + Word16 *x, + Word16 *seed ); + + void lpc_from_spectrum( + HANDLE_FD_CNG_COM hFdCngCom, + const Word16 start, /*i : start band*/ + const Word16 stop, /*i : stop band*/ + const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ + ); + + void msvq_decoder( + const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook vector dimension */ + const Word16 Idx[], /* i : Indices */ + Word16 *uq /* o : quantized vector */ + ); + + void FdCng_exc( + HANDLE_FD_CNG_COM hs, + Word16 *CNG_mode, + Word16 L_frame, + Word16 *lsp_old, + Word16 first_CNG, + Word16 *lsp_CNG, + Word16 *Aq, /* o: LPC coeffs */ + Word16 *lsp_new, /* o: lsp */ + Word16 *lsf_new, /* o: lsf */ + Word16 *exc, /* o: LP excitation */ + Word16 *exc2, /* o: LP excitation */ + Word16 *bwe_exc /* o: LP excitation for BWE */ + ); + + void direct_transform_fx( + const Word32 in32_fx[], + Word32 out32_fx[], + const Word16 is_transient, + const Word16 L, + Word16 *Q, + const Word16 element_mode ); + + void preecho_sb_fx( + const Word32 brate, /* i Q0 : core bit-rate */ + Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ + Word16 q_sig32, /* i Q value for wtda_audio_fx */ + Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ + Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ + const Word16 framelength, /* i Q0 : frame length */ + Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ + Word16 *smoothmem_fx, /* i/o Q15 : memory */ + Word32 *mean_prev_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ + Word16 *wmold_hb_fx, /* i/o Q15 : memory */ + Word16 *prevflag, /* i/o Q0 : flag */ + Word16 *pastpre, /* i/o Q0 : flag */ + const Word16 bwidth /* i Q0 : bandwidth */ + ); + + void Inverse_Transform( + const Word32 *in_mdct, /* i : i MDCT vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 is_transient, /* i : transient flag */ + const Word16 L, /* i : output frame length */ + const Word16 L_inner, /* i : length of the transform */ + const Word16 element_mode /* i : IVAS element mode */ + ); + + void recovernorm_fx( + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ + ); + + Word32 ar_div( Word32 num, Word32 denum ); + + void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); + void ar_encoder_done_fx( PARCODEC arInst ); + void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); + void ar_decoder_done_fx( PARCODEC arInst ); + Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); + + void TCQLSB_fx( + Word16 bcount, + Word32 *abuffer_fx, + Word16 *mbuffer_fx, + Word32 *sbuffer_fx, + Word16 *dpath ); + + void TCQLSBdec_fx( + Word16 *dpath, + Word16 *mbuffer, + Word16 bcount ); + + void RestoreTCQ_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + + void RestoreTCQdec_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + + void InitLSBTCQ_fx( + Word16 *bcount ); + + void SaveTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + + void LoadTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + + Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); + Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); + Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); + + Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); + + void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); + void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); + void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); + void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); + + Word16 GetScale_fx( + Word16 blen, + Word32 bits_fx, + Word32 *surplus_fx ); + + void srt_vec_ind_fx( + const Word32 *linear, + Word32 *srt, + Word16 *I, + Word16 length ); + + void fill_spectrum_fx( + Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ + Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ + const Word16 *R, /* i : number of pulses per band Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + Word16 norm[], /* i : quantization indices for norms Q0 */ + const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ + const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ + const Word16 nf_idx, /* i : noise fill index Q0 */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ + const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ + Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ + const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ + const Word16 core_sfm, /* i : index of the end band for core Q0 */ + const Word16 HQ_mode, /* i : HQ mode Q0 */ + Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ + const Word32 L_core_brate, /* i : target bit-rate Q0 */ + Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ + Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ + Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ + const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ + const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ + const Word16 *npulses, /* i : number of pulses per band Q0 */ + const Word16 prev_is_transient, /* i : previous transient flag Q0 */ + Word32 *prev_normq, /* i/o: previous norms Q14 */ + Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ + const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ + const Word16 *sfmsize, /* i : Length of bands Q0 */ + const Word16 *sfm_start, /* i : Start of bands Q0 */ + const Word16 *sfm_end, /* i : End of bands Q0 */ + Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ + const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + Word16 *prev_env_Q, + const Word16 num_env_bands, + const Word16 element_mode ); + + void hq_bit_allocation_fx( + const Word32 core_brate, /* i : Core bit-rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + const Word16 hqswb_clas, /* i : HQ class Q0 */ + Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ + const Word16 *normqlg2, /* i : Quantized norms Q0 */ + const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ + const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ + Word16 *noise_level, /* o : HVQ noise level Q15 */ + Word16 *R, /* o : Bit allocation per sub band Q0 */ + Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ + Word16 *sum, /* o : Sum of allocated shape bits Q0 */ + Word16 *core_sfm, /* o : Last coded band in core Q0 */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ + ); + + void map_quant_weight_fx( + const Word16 normqlg2[], /* i : quantized norms Q0*/ + Word16 wnorm[], /* o : weighted norm Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ + ); + + void bitalloc_fx( + Word16 *y, /* i : reordered norm of sub-vectors Q0 */ + Word16 *idx, /* i : reordered sub-vector indices Q0 */ + Word16 sum, /* i : number of available bits Q0 */ + Word16 N, /* i : number of norms Q0 */ + Word16 K, /* i : maximum number of bits per dimension Q0 */ + Word16 *r, /* o : bit-allacation vector Q0 */ + const Word16 *sfmsize, /* i : band length Q0 */ + const Word16 hqswb_clas /* i : signal classification flag Q0 */ + ); + + Word16 BitAllocF_fx( + Word16 *y, /* i : norm of sub-vectors :Q0 */ + Word32 bit_rate, /* i : bitrate :Q0 */ + Word16 B, /* i : number of available bits :Q0 */ + Word16 N, /* i : number of sub-vectors :Q0 */ + Word16 *R, /* o : bit-allocation indicator :Q0 */ + Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ + const Word16 hqswb_clas, /* i : hq swb class */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ + ); + + Word16 BitAllocWB_fx( + Word16 *y, /* i : norm of sub-vectors Q0*/ + Word16 B, /* i : number of available bits Q0*/ + Word16 N, /* i : number of sub-vectors Q0*/ + Word16 *R, /* o : bit-allocation indicator Q0*/ + Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ + ); + + void bitallocsum_fx( + Word16 *R, /* i : bit-allocation vector Q0 */ + const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ + Word16 *sum, /* o : total number of bits allocated Q0 */ + Word16 *Rsubband, /* o : rate per subband Q3 */ + const Word16 num_bits, /* i : number of bits Q0 */ + const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ + const Word16 *sfmsize /* i : band length Q0 */ + ); + + Word16 stab_est_fx( + Word16 etot, /* i : Total energy of the current frame Q8*/ + Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ + Word16 *mem_etot, /* i/o : Total energy memory Q8*/ + Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ + Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ + Word16 *thresh, /* i/o : Detection thresold Q11*/ + Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ + const Word16 vad_flag /* i : VAD flag */ + ); + + void enhancer_fx( + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ + ); + + void enhancer_ivas_fx( + const Word16 codec_mode, /* i : flag indicating Codec Mode */ + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 cbk_index, /* i : */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ + ); + + Word16 E_UTIL_enhancer( + Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + Word16 stab_fac, /* i : LP filter stability measure Q15 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ + Word16 *code, /* i/o: innovation(in: Q9) code_exp */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ + Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ + Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ + Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ + Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ + Word16 coder_type, /* i : coder type */ + Word16 cdk_index, /* i : */ + Word16 L_subfr, /* i : */ + Word16 L_frame, /* i : frame size */ + Word16 Q_new ); + + void phase_dispersion( + const Word32 gain_code, /* i : gain of code 15Q16 */ + const Word16 gain_pit, /* i : gain of pitch Q14 */ + Word16 code[], /* i/o: code vector */ + Word16 *code_e, /* i/o: exponent of code */ + const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ + Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ + Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ + Word16 *prev_state, /* i/o: static memory Q0 */ + Word16 L_subfr /* i : subframe length [40,64] */ + ); + + void tcx_ltp_get_lpc( + Word16 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word16 *A, /* Qx */ + const Word16 order /* Q0 */ + ); + + void tcx_ltp_get_lpc_fx( + Word32 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word32 *A, /* Qx */ + const Word16 order /* Q0 */ + ); + + void predict_signal( + const Word16 excI[], /* i : input excitation buffer Qx*/ + Word16 excO[], /* o : output excitation buffer Qx*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i : fraction of lag Q0*/ + const Word16 frac_max, /* i : max fraction Q0*/ + const Word16 L_subfr /* i : subframe size Q0*/ + ); + + Word16 tcx_ltp_decode_params( + Word16 *ltp_param, /* Q0 */ + Word16 *pitch_int, /* Q0 */ + Word16 *pitch_fr, /* Q0 */ + Word16 *gain, /* Q13 */ + const Word16 pitmin, /* Q0 */ + const Word16 pitfr1, /* Q0 */ + const Word16 pitfr2, /* Q0 */ + const Word16 pitmax, /* Q0 */ + const Word16 pitres /* Q0 */ + ); + + void tcx_ltp_post_fx( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word16 *sig, /* Qx */ + Word16 *tcx_buf /* Qx */ + ); + + void tcx_ltp_post_fx32( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word32 *sig, /* sig_q */ + Word32 *tcx_buf, /* sig_q */ + Word16 sig_q ); + + void Inac_switch_ematch_fx( + Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ + Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ + Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ + const Word16 coder_type, /* i : Coding mode */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 L_frame, /* i : Frame lenght */ + const Word16 Q_exc, /* i : input and output format of exc2 */ + const Word16 bfi, /* i : frame lost indicator */ + const Word16 last_core, /* i : Last core used */ + const Word16 last_codec_mode, /* i : Last codec mode */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 element_mode /* i : element mode */ + ); + + /**< out: Q0 | multiplication factor */ + Word16 IGF_ApplyTransFac( + const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ + const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ + ); + + Word16 IGF_MapBitRateToIndex( + const Word32 brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void IGFCommonFuncsCalcSfbEnergyPowerSpec( + const Word16 startSfb, /**< in: Q0 | start sfb index */ + const Word16 stopSfb, /**< in: Q0 | stop sfb index */ + const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ + Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ + Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ + Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ + Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ + ); + + void IGFCommonFuncsMDCTSquareSpec( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ + ); + + void IGFCommonFuncsMDCTSquareSpec_ivas( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ + ); + + Word16 IGFCommonFuncsIGFConfiguration( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + Word16 IGFCommonFuncsIGFGetCFTables_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ + const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ + Word16 *cf_off_se01, /* o : offset for CF table above */ + const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ + const Word16 **cf_off_se02, /* o : offsets for CF tables above */ + const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ + Word16 *cf_off_se10, /* o : offset for CF table above */ + const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ + const Word16 **cf_off_se11 /* o : offsets for CF tables above */ + ); + + Word32 L_multi31x16_X2( + Word16 xh, + Word16 xl, + Word16 y ); + + Word32 mul_sbc_14bits( + Word32 r, /* Q0 */ + Word16 c /* Q0 */ + ); + + void ham_cos_window( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + + void ham_cos_window_ivas( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + + /* o: Q31 */ + Word32 expfp( + const Word16 x, /* i: mantissa Q-e */ + const Word16 x_e ); /* i: exponent Q0 */ + + void powfp_odd2( + const Word16 base, /* Q15 */ + const Word16 exp, /* Q0 */ + Word16 *pout1, /* Q15 */ + Word16 *pout2 ); /* Q15 */ + + void tcx_arith_scale_envelope( + const Word16 L_spec_core, /* i: number of lines to scale Q0 */ + Word16 L_frame, /* i: number of lines Q0 */ + const Word32 env[], /* i: unscaled envelope Q16 */ + Word16 target_bits, /* i: number of available bits Q0 */ + const Word16 low_complexity, /* i: low-complexity flag Q0 */ + Word16 s_env[], /* o: scaled envelope Q15-e */ + Word16 *s_env_e /* o: scaled envelope exponent Q0 */ + ); + + void tcx_arith_render_envelope( + const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i: number of spectral lines Q0*/ + const Word16 L_spec, /* Q0 */ + const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o: shaped signal envelope Q16*/ + ); + + /* returns innovation gain Q16 */ + Word32 calc_gain_inov( + const Word16 *code, /* i : algebraic excitation Q9 */ + const Word16 lcode, /* i : Subframe size Q0 */ + Word32 *dotp, /* o : intermediate result Q31-e */ + Word16 *dotp_e /* o : intermediate result exponent Q0 */ + ); + + /////////////////////////////////// + /* Lib_dec */ + ////////////////////////////////// + + void ResetSHBbuffer_Dec_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl /* i : BWE extension layer */ + ); + + void wb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ + Word16 *Q_synth ); + + void swb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ + Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ + Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ + Word16 *Q_white_exc, + Word16 *synth, /* o : SHB synthesis/final synthesis */ + Word16 *Q_synth, + Word16 *pitch_buf ); + + void ivas_dequantizeSHBparams_fx_9_1( + Decoder_State *st_fx, + const Word16 extl, /* i : extension layer */ + Word32 extl_brate, /* i : extensiuon layer bitrate */ + Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ + Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ + Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ + Word16 *uv_flag, /* o : unvoiced flag*/ + Word32 *Q_shb_ener_sf, /* o : Q15 */ + Word16 *Q_shb_res_gshape, /* o : Q14 */ + Word16 *Q_mixFactors, /* o : Q15 */ + Word16 *MSFlag ); + + void fb_tbe_dec_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word16 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp ); + + void fb_tbe_dec_ivas_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word32 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp, + Word16 *fb_synth_ref, + Word16 Q_fb_synth_ref, + Word16 output_frame ); + + void tbe_read_bitstream_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ + ); + + void GenTransition_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 rf_flag, /* i : RF flag */ + Word32 total_bitrate /* i : total bitrate */ + ); + + void GenTransition_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 prev_Qx ); + + void GenTransition_WB_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output, /* o : synthesized transitions signal */ + const Word32 output_Fs /* i : output sampling rate */ + ); + + void GenTransition_WB_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ + ); + + void TBEreset_dec_fx( + Decoder_State *st_fx /* i/o: decoder state structure */ + ); + + void td_bwe_dec_init_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl, /* i : BWE extension layer */ + const Word32 output_Fs /* i : output sampling rate */ + ); + + void lsf_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ + Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + ); + + /*! r: index of the maximum value in the input vector */ + Word16 maximum_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /*! r: index of the minimum value in the input vector */ + Word16 minimum_l( + const Word32 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word32 *min_val /* o : minimum value in the input vector */ + ); + + void v_multc_fx( + const Word32 x[], /* i : Input vector */ + const Word32 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_fx_16( + const Word32 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_fx_16_16( + const Word16 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word16 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ + ); + + void v_add_fx_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_add_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_add_fx_me( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x1_e, /* i : Exponent for input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + const Word16 x2_e, /* i : Exponent for input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 *y_e, /* i : Exponent for output vector */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_add_w64( + const Word64 x1[], /* i : Input vector 1 */ + const Word64 x2[], /* i : Input vector 2 */ + Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_sub_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_sub_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + /*! r: dot product of x[] and y[] */ + Word32 dotp_fx32( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ + ); + + /*! r: dot product of x[] and y[] in case of overflow*/ + Word32 dotp_fx32_o( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q ); + + Word32 dotp_fx32_fac( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q /*stores resultant Q*/ + ); + + Word32 dotp_fx_ivas_fx( + const Word32 x[], /* i : vector x[] */ + Word16 x_e, + const Word32 y[], /* i : vector y[] */ + Word16 y_e, + const Word16 n, /* i : vector length */ + Word16 *out_e ); + + Word32 dotp_fx_guarded( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ + ); + + Word32 dotp_me_fx( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 exp_x, + Word16 exp_y, + Word16 *exp_suma ); + + void lsf_end_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 mode2_flag, /* Q0 */ + const Word16 coder_type_org, /* i : coding type Q0*/ + const Word16 bwidth, /* i : input signal bandwidth Q0*/ + const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ + Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ + Word16 *lpc_param, /* i : LPC parameters Q0*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + ); + + void lsf_mid_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ + Word16 coder_type, /* i : Coder type Q0*/ + Word16 lsp_mid[] /* o : quantized LSPs Q15*/ + ); + + void CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 last_element_mode, /* i : last element mode Q0 */ + Word16 Aq[], /* o : LP coefficients Q12 */ + Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ + Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ + Word16 *allow_cn_step, /* o : allow CN step Q0 */ + Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ + Word32 *q_env ); + + void swb_CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ + ); + + void swb_CNG_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ + ); + + void td_cng_dec_init_fx( + DEC_CORE_HANDLE st /* i/o: decoder state structure */ + ); + + void set_state( + Word16 *state, + Word16 num, + Word16 N ); + + void concealment_init_x( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + + void concealment_init_ivas_fx( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + + void concealment_update_x( + const Word16 bfi, + const Word16 core, + const Word16 tonality, + Word32 *invkoef /*Qinvkoef_scale*/, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + + Word16 Sqrt_x_fast( + Word32 value ); + + Word32 dot_w32_accuracy_x( + Word16 *s1, + Word16 *s2, + Word16 nbits, + Word16 N ); + + Word16 int_div_s_x( + Word16 a, + Word16 b ); + + Word16 GetW32Norm_x( + Word32 *s, + Word16 N ); + + Word16 harmo_x( + Word32 *X, + Word16 Framesize, + Word16 pitch ); + + void LpFilter2_x( + Word16 *x, + Word16 *y, + Word16 N ); + + void sig_tilt_x( + Word16 *s, + Word16 FrameSize, + Word32 *enr1, + Word32 *enr2 ); + + void get_maxConv_and_pitch_x( + Word16 *s_LP, + Word16 s, + Word16 e, + Word16 N, + Word32 *maxConv, + Word16 *maxConv_bits, + Word16 *pitch ); + + Word16 get_voicing_x( + Word16 *s_LP, + Word16 pitch, + Word32 covMax, + Word16 maxConv_bits, + Word16 Framesize ); + + void pitch_modify_x( + Word16 *s_LP, + Word16 *voicing, + Word16 *pitch, + Word16 FrameSize ); + + Word16 Is_Periodic_x( + Word32 *mdct_data, + Word16 cov_max, + Word16 zp, + Word32 ener, + Word32 ener_mean, + Word16 pitch, + Word16 Framesize ); + + Word16 get_conv_relation_x( + Word16 *s_LP, + Word16 shift, + Word16 N ); + + void concealment_decode_fix( + Word16 curr_mode, + Word32 *invkoef, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + + Word32 Spl_Energy_x( + const Word16 *vector, + const Word16 vector_length, + Word16 *scale_factor ); + + void Log10OfEnergy_x( + const Word16 *s, + Word32 *enerlogval, + const Word16 len ); + + void concealment_update2_x( + const Word16 *outx_new, + T_PLCInfo_HANDLE hPlcInfo, + const Word16 FrameSize ); + + Word16 ffr_getSfWord16( + Word16 *vector, /*!< Pointer to i vector */ + Word16 len ); + + void waveform_adj2_fix( + T_PLCInfo_HANDLE hPlcInfo, + Word16 *overlapbuf, + Word16 *outx_new, + const Word16 delay, + const Word16 bfi_cnt, + const Word16 bfi ); + + void concealment_signal_tuning_fx( + Decoder_State *st, + const Word16 bfi, + Word16 *outx_new_fx /*Qoutx_new_fx*/, + const Word16 past_core ); + + void DetectTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + + void RefineTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + + void ivas_RefineTonalComponents_fx( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 secondLastPowerSpectrum_e, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode, + const PsychoacousticParameters *psychParamsCurrent ); + + ivas_error PsychoacousticParameters_Init( + const Word32 sr_core, /* i : sampling rate of core-coder */ + const Word16 nBins, /* i : Number of bins (spectral lines) */ + const Word8 nBands, /* i : Number of spectrum subbands */ + const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ + const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ + PsychoacousticParameters *pPsychParams ); + + ivas_error TonalMDCTConceal_Init( + TonalMDCTConcealPtr self, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ + ); + + ivas_error TonalMDCTConceal_Init_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const UWord16 nSamples, + const UWord16 nSamplesCore, + const UWord16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ + ); + + /* Must be called only when a good frame is recieved - concealment is inactive */ + void TonalMDCTConceal_SaveFreqSignal( + TonalMDCTConcealPtr self, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + Word16 nNewSamples, + Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp ); + + void TonalMDCTConceal_SaveFreqSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + const Word16 nNewSamples, + const Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp, + const Word16 infoIGFStartLine ); + + void TonalMDCTConceal_UpdateState( + TonalMDCTConcealPtr self, + Word16 nNewSamples, + Word32 pitchLag, + Word16 badBlock, + Word8 tonalConcealmentActive ); + + void TonalMDCTConceal_Detect( + const TonalMDCTConcealPtr self, /*IN */ + const Word32 pitchLag, /*IN */ + Word16 *umIndices, /*OUT*/ + Word16 element_mode /* IN */ + ); + + void TonalMDCTConceal_Apply( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 *mdctSpectrum_exp /*IN */ + ); + + void TonalMDCTConceal_Apply_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 mdctSpectrum_exp, /*IN */ + const PsychoacousticParameters *psychParamsCurrent ); + + void TonalMDCTConceal_InsertNoise_ivas_fx( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, + Word16 *mdctSpectrum_exp, + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + const Word16 crossfadeGain, + const Word32 concealment_noise[L_FRAME48k], + const Word16 concealment_noise_e, + const Word32 cngLevelBackgroundTrace_bfi, + const Word16 cngLevelBackgroundTrace_e, + const Word16 crossOverFreq ); + + void TonalMDCTConceal_InsertNoise( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*OUT*/ + Word16 *mdctSpectrum_exp, /*OUT*/ + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + Word16 crossfadeGain, + const Word16 crossOverFreq ); + + void TonalMDCTConceal_SaveTimeSignal( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 nNewSamples ); + + void TonalMDCTConceal_SaveTimeSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 q_timeSignal, + Word16 nNewSamples ); + + void decision_matrix_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ + Word16 *hq_core_type, /* o : HQ core type Q0 */ + Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ + ); + + void hf_synth_init_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ + ); + + void hf_synth_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ + ); + + void hf_synth_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ + ); + + void hf_synth_ivas_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ + ); + + void hf_synth_amr_wb_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ + ); + + void hf_synth_amr_wb_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ + ); + + void hf_synth_amr_wb_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az : Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ + Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ + Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ + Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ + Word16 fmerit, /* i : classify parameter from FEC : Q14*/ + const Word16 *hf_gain, /* i : decoded HF gain Q0*/ + const Word16 *voice_factors, /* i : voicing factors : Q15*/ + const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ + const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ + const Word16 *lsf_new, /* i : ISF vector : Q2*/ + const Word16 Q_exc, /* i : exc scaling */ + const Word16 Q_out /* i : Q_syn2-1 */ + ); + + void Init_post_filter_fx( + PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ + ); /* i : core decoder parameters */ + + void nb_post_filt_fx( + const Word16 L_frame, /* i : frame length */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *psf_lp_noise, /* i : Long term noise Q8 */ + const Word16 tmp_noise, /* i : noise energy Q0 */ + Word16 *Synth, /* i : 12k8 synthesis Qsyn */ + const Word16 *Aq, /* i : LP filter coefficient Q12 */ + const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ + const Word16 coder_type, /* i : coder_type */ + const Word16 BER_detect, /* i : BER detect flag */ + const Word16 disable_hpf /* i : flag to diabled HPF */ + ); + + void formant_post_filt_fx( + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *synth_in, /* i : 12k8 synthesis */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ + Word16 *synth_out, /* i/o: input signal */ + const Word16 L_frame, /* i : frame length */ + const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ + const Word32 brate, /* (i) : bit-rate */ + const Word16 off_flag /* i : off flag */ + ); + + void Filt_mu_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr /* i : the length of subframe */ + ); + + void Filt_mu_ivas_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr, /* i : the length of subframe */ + const Word16 extl ); + + void scale_st_fx( + const Word16 *sig_in, /* i : postfilter i signal */ + Word16 *sig_out, /* i/o: postfilter o signal */ + Word16 *gain_prec, /* i/o: last value of gain for subframe */ + Word16 L_subfr ); + + void blend_subfr2_fx( + Word16 *sigIn1, /* i : i signal for fade-out */ + Word16 *sigIn2, /* i : i signal for fade-in */ + Word16 *sigOut /* o : output signal */ + ); + + void init_tcx_window_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ + const Word32 sr_core, /* i : SR core */ + const Word32 input_Fs, /* i : input/output SR */ + const Word16 L_frame, /* i : L_frame at sr_core */ + const Word16 L_frameTCX, /* i : L_frame at i/o SR */ + const Word16 mdctWindowLength, /* i : window length at sr_core */ + const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ + const Word16 element_mode /* i : mode of CPE/SCE */ + ); + + void init_tcx_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, /*Q15*/ + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, + const Word16 fscaleFB ); + + void syn_output_fx( + const Word16 codec_mode, /* i : MODE1 or MODE2 */ + Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ + const Word16 output_frame, /* i : output frame length */ + Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ + const Word16 Q_syn2 /* i : Synthesis scaling factor */ + ); + + void unscale_AGC( + const Word16 x[], /* i: 16kHz synthesis Qx */ + const Word16 Qx, /* i: scale factor of x */ + Word16 y[], /* o: output vector Q0 */ + Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ + const Word16 n /* i: vector size */ + ); + + void bass_psfilter_init_fx( + BPF_DEC_HANDLE hBPF /* o : BPF data handle */ + ); + + void bass_psfilter_fx( + BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ + const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ + Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ + const Word16 L_frame, /* i : length of the last frame Q0*/ + Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ + const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ + Word16 v_stab_fx, /* i : stability factor Q15*/ + Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ + const Word16 coder_type, /* i : coder_type Q0*/ + Word16 Q_syn, + Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ + ); + + void addBassPostFilter_fx( + const Word16 *harm_timeIn_Fx, /* timeIn_e */ + Word32 **rAnalysis_Fx, /* Qx - 5 */ + Word32 **iAnalysis_Fx, /* Qx - 5 */ + HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, + Word32 *workBuffer, /* Qx */ + const Word16 timeIn_e, + const Word16 nTimeSlots, /* Q0 */ + const Word16 nTimeSlotsTotal, /* Q0 */ + const Word16 nBandsTotal, /* Q0 */ + CLDFB_SCALE_FACTOR *cldfb_scale ); + + void FEC_exc_estim_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* o : pointer to excitation buffer (with past) */ + Word16 *exc2, /* o : total excitation (for synthesis) */ + Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ + Word16 *pitch_buf, /* o : Floating pitch for each subframe */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *tmp_tc, /* o : FEC pitch Q6 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *lsf_new, /* i : ISFs at the end of the frame */ + Word16 *Q_exc, + Word16 *tmp_noise /* o : long-term noise energy Q0 */ + ); + + void pitch_pred_linear_fit( + const Word16 bfi_cnt, /* i: bfi counter Q0 */ + const Word16 last_good, /* i: last classification type Q0 */ + Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ + Word32 *old_fpitch, /* i: Q16*/ + Word32 *T0_out, /* o: estimated close loop pitch Q16*/ + Word16 pit_min, /* i: Minimum pitch lag Q0 */ + Word16 pit_max, /* i: Maximum pitch lag Q0 */ + Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ + Word16 limitation, + Word16 plc_use_future_lag, /* i: Q0 */ + Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ + Word16 nb_subfr /* i: number of ACELP subframes */ + ); + + void get_subframe_pitch( + Word16 nSubframes, /* i: number of subframes Q0 */ + Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ + Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ + Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ + ); + + void PulseResynchronization_fx( + Word16 const *const src_exc, /*i Q15*/ + Word16 *const dst_exc, /*o Q15*/ + Word16 const nFrameLength, /*i Q0 */ + Word16 const nSubframes, /*i Q0 */ + Word32 const pitchStart, /*i Q16*/ + Word32 const pitchEnd /*i Q16*/ + ); + + void decod_audio_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ + ); + + void gsc_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ + Word16 *Q_exc ); + + void GSC_dec_init_fx( + GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ + ); + + void Es_pred_dec_fx( + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + const Word16 enr_idx, /* i : indice */ + const Word16 nb_bits, /* i : number of bits */ + const Word16 no_ltp /* i : no LTP flag */ + ); + + void gain_dec_tc_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ + ); + + void gain_dec_tc_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ + ); + + void gain_dec_mless_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ + ); + + void gain_dec_lbr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 *code_fx, /* i : algebraic excitation Q9 */ + Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes */ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ + const Word16 L_subfr /* i : subfr lenght */ + ); + +#ifndef CLEANUP_ACELP_ENC + void lp_gain_updt_fx( + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ + ); +#endif +#ifdef CLEANUP_ACELP_ENC + void lp_gain_updt_fx( + const Word16 element_mode, /* i : element 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( - const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ - Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ - const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ - Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ - const Word16 lsfBase[], /* i : base for differential lsf coding */ - Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ - const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ - Word16 L_frame, - const Word16 last_good, /*!< i : last good received frame */ - const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ - const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ - Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ - Word16 *lsf_cng, /* Q2.56 */ - Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ - const Word16 Last_GSC_pit_band_idx, - const Word16 Opt_AMR_WB, /* i : IO flag */ - const Word8 tcxonly, - const short bwidth /* i: coded bandwidth */ -); - -Word16 const *PlcGetLsfBase( - Word16 const lpcQuantization, - Word16 const narrowBand, - Word32 const sr_core ); - -/* Create an instance of type FD_CNG */ -ivas_error createFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - -void initFdCngCom( - HANDLE_FD_CNG_COM hFdCngCom, - Word16 scale ); - -/* Delete the instance of type FD_CNG */ -void deleteFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - -/* Initialize the spectral partitioning */ -void initPartitions( - const Word16 *part_in, - const Word16 npart_in, - const Word16 startBand, - const Word16 stopBand, - Word16 *part_out, - Word16 *npart_out, - Word16 *midband, - Word16 *psize, - Word16 *psize_norm, - Word16 *psize_norm_exp, - Word16 *psize_inv, - const Word16 stopBandFR ); - -/* Noise estimation using Minimum Statistics (MS) */ -void compress_range( - Word32 *in, - Word16 in_exp, - Word16 *out, - const Word16 len ); - -void expand_range( - Word16 *in, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - -void expand_range_fx( - Word32 *in, // Q25 - Word32 *out, // exp:out_exp - Word16 *out_exp, - const Word16 len ); - -void expand_range_var_exp( - Word16 *in, - Word16 in_exp, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - -void minimum_statistics( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ -); - -void minimum_statistics_fx( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ - Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ -); - -/* Apply bitrate-dependant scale */ -void apply_scale( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ -); - -Word16 apply_scale_ind( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ -); -void apply_scale_ivas_fx( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize, /* i : Size of scale table */ - Word16 *index ); - -/* Compute the power for each partition */ -void bandcombinepow( - const Word32 *bandpow, /* i : Power for each band */ - const Word16 exp_bandpow, /* i : exponent of bandpow */ - const Word16 nband, /* i : Number of bands */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - const Word16 *psize_inv, /* i : Inverse partition sizes */ - Word32 *partpow, /* o : Power for each partition */ - Word16 *exp_partpow ); - -/* Scale partitions (with smoothing) */ -void scalebands( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - -void scalebands_fx( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - -/* STFT analysis filterbank */ -void AnalysisSTFT( - const Word16 *timeDomainInput, /* i : pointer to time signal */ - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void AnalysisSTFT_fx( - const Word16 *timeDomainInput, - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -/* STFT synthesis filterbank */ -void SynthesisSTFT( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -void SynthesisSTFT_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -Word32 sign_l( - const Word32 x /* i : input value of x */ -); - -void ivas_updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ -); - -/* Random generator with Gaussian distribution with mean 0 and std 1 */ -Word32 rand_gauss( - Word16 *seed ); - -Word16 rand_gauss_fix( - Word16 *x, - Word16 *seed ); - -void lpc_from_spectrum( - HANDLE_FD_CNG_COM hFdCngCom, - const Word16 start, /*i : start band*/ - const Word16 stop, /*i : stop band*/ - const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ -); - -void msvq_decoder( - const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook vector dimension */ - const Word16 Idx[], /* i : Indices */ - Word16 *uq /* o : quantized vector */ -); - -void FdCng_exc( - HANDLE_FD_CNG_COM hs, - Word16 *CNG_mode, - Word16 L_frame, - Word16 *lsp_old, - Word16 first_CNG, - Word16 *lsp_CNG, - Word16 *Aq, /* o: LPC coeffs */ - Word16 *lsp_new, /* o: lsp */ - Word16 *lsf_new, /* o: lsf */ - Word16 *exc, /* o: LP excitation */ - Word16 *exc2, /* o: LP excitation */ - Word16 *bwe_exc /* o: LP excitation for BWE */ -); - -void direct_transform_fx( - const Word32 in32_fx[], - Word32 out32_fx[], - const Word16 is_transient, - const Word16 L, - Word16 *Q, - const Word16 element_mode ); - -void preecho_sb_fx( - const Word32 brate, /* i Q0 : core bit-rate */ - Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ - Word16 q_sig32, /* i Q value for wtda_audio_fx */ - Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ - Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ - const Word16 framelength, /* i Q0 : frame length */ - Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ - Word16 *smoothmem_fx, /* i/o Q15 : memory */ - Word32 *mean_prev_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ - Word16 *wmold_hb_fx, /* i/o Q15 : memory */ - Word16 *prevflag, /* i/o Q0 : flag */ - Word16 *pastpre, /* i/o Q0 : flag */ - const Word16 bwidth /* i Q0 : bandwidth */ -); - -void Inverse_Transform( - const Word32 *in_mdct, /* i : i MDCT vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 is_transient, /* i : transient flag */ - const Word16 L, /* i : output frame length */ - const Word16 L_inner, /* i : length of the transform */ - const Word16 element_mode /* i : IVAS element mode */ -); - -void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ - Word16 *ynrm, /* o : recovered quantization indices Q0*/ - Word16 *normqlg2, /* o : recovered quantized norms Q0*/ - const Word16 nb_sfm /* i : number of SFMs Q0*/ -); - -Word32 ar_div( Word32 num, Word32 denum ); - -void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); -void ar_encoder_done_fx( PARCODEC arInst ); -void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); -void ar_decoder_done_fx( PARCODEC arInst ); -Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); - -void TCQLSB_fx( - Word16 bcount, - Word32 *abuffer_fx, - Word16 *mbuffer_fx, - Word32 *sbuffer_fx, - Word16 *dpath ); - -void TCQLSBdec_fx( - Word16 *dpath, - Word16 *mbuffer, - Word16 bcount ); - -void RestoreTCQ_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - -void RestoreTCQdec_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - -void InitLSBTCQ_fx( - Word16 *bcount ); - -void SaveTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - -void LoadTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - -Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); -Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); -Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); - -Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); - -void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); -void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); -void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); -void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); - -Word16 GetScale_fx( - Word16 blen, - Word32 bits_fx, - Word32 *surplus_fx ); - -void srt_vec_ind_fx( - const Word32 *linear, - Word32 *srt, - Word16 *I, - Word16 length ); - -void fill_spectrum_fx( - Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ - Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ - const Word16 *R, /* i : number of pulses per band Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - Word16 norm[], /* i : quantization indices for norms Q0 */ - const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ - const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ - const Word16 nf_idx, /* i : noise fill index Q0 */ - const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ - const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ - Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ - Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ - Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ - const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ - const Word16 core_sfm, /* i : index of the end band for core Q0 */ - const Word16 HQ_mode, /* i : HQ mode Q0 */ - Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ - const Word32 L_core_brate, /* i : target bit-rate Q0 */ - Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ - Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ - Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ - const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ - const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ - const Word16 *npulses, /* i : number of pulses per band Q0 */ - const Word16 prev_is_transient, /* i : previous transient flag Q0 */ - Word32 *prev_normq, /* i/o: previous norms Q14 */ - Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ - const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ - const Word16 *sfmsize, /* i : Length of bands Q0 */ - const Word16 *sfm_start, /* i : Start of bands Q0 */ - const Word16 *sfm_end, /* i : End of bands Q0 */ - Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ - const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ - const Word16 num_sfm, /* i : Total number of bands Q0 */ - Word16 *prev_env_Q, - const Word16 num_env_bands, - const Word16 element_mode ); - -void hq_bit_allocation_fx( - const Word32 core_brate, /* i : Core bit-rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - const Word16 hqswb_clas, /* i : HQ class Q0 */ - Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ - const Word16 *normqlg2, /* i : Quantized norms Q0 */ - const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ - const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ - Word16 *noise_level, /* o : HVQ noise level Q15 */ - Word16 *R, /* o : Bit allocation per sub band Q0 */ - Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ - Word16 *sum, /* o : Sum of allocated shape bits Q0 */ - Word16 *core_sfm, /* o : Last coded band in core Q0 */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ -); - -void map_quant_weight_fx( - const Word16 normqlg2[], /* i : quantized norms Q0*/ - Word16 wnorm[], /* o : weighted norm Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ -); - -void bitalloc_fx( - Word16 *y, /* i : reordered norm of sub-vectors Q0 */ - Word16 *idx, /* i : reordered sub-vector indices Q0 */ - Word16 sum, /* i : number of available bits Q0 */ - Word16 N, /* i : number of norms Q0 */ - Word16 K, /* i : maximum number of bits per dimension Q0 */ - Word16 *r, /* o : bit-allacation vector Q0 */ - const Word16 *sfmsize, /* i : band length Q0 */ - const Word16 hqswb_clas /* i : signal classification flag Q0 */ -); - -Word16 BitAllocF_fx( - Word16 *y, /* i : norm of sub-vectors :Q0 */ - Word32 bit_rate, /* i : bitrate :Q0 */ - Word16 B, /* i : number of available bits :Q0 */ - Word16 N, /* i : number of sub-vectors :Q0 */ - Word16 *R, /* o : bit-allocation indicator :Q0 */ - Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ - const Word16 hqswb_clas, /* i : hq swb class */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ -); - -Word16 BitAllocWB_fx( - Word16 *y, /* i : norm of sub-vectors Q0*/ - Word16 B, /* i : number of available bits Q0*/ - Word16 N, /* i : number of sub-vectors Q0*/ - Word16 *R, /* o : bit-allocation indicator Q0*/ - Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ -); - -void bitallocsum_fx( - Word16 *R, /* i : bit-allocation vector Q0 */ - const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ - Word16 *sum, /* o : total number of bits allocated Q0 */ - Word16 *Rsubband, /* o : rate per subband Q3 */ - const Word16 num_bits, /* i : number of bits Q0 */ - const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ - const Word16 *sfmsize /* i : band length Q0 */ -); - -Word16 stab_est_fx( - Word16 etot, /* i : Total energy of the current frame Q8*/ - Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ - Word16 *mem_etot, /* i/o : Total energy memory Q8*/ - Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ - Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ - Word16 *thresh, /* i/o : Detection thresold Q11*/ - Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ - const Word16 vad_flag /* i : VAD flag */ -); - -void enhancer_fx( - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ -); - -void enhancer_ivas_fx( - const Word16 codec_mode, /* i : flag indicating Codec Mode */ - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 cbk_index, /* i : */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ -); - -Word16 E_UTIL_enhancer( - Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - Word16 stab_fac, /* i : LP filter stability measure Q15 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ - Word16 *code, /* i/o: innovation(in: Q9) code_exp */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ - Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ - Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ - Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ - Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ - Word16 coder_type, /* i : coder type */ - Word16 cdk_index, /* i : */ - Word16 L_subfr, /* i : */ - Word16 L_frame, /* i : frame size */ - Word16 Q_new ); - -void phase_dispersion( - const Word32 gain_code, /* i : gain of code 15Q16 */ - const Word16 gain_pit, /* i : gain of pitch Q14 */ - Word16 code[], /* i/o: code vector */ - Word16 *code_e, /* i/o: exponent of code */ - const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ - Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ - Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ - Word16 *prev_state, /* i/o: static memory Q0 */ - Word16 L_subfr /* i : subframe length [40,64] */ -); - -void tcx_ltp_get_lpc( - Word16 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word16 *A, /* Qx */ - const Word16 order /* Q0 */ -); - -void tcx_ltp_get_lpc_fx( - Word32 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word32 *A, /* Qx */ - const Word16 order /* Q0 */ -); - -void predict_signal( - const Word16 excI[], /* i : input excitation buffer Qx*/ - Word16 excO[], /* o : output excitation buffer Qx*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i : fraction of lag Q0*/ - const Word16 frac_max, /* i : max fraction Q0*/ - const Word16 L_subfr /* i : subframe size Q0*/ -); - -Word16 tcx_ltp_decode_params( - Word16 *ltp_param, /* Q0 */ - Word16 *pitch_int, /* Q0 */ - Word16 *pitch_fr, /* Q0 */ - Word16 *gain, /* Q13 */ - const Word16 pitmin, /* Q0 */ - const Word16 pitfr1, /* Q0 */ - const Word16 pitfr2, /* Q0 */ - const Word16 pitmax, /* Q0 */ - const Word16 pitres /* Q0 */ -); - -void tcx_ltp_post_fx( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word16 *sig, /* Qx */ - Word16 *tcx_buf /* Qx */ -); - -void tcx_ltp_post_fx32( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word32 *sig, /* sig_q */ - Word32 *tcx_buf, /* sig_q */ - Word16 sig_q ); - -void Inac_switch_ematch_fx( - Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ - Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ - const Word16 coder_type, /* i : Coding mode */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 L_frame, /* i : Frame lenght */ - const Word16 Q_exc, /* i : input and output format of exc2 */ - const Word16 bfi, /* i : frame lost indicator */ - const Word16 last_core, /* i : Last core used */ - const Word16 last_codec_mode, /* i : Last codec mode */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 element_mode /* i : element mode */ -); - -/**< out: Q0 | multiplication factor */ -Word16 IGF_ApplyTransFac( - const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ - const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ -); - -Word16 IGF_MapBitRateToIndex( - const Word32 brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void IGFCommonFuncsCalcSfbEnergyPowerSpec( - const Word16 startSfb, /**< in: Q0 | start sfb index */ - const Word16 stopSfb, /**< in: Q0 | stop sfb index */ - const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ - Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ - Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ - Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ - Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ -); - -void IGFCommonFuncsMDCTSquareSpec( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ -); - -void IGFCommonFuncsMDCTSquareSpec_ivas( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ -); - -Word16 IGFCommonFuncsIGFConfiguration( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -Word16 IGFCommonFuncsIGFGetCFTables_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ - const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ - Word16 *cf_off_se01, /* o : offset for CF table above */ - const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ - const Word16 **cf_off_se02, /* o : offsets for CF tables above */ - const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ - Word16 *cf_off_se10, /* o : offset for CF table above */ - const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ - const Word16 **cf_off_se11 /* o : offsets for CF tables above */ -); - -Word32 L_multi31x16_X2( - Word16 xh, - Word16 xl, - Word16 y ); - -Word32 mul_sbc_14bits( - Word32 r, /* Q0 */ - Word16 c /* Q0 */ -); - -void ham_cos_window( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - -void ham_cos_window_ivas( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - -/* o: Q31 */ -Word32 expfp( - const Word16 x, /* i: mantissa Q-e */ - const Word16 x_e ); /* i: exponent Q0 */ - -void powfp_odd2( - const Word16 base, /* Q15 */ - const Word16 exp, /* Q0 */ - Word16 *pout1, /* Q15 */ - Word16 *pout2 ); /* Q15 */ - -void tcx_arith_scale_envelope( - const Word16 L_spec_core, /* i: number of lines to scale Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - const Word32 env[], /* i: unscaled envelope Q16 */ - Word16 target_bits, /* i: number of available bits Q0 */ - const Word16 low_complexity, /* i: low-complexity flag Q0 */ - Word16 s_env[], /* o: scaled envelope Q15-e */ - Word16 *s_env_e /* o: scaled envelope exponent Q0 */ -); - -void tcx_arith_render_envelope( - const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i: number of spectral lines Q0*/ - const Word16 L_spec, /* Q0 */ - const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o: shaped signal envelope Q16*/ -); - -/* returns innovation gain Q16 */ -Word32 calc_gain_inov( - const Word16 *code, /* i : algebraic excitation Q9 */ - const Word16 lcode, /* i : Subframe size Q0 */ - Word32 *dotp, /* o : intermediate result Q31-e */ - Word16 *dotp_e /* o : intermediate result exponent Q0 */ -); - -/////////////////////////////////// -/* Lib_dec */ -////////////////////////////////// - -void ResetSHBbuffer_Dec_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl /* i : BWE extension layer */ -); - -void wb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ - Word16 *Q_synth ); - -void swb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ - Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ - Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ - Word16 *Q_white_exc, - Word16 *synth, /* o : SHB synthesis/final synthesis */ - Word16 *Q_synth, - Word16 *pitch_buf ); - -void ivas_dequantizeSHBparams_fx_9_1( - Decoder_State *st_fx, - const Word16 extl, /* i : extension layer */ - Word32 extl_brate, /* i : extensiuon layer bitrate */ - Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ - Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ - Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ - Word16 *uv_flag, /* o : unvoiced flag*/ - Word32 *Q_shb_ener_sf, /* o : Q15 */ - Word16 *Q_shb_res_gshape, /* o : Q14 */ - Word16 *Q_mixFactors, /* o : Q15 */ - Word16 *MSFlag ); - -void fb_tbe_dec_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word16 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp ); - -void fb_tbe_dec_ivas_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word32 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp, - Word16 *fb_synth_ref, - Word16 Q_fb_synth_ref, - Word16 output_frame ); - -void tbe_read_bitstream_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); - -void GenTransition_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 rf_flag, /* i : RF flag */ - Word32 total_bitrate /* i : total bitrate */ -); - -void GenTransition_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 prev_Qx ); - -void GenTransition_WB_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output, /* o : synthesized transitions signal */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void GenTransition_WB_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void TBEreset_dec_fx( - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -void td_bwe_dec_init_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl, /* i : BWE extension layer */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void lsf_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ -); - -/*! r: index of the maximum value in the input vector */ -Word16 maximum_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -Word16 minimum_l( - const Word32 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word32 *min_val /* o : minimum value in the input vector */ -); - -void v_multc_fx( - const Word32 x[], /* i : Input vector */ - const Word32 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_fx_16( - const Word32 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_fx_16_16( - const Word16 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word16 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ -); - -void v_add_fx_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_add_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_add_fx_me( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x1_e, /* i : Exponent for input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - const Word16 x2_e, /* i : Exponent for input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 *y_e, /* i : Exponent for output vector */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_add_w64( - const Word64 x1[], /* i : Input vector 1 */ - const Word64 x2[], /* i : Input vector 2 */ - Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_sub_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_sub_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -/*! r: dot product of x[] and y[] */ -Word32 dotp_fx32( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ -); - -/*! r: dot product of x[] and y[] in case of overflow*/ -Word32 dotp_fx32_o( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q ); - -Word32 dotp_fx32_fac( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q /*stores resultant Q*/ -); - -Word32 dotp_fx_ivas_fx( - const Word32 x[], /* i : vector x[] */ - Word16 x_e, - const Word32 y[], /* i : vector y[] */ - Word16 y_e, - const Word16 n, /* i : vector length */ - Word16 *out_e ); - -Word32 dotp_fx_guarded( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ -); - -Word32 dotp_me_fx( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 exp_x, - Word16 exp_y, - Word16 *exp_suma ); - -void lsf_end_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 mode2_flag, /* Q0 */ - const Word16 coder_type_org, /* i : coding type Q0*/ - const Word16 bwidth, /* i : input signal bandwidth Q0*/ - const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ - Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ - Word16 *lpc_param, /* i : LPC parameters Q0*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices, /* o : number of indices Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ -); - -void lsf_mid_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ - Word16 coder_type, /* i : Coder type Q0*/ - Word16 lsp_mid[] /* o : quantized LSPs Q15*/ -); - -void CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ - Word16 Aq[], /* o : LP coefficients Q12 */ - Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ - Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ - Word32 *q_env ); - -void swb_CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -); - -void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -); - -void td_cng_dec_init_fx( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ -); - -void set_state( - Word16 *state, - Word16 num, - Word16 N ); - -void concealment_init_x( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_init_ivas_fx( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_update_x( - const Word16 bfi, - const Word16 core, - const Word16 tonality, - Word32 *invkoef /*Qinvkoef_scale*/, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - -Word16 Sqrt_x_fast( - Word32 value ); - -Word32 dot_w32_accuracy_x( - Word16 *s1, - Word16 *s2, - Word16 nbits, - Word16 N ); - -Word16 int_div_s_x( - Word16 a, - Word16 b ); - -Word16 GetW32Norm_x( - Word32 *s, - Word16 N ); - -Word16 harmo_x( - Word32 *X, - Word16 Framesize, - Word16 pitch ); - -void LpFilter2_x( - Word16 *x, - Word16 *y, - Word16 N ); - -void sig_tilt_x( - Word16 *s, - Word16 FrameSize, - Word32 *enr1, - Word32 *enr2 ); - -void get_maxConv_and_pitch_x( - Word16 *s_LP, - Word16 s, - Word16 e, - Word16 N, - Word32 *maxConv, - Word16 *maxConv_bits, - Word16 *pitch ); - -Word16 get_voicing_x( - Word16 *s_LP, - Word16 pitch, - Word32 covMax, - Word16 maxConv_bits, - Word16 Framesize ); - -void pitch_modify_x( - Word16 *s_LP, - Word16 *voicing, - Word16 *pitch, - Word16 FrameSize ); - -Word16 Is_Periodic_x( - Word32 *mdct_data, - Word16 cov_max, - Word16 zp, - Word32 ener, - Word32 ener_mean, - Word16 pitch, - Word16 Framesize ); - -Word16 get_conv_relation_x( - Word16 *s_LP, - Word16 shift, - Word16 N ); - -void concealment_decode_fix( - Word16 curr_mode, - Word32 *invkoef, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - -Word32 Spl_Energy_x( - const Word16 *vector, - const Word16 vector_length, - Word16 *scale_factor ); - -void Log10OfEnergy_x( - const Word16 *s, - Word32 *enerlogval, - const Word16 len ); - -void concealment_update2_x( - const Word16 *outx_new, - T_PLCInfo_HANDLE hPlcInfo, - const Word16 FrameSize ); - -Word16 ffr_getSfWord16( - Word16 *vector, /*!< Pointer to i vector */ - Word16 len ); - -void waveform_adj2_fix( - T_PLCInfo_HANDLE hPlcInfo, - Word16 *overlapbuf, - Word16 *outx_new, - const Word16 delay, - const Word16 bfi_cnt, - const Word16 bfi ); - -void concealment_signal_tuning_fx( - Decoder_State *st, - const Word16 bfi, - Word16 *outx_new_fx /*Qoutx_new_fx*/, - const Word16 past_core ); - -void DetectTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - -void RefineTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - -void ivas_RefineTonalComponents_fx( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 secondLastPowerSpectrum_e, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode, - const PsychoacousticParameters *psychParamsCurrent ); - -ivas_error PsychoacousticParameters_Init( - const Word32 sr_core, /* i : sampling rate of core-coder */ - const Word16 nBins, /* i : Number of bins (spectral lines) */ - const Word8 nBands, /* i : Number of spectrum subbands */ - const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ - const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ - PsychoacousticParameters *pPsychParams ); - -ivas_error TonalMDCTConceal_Init( - TonalMDCTConcealPtr self, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ -); - -ivas_error TonalMDCTConceal_Init_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const UWord16 nSamples, - const UWord16 nSamplesCore, - const UWord16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ -); - -/* Must be called only when a good frame is recieved - concealment is inactive */ -void TonalMDCTConceal_SaveFreqSignal( - TonalMDCTConcealPtr self, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - Word16 nNewSamples, - Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp ); - -void TonalMDCTConceal_SaveFreqSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - const Word16 nNewSamples, - const Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp, - const Word16 infoIGFStartLine ); - -void TonalMDCTConceal_UpdateState( - TonalMDCTConcealPtr self, - Word16 nNewSamples, - Word32 pitchLag, - Word16 badBlock, - Word8 tonalConcealmentActive ); - -void TonalMDCTConceal_Detect( - const TonalMDCTConcealPtr self, /*IN */ - const Word32 pitchLag, /*IN */ - Word16 *umIndices, /*OUT*/ - Word16 element_mode /* IN */ -); - -void TonalMDCTConceal_Apply( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 *mdctSpectrum_exp /*IN */ -); - -void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 mdctSpectrum_exp, /*IN */ - const PsychoacousticParameters *psychParamsCurrent ); - -void TonalMDCTConceal_InsertNoise_ivas_fx( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, - Word16 *mdctSpectrum_exp, - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - const Word16 crossfadeGain, - const Word32 concealment_noise[L_FRAME48k], - const Word16 concealment_noise_e, - const Word32 cngLevelBackgroundTrace_bfi, - const Word16 cngLevelBackgroundTrace_e, - const Word16 crossOverFreq ); - -void TonalMDCTConceal_InsertNoise( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*OUT*/ - Word16 *mdctSpectrum_exp, /*OUT*/ - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - Word16 crossfadeGain, - const Word16 crossOverFreq ); - -void TonalMDCTConceal_SaveTimeSignal( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 nNewSamples ); - -void TonalMDCTConceal_SaveTimeSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 q_timeSignal, - Word16 nNewSamples ); - -void decision_matrix_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ - Word16 *hq_core_type, /* o : HQ core type Q0 */ - Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ -); - -void hf_synth_init_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); - -void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); - -void hf_synth_amr_wb_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az : Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ - Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ - Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ - Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ - Word16 fmerit, /* i : classify parameter from FEC : Q14*/ - const Word16 *hf_gain, /* i : decoded HF gain Q0*/ - const Word16 *voice_factors, /* i : voicing factors : Q15*/ - const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ - const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ - const Word16 *lsf_new, /* i : ISF vector : Q2*/ - const Word16 Q_exc, /* i : exc scaling */ - const Word16 Q_out /* i : Q_syn2-1 */ -); - -void Init_post_filter_fx( - PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ -); /* i : core decoder parameters */ - -void nb_post_filt_fx( - const Word16 L_frame, /* i : frame length */ - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *psf_lp_noise, /* i : Long term noise Q8 */ - const Word16 tmp_noise, /* i : noise energy Q0 */ - Word16 *Synth, /* i : 12k8 synthesis Qsyn */ - const Word16 *Aq, /* i : LP filter coefficient Q12 */ - const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ - const Word16 coder_type, /* i : coder_type */ - const Word16 BER_detect, /* i : BER detect flag */ - const Word16 disable_hpf /* i : flag to diabled HPF */ -); - -void formant_post_filt_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient Q12 */ - Word16 *synth_out, /* i/o: input signal */ - const Word16 L_frame, /* i : frame length */ - const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - const Word32 brate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ -); - -void Filt_mu_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr /* i : the length of subframe */ -); - -void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ); - -void scale_st_fx( - const Word16 *sig_in, /* i : postfilter i signal */ - Word16 *sig_out, /* i/o: postfilter o signal */ - Word16 *gain_prec, /* i/o: last value of gain for subframe */ - Word16 L_subfr ); - -void blend_subfr2_fx( - Word16 *sigIn1, /* i : i signal for fade-out */ - Word16 *sigIn2, /* i : i signal for fade-in */ - Word16 *sigOut /* o : output signal */ -); - -void init_tcx_window_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ - const Word32 sr_core, /* i : SR core */ - const Word32 input_Fs, /* i : input/output SR */ - const Word16 L_frame, /* i : L_frame at sr_core */ - const Word16 L_frameTCX, /* i : L_frame at i/o SR */ - const Word16 mdctWindowLength, /* i : window length at sr_core */ - const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ - const Word16 element_mode /* i : mode of CPE/SCE */ -); - -void init_tcx_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, /*Q15*/ - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, - const Word16 fscaleFB ); - -void syn_output_fx( - const Word16 codec_mode, /* i : MODE1 or MODE2 */ - Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ - const Word16 output_frame, /* i : output frame length */ - Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ - const Word16 Q_syn2 /* i : Synthesis scaling factor */ -); - -void unscale_AGC( - const Word16 x[], /* i: 16kHz synthesis Qx */ - const Word16 Qx, /* i: scale factor of x */ - Word16 y[], /* o: output vector Q0 */ - Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ - const Word16 n /* i: vector size */ -); - -void bass_psfilter_init_fx( - BPF_DEC_HANDLE hBPF /* o : BPF data handle */ -); - -void bass_psfilter_fx( - BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ - const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ - Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ - const Word16 L_frame, /* i : length of the last frame Q0*/ - Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ - const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ - Word16 v_stab_fx, /* i : stability factor Q15*/ - Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ - const Word16 coder_type, /* i : coder_type Q0*/ - Word16 Q_syn, - Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ -); - -void addBassPostFilter_fx( - const Word16 *harm_timeIn_Fx, /* timeIn_e */ - Word32 **rAnalysis_Fx, /* Qx - 5 */ - Word32 **iAnalysis_Fx, /* Qx - 5 */ - HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, - Word32 *workBuffer, /* Qx */ - const Word16 timeIn_e, - const Word16 nTimeSlots, /* Q0 */ - const Word16 nTimeSlotsTotal, /* Q0 */ - const Word16 nBandsTotal, /* Q0 */ - CLDFB_SCALE_FACTOR *cldfb_scale ); - -void FEC_exc_estim_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* o : pointer to excitation buffer (with past) */ - Word16 *exc2, /* o : total excitation (for synthesis) */ - Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ - Word16 *pitch_buf, /* o : Floating pitch for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *tmp_tc, /* o : FEC pitch Q6 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *Q_exc, - Word16 *tmp_noise /* o : long-term noise energy Q0 */ -); - -void pitch_pred_linear_fit( - const Word16 bfi_cnt, /* i: bfi counter Q0 */ - const Word16 last_good, /* i: last classification type Q0 */ - Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ - Word32 *old_fpitch, /* i: Q16*/ - Word32 *T0_out, /* o: estimated close loop pitch Q16*/ - Word16 pit_min, /* i: Minimum pitch lag Q0 */ - Word16 pit_max, /* i: Maximum pitch lag Q0 */ - Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ - Word16 limitation, - Word16 plc_use_future_lag, /* i: Q0 */ - Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ - Word16 nb_subfr /* i: number of ACELP subframes */ -); - -void get_subframe_pitch( - Word16 nSubframes, /* i: number of subframes Q0 */ - Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ - Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ - Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ -); - -void PulseResynchronization_fx( - Word16 const *const src_exc, /*i Q15*/ - Word16 *const dst_exc, /*o Q15*/ - Word16 const nFrameLength, /*i Q0 */ - Word16 const nSubframes, /*i Q0 */ - Word32 const pitchStart, /*i Q16*/ - Word32 const pitchEnd /*i Q16*/ -); - -void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ -); - -void gsc_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ - Word16 *Q_exc ); - -void GSC_dec_init_fx( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ -); - -void Es_pred_dec_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ - const Word16 enr_idx, /* i : indice */ - const Word16 nb_bits, /* i : number of bits */ - const Word16 no_ltp /* i : no LTP flag */ -); - -void gain_dec_tc_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -); - -void gain_dec_tc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -); - -void gain_dec_mless_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ -); - -void gain_dec_lbr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 *code_fx, /* i : algebraic excitation Q9 */ - Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes */ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ - const Word16 L_subfr /* i : subfr lenght */ -); - -#ifndef CLEANUP_ACELP_ENC -void lp_gain_updt_fx( - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ -); -#endif -#ifdef CLEANUP_ACELP_ENC -void lp_gain_updt_fx( - const Word16 element_mode, /* i : element mode */ -#else -void lp_gain_updt_ivas_fx( -#endif - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ -); - -/*! r: quantized codebook gain Q16 */ -Word32 gain_dec_gaus_fx( - Word16 index, /* i : quantization index */ - const Word16 bits, /* i : number of bits to quantize */ - const Word16 lowBound, /* i : lower bound of quantizer (dB) */ - const Word16 topBound, /* i : upper bound of quantizer (dB) */ - const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ -); - -void gain_dec_SQ_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 *code, /* i : algebraic code excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ - Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ -); - -void gain_dec_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - Word16 *gain_pit, /* o : Quantized pitch gain */ - Word32 *gain_code, /* o : Quantized codeebook gain */ - Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ - Word16 *gain_inov, /* o : unscaled innovation gain */ - const Word16 *code, /* i : algebraic code excitation */ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -void transf_cdbk_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ - const Word32 gain_code, /* i : innovative excitation gain (Q16) */ - Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ - Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ - Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ - Word16 *unbits /* o : number of AVQ unused bits */ -); - -/* o: decoded gain */ -Word16 gain_dequant_fx( - Word16 index, /* i: quantization index */ - const Word16 min, /* i: value of lower limit */ - const Word16 max, /* i: value of upper limit */ - const Word16 bits, /* i: number of bits to dequantize */ - Word16 *expg ); - -void AVQ_demuxdec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ - Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ - const Word16 Nsv, /* i : number of subvectors Q0*/ - Word16 nq[], /* i/o: AVQ nq index Q0*/ - Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ - Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ -); - -void AVQ_dec_lpc( - Word16 *indx, /* input: index[] (4 bits per words) Q0*/ - Word16 *nvecq, /* output: vector quantized Q0*/ - Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ - -void re8_dec_fx( - Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ - const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ - const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ -); - -void re8_decode_base_index_fx( - const Word16 n, - UWord16 I, - Word16 *x ); - -void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ -); - -void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ - Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ -); - -void re8_PPV_fx( - const Word32 x[], /* i : point in R^8 Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ -); - -void dec_pit_exc_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx, /* i : Number of subframe considered */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -/* o: pitch value Q16 */ -Word32 Mode2_pit_decode( - const Word16 coder_type, /* i: coding model */ - Word16 i_subfr, /* i: subframe index */ - Word16 L_subfr, - Word16 **pt_indice, /* i/o: quantization indices pointer */ - Word16 *T0, /* i/o: close loop integer pitch Q0 */ - Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ - Word16 *T0_res, /* i/o: pitch resolution Q0 */ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ - Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr1b, - Word16 pit_fr2, - Word16 pit_max, - Word16 pit_res_max ); - -void Mode2_abs_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 *T0_res, /* o: pitch resolution Q0 */ - Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr2, - Word16 pit_res_max ); - -void Mode2_delta_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 T0_res, /* i: pitch resolution Q0 */ - Word16 *T0_min, /* i: delta search min Q0 */ - Word16 *T0_min_frac, /* i: delta search min Q0 */ - Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ -); - -/* o : floating pitch value */ -Word16 pit_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ -); - -void pit_Q_dec_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 delta, /* i : Half the CL searched interval */ - const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ -); - -void pit16k_Q_dec_fx( - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ -); - -void abs_pit_dec_fx( - const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ - Word16 pitch_index, /* i: pitch index */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o: integer pitch lag */ - Word16 *T0_frac /* o: pitch fraction */ -); - -void delta_pit_dec_fx( - const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - const Word16 pitch_index, /* i : pitch index */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - const Word16 T0_min /* i : delta search min */ -); - -void limit_T0_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 delta, /* i : Half the close-loop searched interval */ - const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_max /* o : higher pitch limit */ -); - -void limit_T0_voiced( - const Word16 nbits, - const Word16 res, - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - const Word16 T0_res, /* i : pitch resolution */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_min_frac, /* o : lower pitch limit */ - Word16 *T0_max, /* o : higher pitch limit */ - Word16 *T0_max_frac, /* o : higher pitch limit */ - const Word16 pit_min, /* i : Minimum pitch lag */ - const Word16 pit_max /* i : Maximum pitch lag */ -); - -void inov_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ -); - -void inov_decode_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ -); - -void dec_acelp_4t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 nbbits, /* i : number of bits per codebook */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - const Word16 Opt_AMR_WB ); - -void D_ACELP_decode_43bit_fx( - UWord16 idxs[], - Word16 code[], - Word16 *pulsestrack ); - -void D_ACELP_indexing_fx( - Word16 code[], - PulseConfig config, - Word16 num_tracks, - Word16 index[], - Word16 *BER_detect ); - -void fcb_pulse_track_joint_decode_fx( - UWord16 *idxs, - Word16 wordcnt, - UWord32 *index_n, - Word16 *pulse_num, - Word16 track_num ); - -void dec_acelp_2t32_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[] /* o: algebraic (fixed) codebook excitation */ -); - -void dec_acelp_1t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ - const Word16 L_subfr /* i : sub frame lenght*/ -); - -ivas_error acelp_core_switch_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ - Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ - const Word16 output_frame, /* i : input frame length */ - const Word16 core_switching_flag, /* i : core switching flag */ - Word16 *mem_synth, /* o : synthesis to overlap */ - Word16 *Q_syn ); - -ivas_error acelp_core_switch_dec_bfi_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -); - -ivas_error acelp_core_switch_dec_bfi_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -); - -void pred_lt4( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ -); - -void pred_lt4_ivas_fx( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word32 *win, /* i : interpolation window Q31*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ -); - -void pred_lt4_tc_fx( - Word16 exc[], /* i/o: excitation buffer Q0*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i: fraction of lag Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 imp_pos, /* i : glottal impulse position Q0*/ - const Word16 i_subfr /* i : subframe index Q0*/ -); - -void pvq_decode_frame_fx( - Decoder_State *st_fx, - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ -); - -Word16 pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - -Word16 ivas_pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, /* Q3 */ - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - -void decode_energies_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 Np, - Word16 *dim_part, - Word16 *bits_part, - Word16 *g_part, /* Q15 */ - Word16 qband, - Word16 *bits_left, - Word16 dim, - const Word16 strict_bits ); - -void rc_dec_init_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 tot_bits /* i : Total bit budget */ -); - -/* o : Decoded cumulative frequency */ -UWord32 rc_decode_fx( - Word16 *BER_detect, /* o : Bit error detection flag */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Total cumulative frequency */ -); - -void rc_dec_update_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - - UWord32 cum_freq, /* i : Cumulative frequency */ - UWord32 sym_freq /* i : Symbol frequency */ -); - -/* o : Decoded value */ -Word32 rc_dec_bits_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 bits /* i : Number of bits */ -); - -/* o : Decoded value */ -UWord32 rc_dec_uniform_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Maximum value */ -); - -void rc_dec_finish_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ -); - -void pvq_decode_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 *xq, /* o: decoded vector (Q15) */ - Word16 *y, /* o: decoded vector (non-scaled int) */ - const Word16 k_val, /* i: number of allocated pulses */ - const Word16 dim, /* i: Length of vector */ - const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ -); -void nelp_decoder_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ - Word16 *exc, /* o : adapt. excitation exc Q_exc */ - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate Q0 */ - const Word16 coder_type, /* i : coding type Q0 */ - Word16 *gain_buf /* Q14 */ -); - -void decod_nelp_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ - Word16 *exc_fx, /* o : adapt. excitation exc */ - Word16 *exc2_fx, /* o : adapt. excitation/total exc */ - Word16 *voice_factors, /* o : Voice factor */ - Word16 *bwe_exc, - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate */ - Word16 *gain_buf /*Q14*/ -); - -void lp_filt_exc_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 codec_mode, /* i : coder mode */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 L_subfr, /* i : subframe size */ - const Word16 L_frame, /* i : frame size */ - Word16 lp_flag, /* i : operation mode signalling */ - Word16 *exc ); - -void FEC_lsf2lsp_interp( - Decoder_State *st, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *Aq, /* o : calculated A(z) for 4 subframes */ - Word16 *lsf, /* o : estimated LSF vector */ - Word16 *lsp /* o : estimated LSP vector */ -); - -ivas_error createFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -void initFdCngDec_fx( - DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - const Word16 scale ); - -/* Delete the instance of type FD_CNG */ -void deleteFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -/* Configure CLDFB-CNG */ -void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ - Word16 bandwidth, - Word32 bitrate, - Word16 L_frame, - const Word16 Last_L_frame, - const Word16 element_mode ); - -Word16 ApplyFdCng_fx( - Word16 *timeDomainInput, /* i : pointer to time domain input */ - Word16 Q, - Word32 *powerSpectrum, - Word16 Q_power_spectrum, - Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ - Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ - Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ - Decoder_State *st, - const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ - Word16 is_music ); - -/* Perform noise estimation */ -void perform_noise_estimation_dec_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain i */ - const Word16 Q, - HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void perform_noise_estimation_dec_ivas_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain input */ - const Word16 Q, - Word32 *power_spectrum, - Word16 Q_power_spectrum, - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - const Word16 VAD /* i : VAD flag in the decoder */ -); - -/* Decode the CLDFB-CNG bitstream */ -void FdCng_decodeSID_fx( - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Decoder_State *corest ); /* i/o: decoder state structure */ - -void noisy_speech_detection_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ - const Word16 vad, /* i : VAD flag */ - const Word16 *syn, /* i : i time-domain frame */ - const Word16 Q ); - -void generate_comfort_noise_dec_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ -); - -void generate_comfort_noise_dec_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ -); - -void generate_comfort_noise_dec_hf_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec ); - -void generate_comfort_noise_dec_hf_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of input bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ -); - -/* Generate the comfort noise based on the target noise level */ -void generate_masking_noise_fx( - Word16 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 Q, - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 length, - Word16 core ); - -void generate_masking_noise_update_seed_fx( - HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ -); - -void generate_masking_noise_mdct_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 L_frame ); - -void generate_masking_noise_mdct_ivas_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); - -ivas_error init_decoder_fx( - Decoder_State *st_fx, /* o : Decoder static variables structure */ - const Word16 idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ -); - -void reset_preecho_dec_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ -); - -void destroy_cldfb_decoder_fx( - Decoder_State *st_fx /* o: Decoder static variables structure */ -); - -void destroy_cldfb_encoder_fx( - Encoder_State *st /* i/o: state structure */ -); - -Word16 WB_BWE_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *WB_fenv /*Q15*/ -); - -Word16 wb_bwe_dec_fx( - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *Qpost ); - -/* o : BWE class */ -Word16 swb_bwe_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 core, /* i : core */ - Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ - Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ - const Word16 hr_flag, /* i : high rate flag */ - const Word16 hqswb_clas /* i : HQ BWE class */ -); - -/*o :Q_syn_hb*/ -Word16 swb_bwe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *Qpost ); - -void fd_bwe_dec_init( - Decoder_State *st_fx, /* i/o: decoder state structure */ - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void hq_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *audio_fx, /* i : input audio signal Q0 */ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ -); - -void hq_core_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word16 synth[], /* o : output synthesis Q_synth*/ - Word16 *Q_synth, /* o : Q value of synth */ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ -); - -void HQ_core_dec_init_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ -); - -void HQ_nbfec_init_fx( - HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ -); - - -void hq_ecu_fx( - const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ - Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ - Word16 *time_offs, - Word16 *X_sav, - Word16 *Q_spec, /* i/o : Q value of stored spectrum */ - Word16 *num_p, - Word16 *plocs, - Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ - const Word16 env_stab, - Word16 *last_fec, - const Word16 ph_ecu_HqVoicing, - Word16 *ph_ecu_active, /* i : Phase ECU active flag */ - Word16 *gapsynth, - const Word16 prev_bfi, /* i : indicating burst frame error */ - const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ - Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ - Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ - Word16 *beta_mute, /* o : Factor for long-term mute */ - const Word16 output_frame, /* i : frame length */ - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -void hq_lr_dec_fx( - Decoder_State *st_fx, /* i/o: : decoder state structure */ - Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ - const Word16 inner_frame, /* i : Q0 : inner frame length */ - Word16 num_bits, /* i : Q0 : number of available bits */ - Word16 *is_transient_fx /* o : Q0 : transient flag */ -); - -/* o : Number of bits Q0*/ -Word16 decode_envelope_indices_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : starting band index Q0*/ - const Word16 num_sfm, /* i : Number of subbands Q0*/ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ - Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ -); - -void dequantize_norms_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : First SDE encoded norm Q0*/ - const Word16 num_sfm, /* i : Number of norms Q0*/ - const Word16 is_transient, /* i : Transient flag Q0*/ - Word16 *ynrm, /* o : Decoded norm indices Q0*/ - Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ -); - -void hdecnrm_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* (i) number of norms Q0*/ - Word16 *index ); /* (o) indices of quantized norms Q0*/ - -Word16 decode_huff_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *hufftab, - Word16 *rbits ); - -void hdecnrm_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* Q0 */ - Word16 *index, /* Q0 */ - Word16 *n_length /* Q0 */ -); - -void hdecnrm_resize_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs Q0*/ - Word16 *index /* (o) norm quantization index vector Q0*/ -); - -void huff_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : Number of codewords to decode Q0*/ - const Word16 buffer_len, /* i : Number of bits to read Q0*/ - const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ - const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ - const Word16 *offset, /* i : Offset for first codeword Q0*/ - const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ - Word16 *index /* o : Decoded index Q0*/ -); - -void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms Q0*/ - Word16 *index /* o : indices of quantized norms Q0*/ -); - -void tcq_core_LR_dec_fx( - Decoder_State *st_fx, - Word16 *inp_vector_fx, /*x5 */ - const Word16 bit_budget, /*Q0 */ - const Word16 BANDS, /*Q0 */ - const Word16 *band_start, /*Q0 */ - const Word16 *band_width, /*Q0 */ - Word32 *Rk_fx, /*Q16*/ - Word16 *npulses, /*Q0 */ - Word16 *k_sort, /*Q0 */ - const Word16 *p2a_flags, /*Q0 */ - const Word16 p2a_bands, /*Q0 */ - const Word16 *last_bitalloc, /*Q0 */ - const Word16 input_frame, /*Q0 */ - const Word16 adjustFlag, /*Q0 */ - const Word16 *is_transient /*Q0 */ -); - -void HQ_FEC_processing_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ - Word16 is_transient, /* i : Old flag for transient */ - Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ - Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ - Word16 num_Sb, /* i : Number of sub-band group */ - Word16 nb_sfm, /* i : Number of sub-band */ - Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ - Word16 output_frame, /* i : Frame size */ - const Word16 *sfm_start, /* i : Start of bands */ - const Word16 *sfm_end /* i : End of bands */ -); - -void HQ_FEC_Mem_update_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /*Q12*/ - Word32 *normq_fx, /*Q14*/ - Word16 *ynrm, - Word16 *Num_bands_p, - Word16 is_transient, - Word16 hqswb_clas, - Word16 c_switching_flag, - Word16 nb_sfm, - Word16 num_Sb, - Word16 *mean_en_high_fx, /*Q5*/ - Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - Word16 output_frame ); - -void time_domain_FEC_HQ_fx( - Decoder_State *st_fx, /* i : Decoder State */ - Word32 *wtda_audio_fx, /* i : i */ - Word16 *out_fx, /* o : output audio */ - Word16 mean_en_high_fx, /* i : transient flag */ - const Word16 output_frame, - Word16 *Q_synth ); - -void hq_pred_hb_bws_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *ynrm, /* i : norm quantization index vector Q0*/ - const Word16 length, /* i : frame length Q0*/ - const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ - const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ -); - -void hq_hr_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ - const Word16 length, /* i : frame length Q0 */ - Word16 num_bits, /* i : number of available bits Q0 */ - Word16 *ynrm, /* o : norm quantization index vector Q0 */ - Word16 *is_transient, /* o : transient flag Q0 */ - Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ - Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ - const Word16 core_switching_flag /* i : Core switching flag Q1 */ -); - -/* o : Consumed bits */ -Word16 hq_classifier_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : Core bit rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - Word16 *is_transient, /* o : Transient flag Q0 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ -); - -void hvq_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 num_bits, /* i : Number of available bits */ - const Word32 core_brate, /* i : Core bit-rate */ - const Word16 *ynrm, /* i : Envelope coefficients Q0 */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *noise_level, /* o : Noise level in Q15 */ - Word16 *peak_idx, /* o : Peak position vector */ - Word16 *Npeaks, /* o : Total number of peaks */ - Word32 *coefsq_norm, /* o : Output vector in Q12 */ - const Word16 core ); - -Word16 hvq_pvq_bitalloc_fx( - Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ - const Word32 brate, /* i : bitrate */ - const Word16 bwidth_fx, /* i : Encoded bandwidth */ - const Word16 *ynrm, /* i : Envelope coefficients */ - const Word32 manE_peak, /* i : Peak energy mantissa */ - const Word16 expE_peak, /* i : Peak energy exponent */ - Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ - Word16 *R, /* Q0 i/o: Global bit allocation */ - Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ - Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ -); - -void hq_configure_bfi_fx( - Word16 *nb_sfm, /* o : Number of sub bands Q0*/ - Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ - Word16 *num_bands_p, /* o : FEC sub bands Q0*/ - const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ - const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ - const Word16 **sfm_end /* o : Subband end coefficients Q0*/ -); - -void bandwidth_switching_detect_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); - -void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); - -void bw_switching_pre_proc_fx( - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -ivas_error core_switching_pre_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ -); - -ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -); - -ivas_error core_switching_post_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ - const Word16 nchan_out, /* i : number of output channels Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -); - -void core_switching_hq_prepare_dec_fx( - Decoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 output_frame /* i : output frame length Q0*/ -); - -ivas_error amr_wb_dec_fx( - Word16 output_sp[], /* o : synthesis output */ - Decoder_State *st_fx /* o : Decoder static variables structure */ -); - -void amr_wb_dec_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void updt_dec_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 *old_exc_fx, /* i : buffer of excitation */ - const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ - const Word16 Es_pred, /* i : predicited scaled innovation energy */ - const Word16 *Aq, /* i : A(z) quantized for all subframes */ - const Word16 *lsf_new_fx, /* i : current frame LSF vector */ - const Word16 *lsp_new_fx, /* i : current frame LSP vector */ - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ - const Word16 *gain_buf /*Q14*/ -); - -void updt_IO_switch_dec_fx( - const Word16 output_frame, /* i : output frame length */ - Decoder_State *st_fx /* o : Decoder static variables structure */ -); - -void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost ); - -void updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ -); - -void update_decoder_LPD_cng( - Decoder_State *st, - Word16 coder_type, - Word16 *timeDomainBuffer, - Word16 *A, - Word16 *bpf_noise_buf ); - -void FEC_clas_estim_fx( - Decoder_State *st_fx, /* i/o: decoder state handle */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ - const Word16 L_frame, /* i : length of the frame */ - Word16 *clas, /* i/o: frame classification */ - const Word16 coder_type, /* i : coder type */ - const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ - Word16 *syn, /* i : synthesis buffer */ - Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ - Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ - Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ - Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ - Word16 *Last_ener, /* i/o: last_energy frame A*/ - Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ - Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ - Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ - Word16 Q_syn, /* i : Synthesis scaling */ - Word16 *class_para, /* o : classification para. fmerit1 A*/ - Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ - Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ - Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ - Word16 mode, /* i : signal classifier mode B*/ - Word16 bfi, /* i : bad frame indicator B*/ - Word32 last_core_brate, /* i : bitrate of previous frame */ - const Word16 FEC_mode /* i : ACELP FEC mode */ -); - -Word16 FEC_pos_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ - Word32 *enr_q, /* o : decoded energy in Q0 */ - const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ -); - -void post_decoder( - Decoder_State *st, - Word16 synth_buf[], /* Q0 */ - Word16 pit_gain[], /* Q14 */ - Word16 pitch[], /* Q0 */ - Word16 signal_out[], /* Q0 */ - Word16 *bpf_noise_buf /* Q0 */ -); - -void post_decoder_ivas_fx( - Decoder_State *st, - Word16 synth_buf[], // Q0 - Word16 pit_gain[], // Q14 - Word16 pitch[], // Q0 - Word16 signal_out[], // Q0 - Word16 *bpf_noise_buf // Q0 -); - -void cldfb_synth_set_bandsToZero( - Decoder_State *st, - Word32 **rAnalysis, - Word32 **iAnalysis, - const Word16 nTimeSlots, - const CLDFB_SCALE_FACTOR scaleFactor ); - -void FEC_pitch_estim_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 last_core, /* i : last core */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 clas, /* i : current frame classification */ - const Word16 last_good, /* i : last good clas information */ - const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ - const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ - Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ - Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ - Word16 *upd_cnt, /* i/o: update counter */ - const Word16 coder_type, /* i : coder_type */ - Word16 element_mode /* i : element mode */ -); - -void FEC_scale_syn_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ - Word16 clas, /* i/o: frame classification */ - const Word16 last_good, /* i: last good frame classification */ - Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ - const Word16 *pitch, /* i: pitch values for each subframe */ - Word32 L_enr_old, /* i: energy at the end of previous frame */ - Word32 L_enr_q, /* i: transmitted energy for current frame */ - const Word16 coder_type, /* i: coder type */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ - Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ - Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ - const Word16 bfi, /* i: current frame BFI */ - const Word32 total_brate, /* i: total bitrate */ - const Word16 prev_bfi, /* i: previous frame BFI */ - const Word32 last_core_brate, /* i: previous frame core bitrate */ - Word16 *exc, /* i/o: excitation signal without enhancement */ - Word16 *exc2, /* i/o: excitation signal with enhancement */ - Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ - Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ - const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ - Word16 *mem_syn, /* o: initial synthesis filter states */ - Word16 Q_exc, - Word16 Q_syn, - const Word16 element_mode, /* i : element mode */ - const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i : force scaling */ -); - -void LD_music_post_filter_fx( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const Word16 dtc_in[], /* i : i synthesis Qdct */ - Word16 dtc_out[], /* o : output synthesis Qdct */ - const Word32 core_brate, /* i : core bitrate Q0 */ - Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ - const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ - const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ -); - -void Prep_music_postP_fx( - Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ - Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ - Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ - const Word16 last_core, /* i : last core */ - const Word16 element_mode, /* i : element mode */ - const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ - Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 *qdct /* o : Scaling factor of dct coefficient */ -); - -void Post_music_postP_fx( - Word16 dct_buffer_in[], /* i/o: excitation buffer */ - Word16 *exc2, /* i/o: Current excitation to be overwriten */ - const Word16 *mem_tmp, /* i : previous frame synthesis memory */ - Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ - const Word16 *Aq, /* i : LPC filter coefficients */ - Word16 *syn, /* i/o: 12k8 synthesis */ - Word16 *Q_exc, /* i : excitation scaling */ - Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ - Word16 *Q_syn, /* i : Current frame synthesis scaling */ - Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ - const Word16 IsIO, /* i : Flag to indicate IO mode */ - Word16 *mem_deemph, /* i/o: speech deemph filter memory */ - Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ - Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ - Word16 *mem_agc, - PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ - const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ - Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ -); - -void music_postfilt_init( - MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ -); - -void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class Q0*/ - const Word16 coder_type, /* i : coder type Q0*/ - const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ - Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ - Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ - const Word16 locattack, /* i : Flag for a detected attack Q0*/ - Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ - Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ - Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ - const Word16 Q_syn, /* i : Synthesis scaling */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ - const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ - const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ - const Word16 last_coder_type /* i : Last coder_type Q0*/ -); - -void decod_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficients */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ -); - -void CNG_reset_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ - Word16 *voice_factors /* o : voicing factors Q15*/ -); - -ivas_error ppp_voiced_decoder_fx( - Decoder_State *st_fx, /* i/o: state structure */ - Word16 *out_fx, /* o : residual signal */ - const Word16 *lpc2_fx, /* i : current frame LPC */ - Word16 *exc_fx, /* i : previous frame excitation */ - Word16 *pitch, /* o : floating pitch values for each subframe */ - Word16 bfi /* i : Frame error rate */ -); - -void sc_vbr_dec_init( - SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ -); - -ivas_error ppp_quarter_decoder_fx( - DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ - Word16 prevCW_lag_fx, /* i : Previous lag */ - Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ - Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ - Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ - Word16 bfi, /* i : FER flag */ - Word16 *S_fx, /* i : sine table, Q15 */ - Word16 *C_fx, /* i : cosine table, Q15 */ - DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ - Decoder_State *st_fx ); - -void open_decoder_LPD_fx( - Decoder_State *st, - const Word32 total_brate, /* Q0 */ - const Word16 bwidth /* Q0 */ -); - -void open_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - -void reset_tcx_overl_buf_fx( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ -); - -void acelp_plc_mdct_transition_fx( - Decoder_State *st /* i/o: Decoder state */ -); - -void cldfb_reset_memory_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void tcxltp_dec_init_fx( - TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ - const Word16 ini_frame, /* Q0 */ - const Word16 last_codec_mode, /* Q0 */ - const Word16 element_mode, /* Q0 */ - const Word16 pit_max, /* Q0 */ - const Word32 sr_core ); /* Q0 */ - -/* o : Exponent of SHB synthesis */ -Word16 swb_bwe_dec_hr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ - const Word16 exp, /* i : Exponent of core synthesis */ - Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ - const Word16 output_frame, /* i : frame length */ - const Word16 unbits, /* i : number of core unused bits */ - const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ -); - -void hr_bwe_dec_init( - HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ -); - -void swb_hr_noise_fill_fx( - const Word16 is_transient, /* i : transient flag */ - const Word16 spect_start, /* i : spectrum start point */ - const Word16 spect_end, /* i : spectrum end point */ - const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ - const Word16 pitch, /* i : pitch value Q15 */ - const Word16 nq[], /* i : AVQ nq index */ - Word16 Nsv, /* i : number of subband */ - Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ - Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ - Word16 Q_audio ); - -void stat_noise_uv_dec_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ - Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ - Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ - const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ -); - -void stat_noise_uv_mod_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ - Word16 *exc2, /* i/o: excitation buffer Q_exc */ - Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q15 */ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : input bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ -); - -void stat_noise_uv_mod_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q=0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ - Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q=15*/ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : i bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ -); - -Word16 FEC_SinOnset_fx( - Word16 *exc, /* i/o : exc vector to modify */ - Word16 puls_pos, /* i : last pulse position desired */ - const Word16 T0, /* i : Pitch information of the 1 subfr */ - Word32 enr_q, /* i : energy provide by the encoder */ - Word16 *Aq, /* i : A(z) filter Q12 */ - const Word16 L_frame, /* i : frame length */ - const Word16 Qold ); - -Word16 FEC_enhACB_fx( - const Word16 L_frame, /* i : frame length */ - const Word16 last_L_frame, /* i : frame length of previous frame */ - Word16 *exc_io, /* i/o : adaptive codebook memory */ - const Word16 new_pit, /* i : decoded first frame pitch */ - const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ - const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ -); - -/*! r: do_WI flag */ -Word16 FEC_synchro_exc_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* i/o: exc vector to modify */ - const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ - const Word16 true_puls_pos, /* i : Present pulse location */ - const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ -); - -void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ - Word16 *gain_buf ); - -void gaus_dec_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* o : unvoiced excitation Q12 */ - Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ - Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ - Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ - Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ - Word16 *voice_fac, /* o : estimated voicing factor Q15 */ - Word16 *gain_pit, /* o : pitch gain Q14 */ - Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ - Word16 *exc, /* o : excitation signal frame */ - Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ - Word16 *exc2, /* o : Scaled excitation signal frame */ - Word16 *bwe_exc_fx, - Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ - Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ -); - -void gaus_L2_dec( - Word16 *code, /* o : decoded gaussian codevector Q9 */ - Word16 tilt_code, /* i : tilt of code Q15 */ - const Word16 *A, /* i : quantized LPCs Q12 */ - Word16 formant_enh, /* i : formant enhancement factor Q15 */ - Word16 *seed_acelp /*i/o : random seed Q0 */ -); - -ivas_error decod_gen_voic_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void decod_tran_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ - Word16 *unbits, /* i/o: number of unused bits */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 *gain_buf /*Q14*/ -); - -void transition_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *exc, /* o : excitation signal */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - Word16 **pt_pitch, /* o : floating pitch values */ - Word16 *position, /* i/o: first glottal impulse position in frame */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *Q_exc /*i/o : scaling of excitation */ -); - -Word16 tc_classif_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame /* i : length of the frame */ -); - -ivas_error decod_ppp_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ - Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ - Word16 *exc_fx, /* i/o: current non-enhanced excitation */ - Word16 *exc2_fx, /* i/o: current enhanced excitation */ - Word16 bfi, /* i : bad frame indicator */ - Word16 *gain_buf, /*Q14*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ -); - -void swb_bwe_dec_lr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis : QsL */ - const Word16 QsL, /* i : Q value of m_core */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ - Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ - Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ - Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ - const Word16 hqswb_clas_fx, /* i : class information : Q0 */ - Word16 lowlength_fx, /* i : Lowband Length : Q0 */ - Word16 highlength_fx, /* i : Highband Length : Q0 */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ - Word16 *prev_frm_hfe2, /* i/o: : Q0 */ - Word16 *prev_stab_hfe2, /* i/o: : Q0 */ - Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ - const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ - Word16 *ni_seed_fx /* i/o: random seed : QsL */ -); - -Word16 dec_acelp_tcx_frame_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *concealWholeFrame, /* i/o: concealment flag */ - Word16 *pcmBuf, /* o : synthesis */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 *pcmbufFB, /* o : synthesis @output_FS */ - Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 pitch_buf[] /* o : floating pitch for each subframe */ -); - -void decoder_LPD_fx( - Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ - Word16 signal_outFB[], /* o : synthesis @output_FS */ - Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ - Decoder_State *st, /* i/o: decoder memory state pointer */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 bfi, /* i : BFI flag */ - Word16 *bitsRead, /* o : number of read bits */ - Word16 param[], /* o : buffer of parameters */ - Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ -); - -void mode_switch_decoder_LPD_fx( - Decoder_State *st, /* Q0 */ - Word16 bandwidth_in, /* Q0 */ - Word32 bitrate, /* Q0 */ - Word16 frame_size_index /* Q0 */ -); - -void mode_switch_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ - const Word16 frame_size_index, /* i : index determining the frame size Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - -Word16 DecodeIndex( - Decoder_State *st, - const Word16 Bandwidth, /* o : NB, 1: (S)WB */ - Word16 *PeriodicityIndex ); - -Word16 DecodeIndex_fx( - Decoder_State *st, - const Word16 Bandwidth, - Word16 *PeriodicityIndex ); - -void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ -); - -Word16 lsf_msvq_ma_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ -); - -Word16 lsf_bctcvq_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ -); - -Word16 D_lsf_tcxlpc( - const Word16 indices[], /* i : VQ indices Q0*/ - Word16 lsf_q[], /* o : quantized LSF Q1*/ - Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk, /* i : codebook selector Q0*/ - Word16 mem_MA[] /* i : MA memory Q1*/ -); - -Word16 dec_lsf_tcxlpc( - Decoder_State *st, /* i/o: Decoder state */ - Word16 **indices, /* o : Ptr to VQ indices Q0*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk /* i : codebook selector Q0*/ -); - -void midlsf_dec( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 idx, /* i: codebook index */ - Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ - const Word16 coder_type, - Word16 *mid_lsf_int, - const Word16 prev_bfi, - const Word16 safety_net ); - -Word16 lsf_ind_is_active( - const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ - const Word16 means[], /*(14Q1*1.28)*/ - const Word16 narrowband, - const Word16 cdk ); - -void IGFSCFDecoderOpen( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ - H_IGF_INFO hIgfInfo, /* i : IGF info handle */ - const Word32 total_brate, - const Word16 bwidth, - const Word16 element_mode, - const Word16 rf_mode ); - -void IGFSCFDecoderReset( - IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ -); - -void IGFSCFDecoderDecode( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - Decoder_State *st, /* i/o: pointer to decoder state */ - Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, - if 0 on input the decoder will be forced to encode without a reset */ -); - -Word32 ari_decode_overflow_fx( - Tastat *s ); - -void ari_start_decoding_14bits_fx( - Decoder_State *st, - Tastat *s ); - -Word16 ari_start_decoding_14bits_prm_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - -Word16 ari_decode_14bits_s17_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - -Word16 ari_decode_14bits_s27_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - -Word16 ari_decode_14bits_bit_ext_fx( - Decoder_State *st, - Tastat *s ); - -Word16 ari_decode_14bits_pow_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - Word16 base ); - -Word16 ari_decode_14bits_sign_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - -void getTCXparam_fx( - Decoder_State *st, /* i/o: Decoder State handle */ - Decoder_State *st0, /* i : bitstream */ - CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - Word16 param[], /* o : decoded parameters Q0 */ - const Word16 bits_common, /* i : number of common bits Q0 */ - const Word16 start_bit_pos, /* i : position of the start bit Q0 */ - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ - Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ - Word16 nTnsBitsTCX10[2], /*Q0*/ - const Word16 pre_past_flag /*Q0*/ -); - -void dec_prm_fx( - Word16 *coder_type, - Word16 param[], /* (o) : decoded parameters */ - Word16 param_lpc[], /* (o) : LPC parameters */ - Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ - Decoder_State *st, - Word16 L_frame, - Word16 *bitsRead ); - -void getLPCparam_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Word16 param_lpc[], /* o : LTP parameters Q0 */ - Decoder_State *st0, /* i : bitstream */ - const Word16 ch, /* i : channel Q0 */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ -); - -void UnmapIndex( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word16 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ -); - -void ConfigureContextHm( - const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ - const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ - const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ - const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ -); - -Word16 CountIndexBits( - Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ - Word16 PeriodicityIndex /* Q0 */ -); - -Word32 tcx_hm_render( - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ -); - -void tcx_hm_modify_envelope( - Word16 gain, /* i: HM gain Q11 */ - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - Word16 L_frame /* i: number of spectral lines Q0 */ -); - -Word16 ReadTnsData( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -void ReadTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -Word16 DecodeTnsData( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - -Word16 DecodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - -void GetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void const *pParameter, - Word16 **pStream, - Word16 *pnSize, - Word16 *pnBits ); - -void GetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, // Q0 - void const *pParameter, // Q0 - Word16 **pStream, // Q0 - Word16 *pnSize, // Q0 - Word16 *pnBits // Q0 -); - -void EncodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream Q0*/ - Word16 *pnSize, /* o : number of written parameters Q0*/ - Word16 *pnBits /* o : number of written bits Q0*/ -); - -void SetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - -void SetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - -void WriteToBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - -void ReadFromBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - -void ReadFromBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - -void IGFDecReadData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ -); - -void IGFDecReadLevel( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ -); - -void IGFDecApplyMono( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ -); - -void IGFDecApplyMono_ivas( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ - Word16 element_mode /**< in: | IVAS element mode */ -); - -void IGFDecApplyStereo( - const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ - const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ - Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ - Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ - Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ - Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ - const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 *coreMsMask, - const Word16 restrict_hopsize, - const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping ); - -void IGFDecSetMode( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void IGFDecSetMode_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void IGFDecUpdateInfo( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 igfGridIdx /**< in: | IGF grid index */ -); - -void IGFDecUpdateInfo_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const Word16 subFrameIdx, /* i : subframe index */ - const Word16 igfGridIdx /* i : IGF grid index */ -); - -void IGFDecCopyLPCFlatSpectrum( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ -); - -void IGFDecCopyLPCFlatSpectrum_fx( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ -); - -void IGFDecStoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ -); - -void IGFDecRestoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ -); - -void IGFDecRestoreTCX10SubFrameData_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word16 subFrameIdx /* i : index of subframe */ -); - -void init_igf_dec( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ -); - -Word16 dlpc_avq_fx( - Word16 *index, /* (i) Quantization indices */ - Word16 *LSF_Q, /* (o) Quantized LSF vectors */ - Word16 numlpc, /* (i) Number of sets of lpc */ - Word32 sr_core ); - -Word16 decode_lpc_avq_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ -); - -Word16 decode_lpc_avq_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc, /* o : lpc parameters */ - const Word16 ch, /* i : channel */ - const Word16 element_mode, /* i : element mode */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ -); - -void vlpc_1st_dec( - Word16 index, /* i : codebook index */ - Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ - -void vlpc_2st_dec( - Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ - Word16 *indx, /* i : index[] (4 bits per words) */ - Word16 mode, /* i : 0=abs, >0=rel */ - Word32 sr_core ); - -void lsf_weight_2st( - const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ - const Word16 mode /* input: operational mode Q0 */ -); - -/* Returns: index of next coefficient */ -Word16 get_next_coeff_mapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -/* Returns: index of next coefficient */ -Word16 get_next_coeff_unmapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -Word16 update_mixed_context( - Word16 ctx, /* Q0 */ - Word16 a /* Q0 */ -); - -Word32 update_mixed_context_ivas_fx( - Word32 ctx, /* Q0 */ - Word16 a /* Q0 */ -); - -typedef Word16 ( *get_next_coeff_function )( - Word16 ii[2], /* i/o: coefficient indexes */ - Word16 *pp, /* o : peak(1)/hole(0) indicator */ - Word16 *idx, /* o : index in unmapped domain */ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -Word16 ACcontextMapping_decode2_no_mem_s17_LC( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o: decoded spectrum */ - Word16 nt, /* i: size of spectrum */ - Word16 nbbits, /* i: bit budget */ - Word16 resQMaxBits, /* i: residual coding maximum bits*/ - CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ -); - -Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o : decoded spectrum */ - const Word16 nt, /* i : size of spectrum */ - const Word16 nbbits, /* i : bit budget */ - const Word16 resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ -); - -void reconfig_decoder_LPD_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 bits_frame, /* i : bit budget Q0*/ - Word16 bwidth, /* i : audio bandwidth Q0*/ - Word32 total_brate, /* i : total bitrate Q0*/ - Word16 L_frame_old /* i : frame length Q0*/ -); - -void reconfig_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bits_frame, /* i : bit budget Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word16 L_frame_old /* i : frame length Q0*/ -); - -void minimumStatistics_fx( - Word16 *noiseLevelMemory, /* Q15, internal state */ - Word16 *noiseLevelIndex, /* Q0, internal state */ - Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ - Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ - Word16 *lastFrameLevel, /* Q15, level of the last frame */ - Word16 currentFrameLevel, /* Q15, level of the current frame */ - Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ - Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ - Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ - Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ - Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ - -/*10Q5*/ -Word16 getLevelSynDeemph_fx( - Word16 h1Init[], /* i: i value or vector to be processed Q15 */ - Word16 const A[], /* i: LPC coefficients Qx */ - Word16 const lpcorder, /* i: LPC order Q0 */ - Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ - Word16 const preemph_fac, /* i: preemphasis factor Q15 */ - Word16 const numLoops, /* i: number of loops Q0 */ - Word16 *Exp /* o: exponent of return value Q15 */ -); - -void genPlcFiltBWAdap_fx( - Word32 const sr_core, /*mem_syn >rescaling done */ - Word16 *pitch_buffer, - Word16 *voice_factors, - Word16 *bwe_exc ); - -void decoder_acelp_fx( - Decoder_State *st, - Word16 prm[], /* i : parameters */ - Word16 A[], /* i : coefficients NxAz[M+1] */ - ACELP_config acelp_cfg, /* i : ACELP config */ - Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ - Word16 *pT, /* out: pitch for all subframe Q0 */ - Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ - Word16 stab_fac, /* i : stability of isf */ - Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ - Word16 *voice_factors, /* out: voicing factors */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *bwe_exc /* out: excitation for SWB TBE */ -); - -void decode_acelp_gains_fx( - Word16 *code, - Word16 gains_mode, - Word16 mean_ener_code, - Word16 *gain_pit, - Word32 *gain_code, - Word16 **pt_indice, - Word16 *past_gpit, - Word32 *past_gcode, - Word16 *gain_inov, - Word16 L_subfr, - Word16 *code2, - Word32 *gain_code2 ); - -void d_gain_pred_fx( - Word16 nrg_mode, /* i : NRG mode */ - Word16 *Es_pred, /* o : predicited scaled innovation energy */ - Word16 **pt_indice /* i/o: pointer to the buffer of indices */ -); - -ivas_error evs_dec_fx( - Decoder_State *st_fx, /* i/o : Decoder state structure */ - Word16 output_sp[], /* o : output synthesis signal */ - FRAME_MODE frameMode /* i : Decoder frame mode */ -); - -void fft_cldfb_fx( - Word32 *data, /* i/o: input/output vector */ - const Word16 size /* size of fft operation */ -); - -void stereo_dft_dec_analyze_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 *input_fx, /* i : input signal q*/ - Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ - const Word16 chan, /* i : channel number Q0*/ - const Word16 input_frame, /* i : input frame size Q0*/ - const Word16 output_frame, /* i : output frame size Q0*/ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ - const Word16 k_offset, /* i : offset of DFT Q0*/ - const Word16 delay, /* i : delay in samples FOR input signal Q0*/ - Word16 *q, - Word16 *q_DFT ); - -void set32_fx( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ -); - -void delay_signal_q_adj_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay, /* i : delay in samples */ - const Word16 q_x, - const Word16 q_mem ); - -Word32 anint_fx( - const Word32 x, /* i: Round to the nearest integer */ - const Word16 exp /* i: Exponent for round step */ -); - -Word32 ceil_fx( - const Word32 x, /* i: number to ceil */ - const Word16 exp /* i: Exponent for ceil step */ -); - -void v_add_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_shr_16( - const Word16 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word16 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ -); - -void v_shr( - const Word32 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word32 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ -); - -void cldfbAnalysis_ts_fx( - const Word32 *timeIn_fx, /* i : time buffer */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, - Word16 *q_cldfb ); - -Word16 floor_log_2( - Word32 num ); - -void cldfbAnalysis_ts_fx_var_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - -void cldfbAnalysis_ts_fx_fixed_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - -void configureCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - -void dec_acelp_fast_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 cdk_index, /* i : codebook index */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - const Word16 L_subfr /* i : subframe length */ -); - -void tcx5SpectrumInterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - -void tcx5SpectrumDeinterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - -void tcx5TnsGrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum ); - -void tcx5TnsUngrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum, - const Word16 enc_dec ); - -void bpf_pitch_coherence_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ -); - -/* fft_rel.c */ - -#define SIZE_256 256 -#define NUM_STAGE_256 7 -#define SIZE2_256 ( SIZE_256 / 2 ) - -void cldfbAnalysis_ivas_fx( - const Word32 *timeIn_fx, /* i : time buffer Qx */ - Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ - Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ -); - -void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ - const Word16 out_shift, /* i : scale for output buffer */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ -); - -void addBassPostFilter_ivas_fx( - const Word32 *harm_timeIn_fx, - const Word16 samplesToProcess, - Word32 **rAnalysis_fx, - Word32 **iAnalysis_fx, - HANDLE_CLDFB_FILTER_BANK cldfb ); - -/* o : Q22*/ -Word32 ism_dequant_meta_fx( - const Word16 idx, /* i : quantizer index */ - const Word32 borders_fx[], /* i : level borders Q22*/ - const Word32 q_step_fx, /* i : quantization step Q22 */ - const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ - const Word16 cbsize /* i : codebook size */ -); - -void save_synthesis_hq_fec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ - const Word32 output_fx[], /* i : decoded synthesis */ - const Word16 output_frame, /* i : decoded synthesis */ - const Word16 Qpostd, /* i : Q value of delayed signal */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ -); - -void calculate_nbits_meta_fx( - const Word16 nchan_ism, - Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 - Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 - const Word16 numSf, - const Word16 numCodingBands, - Word16 *bits_ism, - const Word16 idx_sep_obj, - const Word16 ism_imp ); - -void ivas_get_stereo_panning_gains_fx( - const Word16 aziDeg, - const Word16 eleDeg, - Word16 panningGains[2] ); - -ivas_error openCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - const Word16 enc_dec ); /* i : encoder/decoder flag */ - -Word32 rand_gauss_fx( - Word32 *x, - Word16 *seed, - Word16 q ); - -void resampleCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate ); - -void generate_masking_noise_dirac_ivas_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ - Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ - Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ - const Word16 slot_index, /* i : CLDFB slot index */ - const Word16 cna_flag, /* i : CNA flag for LB and HB */ - const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ - Word16 q_input, - Word16 *q_cldfb ); - -void IMDCT_fx( - Word32 *x, - Word16 x_e, - Word16 *old_syn_overl, - Word16 *syn_Overl_TDAC, - Word16 *xn_buf, - const Word16 *tcx_aldo_window_1, - const PWord16 *tcx_aldo_window_1_trunc, - const PWord16 *tcx_aldo_window_2, - const PWord16 *tcx_mdct_window_half, - const PWord16 *tcx_mdct_window_minimum, - const PWord16 *tcx_mdct_window_trans, - Word16 tcx_mdct_window_half_length, - Word16 tcx_mdct_window_min_length, - Word16 index, - Word16 left_rect, - Word16 tcx_offset, - Word16 overlap, - Word16 L_frame, - Word16 L_frameTCX, - Word16 L_spec_TCX5, - Word16 L_frame_glob, - Word16 frame_cnt, - Word16 bfi, - Word16 *old_out, - Word16 *Q_old_wtda, - Decoder_State *st, - Word16 fullbandScale, - Word16 *acelp_zir ); - -void IMDCT_ivas_fx( - Word32 *x_fx, - Word16 q_x, - Word16 *old_syn_overl_fx, - Word16 *Q_old_syn_overl_fx, - Word16 *syn_Overl_TDAC_fx, - Word16 *Q_syn_Overl_TDAC_fx, - Word16 *xn_buf_fx, - Word16 q_xn_buf_fx, - const Word16 *tcx_aldo_window_1_fx, - const PWord16 *tcx_aldo_window_1_trunc_fx, - const PWord16 *tcx_aldo_window_2_fx, - const PWord16 *tcx_mdct_window_half_fx, - const PWord16 *tcx_mdct_window_minimum_fx, - const PWord16 *tcx_mdct_window_trans_fx, - const Word16 tcx_mdct_window_half_length, - const Word16 tcx_mdct_window_min_length, - Word16 index, - const UWord16 kernel_type, /* i : TCX transform kernel type */ - const Word16 left_rect, - const Word16 tcx_offset, - const Word16 overlap, - const Word16 L_frame, - const Word16 L_frameTCX, - const Word16 L_spec_TCX5, - const Word16 L_frame_glob, - const Word16 frame_cnt, - const Word16 bfi, - Word16 *old_out_fx, - Word16 *q_old_out_fx, - const Word16 FB_flag, - Decoder_State *st, - const Word16 fullbandScale, - Word16 *acelp_zir_fx, - Word16 *q_acelp_zir_fx, - Word16 *pq_win ); - -void v_mult16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, - const Word32 total_brate, - const Word16 L_frame, - const Word16 last_L_frame, - const Word16 element_mode ); - -Word32 sum2_f_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ -); - -Word32 sum2_f_16_gb_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - -Word32 sum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - -Word16 vq_dec_lvq_ivas_fx( - Word16 sf_flag, /* i : safety net flag */ - Word16 x[], /* o : Decoded vector Q(x2.56)*/ - Word16 indices[], /* i : Indices */ - Word16 stages, /* i : Number of stages */ - Word16 N, /* i : Vector dimension */ - Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ - Word16 no_bits /* (i): no. bits for lattice */ -); - -Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ -); - -void deleteCldfb_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -); - -void fd_bwe_dec_init_fx( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void stereo_dft_dec_open( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 nchan_transport /* i : number of transport channels */ -); - -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ); - -UWord32 mvl2s_r( - const Word32 x[], /* i : input vector */ - const Word16 q, - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ -); - -void decoder_tcx_post_ivas_fx( - Decoder_State *st_fx, - Word16 *synth, - Word16 *synthFB, - Word16 Q_syn, - Word16 *A, - Word16 bfi, - Word16 MCT_flag ); - -void con_tcx_ivas_fx( - Decoder_State *st, /* i/o: coder memory state */ - Word16 synth[], /* i/o: synth[] Q0 */ - const Word16 coh, /* i : coherence of stereo signal */ - Word16 *noise_seed, /* i/o: noise seed for stereo */ - const Word16 only_left, /* i : TD-PLC only in left channel */ - const Word16 *A_cng /* i : CNG LP filter coefficients */ -); - -void ivas_mdct_core_reconstruct_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ - Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ - Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - Word16 q_x, - Word16 e_sig[CPE_CHANNELS] ); - -void ari_start_encoding_14bits_ivas_fx( - Tastat *s ); - -void tcx_scalar_quantization_ivas_fx( - Word32 *x, /* i: input coefficients */ - Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ - Word16 L_frame, /* i: frame length */ - Word16 gain, /* i: quantization gain */ - Word16 gain_e, /* i: quantization gain exponent */ - Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ - const Word16 alfe_flag ); - -Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( - Word16 *x, /* Spectral coefficients Q0*/ - const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ - Word16 *lastnz_out, /* Q0 */ - Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ - const Word16 target, /* Target bits Q0*/ - Word16 *stop, /* Q0 */ - Word16 mode, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ -); - -/* Qx*/ -Word16 usdequant_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta /* i: quantization step Qy*/ -); - -/* Qx*/ -Word32 usdequant32_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word32 delta /* i: quantization step Qy*/ -); - -/* o: index of the winning codeword */ -Word16 usquant_fx( - const Word16 x, /* i: scalar value to quantize Qx*/ - Word16 *xq, /* o: quantized value Qx*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta, /* i: quantization step Qx-1*/ - const Word16 cbsize /* i: codebook size */ -); - -/* o : Sum */ -Word32 Dot_product( - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg /* i : vector length */ -); - -/* o : dot product of x[] and y[] */ -Word32 dotp_fx( - const Word16 x[], /* i : vector x[] */ - const Word16 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 *exp /* (o) : exponent of result (0..+30) */ -); - -/* o : sum of all squared vector elements Q(2x+1)*/ -Word32 sum2_fx_mod( - const Word16 *vec, /* i : i vector Qx*/ - const Word16 lvec /* i : length of i vector */ -); - -void Copy_Scale_sig( - const Word16 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Scale_sig32( - Word32 x[], /* i/o: signal to scale Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_16_32_DEPREC( - const Word16 x[], /* i : signal to scale i Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_16_32_r( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_16_32_no_sat( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_32_16( - const Word32 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Random_Fill( - Word16 *seed, /* i/o: random seed */ - Word16 n, /* i : number of values */ - Word16 *y, /* o : output values */ - Word16 scaling /* i : scaling of values */ -); - -/* o : mean of vector */ -Word16 mean_fx( - const Word16 *vec_fx, /* i : i vector */ - const Word16 lvec_fx /* i : length of i vector */ -); - -/* o : mean of vector Qx */ -Word16 mean_no_sat_fx( - const Word16 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx /* i : length of input vector */ -); - -/* o : mean of vector Qx */ -Word32 mean_no_sat_Word32_fx( - const Word32 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx, /* i : length of input vector */ - const Word16 gb ); -void sort( - UWord16 *x, /* i/o: Vector to be sorted */ - UWord16 len /* i/o: vector length */ -); - -void sort_fx( - Word16 *r, /* i/o: Vector to be sorted in place */ - Word16 lo, /* i : Low limit of sorting range */ - Word16 up /* I : High limit of sorting range */ -); - -void sort_32_fx( - Word32 *r, /* i/o: Vector to be sorted in place */ - const Word16 lo, /* i : Low limit of sorting range */ - const Word16 up /* I : High limit of sorting range */ -); - -/* o : index of the minimum value in the input vector */ -Word16 minimum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *min_fx /* o : minimum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *max_fx /* o : maximum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_exp_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 *exp_vec, /* i : exponents of input vector */ - const Word16 lvec_fx /* i : length of input vector */ -); - -/* o : index of the maximum abs value in the input vector */ -Word16 maximum_abs_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max_val /* o : maximum value in the input vector */ -); - -/* o : index of the minimum value in the input vector */ -Word16 minimum_abs32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ -); - -/* o : index of the minimum value in the input vector */ -Word16 minimum_32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_abs_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the maximum value in the input vector */ -Word16 maximum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ -); - -Word16 Exp16Array( - const Word16 n, /* (i): Array size */ - const Word16 *sx /* (i): Data array */ -); - -Word16 Exp32Array( - const Word16 n, /* (i): Array size */ - const Word32 *sx /* (i): Data array */ -); - -/* o : sum of all vector elements Qx*/ -Word32 sum16_32_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -/* o : sum of all vector elements Qx*/ -Word32 sum32_sat( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -/* o: variance of vector Qx+16*/ -Word32 var_fx_32( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ -); - -/* o: variance of vector Qx+16*/ -Word32 var_fx_32in_32out( - const Word32 *x, /* i: input vector Qx*/ - Word16 *Qx, - const Word16 len, /* i: length of inputvector */ - const Word16 gb ); - -/* o: variance of vector Qx*/ -Word16 var_fx( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ -); - -/* o: variance of vector Qx*/ -Word16 std_fx( - const Word16 x[], /* i: input vector */ - const Word16 len /* i: length of the input vector */ -); - -/* o : the dot product x'*A*x */ -Word32 dot_product_mat_fx( - const Word16 *x, /* i : vector x Q15 */ - const Word32 *A, /* i : matrix A Q0*/ - const Word16 m /* i : vector & matrix size */ -); - -void Vr_subt( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 N /* i : Vector lenght */ -); - -/* o: index of the winning codevector */ -Word16 vquant_ivas_fx( - Word32 x[], /* i: vector to quantize Q25 */ - const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ - Word32 xq[], /* o: quantized vector Q25 */ - const Word32 cb[], /* i: codebook Q25 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ -); - -/* o: index of the winning codevector */ -Word16 vquant_fx( - Word16 x[], /* i: vector to quantize Q13 */ - const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ - Word16 xq[], /* o: quantized vector Q13 */ - const Word16 cb[], /* i: codebook Q13 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ -); - -Word16 w_vquant_fx( - Word16 x[], /* i: vector to quantize in Q10 */ - Word16 Qx, - const Word16 weights[], /* i: error weights in Q0 */ - Word16 xq[], /* o: quantized vector in Q15 */ - const Word16 cb[], /* i: codebook in Q15 */ - const Word16 cbsize, /* i: codebook size */ - const Word16 rev_vect /* i: reverse codebook vectors */ -); - -/* o : return index with max energy value in vector Q0 */ -Word16 emaximum_fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word16 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ -); - -/* o : return index with max energy value in vector Q0 */ -Word16 emaximum_32fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word32 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ -); - -/* o : mean of the elements of the vector */ -Word32 Mean32( - const Word32 in[], /* i : input vector */ - const Word16 L /* i : length of input vector */ -); - -/* o : sum of all vector elements Qx*/ -Word32 sum32_fx( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -/* o : sum of all vector elements Qx*/ -Word16 sum16_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -Word16 own_random2_fx( - Word16 seed ); - -void iDiv_and_mod_32( - const Word32 Numer, /* i : 32 bits numerator */ - const Word16 Denom, /* i : 16 bits denominator */ - Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ - Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ - const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ -); - -void pz_filter_sp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word16 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - -Word32 root_a_fx( - Word32 a, - Word16 Q_a, - Word16 *exp_out ); - -Word32 root_a_over_b_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - -Word32 root_a_over_b_ivas_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - -void fir_fx( - const Word16 x[], /* i : input vector Qx*/ - const Word16 h[], /* i : impulse response of the FIR filter Q12*/ - Word16 y[], /* o : output vector (result of filtering) Qx*/ - Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ - const Word16 L, /* i : input vector size */ - const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ - const Word16 upd, /* i : 1 = update the memory, 0 = not */ - Word16 shift /* i : difference between Q15 and scaling of h[] */ -); - -void v_add_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_shr_32( - Word32 x1[], /* i : Input vector 1 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N, /* i : Vector length */ - Word16 shift /*shift value*/ -); - -void v_sub_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_add_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_sub_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -/* o: index of the winning codeword */ -Word16 squant_fx( - const Word16 x, /* i: scalar value to quantize */ - Word16 *xq, /* o: quantized value */ - const Word16 cb[], /* i: codebook */ - const Word16 cbsize /* i: codebook size */ -); - -Word16 squant_int_fx( - UWord8 x, /* i : scalar value to quantize */ - UWord8 *xq, /* o : quantized value */ - const UWord8 *cb, /* i : codebook */ - const Word16 cbsize /* i : codebook size */ -); - -void pz_filter_dp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word32 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - -void Copy_Scale_sig32_16( - const Word32 *src, /* i : signal to scale Qx */ - Word16 *dst, /* o : scaled signal Qx */ - Word16 len, /* i : size of x[] Q0 */ - Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ - -void v_multc_att( - const Word16 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word16 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_att32( - const Word32 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_att3232( - const Word32 x[], /* i : Input vector Qx */ - const Word32 att, /* i : Constant Q32, <= MAX_32 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ -); - -void v_L_mult_1616( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_L_mult_3216( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void add_vec_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 Qx1, /* i : SCaling of input 1 */ - const Word16 x2[], /* i : Input vector 2 */ - const Word16 Qx2, /* i : SCaling of input 1 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 Qy, /* i : SCaling of output 1 */ - const Word16 N /* i : Vector lenght */ -); - -/* o: Result (Normalized) */ -Word32 Add_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ -); - -/* o: Result (Normalized) */ -Word32 Mul_flt32_Q15( - Word32 value, /* i: Pseudo_float Value */ - Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ - Word16 frac /* i: Q15 value */ -); - -/* o: Result (Normalized) */ -Word32 Div_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ -); - -/* o: Result (Normalized) */ -Word32 Calc_Energy_Autoscaled( - const Word16 *signal, /* i: Signal */ - Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ - Word16 len, /* i: Frame Length */ - Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ -); - -Word16 Find_Max_Norm16( - const Word16 *src, - Word16 len ); - -Word16 Find_Max_Norm32( - const Word32 *src, - Word16 len ); - -/* o: Result in Q31 */ -Word32 Sqrt_Ratio32( - Word32 L_val1, /* i: Mantisa of Val1 */ - Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ - Word32 L_val2, /* i: Mantisa of Val2 */ - Word16 exp2, /* i: Exp of Val2 (same as exp1) */ - Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ -); - -/* result in Q'15 + 'exp' */ -Word16 Invert16( - Word16 val, - Word16 *exp ); - -Word16 find_rem( - Word16 n, - Word16 m, - Word16 *r ); - -Word32 find_remd( - Word32 n, - Word32 m, - Word32 *r ); - -Word16 rint_new_fx( - Word32 x /*Q16 */ -); - -Word16 erb_diff_search_fx( - Word16 *prev_erb, - const Word16 *curr_erb, - Word16 *dif_erb, - Word16 *pow_spec, - const Word16 *cb_fx, - Word16 cb_size, - Word16 cb_dim, - Word16 offset ); - -void Acelp_dec_total_exc( - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - const Word16 gain_code16, /* i : Gain code Q0 */ - const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ - const Word16 i_subfr, /* i ; subfr */ - const Word16 *code_fx, /* i : code in Q9 */ - const Word16 L_subfr /* i : Subframne lenght */ -); - -UWord32 UL_inverse( - const UWord32 UL_val, - Word16 *exp ); - -UWord32 UL_div( - const UWord32 UL_num, - const UWord32 UL_den ); - -Word16 ratio( - const Word32 numer, - const Word32 denom, - Word16 *expo ); - -void hp400_12k8_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ -); - -void hp400_12k8_ivas_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ -); - -Word16 dot_prod_satcontr( - const Word16 *x, - const Word16 *y, - Word16 qx, - Word16 qy, - Word16 *qo, - Word16 len ); - -void E_UTIL_f_convolve( - const Word16 x[], - const Word16 h[], - Word16 y[], - const Word16 size ); - -void floating_point_add( - Word32 *mx, /* io: mantissa of the addend Q31 */ - Word16 *ex, /* io: exponent of the addend Q0 */ - const Word32 my, /* i: mantissa of the adder Q31 */ - const Word16 ey /* i: exponent of the adder Q0 */ -); - -void delay_signal_fx( - Word16 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word16 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ -); - -void delay_signal32_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ -); - -Word16 lin_interp_ivas_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ -); - -Word16 lin_interp_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ -); - -Word16 ceil_log_2( - UWord64 val ); - -Word32 imax_pos_fx( - const Word32 *y /* i : Input vector for peak interpolation Qx*/ -); - -void msvq_enc_ivas_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ - const Word16 Q_cb, /* i : Codebook Q */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ - const Word16 u_e, /* i : Exponent for Vector to be encoded */ - const Word16 *levels, /* i : Number of levels in each stage */ - const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ - const Word16 stages, /* i : Number of stages */ - const Word16 w[], /* i : Weights Q8 */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 applyDCT_flag, /* i : applyDCT flag */ - Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ - Word16 Idx[] /* o : Indices */ -); - -void msvq_dec_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 Idx[], /* i : Indices */ - const Word16 applyIDCT_flag, /* i : applyIDCT flag */ - const Word32 *invTrfMatrix, /* i : synthesis matrix */ - Word32 *uq, /* o : quantized vector */ - Word16 *uq_ind, /* o : quantized vector (fixed point) */ - Word16 exp ); - -void dec_FDCNG_MSVQ_stage1_fx( - Word16 j_full, /* i : index full range */ - Word16 n, /* i : dimension to generate */ - const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ - const DCTTYPE idcttype, /* i : specify which IDCT */ - Word32 *uq, /* o : synthesized stage1 vector Q20 */ - Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ -); - -void dctT2_N_apply_matrix_fx( - const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ - Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ - const Word16 dct_dim, /* i : dct processing dim possibly truncated */ - const Word16 fdcngvq_dim, /* i : fdcng domain length */ - const Word32 *matrix, /* i : IDCT matrix */ - const Word16 matrix_row_dim, /* i : */ - const DCTTYPE dcttype /* i : matrix operation type */ -); - -Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - -Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - -void v_mult_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_sub_s16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_sub32_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -void ivas_swb_tbe_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ - Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ - Word16 *Q_white_exc ); - -Word16 swb_bwe_dec_fx32( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ - Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ - Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ - Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - Word16 output_frame /* i : frame length */ -); - -ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs */ - Word16 synth_fx16[], /* o : synthesis */ - Word16 save_hb_synth_fx16[], /* o : HB synthesis */ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word16 *unbits, /* o : number of unused bits */ - Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 read_sid_info /* i : read SID info flag */ -); - -void wtda_fx32( - const Word32 *new_audio, /* i : input audio Q11 */ - Word32 *wtda_audio, /* o : windowed audio Q11 */ - Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ - const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const Word16 L /* i : length */ -); - -ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ); - -void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - -void hp20_fx_32_opt( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - -void getTCXMode_ivas_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void getTCXWindowing_ivas_fx( - const Word16 core, /* i : current frame mode */ - const Word16 last_core, /* i : last frame mode */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ -); - -Word16 ari_start_decoding_14bits_prm_ivas_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - -void generate_masking_noise_ivas_fx( - Word32 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 *exp_out, /* o : time-domain signal exp */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 length, /* i : frame size */ - const Word16 core, /* i : core */ - const Word16 return_noise, /* i : noise is returned instead of added */ - const Word16 secondary, /* i : flag to indicate secondary noise generation */ - const Word16 element_mode, /* i : element mode */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ -); - -void SynthesisSTFT_dirac_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 samples_out, - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void generate_stereo_masking_noise_fx( - Word16 *syn, /* i/o: time-domain signal */ - Word16 Q_syn, - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ -); - -void SynthesisSTFT_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -void FdCng_decodeSID_ivas_fx( - Decoder_State *st /* i/o: decoder state structure */ -); - -void cldfb_restore_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -ivas_error cldfb_save_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ -); - -Word16 sr2fscale( - const Word32 sr_core /* i : internal sampling rate */ -); - -void Copy_Scale_sig32( - const Word32 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ - Word16 *Q_shb_spch, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); - -void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ -); - -void updt_enc_common_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Q_new /* i : CUrrent frame scaling */ -); - -/* o : Q(2x - 31 - gb) */ -Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb /* i : guard bits */ -); - -Word32 sum2_16_exp_fx( - const Word16 *vec, /* i : input vector Q(15 - exp) */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ -); - -Word32 sum2_32_exp_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ -); +void lp_gain_updt_ivas_fx( +#endif + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ + ); + + /*! r: quantized codebook gain Q16 */ + Word32 gain_dec_gaus_fx( + Word16 index, /* i : quantization index */ + const Word16 bits, /* i : number of bits to quantize */ + const Word16 lowBound, /* i : lower bound of quantizer (dB) */ + const Word16 topBound, /* i : upper bound of quantizer (dB) */ + const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ + ); + + void gain_dec_SQ_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 *code, /* i : algebraic code excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ + Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ + ); + + void gain_dec_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + Word16 *gain_pit, /* o : Quantized pitch gain */ + Word32 *gain_code, /* o : Quantized codeebook gain */ + Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ + Word16 *gain_inov, /* o : unscaled innovation gain */ + const Word16 *code, /* i : algebraic code excitation */ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ + ); + + void transf_cdbk_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ + const Word32 gain_code, /* i : innovative excitation gain (Q16) */ + Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ + Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ + Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ + Word16 *unbits /* o : number of AVQ unused bits */ + ); + + /* o: decoded gain */ + Word16 gain_dequant_fx( + Word16 index, /* i: quantization index */ + const Word16 min, /* i: value of lower limit */ + const Word16 max, /* i: value of upper limit */ + const Word16 bits, /* i: number of bits to dequantize */ + Word16 *expg ); + + void AVQ_demuxdec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ + Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ + const Word16 Nsv, /* i : number of subvectors Q0*/ + Word16 nq[], /* i/o: AVQ nq index Q0*/ + Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ + Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ + ); + + void AVQ_dec_lpc( + Word16 *indx, /* input: index[] (4 bits per words) Q0*/ + Word16 *nvecq, /* output: vector quantized Q0*/ + Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ + + void re8_dec_fx( + Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ + const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ + const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ + ); + + void re8_decode_base_index_fx( + const Word16 n, + UWord16 I, + Word16 *x ); + + void re8_k2y_fx( + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ + ); + + void re8_vor_fx( + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ + ); + + void re8_PPV_fx( + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ + ); + + void dec_pit_exc_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + ); + + /* o: pitch value Q16 */ + Word32 Mode2_pit_decode( + const Word16 coder_type, /* i: coding model */ + Word16 i_subfr, /* i: subframe index */ + Word16 L_subfr, + Word16 **pt_indice, /* i/o: quantization indices pointer */ + Word16 *T0, /* i/o: close loop integer pitch Q0 */ + Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ + Word16 *T0_res, /* i/o: pitch resolution Q0 */ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ + Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr1b, + Word16 pit_fr2, + Word16 pit_max, + Word16 pit_res_max ); + + void Mode2_abs_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 *T0_res, /* o: pitch resolution Q0 */ + Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr2, + Word16 pit_res_max ); + + void Mode2_delta_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 T0_res, /* i: pitch resolution Q0 */ + Word16 *T0_min, /* i: delta search min Q0 */ + Word16 *T0_min_frac, /* i: delta search min Q0 */ + Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ + ); + + /* o : floating pitch value */ + Word16 pit_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ + ); + + void pit_Q_dec_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 delta, /* i : Half the CL searched interval */ + const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ + ); + + void pit16k_Q_dec_fx( + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ + ); + + void abs_pit_dec_fx( + const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ + Word16 pitch_index, /* i: pitch index */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o: integer pitch lag */ + Word16 *T0_frac /* o: pitch fraction */ + ); + + void delta_pit_dec_fx( + const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ + const Word16 pitch_index, /* i : pitch index */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + const Word16 T0_min /* i : delta search min */ + ); + + void limit_T0_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 delta, /* i : Half the close-loop searched interval */ + const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ + const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_max /* o : higher pitch limit */ + ); + + void limit_T0_voiced( + const Word16 nbits, + const Word16 res, + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + const Word16 T0_res, /* i : pitch resolution */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_min_frac, /* o : lower pitch limit */ + Word16 *T0_max, /* o : higher pitch limit */ + Word16 *T0_max_frac, /* o : higher pitch limit */ + const Word16 pit_min, /* i : Minimum pitch lag */ + const Word16 pit_max /* i : Maximum pitch lag */ + ); + + void inov_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ + ); + + void inov_decode_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ + ); + + void dec_acelp_4t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 nbbits, /* i : number of bits per codebook */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + const Word16 Opt_AMR_WB ); + + void D_ACELP_decode_43bit_fx( + UWord16 idxs[], + Word16 code[], + Word16 *pulsestrack ); + + void D_ACELP_indexing_fx( + Word16 code[], + PulseConfig config, + Word16 num_tracks, + Word16 index[], + Word16 *BER_detect ); + + void fcb_pulse_track_joint_decode_fx( + UWord16 *idxs, + Word16 wordcnt, + UWord32 *index_n, + Word16 *pulse_num, + Word16 track_num ); + + void dec_acelp_2t32_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[] /* o: algebraic (fixed) codebook excitation */ + ); + + void dec_acelp_1t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ + const Word16 L_subfr /* i : sub frame lenght*/ + ); + + ivas_error acelp_core_switch_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ + Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ + const Word16 output_frame, /* i : input frame length */ + const Word16 core_switching_flag, /* i : core switching flag */ + Word16 *mem_synth, /* o : synthesis to overlap */ + Word16 *Q_syn ); + + ivas_error acelp_core_switch_dec_bfi_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ + ); + + ivas_error acelp_core_switch_dec_bfi_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ + ); + + void pred_lt4( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ + ); + + void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ + ); + + void pred_lt4_tc_fx( + Word16 exc[], /* i/o: excitation buffer Q0*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i: fraction of lag Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 imp_pos, /* i : glottal impulse position Q0*/ + const Word16 i_subfr /* i : subframe index Q0*/ + ); + + void pvq_decode_frame_fx( + Decoder_State *st_fx, + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ + ); + + Word16 pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + + Word16 ivas_pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, /* Q3 */ + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + + void decode_energies_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 Np, + Word16 *dim_part, + Word16 *bits_part, + Word16 *g_part, /* Q15 */ + Word16 qband, + Word16 *bits_left, + Word16 dim, + const Word16 strict_bits ); + + void rc_dec_init_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 tot_bits /* i : Total bit budget */ + ); + + /* o : Decoded cumulative frequency */ + UWord32 rc_decode_fx( + Word16 *BER_detect, /* o : Bit error detection flag */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Total cumulative frequency */ + ); + + void rc_dec_update_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + + UWord32 cum_freq, /* i : Cumulative frequency */ + UWord32 sym_freq /* i : Symbol frequency */ + ); + + /* o : Decoded value */ + Word32 rc_dec_bits_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 bits /* i : Number of bits */ + ); + + /* o : Decoded value */ + UWord32 rc_dec_uniform_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Maximum value */ + ); + + void rc_dec_finish_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ + ); + + void pvq_decode_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 *xq, /* o: decoded vector (Q15) */ + Word16 *y, /* o: decoded vector (non-scaled int) */ + const Word16 k_val, /* i: number of allocated pulses */ + const Word16 dim, /* i: Length of vector */ + const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ + ); + void nelp_decoder_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ + Word16 *exc, /* o : adapt. excitation exc Q_exc */ + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate Q0 */ + const Word16 coder_type, /* i : coding type Q0 */ + Word16 *gain_buf /* Q14 */ + ); + + void decod_nelp_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ + Word16 *exc_fx, /* o : adapt. excitation exc */ + Word16 *exc2_fx, /* o : adapt. excitation/total exc */ + Word16 *voice_factors, /* o : Voice factor */ + Word16 *bwe_exc, + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate */ + Word16 *gain_buf /*Q14*/ + ); + + void lp_filt_exc_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 codec_mode, /* i : coder mode */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 L_subfr, /* i : subframe size */ + const Word16 L_frame, /* i : frame size */ + Word16 lp_flag, /* i : operation mode signalling */ + Word16 *exc ); + + void FEC_lsf2lsp_interp( + Decoder_State *st, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *Aq, /* o : calculated A(z) for 4 subframes */ + Word16 *lsf, /* o : estimated LSF vector */ + Word16 *lsp /* o : estimated LSP vector */ + ); + + ivas_error createFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + + void initFdCngDec_fx( + DEC_CORE_HANDLE st, /* i/o: decoder state structure */ + const Word16 scale ); + + /* Delete the instance of type FD_CNG */ + void deleteFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + + /* Configure CLDFB-CNG */ + void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ + Word16 bandwidth, + Word32 bitrate, + Word16 L_frame, + const Word16 Last_L_frame, + const Word16 element_mode ); + + Word16 ApplyFdCng_fx( + Word16 *timeDomainInput, /* i : pointer to time domain input */ + Word16 Q, + Word32 *powerSpectrum, + Word16 Q_power_spectrum, + Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ + Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ + Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ + Decoder_State *st, + const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ + Word16 is_music ); + + /* Perform noise estimation */ + void perform_noise_estimation_dec_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain i */ + const Word16 Q, + HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + void perform_noise_estimation_dec_ivas_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain input */ + const Word16 Q, + Word32 *power_spectrum, + Word16 Q_power_spectrum, + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + const Word16 VAD /* i : VAD flag in the decoder */ + ); + + /* Decode the CLDFB-CNG bitstream */ + void FdCng_decodeSID_fx( + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Decoder_State *corest ); /* i/o: decoder state structure */ + + void noisy_speech_detection_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ + const Word16 vad, /* i : VAD flag */ + const Word16 *syn, /* i : i time-domain frame */ + const Word16 Q ); + + void generate_comfort_noise_dec_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ + ); + + void generate_comfort_noise_dec_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ + ); + + void generate_comfort_noise_dec_hf_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec ); + + void generate_comfort_noise_dec_hf_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of input bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ + ); + + /* Generate the comfort noise based on the target noise level */ + void generate_masking_noise_fx( + Word16 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 Q, + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 length, + Word16 core ); + + void generate_masking_noise_update_seed_fx( + HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ + ); + + void generate_masking_noise_mdct_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 L_frame ); + + void generate_masking_noise_mdct_ivas_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); + + ivas_error init_decoder_fx( + Decoder_State *st_fx, /* o : Decoder static variables structure */ + const Word16 idchan, /* i : channel ID */ + const MC_MODE mc_mode /* i : MC mode */ + ); + + void reset_preecho_dec_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ + ); + + void destroy_cldfb_decoder_fx( + Decoder_State *st_fx /* o: Decoder static variables structure */ + ); + + void destroy_cldfb_encoder_fx( + Encoder_State *st /* i/o: state structure */ + ); + + Word16 WB_BWE_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *WB_fenv /*Q15*/ + ); + + Word16 wb_bwe_dec_fx( + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *voice_factors_fx, /* i : voicing factors Q15 */ + const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *Qpost ); + + /* o : BWE class */ + Word16 swb_bwe_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 core, /* i : core */ + Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ + Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ + const Word16 hr_flag, /* i : high rate flag */ + const Word16 hqswb_clas /* i : HQ BWE class */ + ); + + /*o :Q_syn_hb*/ + Word16 swb_bwe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *Qpost ); + + void fd_bwe_dec_init( + Decoder_State *st_fx, /* i/o: decoder state structure */ + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ + ); + + void hq_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *audio_fx, /* i : input audio signal Q0 */ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ + ); + + void hq_core_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word16 synth[], /* o : output synthesis Q_synth*/ + Word16 *Q_synth, /* o : Q value of synth */ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ + ); + + void HQ_core_dec_init_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ + ); + + void HQ_nbfec_init_fx( + HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ + ); + + + void hq_ecu_fx( + const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ + Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ + Word16 *time_offs, + Word16 *X_sav, + Word16 *Q_spec, /* i/o : Q value of stored spectrum */ + Word16 *num_p, + Word16 *plocs, + Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ + const Word16 env_stab, + Word16 *last_fec, + const Word16 ph_ecu_HqVoicing, + Word16 *ph_ecu_active, /* i : Phase ECU active flag */ + Word16 *gapsynth, + const Word16 prev_bfi, /* i : indicating burst frame error */ + const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ + Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ + Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ + Word16 *beta_mute, /* o : Factor for long-term mute */ + const Word16 output_frame, /* i : frame length */ + Decoder_State *st_fx /* i/o: decoder state structure */ + ); + + void hq_lr_dec_fx( + Decoder_State *st_fx, /* i/o: : decoder state structure */ + Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ + const Word16 inner_frame, /* i : Q0 : inner frame length */ + Word16 num_bits, /* i : Q0 : number of available bits */ + Word16 *is_transient_fx /* o : Q0 : transient flag */ + ); + + /* o : Number of bits Q0*/ + Word16 decode_envelope_indices_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : starting band index Q0*/ + const Word16 num_sfm, /* i : Number of subbands Q0*/ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ + Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ + ); + + void dequantize_norms_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : First SDE encoded norm Q0*/ + const Word16 num_sfm, /* i : Number of norms Q0*/ + const Word16 is_transient, /* i : Transient flag Q0*/ + Word16 *ynrm, /* o : Decoded norm indices Q0*/ + Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ + ); + + void hdecnrm_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 numNorms, /* (i) number of norms Q0*/ + Word16 *index ); /* (o) indices of quantized norms Q0*/ + + Word16 decode_huff_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *hufftab, + Word16 *rbits ); + + void hdecnrm_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* Q0 */ + Word16 *index, /* Q0 */ + Word16 *n_length /* Q0 */ + ); + + void hdecnrm_resize_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ + ); + + void huff_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : Number of codewords to decode Q0*/ + const Word16 buffer_len, /* i : Number of bits to read Q0*/ + const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ + const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ + const Word16 *offset, /* i : Offset for first codeword Q0*/ + const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ + Word16 *index /* o : Decoded index Q0*/ + ); + + void hdecnrm_tran_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ + ); + + void tcq_core_LR_dec_fx( + Decoder_State *st_fx, + Word16 *inp_vector_fx, /*x5 */ + const Word16 bit_budget, /*Q0 */ + const Word16 BANDS, /*Q0 */ + const Word16 *band_start, /*Q0 */ + const Word16 *band_width, /*Q0 */ + Word32 *Rk_fx, /*Q16*/ + Word16 *npulses, /*Q0 */ + Word16 *k_sort, /*Q0 */ + const Word16 *p2a_flags, /*Q0 */ + const Word16 p2a_bands, /*Q0 */ + const Word16 *last_bitalloc, /*Q0 */ + const Word16 input_frame, /*Q0 */ + const Word16 adjustFlag, /*Q0 */ + const Word16 *is_transient /*Q0 */ + ); + + void HQ_FEC_processing_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ + Word16 is_transient, /* i : Old flag for transient */ + Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ + Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ + Word16 num_Sb, /* i : Number of sub-band group */ + Word16 nb_sfm, /* i : Number of sub-band */ + Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ + Word16 output_frame, /* i : Frame size */ + const Word16 *sfm_start, /* i : Start of bands */ + const Word16 *sfm_end /* i : End of bands */ + ); + + void HQ_FEC_Mem_update_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /*Q12*/ + Word32 *normq_fx, /*Q14*/ + Word16 *ynrm, + Word16 *Num_bands_p, + Word16 is_transient, + Word16 hqswb_clas, + Word16 c_switching_flag, + Word16 nb_sfm, + Word16 num_Sb, + Word16 *mean_en_high_fx, /*Q5*/ + Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ + Word16 output_frame ); + + void time_domain_FEC_HQ_fx( + Decoder_State *st_fx, /* i : Decoder State */ + Word32 *wtda_audio_fx, /* i : i */ + Word16 *out_fx, /* o : output audio */ + Word16 mean_en_high_fx, /* i : transient flag */ + const Word16 output_frame, + Word16 *Q_synth ); + + void hq_pred_hb_bws_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *ynrm, /* i : norm quantization index vector Q0*/ + const Word16 length, /* i : frame length Q0*/ + const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ + const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ + ); + + void hq_hr_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ + const Word16 length, /* i : frame length Q0 */ + Word16 num_bits, /* i : number of available bits Q0 */ + Word16 *ynrm, /* o : norm quantization index vector Q0 */ + Word16 *is_transient, /* o : transient flag Q0 */ + Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ + Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ + const Word16 core_switching_flag /* i : Core switching flag Q1 */ + ); + + /* o : Consumed bits */ + Word16 hq_classifier_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : Core bit rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + Word16 *is_transient, /* o : Transient flag Q0 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ + ); + + void hvq_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 num_bits, /* i : Number of available bits */ + const Word32 core_brate, /* i : Core bit-rate */ + const Word16 *ynrm, /* i : Envelope coefficients Q0 */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *noise_level, /* o : Noise level in Q15 */ + Word16 *peak_idx, /* o : Peak position vector */ + Word16 *Npeaks, /* o : Total number of peaks */ + Word32 *coefsq_norm, /* o : Output vector in Q12 */ + const Word16 core ); + + Word16 hvq_pvq_bitalloc_fx( + Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ + const Word32 brate, /* i : bitrate */ + const Word16 bwidth_fx, /* i : Encoded bandwidth */ + const Word16 *ynrm, /* i : Envelope coefficients */ + const Word32 manE_peak, /* i : Peak energy mantissa */ + const Word16 expE_peak, /* i : Peak energy exponent */ + Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ + Word16 *R, /* Q0 i/o: Global bit allocation */ + Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ + Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ + ); + + void hq_configure_bfi_fx( + Word16 *nb_sfm, /* o : Number of sub bands Q0*/ + Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ + Word16 *num_bands_p, /* o : FEC sub bands Q0*/ + const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ + const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ + const Word16 **sfm_end /* o : Subband end coefficients Q0*/ + ); + + void bandwidth_switching_detect_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ + ); + + void bandwidth_switching_detect_ivas_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ + ); + + void bw_switching_pre_proc_fx( + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + Decoder_State *st_fx /* i/o: decoder state structure */ + ); + + ivas_error core_switching_pre_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 output_frame /* i : frame length Q0*/ + ); + + ivas_error core_switching_post_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + ); + + ivas_error core_switching_post_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ + const Word16 nchan_out, /* i : number of output channels Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + ); + + void core_switching_hq_prepare_dec_fx( + Decoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 output_frame /* i : output frame length Q0*/ + ); + + ivas_error amr_wb_dec_fx( + Word16 output_sp[], /* o : synthesis output */ + Decoder_State *st_fx /* o : Decoder static variables structure */ + ); + + void amr_wb_dec_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ + ); + + void updt_dec_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 *old_exc_fx, /* i : buffer of excitation */ + const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ + const Word16 Es_pred, /* i : predicited scaled innovation energy */ + const Word16 *Aq, /* i : A(z) quantized for all subframes */ + const Word16 *lsf_new_fx, /* i : current frame LSF vector */ + const Word16 *lsp_new_fx, /* i : current frame LSP vector */ + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ + const Word16 *gain_buf /*Q14*/ + ); + + void updt_IO_switch_dec_fx( + const Word16 output_frame, /* i : output frame length */ + Decoder_State *st_fx /* o : Decoder static variables structure */ + ); + + void updt_bw_switching_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ + const Word16 Qpost ); + + void updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word16 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ + ); + + void update_decoder_LPD_cng( + Decoder_State *st, + Word16 coder_type, + Word16 *timeDomainBuffer, + Word16 *A, + Word16 *bpf_noise_buf ); + + void FEC_clas_estim_fx( + Decoder_State *st_fx, /* i/o: decoder state handle */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ + const Word16 L_frame, /* i : length of the frame */ + Word16 *clas, /* i/o: frame classification */ + const Word16 coder_type, /* i : coder type */ + const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ + Word16 *syn, /* i : synthesis buffer */ + Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ + Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ + Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ + Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ + Word16 *Last_ener, /* i/o: last_energy frame A*/ + Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ + Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ + Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ + Word16 Q_syn, /* i : Synthesis scaling */ + Word16 *class_para, /* o : classification para. fmerit1 A*/ + Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ + Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ + Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ + Word16 mode, /* i : signal classifier mode B*/ + Word16 bfi, /* i : bad frame indicator B*/ + Word32 last_core_brate, /* i : bitrate of previous frame */ + const Word16 FEC_mode /* i : ACELP FEC mode */ + ); + + Word16 FEC_pos_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ + Word32 *enr_q, /* o : decoded energy in Q0 */ + const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ + ); + + void post_decoder( + Decoder_State *st, + Word16 synth_buf[], /* Q0 */ + Word16 pit_gain[], /* Q14 */ + Word16 pitch[], /* Q0 */ + Word16 signal_out[], /* Q0 */ + Word16 *bpf_noise_buf /* Q0 */ + ); + + void post_decoder_ivas_fx( + Decoder_State *st, + Word16 synth_buf[], // Q0 + Word16 pit_gain[], // Q14 + Word16 pitch[], // Q0 + Word16 signal_out[], // Q0 + Word16 *bpf_noise_buf // Q0 + ); + + void cldfb_synth_set_bandsToZero( + Decoder_State *st, + Word32 **rAnalysis, + Word32 **iAnalysis, + const Word16 nTimeSlots, + const CLDFB_SCALE_FACTOR scaleFactor ); + + void FEC_pitch_estim_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 last_core, /* i : last core */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 clas, /* i : current frame classification */ + const Word16 last_good, /* i : last good clas information */ + const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ + const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ + Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ + Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ + Word16 *upd_cnt, /* i/o: update counter */ + const Word16 coder_type, /* i : coder_type */ + Word16 element_mode /* i : element mode */ + ); + + void FEC_scale_syn_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ + Word16 clas, /* i/o: frame classification */ + const Word16 last_good, /* i: last good frame classification */ + Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ + const Word16 *pitch, /* i: pitch values for each subframe */ + Word32 L_enr_old, /* i: energy at the end of previous frame */ + Word32 L_enr_q, /* i: transmitted energy for current frame */ + const Word16 coder_type, /* i: coder type */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ + Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ + Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ + const Word16 bfi, /* i: current frame BFI */ + const Word32 total_brate, /* i: total bitrate */ + const Word16 prev_bfi, /* i: previous frame BFI */ + const Word32 last_core_brate, /* i: previous frame core bitrate */ + Word16 *exc, /* i/o: excitation signal without enhancement */ + Word16 *exc2, /* i/o: excitation signal with enhancement */ + Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ + Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ + const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ + Word16 *mem_syn, /* o: initial synthesis filter states */ + Word16 Q_exc, + Word16 Q_syn, + const Word16 element_mode, /* i : element mode */ + const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ + const Word16 force_scaling /* i : force scaling */ + ); + + void LD_music_post_filter_fx( + MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ + const Word16 dtc_in[], /* i : i synthesis Qdct */ + Word16 dtc_out[], /* o : output synthesis Qdct */ + const Word32 core_brate, /* i : core bitrate Q0 */ + Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ + const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ + const Word16 Last_coder_type, /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ + ); + + void Prep_music_postP_fx( + Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ + Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ + Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ + const Word16 last_core, /* i : last core */ + const Word16 element_mode, /* i : element mode */ + const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ + Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ + const Word16 Q_exc, /* i : excitation scaling */ + Word16 *qdct /* o : Scaling factor of dct coefficient */ + ); + + void Post_music_postP_fx( + Word16 dct_buffer_in[], /* i/o: excitation buffer */ + Word16 *exc2, /* i/o: Current excitation to be overwriten */ + const Word16 *mem_tmp, /* i : previous frame synthesis memory */ + Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ + const Word16 *Aq, /* i : LPC filter coefficients */ + Word16 *syn, /* i/o: 12k8 synthesis */ + Word16 *Q_exc, /* i : excitation scaling */ + Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ + Word16 *Q_syn, /* i : Current frame synthesis scaling */ + Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ + const Word16 IsIO, /* i : Flag to indicate IO mode */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory */ + Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ + Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ + Word16 *mem_agc, + PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ + const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ + Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ + ); + + void music_postfilt_init( + MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ + ); + + void improv_amr_wb_gs_fx( + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 locattack, /* i : Flag for a detected attack Q0*/ + Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ + Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ + ); + + void decod_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficients */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ + ); + + void CNG_reset_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ + Word16 *voice_factors /* o : voicing factors Q15*/ + ); + + ivas_error ppp_voiced_decoder_fx( + Decoder_State *st_fx, /* i/o: state structure */ + Word16 *out_fx, /* o : residual signal */ + const Word16 *lpc2_fx, /* i : current frame LPC */ + Word16 *exc_fx, /* i : previous frame excitation */ + Word16 *pitch, /* o : floating pitch values for each subframe */ + Word16 bfi /* i : Frame error rate */ + ); + + void sc_vbr_dec_init( + SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ + ); + + ivas_error ppp_quarter_decoder_fx( + DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ + Word16 prevCW_lag_fx, /* i : Previous lag */ + Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ + Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ + Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ + Word16 bfi, /* i : FER flag */ + Word16 *S_fx, /* i : sine table, Q15 */ + Word16 *C_fx, /* i : cosine table, Q15 */ + DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ + Decoder_State *st_fx ); + + void open_decoder_LPD_fx( + Decoder_State *st, + const Word32 total_brate, /* Q0 */ + const Word16 bwidth /* Q0 */ + ); + + void open_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + + void reset_tcx_overl_buf_fx( + TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ + ); + + void acelp_plc_mdct_transition_fx( + Decoder_State *st /* i/o: Decoder state */ + ); + + void cldfb_reset_memory_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + void tcxltp_dec_init_fx( + TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ + const Word16 ini_frame, /* Q0 */ + const Word16 last_codec_mode, /* Q0 */ + const Word16 element_mode, /* Q0 */ + const Word16 pit_max, /* Q0 */ + const Word32 sr_core ); /* Q0 */ + + /* o : Exponent of SHB synthesis */ + Word16 swb_bwe_dec_hr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ + const Word16 exp, /* i : Exponent of core synthesis */ + Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ + const Word16 output_frame, /* i : frame length */ + const Word16 unbits, /* i : number of core unused bits */ + const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ + ); + + void hr_bwe_dec_init( + HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ + ); + + void swb_hr_noise_fill_fx( + const Word16 is_transient, /* i : transient flag */ + const Word16 spect_start, /* i : spectrum start point */ + const Word16 spect_end, /* i : spectrum end point */ + const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ + const Word16 pitch, /* i : pitch value Q15 */ + const Word16 nq[], /* i : AVQ nq index */ + Word16 Nsv, /* i : number of subband */ + Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ + Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ + Word16 Q_audio ); + + void stat_noise_uv_dec_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ + Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ + Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ + const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ + ); + + void stat_noise_uv_mod_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ + Word16 *exc2, /* i/o: excitation buffer Q_exc */ + Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q15 */ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : input bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ + ); + + void stat_noise_uv_mod_ivas_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ + ); + + Word16 FEC_SinOnset_fx( + Word16 *exc, /* i/o : exc vector to modify */ + Word16 puls_pos, /* i : last pulse position desired */ + const Word16 T0, /* i : Pitch information of the 1 subfr */ + Word32 enr_q, /* i : energy provide by the encoder */ + Word16 *Aq, /* i : A(z) filter Q12 */ + const Word16 L_frame, /* i : frame length */ + const Word16 Qold ); + + Word16 FEC_enhACB_fx( + const Word16 L_frame, /* i : frame length */ + const Word16 last_L_frame, /* i : frame length of previous frame */ + Word16 *exc_io, /* i/o : adaptive codebook memory */ + const Word16 new_pit, /* i : decoded first frame pitch */ + const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ + const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ + ); + + /*! r: do_WI flag */ + Word16 FEC_synchro_exc_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* i/o: exc vector to modify */ + const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ + const Word16 true_puls_pos, /* i : Present pulse location */ + const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ + ); + + void decod_unvoiced_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + Word16 *gain_buf ); + + void gaus_dec_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* o : unvoiced excitation Q12 */ + Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ + Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ + Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ + Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ + Word16 *voice_fac, /* o : estimated voicing factor Q15 */ + Word16 *gain_pit, /* o : pitch gain Q14 */ + Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ + Word16 *exc, /* o : excitation signal frame */ + Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ + Word16 *exc2, /* o : Scaled excitation signal frame */ + Word16 *bwe_exc_fx, + Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ + Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ + ); + + void gaus_L2_dec( + Word16 *code, /* o : decoded gaussian codevector Q9 */ + Word16 tilt_code, /* i : tilt of code Q15 */ + const Word16 *A, /* i : quantized LPCs Q12 */ + Word16 formant_enh, /* i : formant enhancement factor Q15 */ + Word16 *seed_acelp /*i/o : random seed Q0 */ + ); + + ivas_error decod_gen_voic_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 sharpFlag_fx, /* i : formant sharpening flag */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 do_WI_fx, /* i : do interpolation after a FER */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + Word16 *unbits, /* number of unused bits */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + ); + + void decod_tran_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ + Word16 *unbits, /* i/o: number of unused bits */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 *gain_buf /*Q14*/ + ); + + void transition_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 tc_subfr, /* i : TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *exc, /* o : excitation signal */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + Word16 **pt_pitch, /* o : floating pitch values */ + Word16 *position, /* i/o: first glottal impulse position in frame */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *Q_exc /*i/o : scaling of excitation */ + ); + + Word16 tc_classif_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame /* i : length of the frame */ + ); + + ivas_error decod_ppp_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ + Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ + Word16 *exc_fx, /* i/o: current non-enhanced excitation */ + Word16 *exc2_fx, /* i/o: current enhanced excitation */ + Word16 bfi, /* i : bad frame indicator */ + Word16 *gain_buf, /*Q14*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ + ); + + void swb_bwe_dec_lr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis : QsL */ + const Word16 QsL, /* i : Q value of m_core */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ + Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ + Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ + Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ + const Word16 hqswb_clas_fx, /* i : class information : Q0 */ + Word16 lowlength_fx, /* i : Lowband Length : Q0 */ + Word16 highlength_fx, /* i : Highband Length : Q0 */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ + Word16 *prev_frm_hfe2, /* i/o: : Q0 */ + Word16 *prev_stab_hfe2, /* i/o: : Q0 */ + Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ + const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ + Word16 *ni_seed_fx /* i/o: random seed : QsL */ + ); + + Word16 dec_acelp_tcx_frame_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *concealWholeFrame, /* i/o: concealment flag */ + Word16 *pcmBuf, /* o : synthesis */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 *pcmbufFB, /* o : synthesis @output_FS */ + Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 pitch_buf[] /* o : floating pitch for each subframe */ + ); + + void decoder_LPD_fx( + Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ + Word16 signal_outFB[], /* o : synthesis @output_FS */ + Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ + Decoder_State *st, /* i/o: decoder memory state pointer */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 bfi, /* i : BFI flag */ + Word16 *bitsRead, /* o : number of read bits */ + Word16 param[], /* o : buffer of parameters */ + Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ + ); + + void mode_switch_decoder_LPD_fx( + Decoder_State *st, /* Q0 */ + Word16 bandwidth_in, /* Q0 */ + Word32 bitrate, /* Q0 */ + Word16 frame_size_index /* Q0 */ + ); + + void mode_switch_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ + const Word16 frame_size_index, /* i : index determining the frame size Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + + Word16 DecodeIndex( + Decoder_State *st, + const Word16 Bandwidth, /* o : NB, 1: (S)WB */ + Word16 *PeriodicityIndex ); + + Word16 DecodeIndex_fx( + Decoder_State *st, + const Word16 Bandwidth, + Word16 *PeriodicityIndex ); + + void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ + ); + + Word16 lsf_msvq_ma_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ + ); + + Word16 lsf_bctcvq_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ + ); + + Word16 D_lsf_tcxlpc( + const Word16 indices[], /* i : VQ indices Q0*/ + Word16 lsf_q[], /* o : quantized LSF Q1*/ + Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk, /* i : codebook selector Q0*/ + Word16 mem_MA[] /* i : MA memory Q1*/ + ); + + Word16 dec_lsf_tcxlpc( + Decoder_State *st, /* i/o: Decoder state */ + Word16 **indices, /* o : Ptr to VQ indices Q0*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk /* i : codebook selector Q0*/ + ); + + void midlsf_dec( + const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 idx, /* i: codebook index */ + Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ + const Word16 coder_type, + Word16 *mid_lsf_int, + const Word16 prev_bfi, + const Word16 safety_net ); + + Word16 lsf_ind_is_active( + const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ + const Word16 means[], /*(14Q1*1.28)*/ + const Word16 narrowband, + const Word16 cdk ); + + void IGFSCFDecoderOpen( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ + H_IGF_INFO hIgfInfo, /* i : IGF info handle */ + const Word32 total_brate, + const Word16 bwidth, + const Word16 element_mode, + const Word16 rf_mode ); + + void IGFSCFDecoderReset( + IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ + ); + + void IGFSCFDecoderDecode( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + Decoder_State *st, /* i/o: pointer to decoder state */ + Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, + if 0 on input the decoder will be forced to encode without a reset */ + ); + + Word32 ari_decode_overflow_fx( + Tastat *s ); + + void ari_start_decoding_14bits_fx( + Decoder_State *st, + Tastat *s ); + + Word16 ari_start_decoding_14bits_prm_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + + Word16 ari_decode_14bits_s17_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + + Word16 ari_decode_14bits_s27_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + + Word16 ari_decode_14bits_bit_ext_fx( + Decoder_State *st, + Tastat *s ); + + Word16 ari_decode_14bits_pow_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + Word16 base ); + + Word16 ari_decode_14bits_sign_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + + void getTCXparam_fx( + Decoder_State *st, /* i/o: Decoder State handle */ + Decoder_State *st0, /* i : bitstream */ + CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ + Word16 param[], /* o : decoded parameters Q0 */ + const Word16 bits_common, /* i : number of common bits Q0 */ + const Word16 start_bit_pos, /* i : position of the start bit Q0 */ + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ + Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ + Word16 nTnsBitsTCX10[2], /*Q0*/ + const Word16 pre_past_flag /*Q0*/ + ); + + void dec_prm_fx( + Word16 *coder_type, + Word16 param[], /* (o) : decoded parameters */ + Word16 param_lpc[], /* (o) : LPC parameters */ + Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ + Decoder_State *st, + Word16 L_frame, + Word16 *bitsRead ); + + void getLPCparam_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Word16 param_lpc[], /* o : LTP parameters Q0 */ + Decoder_State *st0, /* i : bitstream */ + const Word16 ch, /* i : channel Q0 */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ + ); + + void UnmapIndex( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word16 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ + ); + + void ConfigureContextHm( + const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ + const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ + const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ + const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ + ); + + Word16 CountIndexBits( + Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ + Word16 PeriodicityIndex /* Q0 */ + ); + + Word32 tcx_hm_render( + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ + ); + + void tcx_hm_modify_envelope( + Word16 gain, /* i: HM gain Q11 */ + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + Word16 L_frame /* i: number of spectral lines Q0 */ + ); + + Word16 ReadTnsData( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + + void ReadTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + + Word16 DecodeTnsData( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + + Word16 DecodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + + void GetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void const *pParameter, + Word16 **pStream, + Word16 *pnSize, + Word16 *pnBits ); + + void GetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, // Q0 + void const *pParameter, // Q0 + Word16 **pStream, // Q0 + Word16 *pnSize, // Q0 + Word16 *pnBits // Q0 + ); + + void EncodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream Q0*/ + Word16 *pnSize, /* o : number of written parameters Q0*/ + Word16 *pnBits /* o : number of written bits Q0*/ + ); + + void SetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + + void SetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + + void WriteToBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + void ReadFromBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + + void ReadFromBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + + void IGFDecReadData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ + ); + + void IGFDecReadLevel( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ + ); + + void IGFDecApplyMono( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ + ); + + void IGFDecApplyMono_ivas( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ + Word16 element_mode /**< in: | IVAS element mode */ + ); + + void IGFDecApplyStereo( + const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ + const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ + Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ + Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ + Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ + Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ + const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 *coreMsMask, + const Word16 restrict_hopsize, + const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ + const Word16 bfi_apply_damping ); + + void IGFDecSetMode( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void IGFDecSetMode_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void IGFDecUpdateInfo( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 igfGridIdx /**< in: | IGF grid index */ + ); + + void IGFDecUpdateInfo_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ + const Word16 subFrameIdx, /* i : subframe index */ + const Word16 igfGridIdx /* i : IGF grid index */ + ); + + void IGFDecCopyLPCFlatSpectrum( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ + ); + + void IGFDecCopyLPCFlatSpectrum_fx( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ + ); + + void IGFDecStoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ + ); + + void IGFDecRestoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ + ); + + void IGFDecRestoreTCX10SubFrameData_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word16 subFrameIdx /* i : index of subframe */ + ); + + void init_igf_dec( + IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ + ); + + Word16 dlpc_avq_fx( + Word16 *index, /* (i) Quantization indices */ + Word16 *LSF_Q, /* (o) Quantized LSF vectors */ + Word16 numlpc, /* (i) Number of sets of lpc */ + Word32 sr_core ); + + Word16 decode_lpc_avq_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc /* o : lpc parameters */ + ); + + Word16 decode_lpc_avq_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc, /* o : lpc parameters */ + const Word16 ch, /* i : channel */ + const Word16 element_mode, /* i : element mode */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ + ); + + void vlpc_1st_dec( + Word16 index, /* i : codebook index */ + Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ + + void vlpc_2st_dec( + Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ + Word16 *indx, /* i : index[] (4 bits per words) */ + Word16 mode, /* i : 0=abs, >0=rel */ + Word32 sr_core ); + + void lsf_weight_2st( + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 mode /* input: operational mode Q0 */ + ); + + /* Returns: index of next coefficient */ + Word16 get_next_coeff_mapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + /* Returns: index of next coefficient */ + Word16 get_next_coeff_unmapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + Word16 update_mixed_context( + Word16 ctx, /* Q0 */ + Word16 a /* Q0 */ + ); + + Word32 update_mixed_context_ivas_fx( + Word32 ctx, /* Q0 */ + Word16 a /* Q0 */ + ); + + typedef Word16 ( *get_next_coeff_function )( + Word16 ii[2], /* i/o: coefficient indexes */ + Word16 *pp, /* o : peak(1)/hole(0) indicator */ + Word16 *idx, /* o : index in unmapped domain */ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + Word16 ACcontextMapping_decode2_no_mem_s17_LC( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o: decoded spectrum */ + Word16 nt, /* i: size of spectrum */ + Word16 nbbits, /* i: bit budget */ + Word16 resQMaxBits, /* i: residual coding maximum bits*/ + CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ + ); + + Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o : decoded spectrum */ + const Word16 nt, /* i : size of spectrum */ + const Word16 nbbits, /* i : bit budget */ + const Word16 resQMaxBits, /* i : residual coding maximum bits */ + CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ + ); + + void reconfig_decoder_LPD_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 bits_frame, /* i : bit budget Q0*/ + Word16 bwidth, /* i : audio bandwidth Q0*/ + Word32 total_brate, /* i : total bitrate Q0*/ + Word16 L_frame_old /* i : frame length Q0*/ + ); + + void reconfig_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bits_frame, /* i : bit budget Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word16 L_frame_old /* i : frame length Q0*/ + ); + + void minimumStatistics_fx( + Word16 *noiseLevelMemory, /* Q15, internal state */ + Word16 *noiseLevelIndex, /* Q0, internal state */ + Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ + Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ + Word16 *lastFrameLevel, /* Q15, level of the last frame */ + Word16 currentFrameLevel, /* Q15, level of the current frame */ + Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ + Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ + Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ + Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ + Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ + + /*10Q5*/ + Word16 getLevelSynDeemph_fx( + Word16 h1Init[], /* i: i value or vector to be processed Q15 */ + Word16 const A[], /* i: LPC coefficients Qx */ + Word16 const lpcorder, /* i: LPC order Q0 */ + Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ + Word16 const preemph_fac, /* i: preemphasis factor Q15 */ + Word16 const numLoops, /* i: number of loops Q0 */ + Word16 *Exp /* o: exponent of return value Q15 */ + ); + + void genPlcFiltBWAdap_fx( + Word32 const sr_core, /*mem_syn >rescaling done */ + Word16 *pitch_buffer, + Word16 *voice_factors, + Word16 *bwe_exc ); + + void decoder_acelp_fx( + Decoder_State *st, + Word16 prm[], /* i : parameters */ + Word16 A[], /* i : coefficients NxAz[M+1] */ + ACELP_config acelp_cfg, /* i : ACELP config */ + Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ + Word16 *pT, /* out: pitch for all subframe Q0 */ + Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ + Word16 stab_fac, /* i : stability of isf */ + Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ + Word16 *voice_factors, /* out: voicing factors */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *bwe_exc /* out: excitation for SWB TBE */ + ); + + void decode_acelp_gains_fx( + Word16 *code, + Word16 gains_mode, + Word16 mean_ener_code, + Word16 *gain_pit, + Word32 *gain_code, + Word16 **pt_indice, + Word16 *past_gpit, + Word32 *past_gcode, + Word16 *gain_inov, + Word16 L_subfr, + Word16 *code2, + Word32 *gain_code2 ); + + void d_gain_pred_fx( + Word16 nrg_mode, /* i : NRG mode */ + Word16 *Es_pred, /* o : predicited scaled innovation energy */ + Word16 **pt_indice /* i/o: pointer to the buffer of indices */ + ); + + ivas_error evs_dec_fx( + Decoder_State *st_fx, /* i/o : Decoder state structure */ + Word16 output_sp[], /* o : output synthesis signal */ + FRAME_MODE frameMode /* i : Decoder frame mode */ + ); + + void fft_cldfb_fx( + Word32 *data, /* i/o: input/output vector */ + const Word16 size /* size of fft operation */ + ); + + void stereo_dft_dec_analyze_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 *input_fx, /* i : input signal q*/ + Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ + const Word16 chan, /* i : channel number Q0*/ + const Word16 input_frame, /* i : input frame size Q0*/ + const Word16 output_frame, /* i : output frame size Q0*/ + const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ + const Word16 k_offset, /* i : offset of DFT Q0*/ + const Word16 delay, /* i : delay in samples FOR input signal Q0*/ + Word16 *q, + Word16 *q_DFT ); + + void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ + ); + + void delay_signal_q_adj_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay, /* i : delay in samples */ + const Word16 q_x, + const Word16 q_mem ); + + Word32 anint_fx( + const Word32 x, /* i: Round to the nearest integer */ + const Word16 exp /* i: Exponent for round step */ + ); + + Word32 ceil_fx( + const Word32 x, /* i: number to ceil */ + const Word16 exp /* i: Exponent for ceil step */ + ); + + void v_add_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_shr_16( + const Word16 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word16 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ + ); + + void v_shr( + const Word32 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word32 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ + ); + + void cldfbAnalysis_ts_fx( + const Word32 *timeIn_fx, /* i : time buffer */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, + Word16 *q_cldfb ); + + Word16 floor_log_2( + Word32 num ); + + void cldfbAnalysis_ts_fx_var_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + + void cldfbAnalysis_ts_fx_fixed_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + + void configureCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ + const Word32 sampling_rate /* i : sampling rate */ + ); + + void dec_acelp_fast_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 cdk_index, /* i : codebook index */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + const Word16 L_subfr /* i : subframe length */ + ); + + void tcx5SpectrumInterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + + void tcx5SpectrumDeinterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + + void tcx5TnsGrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum ); + + void tcx5TnsUngrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum, + const Word16 enc_dec ); + + void bpf_pitch_coherence_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ + ); + + /* fft_rel.c */ -Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - -void ProcessStereoIGF_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ - Word16 q_pITFMDCTSpectrum_1, - Word16 q_pITFMDCTSpectrum_2, - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - -void IGFEncApplyStereo_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - -void IGFSaveSpectrumForITF_ivas_fx( - IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - const Word32 *pITFSpectrum, /* i : MDCT spectrum */ - Word16 exp_pITFSpectrum ); - -Word16 IGFEncWriteBitstream_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /* i : ptr to bitOffset counter */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -); - -Word16 IGFSCFEncoderEncode_ivas_fx( - IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ - Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -); - -Word16 ari_encode_14bits_ext_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s, - Word32 symbol, /* Q0 */ - UWord16 const *cum_freq /* Q0 */ -); - -Word16 ari_encode_14bits_sign_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word32 bits, /* Q0 */ - Tastat *s, - Word16 sign /* Q0 */ -); - -Word16 ari_done_encoding_14bits_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s ); - -void IGFEncConcatenateBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const Word16 bsBits, /* i : number of IGF bits written to list of indices */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - -void hq_generic_hf_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ - Word16 length ); - -Word16 ari_decode_14bits_pow_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - UWord16 base ); - -Word16 ari_decode_14bits_sign_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - -void lsf_syn_mem_backup_ivas_fx( - Encoder_State *st_fx, /* i: state structure */ - Word16 *btilt_code_fx, /* i: tilt code Q15 */ - Word32 *gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *next_force_sf_bck_fx, /* o: */ - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ - Word16 *pstreaklen ); +#define SIZE_256 256 +#define NUM_STAGE_256 7 +#define SIZE2_256 ( SIZE_256 / 2 ) -ivas_error config_acelp1_fx( - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word32 total_brate, /* i : total bitrate */ - const Word32 core_brate_inp, /* i : core bitrate */ - const Word16 core, /* i : core */ - const Word16 extl, /* i : extension layer */ - const Word32 extl_brate, /* i : extension layer bitrate */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const Word16 signaling_bits, /* i : number of signaling bits */ - const Word16 coder_type, /* i : coder type */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 tc_subfr, /* i : TC subfr ID */ - const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ - Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ - Word16 *unbits, /* o : number of unused bits */ - const Word16 element_mode, /* i : element mode */ - Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 idchan, /* i : stereo channel ID */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); + void cldfbAnalysis_ivas_fx( + const Word32 *timeIn_fx, /* i : time buffer Qx */ + Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ + Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ + ); + + void cldfbSynthesis_ivas_fx( + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ + const Word16 out_shift, /* i : scale for output buffer */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ + ); + + void addBassPostFilter_ivas_fx( + const Word32 *harm_timeIn_fx, + const Word16 samplesToProcess, + Word32 **rAnalysis_fx, + Word32 **iAnalysis_fx, + HANDLE_CLDFB_FILTER_BANK cldfb ); + + /* o : Q22*/ + Word32 ism_dequant_meta_fx( + const Word16 idx, /* i : quantizer index */ + const Word32 borders_fx[], /* i : level borders Q22*/ + const Word32 q_step_fx, /* i : quantization step Q22 */ + const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ + const Word16 cbsize /* i : codebook size */ + ); + + void save_synthesis_hq_fec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ + const Word32 output_fx[], /* i : decoded synthesis */ + const Word16 output_frame, /* i : decoded synthesis */ + const Word16 Qpostd, /* i : Q value of delayed signal */ + CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ + ); + + void calculate_nbits_meta_fx( + const Word16 nchan_ism, + Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 + Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 + const Word16 numSf, + const Word16 numCodingBands, + Word16 *bits_ism, + const Word16 idx_sep_obj, + const Word16 ism_imp ); + + void ivas_get_stereo_panning_gains_fx( + const Word16 aziDeg, + const Word16 eleDeg, + Word16 panningGains[2] ); + + ivas_error openCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + const Word16 enc_dec ); /* i : encoder/decoder flag */ + + Word32 rand_gauss_fx( + Word32 *x, + Word16 *seed, + Word16 q ); + + void resampleCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate ); + + void generate_masking_noise_dirac_ivas_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ + Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ + Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ + const Word16 slot_index, /* i : CLDFB slot index */ + const Word16 cna_flag, /* i : CNA flag for LB and HB */ + const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ + Word16 q_input, + Word16 *q_cldfb ); + + void IMDCT_fx( + Word32 *x, + Word16 x_e, + Word16 *old_syn_overl, + Word16 *syn_Overl_TDAC, + Word16 *xn_buf, + const Word16 *tcx_aldo_window_1, + const PWord16 *tcx_aldo_window_1_trunc, + const PWord16 *tcx_aldo_window_2, + const PWord16 *tcx_mdct_window_half, + const PWord16 *tcx_mdct_window_minimum, + const PWord16 *tcx_mdct_window_trans, + Word16 tcx_mdct_window_half_length, + Word16 tcx_mdct_window_min_length, + Word16 index, + Word16 left_rect, + Word16 tcx_offset, + Word16 overlap, + Word16 L_frame, + Word16 L_frameTCX, + Word16 L_spec_TCX5, + Word16 L_frame_glob, + Word16 frame_cnt, + Word16 bfi, + Word16 *old_out, + Word16 *Q_old_wtda, + Decoder_State *st, + Word16 fullbandScale, + Word16 *acelp_zir ); + + void IMDCT_ivas_fx( + Word32 *x_fx, + Word16 q_x, + Word16 *old_syn_overl_fx, + Word16 *Q_old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, + Word16 *Q_syn_Overl_TDAC_fx, + Word16 *xn_buf_fx, + Word16 q_xn_buf_fx, + const Word16 *tcx_aldo_window_1_fx, + const PWord16 *tcx_aldo_window_1_trunc_fx, + const PWord16 *tcx_aldo_window_2_fx, + const PWord16 *tcx_mdct_window_half_fx, + const PWord16 *tcx_mdct_window_minimum_fx, + const PWord16 *tcx_mdct_window_trans_fx, + const Word16 tcx_mdct_window_half_length, + const Word16 tcx_mdct_window_min_length, + Word16 index, + const UWord16 kernel_type, /* i : TCX transform kernel type */ + const Word16 left_rect, + const Word16 tcx_offset, + const Word16 overlap, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 L_spec_TCX5, + const Word16 L_frame_glob, + const Word16 frame_cnt, + const Word16 bfi, + Word16 *old_out_fx, + Word16 *q_old_out_fx, + const Word16 FB_flag, + Decoder_State *st, + const Word16 fullbandScale, + Word16 *acelp_zir_fx, + Word16 *q_acelp_zir_fx, + Word16 *pq_win ); + + void v_mult16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, + const Word32 total_brate, + const Word16 L_frame, + const Word16 last_L_frame, + const Word16 element_mode ); + + Word32 sum2_f_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ + ); + + Word32 sum2_f_16_gb_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + + Word32 sum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + + Word16 vq_dec_lvq_ivas_fx( + Word16 sf_flag, /* i : safety net flag */ + Word16 x[], /* o : Decoded vector Q(x2.56)*/ + Word16 indices[], /* i : Indices */ + Word16 stages, /* i : Number of stages */ + Word16 N, /* i : Vector dimension */ + Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ + Word16 no_bits /* (i): no. bits for lattice */ + ); + + Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ + ); + + void deleteCldfb_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ + ); + + void fd_bwe_dec_init_fx( + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ + ); + + void stereo_dft_dec_open( + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_transport /* i : number of transport channels */ + ); + + void ivas_bw_switching_pre_proc_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + Word32 *old_syn_12k8_16k_fx, + Word16 Q, + Word16 Q_audio ); + + UWord32 mvl2s_r( + const Word32 x[], /* i : input vector */ + const Word16 q, + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ + ); + + void decoder_tcx_post_ivas_fx( + Decoder_State *st_fx, + Word16 *synth, + Word16 *synthFB, + Word16 Q_syn, + Word16 *A, + Word16 bfi, + Word16 MCT_flag ); + + void con_tcx_ivas_fx( + Decoder_State *st, /* i/o: coder memory state */ + Word16 synth[], /* i/o: synth[] Q0 */ + const Word16 coh, /* i : coherence of stereo signal */ + Word16 *noise_seed, /* i/o: noise seed for stereo */ + const Word16 only_left, /* i : TD-PLC only in left channel */ + const Word16 *A_cng /* i : CNG LP filter coefficients */ + ); + + void ivas_mdct_core_reconstruct_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ + Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ + Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + Word16 q_x, + Word16 e_sig[CPE_CHANNELS] ); + + void ari_start_encoding_14bits_ivas_fx( + Tastat *s ); + + void tcx_scalar_quantization_ivas_fx( + Word32 *x, /* i: input coefficients */ + Word16 x_e, /* i: exponent */ + Word16 *xq, /* o: quantized coefficients */ + Word16 L_frame, /* i: frame length */ + Word16 gain, /* i: quantization gain */ + Word16 gain_e, /* i: quantization gain exponent */ + Word16 offset, /* i: rounding offset (deadzone) */ + Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ + const Word16 alfe_flag ); + + Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( + Word16 *x, /* Spectral coefficients Q0*/ + const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ + Word16 *lastnz_out, /* Q0 */ + Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ + const Word16 target, /* Target bits Q0*/ + Word16 *stop, /* Q0 */ + Word16 mode, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ + ); + + /* Qx*/ + Word16 usdequant_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i: quantization step Qy*/ + ); + + /* Qx*/ + Word32 usdequant32_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word32 delta /* i: quantization step Qy*/ + ); + + /* o: index of the winning codeword */ + Word16 usquant_fx( + const Word16 x, /* i: scalar value to quantize Qx*/ + Word16 *xq, /* o: quantized value Qx*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i: quantization step Qx-1*/ + const Word16 cbsize /* i: codebook size */ + ); + + /* o : Sum */ + Word32 Dot_product( + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg /* i : vector length */ + ); + + /* o : dot product of x[] and y[] */ + Word32 dotp_fx( + const Word16 x[], /* i : vector x[] */ + const Word16 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 *exp /* (o) : exponent of result (0..+30) */ + ); + + /* o : sum of all squared vector elements Q(2x+1)*/ + Word32 sum2_fx_mod( + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ + ); + + void Copy_Scale_sig( + const Word16 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Scale_sig32( + Word32 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_16_32_DEPREC( + const Word16 x[], /* i : signal to scale i Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_16_32_r( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_16_32_no_sat( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_32_16( + const Word32 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Random_Fill( + Word16 *seed, /* i/o: random seed */ + Word16 n, /* i : number of values */ + Word16 *y, /* o : output values */ + Word16 scaling /* i : scaling of values */ + ); + + /* o : mean of vector */ + Word16 mean_fx( + const Word16 *vec_fx, /* i : i vector */ + const Word16 lvec_fx /* i : length of i vector */ + ); + + /* o : mean of vector Qx */ + Word16 mean_no_sat_fx( + const Word16 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx /* i : length of input vector */ + ); + + /* o : mean of vector Qx */ + Word32 mean_no_sat_Word32_fx( + const Word32 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx, /* i : length of input vector */ + const Word16 gb ); + void sort( + UWord16 *x, /* i/o: Vector to be sorted */ + UWord16 len /* i/o: vector length */ + ); + + void sort_fx( + Word16 *r, /* i/o: Vector to be sorted in place */ + Word16 lo, /* i : Low limit of sorting range */ + Word16 up /* I : High limit of sorting range */ + ); + + void sort_32_fx( + Word32 *r, /* i/o: Vector to be sorted in place */ + const Word16 lo, /* i : Low limit of sorting range */ + const Word16 up /* I : High limit of sorting range */ + ); + + /* o : index of the minimum value in the input vector */ + Word16 minimum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *min_fx /* o : minimum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *max_fx /* o : maximum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_exp_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 *exp_vec, /* i : exponents of input vector */ + const Word16 lvec_fx /* i : length of input vector */ + ); + + /* o : index of the maximum abs value in the input vector */ + Word16 maximum_abs_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max_val /* o : maximum value in the input vector */ + ); + + /* o : index of the minimum value in the input vector */ + Word16 minimum_abs32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ + ); + + /* o : index of the minimum value in the input vector */ + Word16 minimum_32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_abs_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /*! r: index of the maximum value in the input vector */ + Word16 maximum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max /* o : maximum value in the input vector */ + ); + + /*! r: index of the minimum value in the input vector */ + Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ + ); + + Word16 Exp16Array( + const Word16 n, /* (i): Array size */ + const Word16 *sx /* (i): Data array */ + ); + + Word16 Exp32Array( + const Word16 n, /* (i): Array size */ + const Word32 *sx /* (i): Data array */ + ); + + /* o : sum of all vector elements Qx*/ + Word32 sum16_32_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + /* o : sum of all vector elements Qx*/ + Word32 sum32_sat( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + /* o: variance of vector Qx+16*/ + Word32 var_fx_32( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ + ); + + /* o: variance of vector Qx+16*/ + Word32 var_fx_32in_32out( + const Word32 *x, /* i: input vector Qx*/ + Word16 *Qx, + const Word16 len, /* i: length of inputvector */ + const Word16 gb ); + + /* o: variance of vector Qx*/ + Word16 var_fx( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ + ); + + /* o: variance of vector Qx*/ + Word16 std_fx( + const Word16 x[], /* i: input vector */ + const Word16 len /* i: length of the input vector */ + ); + + /* o : the dot product x'*A*x */ + Word32 dot_product_mat_fx( + const Word16 *x, /* i : vector x Q15 */ + const Word32 *A, /* i : matrix A Q0*/ + const Word16 m /* i : vector & matrix size */ + ); + + void Vr_subt( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 N /* i : Vector lenght */ + ); + + /* o: index of the winning codevector */ + Word16 vquant_ivas_fx( + Word32 x[], /* i: vector to quantize Q25 */ + const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ + Word32 xq[], /* o: quantized vector Q25 */ + const Word32 cb[], /* i: codebook Q25 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ + ); + + /* o: index of the winning codevector */ + Word16 vquant_fx( + Word16 x[], /* i: vector to quantize Q13 */ + const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ + Word16 xq[], /* o: quantized vector Q13 */ + const Word16 cb[], /* i: codebook Q13 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ + ); + + Word16 w_vquant_fx( + Word16 x[], /* i: vector to quantize in Q10 */ + Word16 Qx, + const Word16 weights[], /* i: error weights in Q0 */ + Word16 xq[], /* o: quantized vector in Q15 */ + const Word16 cb[], /* i: codebook in Q15 */ + const Word16 cbsize, /* i: codebook size */ + const Word16 rev_vect /* i: reverse codebook vectors */ + ); + + /* o : return index with max energy value in vector Q0 */ + Word16 emaximum_fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word16 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ + ); + + /* o : return index with max energy value in vector Q0 */ + Word16 emaximum_32fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word32 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ + ); + + /* o : mean of the elements of the vector */ + Word32 Mean32( + const Word32 in[], /* i : input vector */ + const Word16 L /* i : length of input vector */ + ); + + /* o : sum of all vector elements Qx*/ + Word32 sum32_fx( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + /* o : sum of all vector elements Qx*/ + Word16 sum16_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + Word16 own_random2_fx( + Word16 seed ); + + void iDiv_and_mod_32( + const Word32 Numer, /* i : 32 bits numerator */ + const Word16 Denom, /* i : 16 bits denominator */ + Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ + Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ + const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ + ); + + void pz_filter_sp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word16 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + + Word32 root_a_fx( + Word32 a, + Word16 Q_a, + Word16 *exp_out ); + + Word32 root_a_over_b_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + + Word32 root_a_over_b_ivas_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + + void fir_fx( + const Word16 x[], /* i : input vector Qx*/ + const Word16 h[], /* i : impulse response of the FIR filter Q12*/ + Word16 y[], /* o : output vector (result of filtering) Qx*/ + Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ + const Word16 L, /* i : input vector size */ + const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ + const Word16 upd, /* i : 1 = update the memory, 0 = not */ + Word16 shift /* i : difference between Q15 and scaling of h[] */ + ); + + void v_add_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_shr_32( + Word32 x1[], /* i : Input vector 1 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N, /* i : Vector length */ + Word16 shift /*shift value*/ + ); + + void v_sub_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_add_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_sub_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + /* o: index of the winning codeword */ + Word16 squant_fx( + const Word16 x, /* i: scalar value to quantize */ + Word16 *xq, /* o: quantized value */ + const Word16 cb[], /* i: codebook */ + const Word16 cbsize /* i: codebook size */ + ); + + Word16 squant_int_fx( + UWord8 x, /* i : scalar value to quantize */ + UWord8 *xq, /* o : quantized value */ + const UWord8 *cb, /* i : codebook */ + const Word16 cbsize /* i : codebook size */ + ); + + void pz_filter_dp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word32 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + + void Copy_Scale_sig32_16( + const Word32 *src, /* i : signal to scale Qx */ + Word16 *dst, /* o : scaled signal Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ + + void v_multc_att( + const Word16 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word16 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_att32( + const Word32 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_att3232( + const Word32 x[], /* i : Input vector Qx */ + const Word32 att, /* i : Constant Q32, <= MAX_32 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ + ); + + void v_L_mult_1616( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_L_mult_3216( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void add_vec_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 Qx1, /* i : SCaling of input 1 */ + const Word16 x2[], /* i : Input vector 2 */ + const Word16 Qx2, /* i : SCaling of input 1 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 Qy, /* i : SCaling of output 1 */ + const Word16 N /* i : Vector lenght */ + ); + + /* o: Result (Normalized) */ + Word32 Add_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ + ); + + /* o: Result (Normalized) */ + Word32 Mul_flt32_Q15( + Word32 value, /* i: Pseudo_float Value */ + Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ + Word16 frac /* i: Q15 value */ + ); + + /* o: Result (Normalized) */ + Word32 Div_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ + ); + + /* o: Result (Normalized) */ + Word32 Calc_Energy_Autoscaled( + const Word16 *signal, /* i: Signal */ + Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ + Word16 len, /* i: Frame Length */ + Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ + ); + + Word16 Find_Max_Norm16( + const Word16 *src, + Word16 len ); + + Word16 Find_Max_Norm32( + const Word32 *src, + Word16 len ); + + /* o: Result in Q31 */ + Word32 Sqrt_Ratio32( + Word32 L_val1, /* i: Mantisa of Val1 */ + Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i: Mantisa of Val2 */ + Word16 exp2, /* i: Exp of Val2 (same as exp1) */ + Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ + ); + + /* result in Q'15 + 'exp' */ + Word16 Invert16( + Word16 val, + Word16 *exp ); + + Word16 find_rem( + Word16 n, + Word16 m, + Word16 *r ); + + Word32 find_remd( + Word32 n, + Word32 m, + Word32 *r ); + + Word16 rint_new_fx( + Word32 x /*Q16 */ + ); + + Word16 erb_diff_search_fx( + Word16 *prev_erb, + const Word16 *curr_erb, + Word16 *dif_erb, + Word16 *pow_spec, + const Word16 *cb_fx, + Word16 cb_size, + Word16 cb_dim, + Word16 offset ); + + void Acelp_dec_total_exc( + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + const Word16 gain_code16, /* i : Gain code Q0 */ + const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ + const Word16 i_subfr, /* i ; subfr */ + const Word16 *code_fx, /* i : code in Q9 */ + const Word16 L_subfr /* i : Subframne lenght */ + ); + + UWord32 UL_inverse( + const UWord32 UL_val, + Word16 *exp ); + + UWord32 UL_div( + const UWord32 UL_num, + const UWord32 UL_den ); + + Word16 ratio( + const Word32 numer, + const Word32 denom, + Word16 *expo ); + + void hp400_12k8_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ + ); + + void hp400_12k8_ivas_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ + ); + + Word16 dot_prod_satcontr( + const Word16 *x, + const Word16 *y, + Word16 qx, + Word16 qy, + Word16 *qo, + Word16 len ); + + void E_UTIL_f_convolve( + const Word16 x[], + const Word16 h[], + Word16 y[], + const Word16 size ); + + void floating_point_add( + Word32 *mx, /* io: mantissa of the addend Q31 */ + Word16 *ex, /* io: exponent of the addend Q0 */ + const Word32 my, /* i: mantissa of the adder Q31 */ + const Word16 ey /* i: exponent of the adder Q0 */ + ); + + void delay_signal_fx( + Word16 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word16 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ + ); + + void delay_signal32_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ + ); + + Word16 lin_interp_ivas_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ + ); + + Word16 lin_interp_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ + ); + + Word16 ceil_log_2( + UWord64 val ); + + Word32 imax_pos_fx( + const Word32 *y /* i : Input vector for peak interpolation Qx*/ + ); + + void msvq_enc_ivas_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ + const Word16 Q_cb, /* i : Codebook Q */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ + const Word16 u_e, /* i : Exponent for Vector to be encoded */ + const Word16 *levels, /* i : Number of levels in each stage */ + const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ + const Word16 stages, /* i : Number of stages */ + const Word16 w[], /* i : Weights Q8 */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 applyDCT_flag, /* i : applyDCT flag */ + Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ + Word16 Idx[] /* o : Indices */ + ); + + void msvq_dec_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 Idx[], /* i : Indices */ + const Word16 applyIDCT_flag, /* i : applyIDCT flag */ + const Word32 *invTrfMatrix, /* i : synthesis matrix */ + Word32 *uq, /* o : quantized vector */ + Word16 *uq_ind, /* o : quantized vector (fixed point) */ + Word16 exp ); + + void dec_FDCNG_MSVQ_stage1_fx( + Word16 j_full, /* i : index full range */ + Word16 n, /* i : dimension to generate */ + const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ + const DCTTYPE idcttype, /* i : specify which IDCT */ + Word32 *uq, /* o : synthesized stage1 vector Q20 */ + Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ + ); + + void dctT2_N_apply_matrix_fx( + const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ + Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ + const Word16 dct_dim, /* i : dct processing dim possibly truncated */ + const Word16 fdcngvq_dim, /* i : fdcng domain length */ + const Word32 *matrix, /* i : IDCT matrix */ + const Word16 matrix_row_dim, /* i : */ + const DCTTYPE dcttype /* i : matrix operation type */ + ); + + Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + + Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + + void v_mult_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_sub_s16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_sub32_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void ivas_swb_tbe_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ + const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ + Word16 Q_exc, + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *Q_white_exc ); + + Word16 swb_bwe_dec_fx32( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ + Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ + Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ + ); + + ivas_error acelp_core_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 output_fx[], /* o : synthesis @internal Fs */ + Word16 synth_fx16[], /* o : synthesis */ + Word16 save_hb_synth_fx16[], /* o : HB synthesis */ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word16 *unbits, /* o : number of unused bits */ + Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const Word16 last_element_mode, /* i : last element mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 read_sid_info /* i : read SID info flag */ + ); + + void wtda_fx32( + const Word32 *new_audio, /* i : input audio Q11 */ + Word32 *wtda_audio, /* o : windowed audio Q11 */ + Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ + const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ + const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const Word16 L /* i : length */ + ); + + ivas_error core_switching_pre_dec_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 output_frame, /* i : frame length */ + const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 last_element_mode, /* i : last_element_mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + Word16 Q_old_synthFB, + Word16 *Q_olapBufferSynth, + Word16 *Q_olapBufferSynth2 ); + + void hp20_fx_32( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + + void hp20_fx_32_opt( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + + void getTCXMode_ivas_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Decoder_State *st0, /* i : bitstream */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ + ); + + void getTCXWindowing_ivas_fx( + const Word16 core, /* i : current frame mode */ + const Word16 last_core, /* i : last frame mode */ + const Word16 element_mode, /* i : element mode */ + TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ + Decoder_State *st0 /* i : bitstream */ + ); + + Word16 ari_start_decoding_14bits_prm_ivas_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + + void generate_masking_noise_ivas_fx( + Word32 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 *exp_out, /* o : time-domain signal exp */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 length, /* i : frame size */ + const Word16 core, /* i : core */ + const Word16 return_noise, /* i : noise is returned instead of added */ + const Word16 secondary, /* i : flag to indicate secondary noise generation */ + const Word16 element_mode, /* i : element mode */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void SynthesisSTFT_dirac_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 samples_out, + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + void generate_stereo_masking_noise_fx( + Word16 *syn, /* i/o: time-domain signal */ + Word16 Q_syn, + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 fadeOut, /* i : only fade out of previous state */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void SynthesisSTFT_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void FdCng_decodeSID_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ + ); + + void cldfb_restore_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + ivas_error cldfb_save_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ + ); + + Word16 sr2fscale( + const Word32 sr_core /* i : internal sampling rate */ + ); + + void Copy_Scale_sig32( + const Word32 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void swb_pre_proc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ + Word16 *Q_shb_spch, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ + Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ + ); + + void core_encode_update_ivas_fx( + Encoder_State *st /* i/o: Encoder state structure */ + ); + + void updt_enc_common_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 Q_new /* i : CUrrent frame scaling */ + ); + + /* o : Q(2x - 31 - gb) */ + Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb /* i : guard bits */ + ); + + Word32 sum2_16_exp_fx( + const Word16 *vec, /* i : input vector Q(15 - exp) */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ + ); + + Word32 sum2_32_exp_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ + ); + + Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + + void ProcessStereoIGF_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ + Word16 q_pITFMDCTSpectrum_1, + Word16 q_pITFMDCTSpectrum_2, + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + + void IGFEncApplyStereo_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + + void IGFSaveSpectrumForITF_ivas_fx( + IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + const Word32 *pITFSpectrum, /* i : MDCT spectrum */ + Word16 exp_pITFSpectrum ); + + Word16 IGFEncWriteBitstream_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ + ); + + Word16 IGFSCFEncoderEncode_ivas_fx( + IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ + Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ + ); + + Word16 ari_encode_14bits_ext_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s, + Word32 symbol, /* Q0 */ + UWord16 const *cum_freq /* Q0 */ + ); + + Word16 ari_encode_14bits_sign_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word32 bits, /* Q0 */ + Tastat *s, + Word16 sign /* Q0 */ + ); + + Word16 ari_done_encoding_14bits_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s ); + + void IGFEncConcatenateBitstream( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + const Word16 bsBits, /* i : number of IGF bits written to list of indices */ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ + ); + + void hq_generic_hf_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ + Word16 length ); + + Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ); + + Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + + void lsf_syn_mem_backup_ivas_fx( + Encoder_State *st_fx, /* i: state structure */ + Word16 *btilt_code_fx, /* i: tilt code Q15 */ + Word32 *gc_threshold_fx, /* i: Q16 */ + Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ + Word16 *next_force_sf_bck_fx, /* o: */ + Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ + Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ + Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ + Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ + Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *streaklimit, /* Q15 */ + Word16 *pstreaklen ); + + ivas_error config_acelp1_fx( + const Word16 enc_dec, /* i : encoder/decoder flag */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 core_brate_inp, /* i : core bitrate */ + const Word16 core, /* i : core */ + const Word16 extl, /* i : extension layer */ + const Word32 extl_brate, /* i : extension layer bitrate */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ + ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ + const Word16 signaling_bits, /* i : number of signaling bits */ + const Word16 coder_type, /* i : coder type */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 tc_subfr, /* i : TC subfr ID */ + const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ + Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ + Word16 *unbits, /* o : number of unused bits */ + const Word16 element_mode, /* i : element mode */ + Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 idchan, /* i : stereo channel ID */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) @@ -10732,749 +10737,749 @@ ivas_error config_acelp1_fx( #endif #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) -ivas_error push_next_indice_( - const char *caller, + ivas_error push_next_indice_( + const char *caller, #else ivas_error push_next_indice( #endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ + ); #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) -ivas_error push_next_bits_( - const char *caller, + ivas_error push_next_bits_( + const char *caller, #else ivas_error push_next_bits( #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ -); - -/*! r: index of next coefficient */ -Word16 get_next_coeff_mapped_ivas_fx( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -void RCcontextMapping_encode2_no_mem_s17_LCS_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - Word16 lastnz, /* Q0 */ - const Word16 nbbits, /* Q0 */ - const Word16 resQMaxBits, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg ); - -void writeTCXparam_fx( - Encoder_State *st, /* i/o: Encoder State handle */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ - Word16 param[], /* i : parameters */ - const Word16 nbits_header, - const Word16 nbits_start, - const Word16 nbits_lpc, - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ - Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ - const Word16 target_bitsTCX10[2], - const Word16 pre_past_flag ); - -void calculate_hangover_attenuation_gain_ivas_fx( - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -); - -void init_coder_ace_plus_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ - const Word32 igf_brate, /* i : IGF configuration bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void core_coder_reconfig_ivas_fx( - Encoder_State *st, - const Word32 last_total_brate ); - -void core_coder_mode_switch_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word32 last_total_brate, /* i : last bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void configureFdCngEnc_ivas_fx( - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, /* Q0 */ - const Word32 total_brate /* Q0 */ -); - -Word16 getTcxonly_ivas_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ -); - -void SetModeIndex_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ -); - -void IGFEncSetMode_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word32 total_brate, /* i : encoder total bitrate */ - const Word16 bwidth, /* i : encoder audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void init_tcx_cfg_ivas_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag ); - -Word16 msvq_stage1_dct_search_fx( - const Word32 *u_fx, /* i : target exp : u_e */ - const Word16 u_e, /* i : exp for target Q0 */ - const Word16 N, /* i : target length and IDCT synthesis length */ - const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ - const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ - const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ - Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ - const Word16 *midQ_truncQ_fx, /* i : midQ vector */ - const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ - const Word16 n_segm, /* i : number of segments */ - const Word16 *cols_per_segment, /* i : remaining length per segment */ - const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ - const Word16 *entries_per_segment, /* i : number of rows per segment */ - const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ - const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ - const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ - const Word16 npost_check, /* i : number of neigbours to check , should be even */ - Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ - Word16 *indices_st1_local, /* o : selected cand indices */ - Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ - Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ - Word16 *dist1_ptr_e ); - -Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( - const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ - const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ - const Word32 *u_fx, /* i : target signal */ - const Word16 u_e, /* i : exp for target signal */ - const Word16 maxC_st1, /* i : number of candidates in stage1 */ - Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ - Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ -); - -void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ -); - -ivas_error IGF_Reconfig_fx( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ + ); + + /*! r: index of next coefficient */ + Word16 get_next_coeff_mapped_ivas_fx( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + void RCcontextMapping_encode2_no_mem_s17_LCS_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + Word16 lastnz, /* Q0 */ + const Word16 nbbits, /* Q0 */ + const Word16 resQMaxBits, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg ); + + void writeTCXparam_fx( + Encoder_State *st, /* i/o: Encoder State handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ + Word16 param[], /* i : parameters */ + const Word16 nbits_header, + const Word16 nbits_start, + const Word16 nbits_lpc, + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ + Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ + const Word16 target_bitsTCX10[2], + const Word16 pre_past_flag ); + + void calculate_hangover_attenuation_gain_ivas_fx( + Encoder_State *st, /* i : encoder state structure */ + Word16 *att, /* o : attenuation factor */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ + ); + + void init_coder_ace_plus_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word32 igf_brate, /* i : IGF configuration bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ + ); + + void core_coder_reconfig_ivas_fx( + Encoder_State *st, + const Word32 last_total_brate ); + + void core_coder_mode_switch_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word32 last_total_brate, /* i : last bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ + ); + + void configureFdCngEnc_ivas_fx( + HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, /* Q0 */ + const Word32 total_brate /* Q0 */ + ); + + Word16 getTcxonly_ivas_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ + ); + + void SetModeIndex_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ + ); + + void IGFEncSetMode_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word32 total_brate, /* i : encoder total bitrate */ + const Word16 bwidth, /* i : encoder audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void init_tcx_cfg_ivas_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag ); + + Word16 msvq_stage1_dct_search_fx( + const Word32 *u_fx, /* i : target exp : u_e */ + const Word16 u_e, /* i : exp for target Q0 */ + const Word16 N, /* i : target length and IDCT synthesis length */ + const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ + Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ + const Word16 *midQ_truncQ_fx, /* i : midQ vector */ + const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ + const Word16 n_segm, /* i : number of segments */ + const Word16 *cols_per_segment, /* i : remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ + const Word16 *entries_per_segment, /* i : number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ + const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ + const Word16 npost_check, /* i : number of neigbours to check , should be even */ + Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ + Word16 *indices_st1_local, /* o : selected cand indices */ + Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ + Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ + Word16 *dist1_ptr_e ); + + Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( + const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ + const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ + const Word32 *u_fx, /* i : target signal */ + const Word16 u_e, /* i : exp for target signal */ + const Word16 maxC_st1, /* i : number of candidates in stage1 */ + Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ + Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ + ); + + void FEC_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ + const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ + const Word16 coder_type, /* i : type of coder Q0*/ + Word16 clas, /* i : signal clas for current frame Q0*/ + const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ + const Word16 *res, /* i : LP residual signal frame Qx*/ + Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ + const Word16 L_frame, /* i : Frame length Q0*/ + const Word32 total_brate, /* i : total codec bitrate Q0*/ + const Word16 Q_synth /* i : input scaling */ + ); + + ivas_error IGF_Reconfig_fx( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void core_switching_post_enc_ivas_fx( + Encoder_State *st /* i/o: encoder state structure */ #ifndef CLEANUP_ACELP_ENC - , - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ - Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new + , + Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ + Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ + Word16 A_fx[], /* i : unquant. LP filter coefs. */ + Word16 Q_new #endif -); - -void residu_ivas_fx( - const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ - const Word16 a_exp, - const Word16 m, /* i : order of LP filter */ - const Word32 *x, /* i : input signal (usually speech) Qx*/ - Word32 *y, /* o : output signal (usually residual) Qx*/ - const Word16 l /* i : size of filtering */ -); - -void WriteToBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - -void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - -/*===========================================================================================*/ -/*----------------------------------------------------------------------------------* - * MODE1 prototypes - *----------------------------------------------------------------------------------*/ - -/*! r: output random value */ -Word16 own_random( - Word16 *seed /* i/o: random seed */ -); - -/*! r: sum of all vector elements */ -Word16 sum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ -); - -void set_c( - Word8 y[], /* i/o: Vector to set */ - const Word8 a, /* i : Value to set the vector to */ - const Word32 N /* i : Length of the vector */ -); - -void set_s( - Word16 y[], /* i/o: Vector to set */ - const Word16 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ -); - -void set_l( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Length of the vector */ -); - -void set_zero_fx( - Word32 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); - -void set_zero2_fx( - Word32 *vec, /* o : input vector */ - const Word32 lvec /* i : length of the vector */ -); - -void set16_zero_fx( - Word16 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); - -void mvs2s( - const Word16 x[], /* i : input vector */ - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ -); - -void mvl2l( - const Word32 x[], /* i : input vector */ - Word32 y[], /* o : output vector */ - const Word16 n /* i : vector size */ -); - -Word16 maximumAbs_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ -); - -void sort_l( - Word32 *x, /* i/o: Vector to be sorted */ - Word16 len /* i/o: vector length */ -); - -ivas_error push_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 id, /* i : ID of the indice */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); - -ivas_error push_next_indice_( + ); + + void residu_ivas_fx( + const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ + const Word16 a_exp, + const Word16 m, /* i : order of LP filter */ + const Word32 *x, /* i : input signal (usually speech) Qx*/ + Word32 *y, /* o : output signal (usually residual) Qx*/ + const Word16 l /* i : size of filtering */ + ); + + void WriteToBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + void WriteToBitstream_ivas_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + + /*===========================================================================================*/ + /*----------------------------------------------------------------------------------* + * MODE1 prototypes + *----------------------------------------------------------------------------------*/ + + /*! r: output random value */ + Word16 own_random( + Word16 *seed /* i/o: random seed */ + ); + + /*! r: sum of all vector elements */ + Word16 sum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ + ); + + void set_c( + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word32 N /* i : Length of the vector */ + ); + + void set_s( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ + ); + + void set_l( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ + ); + + void set_zero_fx( + Word32 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ + ); + + void set_zero2_fx( + Word32 *vec, /* o : input vector */ + const Word32 lvec /* i : length of the vector */ + ); + + void set16_zero_fx( + Word16 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ + ); + + void mvs2s( + const Word16 x[], /* i : input vector */ + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ + ); + + void mvl2l( + const Word32 x[], /* i : input vector */ + Word32 y[], /* o : output vector */ + const Word16 n /* i : vector size */ + ); + + Word16 maximumAbs_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /*! r: index of the minimum value in the input vector */ + Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ + ); + + void sort_l( + Word32 *x, /* i/o: Vector to be sorted */ + Word16 len /* i/o: vector length */ + ); + + ivas_error push_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 id, /* i : ID of the indice */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ + ); + + ivas_error push_next_indice_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ + ); -ivas_error push_next_bits_( + ivas_error push_next_bits_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -/*! r: maximum number of indices */ -Word16 get_BWE_max_num_indices( - const Word32 extl_brate /* i : extensiona layer bitrate */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_metadata_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); -ivas_error ind_list_realloc( - INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ - const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ - Encoder_Struct *st_ivas /* i : IVAS encoder structure */ -); - -ivas_error check_ind_list_limits( - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void move_indices( - INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ - INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const Word16 nb_indices /* i : number of moved indices */ -); - -/*! r: index of the indice in the list, -1 if not found */ -Word16 find_indice( - BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const Word16 id, /* i : ID of the indice */ - UWord16 *value, /* o : value of the quantized indice */ - Word16 *nb_bits /* o : number of bits used to quantize the indice */ -); - -/*! r: number of deleted indices */ -UWord16 delete_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 id /* i : ID of the indice */ -); - -/*! r: value of the indice */ -UWord16 get_indice_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 pos, /* i : absolute position in the bitstream */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ -); - -void reset_indices_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -Word16 rate2EVSmode( - const Word32 brate, /* i : bitrate */ - Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ -); - -/*! r: 1 = OK, 0 = something wrong */ -ivas_error read_indices_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - UWord16 bit_stream[], /* i : bitstream buffer */ - UWord16 num_bits, /* i : number of bits in bitstream */ - Word16 *prev_ft_speech, - Word16 *CNG, - Word16 bfi /* i : bad frame indicator */ -); - -void ivas_set_bitstream_pointers( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -Decoder_State **reset_elements( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void convertSerialToBytestream_fx( - const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ - const UWord16 num_bits, /* i : number of bits in the input bitstream */ - UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ -); - -void mdct_switching_dec_fx( - Decoder_State *st /* i/o: decoder state structure */ -); - -Word16 print_disclaimer( - FILE *fPtr ); - -void preemph_ivas_fx( - Word32 *signal, /* i/o: signal Qx*/ - const Word16 mu, /* i : preemphasis factor Q15*/ - const Word16 L, /* i : vector size Q0*/ - Word32 *mem /* i/o: memory (x[-1]) Qx*/ -); - -void create_offset( - UWord32 *offset_scale1, - UWord32 *offset_scale2, - const Word16 mode, - const Word16 prediction_flag ); - -void BASOP_cfft_ivas( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - Word16 s, /* i : stride real and imag part */ - Word16 *scale /* i : scalefactor */ -); - -Word32 ar_div_ivas( - Word32 num, - Word32 denum ); - -Word32 Mult_32_16( - Word32 a, - Word16 b ); - -Word32 Mult_32_32( - Word32 a, - Word32 b ); + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ + ); + + /*! r: maximum number of indices */ + Word16 get_ivas_max_num_indices_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ + ); + + /*! r: maximum number of indices */ + Word16 get_BWE_max_num_indices( + const Word32 extl_brate /* i : extensiona layer bitrate */ + ); + + /*! r: maximum number of indices */ + Word16 get_ivas_max_num_indices_metadata_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ + ); + ivas_error ind_list_realloc( + INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ + const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ + Encoder_Struct *st_ivas /* i : IVAS encoder structure */ + ); + + ivas_error check_ind_list_limits( + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + ); + + void move_indices( + INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ + INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ + const Word16 nb_indices /* i : number of moved indices */ + ); + + /*! r: index of the indice in the list, -1 if not found */ + Word16 find_indice( + BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ + const Word16 id, /* i : ID of the indice */ + UWord16 *value, /* o : value of the quantized indice */ + Word16 *nb_bits /* o : number of bits used to quantize the indice */ + ); + + /*! r: number of deleted indices */ + UWord16 delete_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 id /* i : ID of the indice */ + ); + + /*! r: value of the indice */ + UWord16 get_indice_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 pos, /* i : absolute position in the bitstream */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ + ); + + void reset_indices_dec( + Decoder_State *st /* i/o: decoder state structure */ + ); + + Word16 rate2EVSmode( + const Word32 brate, /* i : bitrate */ + Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ + ); + + /*! r: 1 = OK, 0 = something wrong */ + ivas_error read_indices_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + UWord16 bit_stream[], /* i : bitstream buffer */ + UWord16 num_bits, /* i : number of bits in bitstream */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ + ); + + void ivas_set_bitstream_pointers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + ); + + Decoder_State **reset_elements( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + ); + + void convertSerialToBytestream_fx( + const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ + const UWord16 num_bits, /* i : number of bits in the input bitstream */ + UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ + ); + + void mdct_switching_dec_fx( + Decoder_State *st /* i/o: decoder state structure */ + ); + + Word16 print_disclaimer( + FILE *fPtr ); + + void preemph_ivas_fx( + Word32 *signal, /* i/o: signal Qx*/ + const Word16 mu, /* i : preemphasis factor Q15*/ + const Word16 L, /* i : vector size Q0*/ + Word32 *mem /* i/o: memory (x[-1]) Qx*/ + ); + + void create_offset( + UWord32 *offset_scale1, + UWord32 *offset_scale2, + const Word16 mode, + const Word16 prediction_flag ); + + void BASOP_cfft_ivas( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + Word16 s, /* i : stride real and imag part */ + Word16 *scale /* i : scalefactor */ + ); + + Word32 ar_div_ivas( + Word32 num, + Word32 denum ); + + Word32 Mult_32_16( + Word32 a, + Word16 b ); + + Word32 Mult_32_32( + Word32 a, + Word32 b ); #ifdef DEBUGGING -void read_next_force( - int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ - FILE *f_force, /* i : force switching profile (0 if N/A) */ - int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ -); + void read_next_force( + int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ + FILE *f_force, /* i : force switching profile (0 if N/A) */ + int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ + ); #endif -ivas_error init_encoder_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ -); - -ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - const Word16 Q_new ); - -void flip_and_downmix_generic_fx32( - Word32 input[], /* i : input spectrum Qx*/ - Word32 output[], /* o : output spectrum Qx*/ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); - -/* o : Q(2x - 31 - gb) */ -Word16 quant_2p_2N1_fx( - const Word16 pos1, /* i: position of the pulse 1 */ - const Word16 pos2, /* i: position of the pulse 2 */ - const Word16 N /* i: number of bits FOR position */ -); - -void bands_and_bit_alloc_ivas_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); - -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ - Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ - const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ - const Word16 tilt_fact, /* i : tilt factor Q15 */ - Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ - Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ - const Word16 gamma, /* i : weighting factor Q15 */ - const Word16 L_look /* i : look-ahead Q0*/ -); - -Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - const Word16 target, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem ); - -Word16 RCcontextMapping_encode2_estimate_bandWise_fx( - Word16 *x, /* Q0 */ - const Word16 start_line, /* Q0 */ - const Word16 end_line, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ -); - -/*! r: Q15 */ -Word16 expfp_evs_fx( - const Word16 x, /* i : mantissa Q15-e */ - const Word16 x_e /* i : exponent Q0 */ -); - -void tcx_arith_render_envelope_ivas_fx( - const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i : number of spectral lines Q0*/ - const Word16 L_spec, /* i : length of the coded spectrum Q0*/ - const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o : shaped signal envelope Q16*/ -); - -void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ -); - -void UnmapIndex_fx( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word8 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ -); + ivas_error init_encoder_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ + ); + + ivas_error acelp_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + const Word16 Q_new ); + + void flip_and_downmix_generic_fx32( + Word32 input[], /* i : input spectrum Qx*/ + Word32 output[], /* o : output spectrum Qx*/ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ + ); + + /* o : Q(2x - 31 - gb) */ + Word16 quant_2p_2N1_fx( + const Word16 pos1, /* i: position of the pulse 1 */ + const Word16 pos2, /* i: position of the pulse 2 */ + const Word16 N /* i: number of bits FOR position */ + ); + + void bands_and_bit_alloc_ivas_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); + + void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ + Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ + const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ + const Word16 tilt_fact, /* i : tilt factor Q15 */ + Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ + Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ + const Word16 gamma, /* i : weighting factor Q15 */ + const Word16 L_look /* i : look-ahead Q0*/ + ); + + Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + const Word16 target, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem ); + + Word16 RCcontextMapping_encode2_estimate_bandWise_fx( + Word16 *x, /* Q0 */ + const Word16 start_line, /* Q0 */ + const Word16 end_line, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ + ); + + /*! r: Q15 */ + Word16 expfp_evs_fx( + const Word16 x, /* i : mantissa Q15-e */ + const Word16 x_e /* i : exponent Q0 */ + ); + + void tcx_arith_render_envelope_ivas_fx( + const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i : number of spectral lines Q0*/ + const Word16 L_spec, /* i : length of the coded spectrum Q0*/ + const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o : shaped signal envelope Q16*/ + ); + + void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ + ); + + void UnmapIndex_fx( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word8 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ + ); #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) -Word32 tcx_hm_render_fx( - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ -); - -void tcx_hm_modify_envelope_fx( - const Word16 gain, /* i: HM gain Q11 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - const Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - const Word16 L_frame /* i: number of spectral lines Q0 */ -); - -void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ -); - -void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ -); - -void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ -); - -void writeLPCparam( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ -); - -void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); -void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); -void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); -void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); - -Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); -Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); -Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); - -Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); -Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -void ResetTnsData_flt( - STnsData *pTnsData ); - -void ClearTnsFilterCoefficients_flt( - STnsFilter *pTnsFilter ); - -void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - Word16 *pnBits /* o : number of written bits */ -); - -Word16 DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const Word16 *stream, - Word16 *pnSize, - STnsData *pTnsData ); - -void WriteTnsData( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const Word16 *stream, /* i : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - BSTR_ENC_HANDLE hBstr, /* o : bitstream */ - Word16 *pnBits /* o : number of written bits */ -); - -void ReadTnsData_ivas( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -void analysisCldfbEncoder_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *timeIn, /*q11*/ - Word16 timeInq, /*q0*/ - Word16 samplesToProcess, /*q0*/ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 *ppBuf_Ener, - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - -ivas_error openCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - -void resampleCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate /* i : new samplerate to operate */ -); - -ivas_error cldfb_save_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -/*! r: flag indicating a valid bitrate */ -Word16 is_EVS_bitrate( - const Word32 ivas_total_brate, /* i : EVS total bitrate */ - Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ -); - -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ -); - -/*===========================================================================================*/ + Word32 tcx_hm_render_fx( + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ + ); + + void tcx_hm_modify_envelope_fx( + const Word16 gain, /* i: HM gain Q11 */ + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + const Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + const Word16 L_frame /* i: number of spectral lines Q0 */ + ); + + void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ + ); + + void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ + ); + + void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ + ); + + void writeLPCparam( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ + ); + + void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); + void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); + void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); + void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); + + Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); + + Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); + Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + void ResetTnsData_flt( + STnsData *pTnsData ); + + void ClearTnsFilterCoefficients_flt( + STnsFilter *pTnsFilter ); + + void EncodeTnsData( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + Word16 *pnBits /* o : number of written bits */ + ); + + Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + + void WriteTnsData( + const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ + const Word16 *stream, /* i : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + BSTR_ENC_HANDLE hBstr, /* o : bitstream */ + Word16 *pnBits /* o : number of written bits */ + ); + + void ReadTnsData_ivas( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + + void analysisCldfbEncoder_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *timeIn, /*q11*/ + Word16 timeInq, /*q0*/ + Word16 samplesToProcess, /*q0*/ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 *ppBuf_Ener, + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + + ivas_error openCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ + ); + + void resampleCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate /* i : new samplerate to operate */ + ); + + ivas_error cldfb_save_memory_ivas( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + /*! r: flag indicating a valid bitrate */ + Word16 is_EVS_bitrate( + const Word32 ivas_total_brate, /* i : EVS total bitrate */ + Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ + ); + + ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ + ); + + /*===========================================================================================*/ #endif diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index c9d307ef2..7073ee69d 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -160,6 +160,7 @@ Word16 tbe_celp_exc_offset( * * Compute tbe bwe celp excitation *-------------------------------------------------------------------*/ +#ifndef CLEANUP_ACELP_ENC void tbe_celp_exc( const Word16 L_frame_fx, /* i : Frame lenght */ const Word16 i_subfr_fx, /* i : sub frame */ @@ -238,7 +239,13 @@ void tbe_celp_exc( * * Compute tbe bwe celp excitation *-------------------------------------------------------------------*/ +#endif + +#ifdef CLEANUP_ACELP_ENC +void tbe_celp_exc( +#else void tbe_celp_exc_ivas( +#endif const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 L_frame_fx, /* i : Frame lenght */ @@ -321,6 +328,8 @@ void tbe_celp_exc_ivas( *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/ move16(); } + + return; } /*===========================================================================*/ @@ -349,6 +358,16 @@ void tbe_celp_exc_ivas( /* RETURN ARGUMENTS : */ /* _ None */ /*---------------------------------------------------------------------------*/ + +#ifdef CLEANUP_ACELP_ENC +static const Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, + -26319, -17530, -6393, 6393, 17530, 26319, + 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ +static const Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739, + -19519, -27683, -32137, -32137, -27683, + -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ +#endif + void flip_and_downmix_generic_fx( Word16 input[], /* i : input spectrum Qx*/ Word16 output[], /* o : output spectrum Qx*/ @@ -371,6 +390,7 @@ void flip_and_downmix_generic_fx( /*Word16 s_tmp[L_FRAME32k];*/ /*Word16 factor;*/ Word16 period; +#ifndef CLEANUP_ACELP_ENC Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, -26319, -17530, -6393, 6393, 17530, 26319, 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ @@ -378,14 +398,16 @@ void flip_and_downmix_generic_fx( -19519, -27683, -32137, -32137, -27683, -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ Word16 *local_negsin_table, *local_cos_table; +#endif Word32 L_tmp; /* 1850 Hz downmix */ period = 17; move16(); +#ifndef CLEANUP_ACELP_ENC local_negsin_table = local_negsin_table17; local_cos_table = local_cos_table17; - +#endif FOR( i = 0; i < length; i = i + 2 ) { @@ -467,9 +489,14 @@ void flip_and_downmix_generic_fx( { WHILE( ( j < period ) && ( i < length ) ) { +#ifdef CLEANUP_ACELP_ENC + L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ + L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ +#else L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */ - output[i] = round_fx( L_tmp ); /*Qx */ +#endif + output[i] = round_fx( L_tmp ); /*Qx */ move16(); i++; j++; @@ -511,6 +538,7 @@ void flip_and_downmix_generic_fx32( /*Word16 s_tmp[L_FRAME32k];*/ /*Word16 factor;*/ Word16 period; +#ifndef CLEANUP_ACELP_ENC Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, -26319, -17530, -6393, 6393, 17530, 26319, 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ @@ -518,14 +546,16 @@ void flip_and_downmix_generic_fx32( -19519, -27683, -32137, -32137, -27683, -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ Word16 *local_negsin_table, *local_cos_table; +#endif Word32 L_tmp; /* 1850 Hz downmix */ period = 17; move16(); +#ifndef CLEANUP_ACELP_ENC local_negsin_table = local_negsin_table17; local_cos_table = local_cos_table17; - +#endif FOR( i = 0; i < length; i = i + 2 ) { @@ -597,9 +627,14 @@ void flip_and_downmix_generic_fx32( WHILE( ( j < period ) && ( i < length ) ) { test(); +#ifdef CLEANUP_ACELP_ENC + L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ + L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ +#else L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */ - output[i] = L_tmp; /*Qx */ +#endif + output[i] = L_tmp; /*Qx */ move32(); i++; j++; @@ -6136,7 +6171,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ #endif j = extract_l( L_shr( L_tmp, 23 ) ); @@ -6153,7 +6188,7 @@ void create_random_vector_fx( } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); @@ -6171,7 +6206,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 0d867fd6f..9870d45cb 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -353,7 +353,11 @@ void decoder_acelp_fx( IF( st->igf != 0 ) { +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); +#else tbe_celp_exc( st->L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); +#endif } pitch_buffer[idx] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); // Q6 diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index f08c5e767..983f6d8e6 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -164,6 +164,7 @@ ivas_error decod_gen_voic_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ + IF( st_fx->element_mode != EVS_MONO ) { pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -173,7 +174,11 @@ ivas_error decod_gen_voic_fx( pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#endif /*--------------------------------------------------------------* * LP filtering of the adaptive excitation diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index d897b116e..a25e259c0 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -267,7 +267,11 @@ void decod_gen_2sbfr_fx( test(); IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) && !( st->tdm_LRTD_flag ) ) ) { +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); +#else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); +#endif } /*--------------------------------------------------------------* diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 66819c4ac..3195a0b60 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -262,7 +262,11 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); +#else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); +#endif } pitch_buf[i_subfr / L_SUBFR] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index b7ceb81bc..28b3f2c02 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -240,8 +240,11 @@ void encod_gen_voic_fx( *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ - +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#else tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); +#endif /*-----------------------------------------------------------------* * Find adaptive exitation @@ -617,7 +620,11 @@ void encod_gen_voic_ivas_fx( L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ move16(); +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#endif /*-----------------------------------------------------------------* * Find adaptive exitation diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 5290ecd22..5bb344a4d 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -288,7 +288,11 @@ void encod_gen_2sbfr( Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13 +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); +#else tbe_celp_exc_ivas( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); +#endif /*-----------------------------------------------------------------* * Find adaptive exitation -- GitLab From 08a75c40b44830e8c4b1126c9979ccacb6f06e3a Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 22:06:37 +0100 Subject: [PATCH 246/750] harmonize encod_gen_voic_fx(), under CLEANUP_ACELP_ENC --- lib_enc/acelp_core_enc_fx.c | 18 ++++ lib_enc/enc_gen_voic_fx.c | 172 +++++++++++++++++++++++++----------- lib_enc/enc_pit_exc_fx.c | 14 +++ lib_enc/inov_enc_fx.c | 5 +- lib_enc/prot_fx_enc.h | 9 +- 5 files changed, 162 insertions(+), 56 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 716313065..324b7672f 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -528,8 +528,13 @@ ivas_error acelp_core_enc_fx( hTdCngEnc->burst_ho_cnt = 0; move16(); /* VOICED frames in SC-VBR when bumped up*/ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, + exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#else encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#endif } } ELSE IF( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_24k40 ) ) ) @@ -541,8 +546,13 @@ ivas_error acelp_core_enc_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, + exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#else encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#endif } /* update st->mem_syn1 for ACELP core switching */ @@ -1385,7 +1395,11 @@ ivas_error acelp_core_enc_ivas_fx( move16(); /* VOICED frames in SC-VBR */ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#else encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#endif } } ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) @@ -1400,7 +1414,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#else encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#endif } /* update mem_syn1_flt for ACELP core switching */ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 28b3f2c02..639fdaffa 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -77,7 +77,7 @@ static void rem_offset( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================*/ - +#ifndef CLEANUP_ACELP_ENC void encod_gen_voic_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ @@ -444,18 +444,22 @@ void encod_gen_voic_fx( return; } +#endif - +#ifdef CLEANUP_ACELP_ENC +void encod_gen_voic_fx( +#else void encod_gen_voic_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Qnew -1 */ + const Word16 speech_fx[], /* i : input speech Q0 / Qnew -1 */ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* i/o: core synthesis Q_new - 1*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/ + Word16 *syn_fx, /* i/o: core synthesis Qnew / Q_new - 1*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0 / Q_new*/ + Word16 *exc2_fx, /* i/o: current enhanced excitation Q0 / Q_new*/ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ @@ -558,7 +562,12 @@ void encod_gen_voic_ivas_fx( set16_fx( code_preQ_fx, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) +#else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) +#endif { shift_wsp = sub( shift_wsp, 1 ); } @@ -595,21 +604,36 @@ void encod_gen_voic_ivas_fx( Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/ - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - q_h1 = sub( 14, norm_s( h1_fx[0] ) ); - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn_fx, L_SUBFR, shift ); - test(); - test(); - IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) ) + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ + Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/ + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn_fx, L_SUBFR, shift ); + } + ELSE +#endif { - /* During core transition, when the temporal correlation is non existent */ - rem_offset( xn_fx, xn_fx, L_SUBFR ); - rem_offset( cn_fx, cn_fx, L_SUBFR ); + find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + + q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn_fx, L_SUBFR, shift ); + test(); + test(); + IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) ) + { + /* During core transition, when the temporal correlation is non existent */ + rem_offset( xn_fx, xn_fx, L_SUBFR ); + rem_offset( cn_fx, cn_fx, L_SUBFR ); + } } /*----------------------------------------------------------------* @@ -630,7 +654,16 @@ void encod_gen_voic_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure @@ -721,7 +754,14 @@ void encod_gen_voic_ivas_fx( gcode16 = round_fx_sat( Lgcode ); #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */ + IF( st_fx->element_mode == EVS_MONO ) + { + hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */ + } + ELSE + { + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */ + } #else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */ #endif @@ -747,30 +787,47 @@ void encod_gen_voic_ivas_fx( * Update memory of the weighting filter *-----------------------------------------------------------------*/ - /*At this point - xn has to be in Qnew - yn has to be in Qnew - y2_fx has to be in Q9 - gcode16 in Q_new - gain_pit_fx in Q14 - */ - Scale_sig( xn_fx, L_SUBFR, 1 ); - Scale_sig( y1_fx, L_SUBFR, 1 ); - /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ - Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); - Ltmp = L_shl( Ltmp, add( 5, shift ) ); - Ltmp = L_negate( Ltmp ); - Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 ); - Ltmp = L_add( Ltmp, Ltmp2 ); - Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx ); - Ltmp = L_sub( Ltmp, Ltmp3 ); - - /*Ltmp is in Q14 + Qnew here - We need memWo in Qnew -1 */ +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ + Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/ + Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ + Ltmp = L_negate( Ltmp ); + Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + } + ELSE +#endif + { + /*At this point + xn has to be in Qnew + yn has to be in Qnew + y2_fx has to be in Q9 + gcode16 in Q_new + gain_pit_fx in Q14 + */ + Scale_sig( xn_fx, L_SUBFR, 1 ); + Scale_sig( y1_fx, L_SUBFR, 1 ); + /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ + Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); + Ltmp = L_shl( Ltmp, add( 5, shift ) ); + Ltmp = L_negate( Ltmp ); + Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 ); + Ltmp = L_add( Ltmp, Ltmp2 ); + Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx ); + Ltmp = L_sub( Ltmp, Ltmp3 ); + + /*Ltmp is in Q14 + Qnew here + We need memWo in Qnew -1 */ + + Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1 + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + move16(); + } - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1 - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ - move16(); IF( gain_preQ_fx != 0 ) { tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); @@ -787,10 +844,10 @@ void encod_gen_voic_ivas_fx( move16(); /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ - Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Q10 / Qnew + 9 + 1 */ + Ltmp = L_shl( Ltmp, 5 ); /*Q15 / Qnew + 9+ 1+5 */ + Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Q15 / Qnew + 14 + 1*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /*Q15 / Qnew + 14 + 1 +1 */ exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); move16(); } @@ -806,10 +863,10 @@ void encod_gen_voic_ivas_fx( { /* code in Q9, gain_pit in Q14 */ /*gcode16 in Qnew*/ - Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ - Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Q10 / Qnew + 9 + 1 */ + Ltmp = L_shl_sat( Ltmp, 5 ); /*Q15 / Qnew + 9+ 1+5 */ + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Q15 / Qnew + 14 + 1*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /*Q15 / Qnew + 14 + 1 +1 */ exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); } } @@ -828,7 +885,16 @@ void encod_gen_voic_ivas_fx( * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); + } + ELSE +#endif + { + syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); + } p_Aw_fx += ( M + 1 ); p_Aq_fx += ( M + 1 ); diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index b40bab692..f98b21729 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -374,6 +374,14 @@ void enc_pit_exc_fx( } ELSE IF( use_fcb == 2 ) { +#ifdef CLEANUP_ACELP_ENC + /*-----------------------------------------------------------------* + * 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, Q_new ); +#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -400,6 +408,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 ); #endif } +#endif /*-----------------------------------------------------------------* * Gain encoding @@ -413,6 +422,10 @@ void enc_pit_exc_fx( * Innovation & gain encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + 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, Q_new ); +#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -435,6 +448,7 @@ void enc_pit_exc_fx( gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); #endif } +#endif /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 4a9ba19fc..c5de16ceb 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -370,7 +370,7 @@ Word16 inov_encode_ivas_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ const Word16 shift, - const Word16 Q_new ) + Word16 Q_new ) { Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2; Word16 nBits, cmpl_flag; @@ -422,6 +422,9 @@ Word16 inov_encode_ivas_fx( #ifdef CLEANUP_ACELP_ENC ELSE { + Q_new = 0; + move16(); + Qxn = 0; move16(); Qcn = 0; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index bfc2228b9..edfb199fa 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2071,6 +2071,7 @@ ivas_error encod_ppp_ivas_fx( Word16 Q_new, Word16 shift ); +#ifndef CLEANUP_ACELP_ENC void encod_gen_voic_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : i speech Q0*/ @@ -2089,8 +2090,12 @@ void encod_gen_voic_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 shift, Word16 Q_new ); - +#endif +#ifdef CLEANUP_ACELP_ENC +void encod_gen_voic_fx( +#else void encod_gen_voic_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -3564,7 +3569,7 @@ Word16 inov_encode_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ const Word16 shift, - const Word16 Q_new ); + Word16 Q_new ); void gain_enc_mless_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ -- GitLab From ff8fe0545a08c0f750f3a31d22343fb4f17816ab Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 10:36:52 +0100 Subject: [PATCH 247/750] harmonize encod_tran_fx(), under CLEANUP_ACELP_ENC --- lib_com/ivas_prot_fx.h | 12 ++--- lib_enc/acelp_core_enc_fx.c | 9 +++- lib_enc/enc_gen_voic_fx.c | 9 +++- lib_enc/enc_ppp_fx.c | 14 +++--- lib_enc/enc_tran_fx.c | 80 +++++++++++++++++++++++-------- lib_enc/enc_uv_fx.c | 5 +- lib_enc/gs_enc_fx.c | 9 ++-- lib_enc/ivas_td_low_rate_enc_fx.c | 39 +++++++-------- lib_enc/prot_fx_enc.h | 35 ++++++++------ 9 files changed, 136 insertions(+), 76 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 85bbcb4b1..6b46e6b8d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2996,7 +2996,7 @@ Word16 ivas_acelp_tcx20_switching_fx( const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */ ); -void encod_gen_2sbfr( +void encod_gen_2sbfr_fx( Encoder_State *st, /* i/o: state structure */ const Word16 speech[], /* i : input speech */ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */ @@ -3010,8 +3010,8 @@ void encod_gen_2sbfr( Word16 *bwe_exc, /* o : excitation for SWB TBE */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel */ - Word16 Q_new, - Word16 shift + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ ); void acelp_fast_fx( @@ -4489,7 +4489,7 @@ ivas_error signaling_enc_secondary_fx( const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag */ ); -void tdm_low_rate_enc( +void tdm_low_rate_enc_fx( Encoder_State *st, /* i/o: State structure */ const Word16 Aq[], /* i : 12k8 Lp coefficient */ const Word16 *res, /* i : residual signal Q_new*/ @@ -4500,8 +4500,8 @@ void tdm_low_rate_enc( Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ const Word16 attack_flag, /* i : attack flag */ const Word16 *lsf_new, /* i : current frame ISF vector x2.56 */ - Word16 *tmp_noise, /* o : long-term noise energy Q8 */ - Word16 Q_new + Word16 *tmp_noise, /* o : long-term noise energy Q8 */ + const Word16 Q_new /* i : Scaling factor */ ); void tdm_low_rate_dec_fx( diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 324b7672f..9fa47424f 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -499,8 +499,13 @@ ivas_error acelp_core_enc_fx( } ELSE IF( EQ_16( coder_type, TRANSITION ) ) { +#ifdef CLEANUP_ACELP_ENC + tc_subfr_fx = encod_tran_ivas_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, + exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ +#else tc_subfr_fx = encod_tran_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ +#endif } ELSE IF( hSC_VBR->ppp_mode ) { @@ -1344,11 +1349,11 @@ ivas_error acelp_core_enc_ivas_fx( { IF( LE_16( st->coder_type, UNVOICED ) ) { - tdm_low_rate_enc( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new ); + tdm_low_rate_enc_fx( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new ); } ELSE /* GENERIC */ { - encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); + encod_gen_2sbfr_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); } } ELSE IF( nelp_mode ) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 639fdaffa..e5e12159f 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -466,8 +466,9 @@ void encod_gen_voic_ivas_fx( Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, /* i : Shift needed to obtain 12 bits vectors */ + const Word16 Q_new /* i : Scaling factor */ +) { Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ Word16 xn2_fx[L_SUBFR]; /* Target vector for codebook search */ @@ -612,6 +613,7 @@ void encod_gen_voic_ivas_fx( Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/ + /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); } @@ -624,8 +626,10 @@ void encod_gen_voic_ivas_fx( q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); + test(); test(); IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) ) @@ -908,6 +912,7 @@ void encod_gen_voic_ivas_fx( push_indice( hBstr, IND_UNUSED, 0, i ); unbits_PI_fx -= i; } + IF( st_fx->Opt_SC_VBR ) { /* SC-VBR */ diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 70360f9d2..66ce8e4e1 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -1,17 +1,15 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ + #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -//#include "prot_fx.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ #include "rom_com.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -/*Temporary location to be move in prot* when merge is done */ -void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ); /*=======================================================================================*/ /* FUNCTION : encod_ppp_fx() */ @@ -51,6 +49,7 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ); /*---------------------------------------------------------------------------------------*/ /* CALLED FROM : TX */ /*=======================================================================================*/ + ivas_error encod_ppp_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q_new*/ @@ -63,8 +62,9 @@ ivas_error encod_ppp_fx( Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors, /* o : voicing factors Q15*/ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 9a371b5a0..0d0d7a2d2 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -43,7 +43,7 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*---------------------------------------------------------------------------------*/ - +#ifndef CLEANUP_ACELP_ENC Word16 encod_tran_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ @@ -422,9 +422,13 @@ Word16 encod_tran_fx( return tc_subfr; } +#endif - +#ifdef CLEANUP_ACELP_ENC Word16 encod_tran_ivas_fx( +#else +Word16 encod_tran_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -485,8 +489,9 @@ Word16 encod_tran_ivas_fx( L_frame_fx = st_fx->L_frame; move16(); +#ifndef CLEANUP_ACELP_ENC set16_fx( h1, 0, L_SUBFR + ( M + 1 ) ); - +#endif /*------------------------------------------------------------------* * Initializations *------------------------------------------------------------------*/ @@ -528,7 +533,12 @@ Word16 encod_tran_ivas_fx( move16(); set16_fx( code_preQ, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) +#else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) +#endif { shift_wsp = sub( shift_wsp, 1 ); } @@ -547,22 +557,38 @@ Word16 encod_tran_ivas_fx( Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); + Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ - q_h1 = sub( 14, norm_s( h1[0] ) ); - tmp = sub( 14, norm_arr( h1, L_SUBFR ) ); - shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */ - shift_wsp = add( Q_new, shift ); - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn, L_SUBFR, shift ); + } + ELSE +#endif { - shift_wsp = sub( shift_wsp, 1 ); + find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + + q_h1 = sub( 14, norm_s( h1[0] ) ); + tmp = sub( 14, norm_arr( h1, L_SUBFR ) ); + shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */ + shift_wsp = add( Q_new, shift ); + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } + Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); + + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn, L_SUBFR, shift ); } - Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn, L_SUBFR, shift ); /*-----------------------------------------------------------------* * TC: subframe determination & @@ -646,7 +672,14 @@ Word16 encod_tran_ivas_fx( gcode16 = round_fx_sat( Lgcode ); #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + IF( st_fx->element_mode == EVS_MONO ) + { + hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ + } + ELSE + { + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + } move16(); #else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 @@ -657,7 +690,16 @@ Word16 encod_tran_ivas_fx( *-----------------------------------------------------------------*/ /*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/ - L_tmp = L_mult0( gcode16, y2[L_SUBFR - 1] ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */ + } + ELSE +#endif + { + L_tmp = L_mult0( gcode16, y2[L_SUBFR - 1] ); + } L_tmp = L_shl( L_tmp, add( 5, shift ) ); // Q_new+14+shift L_tmp = L_negate( L_tmp ); L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 ); // Q_new-1+15+shift @@ -680,7 +722,7 @@ Word16 encod_tran_ivas_fx( { FOR( i = 0; i < L_SUBFR; i++ ) { - exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_exc */ + exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_new / Q_exc */ } } ELSE @@ -688,7 +730,7 @@ Word16 encod_tran_ivas_fx( Gain_pitX2 = shl( gain_pit, 1 ); FOR( i = 0; i < L_SUBFR; i++ ) { - exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_exc */ + exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_new / Q_exc */ } } diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 3b81f4f5d..de7f281f2 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -267,8 +267,9 @@ void encod_unvoiced_ivas_fx( Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ - const Word16 Q_new, - const Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ Word16 h1_fx[L_SUBFR]; /* Impulse response vector */ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 23a9a84fa..0498c0c33 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -14,7 +14,7 @@ * Local function prototypes *-------------------------------------------------------------------*/ -static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, Word16 Qnew ); +static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, const Word16 Qnew ); /*-------------------------------------------------------------------* @@ -39,8 +39,9 @@ void encod_audio_fx( Word16 *tmp_noise, /* o : noise energy Q2 */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0 */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6 */ - const Word16 Q_new, - const Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { const Word16 *p_Aq; Word16 i, i_subfr, nb_subfr, last_pit_bin; @@ -1527,7 +1528,7 @@ void gsc_enc_ivas_fx( static Word16 edyn_fx( const Word16 *vec, /* i : input vector Qnew*/ const Word16 lvec, /* i : length of input vector */ - Word16 Qnew ) + const Word16 Qnew ) { Word16 j = 0; Word16 dyn; diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 5bb344a4d..970e5001f 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -47,20 +47,20 @@ * Encode secondary channel of TD Stereo with a low-bitrate encoder *-------------------------------------------------------------------*/ -void tdm_low_rate_enc( - Encoder_State *st, /* i/o: State structure */ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *pitch_buf, - /* i/o: floating pitch values for each subframe */ // Q6 - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - const Word16 attack_flag, /* i : GSC attack flag Q0*/ - const Word16 *lsf_new, /* i : current frame ISF vector Qx2.56*/ - Word16 *tmp_noise, /* o : long-term noise energy Q11*/ - Word16 Q_new ) +void tdm_low_rate_enc_fx( + Encoder_State *st, /* i/o: State structure */ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + const Word16 attack_flag, /* i : GSC attack flag Q0*/ + const Word16 *lsf_new, /* i : current frame ISF vector Qx2.56*/ + Word16 *tmp_noise, /* o : long-term noise energy Q11*/ + const Word16 Q_new /* i : Scaling factor */ +) { const Word16 *p_Aq; Word16 i_subfr, nb_subfr, last_pit_bin; @@ -183,8 +183,8 @@ void tdm_low_rate_enc( * Encode GC, 2 subframes mode *-------------------------------------------------------------------*/ -void encod_gen_2sbfr( - Encoder_State *st, /* i/o: state structure */ +void encod_gen_2sbfr_fx( + Encoder_State *st, /* i/o: state structure */ const Word16 speech[], /* i : input speech Q_new-1 */ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes e(norm_s(Aw[0]+1)*/ const Word16 Aq[], /* i : LP coefficients e(norm_s(Aw[0]+1)*/ @@ -195,10 +195,11 @@ void encod_gen_2sbfr( Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ Word16 *voice_factors, /* o : voicing factors Q15 */ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel Q4 */ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { Word16 xn[2 * L_SUBFR]; /* Target vector for pitch search */ Word16 xn2[2 * L_SUBFR]; /* Target vector for codebook search */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index edfb199fa..dcfb5e4c0 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2007,9 +2007,11 @@ void encod_unvoiced_fx( Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ - const Word16 Q_new, - const Word16 shift ); + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +); + #ifndef CLEANUP_ACELP_ENC void encod_unvoiced_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -2047,14 +2049,15 @@ ivas_error encod_ppp_fx( const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/ Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *synth_fx, /* o : core synthesis Q-1*/ + Word16 *synth_fx, /* o : core synthesis Q-1*/ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ - Word16 Q_new, - Word16 shift ); + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +); ivas_error encod_ppp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -2109,14 +2112,15 @@ void encod_gen_voic_ivas_fx( Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 shift, - Word16 Q_new ); + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + const Word16 shift, /* i : Shift needed to obtain 12 bits vectors */ + const Word16 Q_new /* i : Scaling factor */ +); void encod_audio_fx( Encoder_State *st_fx, /* i/o: State structure */ - const Word16 speech[], /* i : i speech Q_new */ + const Word16 speech[], /* i : input speech Q_new */ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */ const Word16 Aq[], /* i : 12k8 Lp coefficient */ const Word16 *res, /* i : residual signal Q_new */ @@ -2124,14 +2128,15 @@ void encod_audio_fx( Word16 *exc, /* i/o: current non-enhanced excitation Q_new */ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ Word16 *voice_factors, /* o : voicing factors Q15 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC)*/ Word16 *lsf_new, /* i : current frame ISF vector */ Word16 *tmp_noise, /* o : noise energy */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ - const Word16 Q_new, - const Word16 shift ); + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +); #ifndef CLEANUP_ACELP_ENC void encod_audio_ivas_fx( -- GitLab From b29da4431722e29f0c45c75fd1a92afa07839f1e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 11:11:30 +0100 Subject: [PATCH 248/750] final editorial --- lib_com/est_tilt_fx.c | 2 +- lib_com/prot_fx.h | 16979 +++++++++++++-------------- lib_com/swb_tbe_com_fx.c | 2 +- lib_dec/acelp_core_switch_dec_fx.c | 4 - lib_dec/dec_ace_fx.c | 2 +- lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/dec_tran_fx.c | 14 +- lib_dec/gain_dec_fx.c | 6 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 +- lib_enc/acelp_core_enc_fx.c | 19 +- lib_enc/acelp_core_switch_enc_fx.c | 3 +- lib_enc/cod_ace_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 13 +- lib_enc/enc_pit_exc_fx.c | 20 - lib_enc/enc_tran_fx.c | 18 +- lib_enc/inov_enc_fx.c | 4 +- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 9 +- lib_enc/transition_enc_fx.c | 17 +- 19 files changed, 8532 insertions(+), 8588 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 71a82089a..9d92d5d77 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -122,7 +122,7 @@ Word16 est_tilt_ivas_fx( #endif const Word16 *exc, /* i : adaptive excitation vector Qx */ const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f78f12025..8f3f5eca5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2910,7 +2910,9 @@ Word16 tbe_celp_exc_offset( const Word16 L_frame /* i : frame lenght */ ); -#ifndef CLEANUP_ACELP_ENC +#ifdef CLEANUP_ACELP_ENC +void tbe_celp_exc_fx( +#else void tbe_celp_exc( const Word16 L_frame_fx, /* i : Frame lenght */ const Word16 i_subfr_fx, /* i : sub frame */ @@ -2919,10 +2921,6 @@ void tbe_celp_exc( Word16 *error_fx, /* i/o: Error */ Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */ ); -#endif -#ifdef CLEANUP_ACELP_ENC -void tbe_celp_exc( -#else void tbe_celp_exc_ivas( #endif const Word16 element_mode, /* i : element mode */ @@ -2937,2195 +2935,2163 @@ void tbe_celp_exc_ivas( const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ ); - void flip_and_downmix_generic_fx( - Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ - ); - - void Calc_rc0_h( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ - ); - - void Calc_rc0_h_ivas_enc_fx( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ - ); - - void PostShortTerm_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ - ); - - void PostShortTerm_ivas_enc_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ - ); - - void PostShortTerm_ivas_dec_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ - ); - - void flip_spectrum_and_decimby4_fx( - const Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : vector length */ - Word16 mem1[], /* i/o : memory */ - Word16 mem2[], /* i/o : memory */ - const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ - ); - - void GenShapedWBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb exctiation */ - const Word16 *lpc_shb, /* i : lpc coefficients */ - Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ - Word32 *mem_csfilt, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ - Word16 *state_lpc_syn, /* i/o : memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_bwe_exc, - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor */ - const Word16 signal_type, - const Word16 igf_flag ); - - void GenWBSynth_fx( - const Word16 *input_synspeech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_16k, /* o : output highband compnent */ - Word16 *state_lsyn_filt_shb1, /* i/o: memory */ - Word16 *state_lsyn_filt_shb2 /* i/o: memory */ - ); - - void GenShapedSHBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi ); - - void GenShapedSHBExcitation_ivas_enc_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word16 Q_EnvSHBres_4k, - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ - ); - - void GenShapedSHBExcitation_ivas_dec_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ - ); - - void GenSHBSynth_fx( - const Word16 *shb_target_speech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP Frame length */ - Word16 *syn_dm_phase ); - - void GenSHBSynth_fx32( - const Word32 *input_synspeech, /* i : input synthesized speech */ - Word32 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP frame length */ - Word16 *syn_dm_phase ); - - void ScaleShapedSHB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o: synthesized shb signal */ - Word16 *overlap, /* i/o: buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - Word16 *Q_bwe_exc, - Word16 *Qx, - Word16 n_mem3, - Word16 prev_Q_bwe_syn2 ); - - void ScaleShapedSHB_fx32( - const Word16 length, /* i : SHB overlap length */ - Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ - Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ - const Word16 *subgain_fx, /* i : subframe gain Q15 */ - const Word32 frame_gain_fx, /* i : frame gain */ - const Word16 *win_fx, /* i : window Q15 */ - const Word16 *subwin_fx, /* i : subframes window Q15 */ - Word16 *Q_inp, - Word16 *Q_new ); - - void ScaleShapedWB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o : synthesized shb signal */ - Word16 *overlap, /* i/o : buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - const Word16 Q_bwe_exc, - Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ - Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ - Word16 *Qx, /* o : newly computed Q factor for synSHB */ - Word16 prev_Qx, /* i : prev_Qx for memory scaling */ - Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ - ); - - void non_linearity_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ - ); - - void non_linearity_ivas_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ - ); - - void interp_code_5over2_fx( - const Word16 inp_code[], /* i : i vector */ - Word16 interp_code[], /* o : output vector */ - const Word16 inp_length /* i : length of i vector */ - ); - - void interp_code_4over2_fx( - const Word16 inp_code_fx[], /* i : i vector Qx */ - Word16 interp_code_fx[], /* o : output vector Qx */ - const Word16 inp_length /* i : length of i vector */ - ); - - void wb_tbe_extras_reset_synth_fx( - Word16 state_lsyn_filt_shb[], - Word16 state_lsyn_filt_dwn_shb[], - Word16 state_32and48k_WB_upsample[], - Word16 state_resamp_HB[] ); - - void elliptic_bpf_48k_generic_fx( - const Word16 element_mode, - Word16 IsUpsampled3, - Word16 input_fx[], /* i : input signal Q_input_fx*/ - Word16 *Q_input_fx, - Word16 output_fx[], /* o : output signal */ - Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ - Word16 memory_fx_Q[], - const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ - ); - - void synthesise_fb_high_band_fx( - const Word16 excitation_in[], /* i : full band excitation */ - Word16 Q_fb_exc, - Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ - const Word32 fb_exc_energy, /* i : full band excitation energy */ - const Word16 ratio, /* i : energy ratio */ - const Word16 L_frame, /* i : ACELP frame length */ - const Word16 bfi, /* i : fec flag */ - Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ - Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ - Word16 bpf_memory_Q[], - Word16 Qout, - Word16 element_mode ); - - void prep_tbe_exc_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - const Word16 T0, /* i : integer pitch variables Q0 */ - const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ - ); - - /*! r: Formant filter strength [0,1] */ - Word16 swb_formant_fac_fx( - const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ - Word16 *tilt_mem /* i/o: Tilt smoothing memory */ - ); - - void wb_tbe_extras_reset_fx( - Word16 mem_genSHBexc_filt_down_wb2[], - Word16 mem_genSHBexc_filt_down_wb3[] ); - - Word16 get_tbe_bits_fx( - const Word32 total_brate, /* o : TBE bit consumption per frame */ - const Word16 bwidth, /* i : overall bitrate */ - const Word16 rf_mode /* i : bandwidht mode */ - ); - - UWord32 intLimCDivPos_fx( - UWord32 NUM, /* Qx */ - Word16 DEN /* Q0 */ - ); - - Word16 shrtCDivSignedApprox( - const Word16 num, /* Q0 */ - const Word16 den /* Q0 */ - ); - - void obtainEnergyQuantizerDensity_fx( - const Word16 L, /* i : left vector energy Q0*/ - const Word16 R, /* i : right vector energy Q0*/ - Word16 *Density /* o : quantizer density Q0*/ - ); - - void dsDirac2Dirac_fx( - const Word16 dsDiracIndex, /* Q0 */ - Word16 *diracs /* Q0 */ - ); - - void dsDiracPerQuanta_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ - const Word16 dsm, /* i : Conservative rounding flag Q0*/ - const unsigned char *const *frQuanta, /* i : Quanta lookup table */ - Word16 *DsIdx /* o : Lookup table index Q0*/ - ); - - void QuantaPerDsDirac_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ - const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ - Word16 *Quanta /* i : Quanta Q0*/ - ); - - void conservativeL1Norm_fx( - const Word16 L, /* i : Length of vector segment Q0*/ - const Word16 Qvec, /* i : Assigned number of quanta Q0*/ - const Word16 Fcons, /* i : Conservative rounding flag Q0*/ - const Word16 Qavail, /* i : Input quanta remaining Q0*/ - const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ - const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ - Word16 *Dvec, /* o : actual number of diracs Q0*/ - Word16 *Qspare, /* o : Output quanta remaining Q0*/ - Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ - Word16 *Dspecplus /* o : Output number of diracs Q0*/ - ); - - void bandBitsAdjustment_fx( - const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ - const UWord32 INTrc, /* i : Range coder state Q0*/ - const Word16 Bavail, /* i : Available number of quanta Q3*/ - const Word16 Nbands, /* i : Number of bands Q0*/ - const Word16 D, /* i : Remaining number of bands to encode Q0*/ - const Word16 L, /* i : Size of current band Q0*/ - const Word16 Bband, /* i : Quanta allocation for current band Q0*/ - const Word16 Breserv, /* i : Quanta reservoir Q0*/ - Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ - Word16 *Brem, /* o : Quanta remaining Q0*/ - Word16 *Breservplus /* o : Quanta pool size Q0*/ - ); - - void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density Q0*/ - const Word16 indexphi, /* i : decoded index from AR dec Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ - ); - - void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density Q0*/ - const Word16 phiQ14uq, /* i : angle Q14*/ - Word16 *indexphi, /* o : index Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ - ); - - void NearOppSplitAdjustment_fx( - const Word16 qband, /* i : quanta for current band Q0*/ - const Word16 qzero, /* i : range coder finalization quanta Q0*/ - const Word16 Qac, /* i : range coder current quanta Q0*/ - const UWord32 INTac, /* i : range coder state Q0*/ - const Word16 qglobal, /* i : quanta input Q0*/ - const Word16 FlagCons, /* i : conservative rounding flag Q0*/ - const Word16 Np, /* i : number of parts Q0*/ - const Word16 Nhead, /* i : first part Q0*/ - const Word16 Ntail, /* i : remaining parts Q0*/ - const Word16 Nnear, /* i : length of near component Q0*/ - const Word16 Nopp, /* i : length of opposite component Q0*/ - Word16 oppRQ3, /* i : ratio Q0*/ - Word16 *qnear, /* o : quantized near Q0*/ - Word16 *qopp, /* o : quantized opposite Q0*/ - Word16 *qglobalupd /* o : quanta remaining Q0*/ - ); - - void apply_gain_fx( - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 *band_start, /* i : Sub band start indices Q0 */ - const Word16 *band_end, /* i : Sub band end indices Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gains, /* i : Band gain vector Q12 */ - Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ - ); - - void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ - ); - - void srt_vec_ind16_fx( - const Word16 *linear, /* linear input Q3*/ - Word16 *srt, /* sorted output Q3*/ - Word16 *I, /* index for sorted output Q0*/ - Word16 length /* Q0 */ - ); - - /* o: Angle between 0 and PI/2 radian (Q14) */ - Word16 atan2_fx( - const Word32 y, /* i : near side (Argument must be positive) (Q15) */ - const Word32 x /* i : opposite side (Q15) */ - ); - - /* o: Number of bits needed Q0*/ - Word16 rc_get_bits2_fx( - const Word16 N, /* i: Number of bits currently used Q0*/ - const UWord32 range /* i: Range of range coder Q0*/ - ); - - void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits Q0*/ - UWord32 INTrc, /* i : Range coder state Q0*/ - Word16 *FBits /* i : Fractional finalization bits Q0*/ - ); - - ivas_error DTFS_new_fx( - DTFS_STRUCTURE **dtfs_out ); - - void DTFS_copy_fx( - DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ - DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ - ); - - void DTFS_sub_fx( - DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ - DTFS_STRUCTURE X1, /* i: DTFS i 1 */ - DTFS_STRUCTURE X2 /* i: DTFS i 2 */ - ); - - Word16 DTFS_alignment_full_fx( - DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ - DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ - Word16 ph_offset_fx, /* i : resolution */ - Word16 *S_fx, - Word16 *C_fx, - Word16 FR_flag ); - - void DTFS_phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - - void Q2phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - - void DTFS_zeroPadd_fx( - Word16 N_fx, - DTFS_STRUCTURE *X_fx ); - - void DTFS_to_fs_fx( - const Word16 *x, /* i : time domain signal */ - Word16 N, /* i : Length of i vector */ - DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ - const Word16 Fs, /* i : sampling rate */ - const Word16 FR_flag, /* i : FR flag */ - Word16 *S_fx, - Word16 *C_fx ); - - void DTFS_zeroFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - - void DTFS_poleFilter_fx_9( - DTFS_STRUCTURE *X_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - - void DTFS_adjustLag_fx( - DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ - Word16 N_fx /* i : Target lag */ - ); - - Word32 DTFS_getEngy_fx( - DTFS_STRUCTURE *X_fx ); - - Word32 DTFS_getEngy_P2A_fx( - DTFS_STRUCTURE *X_fx ); - - void DTFS_car2pol_fx( - DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ - ); - - Word32 DTFS_setEngyHarm_fx( - Word16 f1_fx, /* i : lower band freq of i to control energy */ - Word16 f2_fx, /* i : upper band freq of i to control energy */ - Word16 g1_fx, /* i : lower band freq of output to control energy */ - Word16 g2_fx, /* i : upper band freq of output to control energy */ - Word32 en2_fx, /* i : Target Energy to set the DTFS to */ - Word16 Qen2_fx, /* i : Input Q format for en2 */ - Word16 *Qa_fx, /* i : Output Q format for x->a */ - DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ - ); - - void DTFS_to_erb_fx( - const DTFS_STRUCTURE X_fx, /* i : DTFS i */ - Word16 *out_fx /* o : ERB output */ - ); - - void erb_slot_fx( - Word16 lag_fx, /* i : i lag */ - Word16 *out_fx, /* o : ERB slots */ - Word16 *mfreq_fx, /* i : ERB frequencies */ - Word16 num_erb_fx /* i : number of ERBs */ - ); - - void DTFS_erb_inv_fx( - Word16 *in_fx, /* i : ERB inpt */ - Word16 *slot_fx, /* i : ERB slots filled based on lag */ - Word16 *mfreq_fx, /* i : erb frequence edges */ - DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ - Word16 num_erb_fx /* i : Number of ERB bands */ - ); - - void erb_add_fx( - Word16 *curr_erb_fx, /* i/o: current ERB */ - Word16 l_fx, /* i : current lag */ - const Word16 *prev_erb_fx, /* i : previous ERB */ - Word16 pl_fx, /* i : previous lag */ - const Word16 *index_fx, /* i : ERB index */ - Word16 num_erb_fx /* i : number of ERBs */ - ); - - void quant_target_fx( - DTFS_STRUCTURE *X_fx, - const Word16 *curr_lpc, - Word16 *w, - Word16 *target, - Word16 *sin_tab, - Word16 *cos_tab ); - - ivas_error WIsyn_fx( - DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ - DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ - const Word16 *curr_lpc_fx, /* i : LPC */ - Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ - Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ - const Word16 N, /* i : Number of output samples to generate */ - const Word16 FR_flag, /* i : called for post-smoothing in FR */ - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2 ); - - Word16 ppp_extract_pitch_period_fx( - const Word16 *in, /* i : i residual */ - Word16 *out, /* o : output residual */ - Word16 l, /* i : lag */ - Word16 *out_of_bound, /* o : out of bound flag */ - Word16 Qres ); - - void DTFS_peaktoaverage_fx( - DTFS_STRUCTURE X_fx, /* i : DTFS */ - Word32 *pos_fx, /* o : positive peak to ave */ - Word16 *Qpos, /* o : positive peak to ave Q format */ - Word32 *neg_fx, /* o : negative peak to ave */ - Word16 *Qneg /* o : negative peak to ave Q format */ - ); - - void rshiftHarmBand_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband_fx, - Word16 hband_fx, - Word16 shift_fx ); - - void GetSinCosTab_fx( - Word16 L, - Word16 *sinTab, - Word16 *cosTab ); - - void r_fft_4_fx( - Word16 *farray_ptr_fx, - Word16 size, - Word16 stage, - Word16 isign ); - - void copy_phase_fx( - DTFS_STRUCTURE *X1_fx, - DTFS_STRUCTURE X2_fx, - DTFS_STRUCTURE *retX_fx ); - - Word32 getSpEngyFromResAmp_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband, - Word16 hband, - const Word16 *curr_lpc, - Word16 *sin_tab, - Word16 *cos_tab ); - - void DTFS_poleFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - - void poleFilter_setup_fx( - const Word16 *LPC, - Word16 N, - DTFS_STRUCTURE X_fx, - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - - Word32 DTFS_getEngy_band_wb_fx( - DTFS_STRUCTURE X_fx, - Word16 lband, - Word16 hband ); - - void InitTnsConfiguration( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void InitTnsConfiguration_ivas_fx( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void ApplyTnsFilter( - STnsConfig const *pTnsConfig, - STnsData const *pTnsData, - Word32 spectrum[], - const Word8 fIsAnalysis ); - - Word16 ITF_Detect_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); - - Word16 ITF_Detect_ivas_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); +void flip_and_downmix_generic_fx( + Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ +); + +void Calc_rc0_h( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ +); + +void Calc_rc0_h_ivas_enc_fx( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ +); + +void PostShortTerm_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ +); + +void PostShortTerm_ivas_enc_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ +); + +void PostShortTerm_ivas_dec_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ +); + +void flip_spectrum_and_decimby4_fx( + const Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : vector length */ + Word16 mem1[], /* i/o : memory */ + Word16 mem2[], /* i/o : memory */ + const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ +); + +void GenShapedWBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb exctiation */ + const Word16 *lpc_shb, /* i : lpc coefficients */ + Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ + Word32 *mem_csfilt, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ + Word16 *state_lpc_syn, /* i/o : memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_bwe_exc, + Word16 bwe_seed[], /* i/o : random number generator seed */ + const Word16 voice_factors[], /* i : voicing factor */ + const Word16 signal_type, + const Word16 igf_flag ); + +void GenWBSynth_fx( + const Word16 *input_synspeech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_16k, /* o : output highband compnent */ + Word16 *state_lsyn_filt_shb1, /* i/o: memory */ + Word16 *state_lsyn_filt_shb2 /* i/o: memory */ +); + +void GenShapedSHBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi ); + +void GenShapedSHBExcitation_ivas_enc_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 Q_EnvSHBres_4k, + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ +); + +void GenShapedSHBExcitation_ivas_dec_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, /* i : previous frame was concealed */ + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ +); + +void GenSHBSynth_fx( + const Word16 *shb_target_speech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP Frame length */ + Word16 *syn_dm_phase ); + +void GenSHBSynth_fx32( + const Word32 *input_synspeech, /* i : input synthesized speech */ + Word32 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP frame length */ + Word16 *syn_dm_phase ); + +void ScaleShapedSHB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o: synthesized shb signal */ + Word16 *overlap, /* i/o: buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + Word16 *Q_bwe_exc, + Word16 *Qx, + Word16 n_mem3, + Word16 prev_Q_bwe_syn2 ); + +void ScaleShapedSHB_fx32( + const Word16 length, /* i : SHB overlap length */ + Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ + Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ + const Word16 *subgain_fx, /* i : subframe gain Q15 */ + const Word32 frame_gain_fx, /* i : frame gain */ + const Word16 *win_fx, /* i : window Q15 */ + const Word16 *subwin_fx, /* i : subframes window Q15 */ + Word16 *Q_inp, + Word16 *Q_new ); + +void ScaleShapedWB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o : synthesized shb signal */ + Word16 *overlap, /* i/o : buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + const Word16 Q_bwe_exc, + Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ + Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ + Word16 *Qx, /* o : newly computed Q factor for synSHB */ + Word16 prev_Qx, /* i : prev_Qx for memory scaling */ + Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ +); + +void non_linearity_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ +); + +void non_linearity_ivas_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ +); + +void interp_code_5over2_fx( + const Word16 inp_code[], /* i : i vector */ + Word16 interp_code[], /* o : output vector */ + const Word16 inp_length /* i : length of i vector */ +); + +void interp_code_4over2_fx( + const Word16 inp_code_fx[], /* i : i vector Qx */ + Word16 interp_code_fx[], /* o : output vector Qx */ + const Word16 inp_length /* i : length of i vector */ +); + +void wb_tbe_extras_reset_synth_fx( + Word16 state_lsyn_filt_shb[], + Word16 state_lsyn_filt_dwn_shb[], + Word16 state_32and48k_WB_upsample[], + Word16 state_resamp_HB[] ); + +void elliptic_bpf_48k_generic_fx( + const Word16 element_mode, + Word16 IsUpsampled3, + Word16 input_fx[], /* i : input signal Q_input_fx*/ + Word16 *Q_input_fx, + Word16 output_fx[], /* o : output signal */ + Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ + Word16 memory_fx_Q[], + const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ +); + +void synthesise_fb_high_band_fx( + const Word16 excitation_in[], /* i : full band excitation */ + Word16 Q_fb_exc, + Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ + const Word32 fb_exc_energy, /* i : full band excitation energy */ + const Word16 ratio, /* i : energy ratio */ + const Word16 L_frame, /* i : ACELP frame length */ + const Word16 bfi, /* i : fec flag */ + Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ + Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ + Word16 bpf_memory_Q[], + Word16 Qout, + Word16 element_mode ); + +void prep_tbe_exc_fx( + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 i_subfr_fx, /* i : subframe index */ + const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ + const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 voice_fac_fx, /* i : voicing factor Q15*/ + Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ + Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ + const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ + const Word16 code_preQ_fx[], /* i : prequantizer excitation */ + const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ + const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ + const Word16 T0, /* i : integer pitch variables Q0 */ + const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ + const Word16 coder_type, /* i : coding type */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ + const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ + const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ +); + +/*! r: Formant filter strength [0,1] */ +Word16 swb_formant_fac_fx( + const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ + Word16 *tilt_mem /* i/o: Tilt smoothing memory */ +); + +void wb_tbe_extras_reset_fx( + Word16 mem_genSHBexc_filt_down_wb2[], + Word16 mem_genSHBexc_filt_down_wb3[] ); + +Word16 get_tbe_bits_fx( + const Word32 total_brate, /* o : TBE bit consumption per frame */ + const Word16 bwidth, /* i : overall bitrate */ + const Word16 rf_mode /* i : bandwidht mode */ +); + +UWord32 intLimCDivPos_fx( + UWord32 NUM, /* Qx */ + Word16 DEN /* Q0 */ +); + +Word16 shrtCDivSignedApprox( + const Word16 num, /* Q0 */ + const Word16 den /* Q0 */ +); + +void obtainEnergyQuantizerDensity_fx( + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ +); + +void dsDirac2Dirac_fx( + const Word16 dsDiracIndex, /* Q0 */ + Word16 *diracs /* Q0 */ +); + +void dsDiracPerQuanta_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ +); + +void QuantaPerDsDirac_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ + const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ + Word16 *Quanta /* i : Quanta Q0*/ +); + +void conservativeL1Norm_fx( + const Word16 L, /* i : Length of vector segment Q0*/ + const Word16 Qvec, /* i : Assigned number of quanta Q0*/ + const Word16 Fcons, /* i : Conservative rounding flag Q0*/ + const Word16 Qavail, /* i : Input quanta remaining Q0*/ + const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ + const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ + Word16 *Dvec, /* o : actual number of diracs Q0*/ + Word16 *Qspare, /* o : Output quanta remaining Q0*/ + Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ + Word16 *Dspecplus /* o : Output number of diracs Q0*/ +); + +void bandBitsAdjustment_fx( + const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ + const UWord32 INTrc, /* i : Range coder state Q0*/ + const Word16 Bavail, /* i : Available number of quanta Q3*/ + const Word16 Nbands, /* i : Number of bands Q0*/ + const Word16 D, /* i : Remaining number of bands to encode Q0*/ + const Word16 L, /* i : Size of current band Q0*/ + const Word16 Bband, /* i : Quanta allocation for current band Q0*/ + const Word16 Breserv, /* i : Quanta reservoir Q0*/ + Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ + Word16 *Brem, /* o : Quanta remaining Q0*/ + Word16 *Breservplus /* o : Quanta pool size Q0*/ +); + +void densityAngle2RmsProjDec_fx( + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ +); + +void densityAngle2RmsProjEnc_fx( + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ +); + +void NearOppSplitAdjustment_fx( + const Word16 qband, /* i : quanta for current band Q0*/ + const Word16 qzero, /* i : range coder finalization quanta Q0*/ + const Word16 Qac, /* i : range coder current quanta Q0*/ + const UWord32 INTac, /* i : range coder state Q0*/ + const Word16 qglobal, /* i : quanta input Q0*/ + const Word16 FlagCons, /* i : conservative rounding flag Q0*/ + const Word16 Np, /* i : number of parts Q0*/ + const Word16 Nhead, /* i : first part Q0*/ + const Word16 Ntail, /* i : remaining parts Q0*/ + const Word16 Nnear, /* i : length of near component Q0*/ + const Word16 Nopp, /* i : length of opposite component Q0*/ + Word16 oppRQ3, /* i : ratio Q0*/ + Word16 *qnear, /* o : quantized near Q0*/ + Word16 *qopp, /* o : quantized opposite Q0*/ + Word16 *qglobalupd /* o : quanta remaining Q0*/ +); + +void apply_gain_fx( + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 *band_start, /* i : Sub band start indices Q0 */ + const Word16 *band_end, /* i : Sub band end indices Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gains, /* i : Band gain vector Q12 */ + Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ +); + +void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ +); + +void srt_vec_ind16_fx( + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ + Word16 length /* Q0 */ +); + +/* o: Angle between 0 and PI/2 radian (Q14) */ +Word16 atan2_fx( + const Word32 y, /* i : near side (Argument must be positive) (Q15) */ + const Word32 x /* i : opposite side (Q15) */ +); + +/* o: Number of bits needed Q0*/ +Word16 rc_get_bits2_fx( + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ +); + +void rangeCoderFinalizationFBits_fx( + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ +); + +ivas_error DTFS_new_fx( + DTFS_STRUCTURE **dtfs_out ); + +void DTFS_copy_fx( + DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ + DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ +); + +void DTFS_sub_fx( + DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ + DTFS_STRUCTURE X1, /* i: DTFS i 1 */ + DTFS_STRUCTURE X2 /* i: DTFS i 2 */ +); + +Word16 DTFS_alignment_full_fx( + DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ + DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ + Word16 ph_offset_fx, /* i : resolution */ + Word16 *S_fx, + Word16 *C_fx, + Word16 FR_flag ); + +void DTFS_phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + +void Q2phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + +void DTFS_zeroPadd_fx( + Word16 N_fx, + DTFS_STRUCTURE *X_fx ); + +void DTFS_to_fs_fx( + const Word16 *x, /* i : time domain signal */ + Word16 N, /* i : Length of i vector */ + DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ + const Word16 Fs, /* i : sampling rate */ + const Word16 FR_flag, /* i : FR flag */ + Word16 *S_fx, + Word16 *C_fx ); + +void DTFS_zeroFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + +void DTFS_poleFilter_fx_9( + DTFS_STRUCTURE *X_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + +void DTFS_adjustLag_fx( + DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ + Word16 N_fx /* i : Target lag */ +); + +Word32 DTFS_getEngy_fx( + DTFS_STRUCTURE *X_fx ); + +Word32 DTFS_getEngy_P2A_fx( + DTFS_STRUCTURE *X_fx ); + +void DTFS_car2pol_fx( + DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ +); + +Word32 DTFS_setEngyHarm_fx( + Word16 f1_fx, /* i : lower band freq of i to control energy */ + Word16 f2_fx, /* i : upper band freq of i to control energy */ + Word16 g1_fx, /* i : lower band freq of output to control energy */ + Word16 g2_fx, /* i : upper band freq of output to control energy */ + Word32 en2_fx, /* i : Target Energy to set the DTFS to */ + Word16 Qen2_fx, /* i : Input Q format for en2 */ + Word16 *Qa_fx, /* i : Output Q format for x->a */ + DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ +); + +void DTFS_to_erb_fx( + const DTFS_STRUCTURE X_fx, /* i : DTFS i */ + Word16 *out_fx /* o : ERB output */ +); + +void erb_slot_fx( + Word16 lag_fx, /* i : i lag */ + Word16 *out_fx, /* o : ERB slots */ + Word16 *mfreq_fx, /* i : ERB frequencies */ + Word16 num_erb_fx /* i : number of ERBs */ +); + +void DTFS_erb_inv_fx( + Word16 *in_fx, /* i : ERB inpt */ + Word16 *slot_fx, /* i : ERB slots filled based on lag */ + Word16 *mfreq_fx, /* i : erb frequence edges */ + DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ + Word16 num_erb_fx /* i : Number of ERB bands */ +); + +void erb_add_fx( + Word16 *curr_erb_fx, /* i/o: current ERB */ + Word16 l_fx, /* i : current lag */ + const Word16 *prev_erb_fx, /* i : previous ERB */ + Word16 pl_fx, /* i : previous lag */ + const Word16 *index_fx, /* i : ERB index */ + Word16 num_erb_fx /* i : number of ERBs */ +); + +void quant_target_fx( + DTFS_STRUCTURE *X_fx, + const Word16 *curr_lpc, + Word16 *w, + Word16 *target, + Word16 *sin_tab, + Word16 *cos_tab ); + +ivas_error WIsyn_fx( + DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ + DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ + const Word16 *curr_lpc_fx, /* i : LPC */ + Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ + Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ + const Word16 N, /* i : Number of output samples to generate */ + const Word16 FR_flag, /* i : called for post-smoothing in FR */ + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2 ); + +Word16 ppp_extract_pitch_period_fx( + const Word16 *in, /* i : i residual */ + Word16 *out, /* o : output residual */ + Word16 l, /* i : lag */ + Word16 *out_of_bound, /* o : out of bound flag */ + Word16 Qres ); + +void DTFS_peaktoaverage_fx( + DTFS_STRUCTURE X_fx, /* i : DTFS */ + Word32 *pos_fx, /* o : positive peak to ave */ + Word16 *Qpos, /* o : positive peak to ave Q format */ + Word32 *neg_fx, /* o : negative peak to ave */ + Word16 *Qneg /* o : negative peak to ave Q format */ +); + +void rshiftHarmBand_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband_fx, + Word16 hband_fx, + Word16 shift_fx ); + +void GetSinCosTab_fx( + Word16 L, + Word16 *sinTab, + Word16 *cosTab ); + +void r_fft_4_fx( + Word16 *farray_ptr_fx, + Word16 size, + Word16 stage, + Word16 isign ); + +void copy_phase_fx( + DTFS_STRUCTURE *X1_fx, + DTFS_STRUCTURE X2_fx, + DTFS_STRUCTURE *retX_fx ); + +Word32 getSpEngyFromResAmp_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband, + Word16 hband, + const Word16 *curr_lpc, + Word16 *sin_tab, + Word16 *cos_tab ); + +void DTFS_poleFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + +void poleFilter_setup_fx( + const Word16 *LPC, + Word16 N, + DTFS_STRUCTURE X_fx, + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + +Word32 DTFS_getEngy_band_wb_fx( + DTFS_STRUCTURE X_fx, + Word16 lband, + Word16 hband ); + +void InitTnsConfiguration( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void InitTnsConfiguration_ivas_fx( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void ApplyTnsFilter( + STnsConfig const *pTnsConfig, + STnsData const *pTnsData, + Word32 spectrum[], + const Word8 fIsAnalysis ); + +Word16 ITF_Detect_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); + +Word16 ITF_Detect_ivas_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); + +void ITF_Apply_fx( + Word32 spectrum[], + Word16 startLine, + Word16 stopLine, + const Word16 *A, + Word16 Q_A, + Word16 curr_order ); + +void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); + +Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + +Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + +Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); + +Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); + +Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + +Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + +Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + +void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); + +Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); + +Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); + +Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); + +Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); + +Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); + +Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); + +Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); + +void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); + +void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); + +void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); + +void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); + +void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); +void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); + +void ResetTnsData( STnsData *pTnsData ); + +void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); + +/*========================================================================================================/ +gp_clips_fx.c +/========================================================================================================*/ + +void init_gp_clip_fx( + Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ +); + +Word16 gp_clip_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 coder_type, /* i : type of coder Q0*/ + const Word16 xn[], /* i : target vector Q_new*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Q_new /* i : scaling factor */ +); + +void gp_clip_test_isf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ +); + +void gp_clip_test_gain_pit_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ + Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ +); + +Word16 Mode2_gp_clip_fx( + const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 coder_type, /* i : type of coder Q0 */ + const Word16 xn[], /* i : target vector Q_xn */ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ + /* mem[0]: Q0 */ + /* mem[1]: 1Q14 */ + /* mem[2]: 8Q7 */ + /* mem[3]: Q0 (integer) */ + /* mem[4]: Q14 */ + /* mem[5]: Q14 */ + const Word16 L_subfr, /* Q0 */ + const Word16 Q_xn /* i : scaling factor of vector xn[] */ +); + +void gp_clip_test_lsf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 m /* i : dimension of lsf Q0*/ +); + +void gp_clip_test_lsf_ivas_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ +); + +/*========================================================================================================/ +nelp_enc_fx.c +/========================================================================================================*/ + +void quantize_uvg_fx( + Word16 *G, + Word16 *iG1, + Word16 *iG2, + Word16 *quantG, + Word16 bandwidth ); + +void nelp_encoder_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + +void nelp_encoder_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + +void swb_bwe_enc_lr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ +); + +void swb_bwe_enc_lr_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ +); + +void isf_enc_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + Word16 *isf_new, /* i/o: quantized ISF vector */ + Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ + Word16 *Aq /* o : quantized A(z) for 4 subframes */ +); + +Word16 detect_transient_fx( + const Word16 *in_fx, /*Q_new */ + const Word16 L, /*Q0*/ + Word16 Q_new, + Encoder_State *st_fx ); + +Word16 tcxGetNoiseFillingTilt( + const Word16 A[], + const Word16 lpcorder, + const Word16 L_frame, + const Word16 mode, + Word16 *noiseTiltFactor ); + +void tcxFormantEnhancement( + Word16 xn_buf[], + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + +void tcxFormantEnhancement_with_shift( + Word16 xn_buf[], + Word16 *xn_buf_e, + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + +void tcxInvertWindowGrouping( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word32 xn_buf[], + Word32 spectrum[], + const Word16 L_frame, + const Word8 fUseTns, + const Word16 last_core, + const Word16 index, + const Word16 frame_cnt, + const Word16 bfi ); + +void permute_fx( + Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ + const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ +); + +void init_lvq_fx( + Word32 offset_scale1[][MAX_NO_SCALES + 1], + Word32 offset_scale2[][MAX_NO_SCALES + 1], + Word32 offset_scale1_p[][MAX_NO_SCALES + 1], + Word32 offset_scale2_p[][MAX_NO_SCALES + 1], + Word16 no_scales[][2], + Word16 no_scales_p[][2] ); + +Word16 deindex_lvq_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ + Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, /* i : offset for first subvector */ + Word32 *p_offset_scale2, /* i : offset for the second subvector */ + Word16 *p_no_scales ); + +Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ +); + +Word16 deindex_lvq_cng_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q9*/ + Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + +Word16 deindex_lvq_cng_ivas_fx( + Word16 *index, /* i: index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o: decoded codevector Q9 */ + Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ + Word16 no_bits /* i: number of bits for lattice */ +); + +Word16 lsp_convert_poly_fx( + Word16 w[], /* i/o: LSP or ISP parameters */ + const Word16 L_frame, /* i : flag for up or down conversion */ + const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ +); + +void CNG_exc_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 L_frame, /* i : length of the frame */ + Word32 *Enew, /* i/o: decoded SID energy Q6 */ + Word16 *seed, /* i/o: random generator seed */ + Word16 exc[], /* o : current non-enhanced excitation Q_new */ + Word16 exc2[], /* o : current enhanced excitation Q_new */ + Word32 *lp_ener, /* i/o: LP filtered E */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ + Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ + Word16 bwe_exc[], /* o : excitation for SWB TBE */ + const Word16 allow_cn_step, /* i : allow CN step */ + Word16 *last_allow_cn_step, /* i/o: last allow step */ + const Word16 OldQ_exc, /* i : Old excitation scaling */ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 num_ho, /* i : number of selected hangover frames */ + Word32 q_env[], + Word32 *lp_env, + Word32 *old_env, + Word16 *exc_mem, + Word16 *exc_mem1, + Word16 *sid_bw, + Word16 *cng_ener_seed1, + Word16 exc3[], + Word16 Opt_AMR_WB, + const Word16 element_mode /* i : IVAS Element mode */ +); + +void cng_params_postupd_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[] /* i/o: Envelope buffer */ +); + +void cng_params_postupd_ivas_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ +); + +void cng_params_upd_fx( + const Word16 lsp_new[], /* i : LSP parameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate /* i : Last active bit rate Q0 */ +); + +void cng_params_upd_ivas_fx( + const Word16 lsp_new[], /* i : LSP aprameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate, /* i : Last active bit rate Q0 */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ +); + +Word16 get_cng_mode( + const Word32 last_active_brate /* i : last active bitrate */ +); + +/*! r: codec mode */ +Word16 get_codec_mode( + const Word32 total_brate /* i : total bitrate */ +); + +Word16 getTcxonly( + const Word32 total_brate /* i : total bitrate */ +); + +Word16 getTcxonly_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ +); + +Word16 getCtxHm( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_flag /* i : flag to signal the RF mode */ +); + +Word16 getResq( + const Word32 total_brate /* i : total bitrate */ +); + +Word16 getTnsAllowed( + const Word32 total_brate, /* i : total bitrate */ + const Word16 igf, /* i : flag indicating IGF activity*/ + const Word16 element_mode /* i : IVAS element mode */ +); + +Word16 getRestrictedMode( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +); + +Word16 getMdctWindowLength_fx( + const Word16 fscale ); + +Word16 sr2fscale_fx( + const Word32 sr_core /* i : internal sampling rate */ +); + +Word32 getCoreSamplerateMode2( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ +); + +Word16 getTcxBandwidth( + const Word16 bandwidth ); + +Word16 getIgfPresent_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +Word16 getCnaPresent_fx( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth /* i : audio bandwidth */ +); + +Word16 getTcxLtp( + const Word32 sr_core /* i : internal sampling rate */ +); + +Word16 initPitchLagParameters( + const Word32 sr_core, + Word16 *pit_min, + Word16 *pit_fr1, + Word16 *pit_fr1b, + Word16 *pit_fr2, + Word16 *pit_max ); + +Word16 getNumTcxCodedLines( + const Word16 bwidth ); + +Word16 getTcxLpcShapedAri( + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const Word16 element_mode /* i : IVAS element mode */ +); + +void mdct_window_sine( + PWord16 *window, /* Qx */ + Word16 n /* Q0 */ +); + +void mdct_window_sine_IVAS_updated( + PWord16 *window, /* Qx */ + const Word32 Fs, /* Q0 */ + const Word16 n, /* Q0 */ + const Word16 window_type, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void mdct_window_aldo( + Word16 *window1, /* Q15 */ + PWord16 *window1_trunc, /* Q15 */ + PWord16 *window2, /* Q15 */ + Word16 n /* Q0 */ +); + +Word16 getInvFrameLen( + const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ + +void tcx_get_windows( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ + const Word16 left_mode, /* i: overlap mode of left window half */ + const Word16 right_mode, /* i: overlap mode of right window half */ + Word16 *left_overlap, /* o: left overlap length */ + const PWord16 **left_win, /* o: left overlap window */ + Word16 *right_overlap, /* o: right overlap length */ + const PWord16 **right_win, /* o: right overlap window */ + const Word8 fullband /* i: fullband flag */ +); + +void WindowSignal( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word16 offset, /* i : left folding point offset relative to the i signal pointer */ + const Word16 left_overlap_mode, /* i : overlap mode of left window half */ + Word16 right_overlap_mode, /* i : overlap mode of right window half */ + Word16 *left_overlap_length, /* o : TCX window left overlap length */ + Word16 *right_overlap_length, /* o : TCX window right overlap length */ + const Word16 in[], /* i : i signal */ + Word16 *L_frame, /* i/o: frame length */ + Word16 out[], /* o : output windowed signal */ + const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ + const Word8 fullband /* i : fullband flag */ +); + +void tcx_windowing_synthesis_current_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 left_rect, /* i: left part is rectangular */ + const Word16 left_mode, /* i: overlap mode of left window half */ + Word16 *acelp_zir, /* i: acelp ZIR */ + const Word16 *old_syn, + const Word16 *syn_overl, + const Word16 *A_zir, + const PWord16 *window_trans, + Word16 acelp_zir_len, + const Word16 acelp_mem_len, + const Word16 last_core_bfi, /* i : last core */ + const Word8 last_is_cng, + const Word16 fullbandScale ); + +void tcx_windowing_synthesis_past_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ +); + +void lpc2mdct( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 *mdct_gains, + Word16 *mdct_gains_exp, + Word16 *mdct_inv_gains, + Word16 *mdct_inv_gains_exp, + const Word16 length, + const Word16 noInverse ); + +void lpc2mdct_2( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 mdct_gains_fx[], + Word16 mdct_gains_e[], + Word16 mdct_inv_gains_fx[], + Word16 mdct_inv_gains_e[], + const Word16 length ); + +void mdct_shaping( + Word32 x[], + const Word16 lg, + const Word16 gains[], + const Word16 gains_exp[] ); + +void mdct_shaping_16( + const Word16 x[], + const Word16 lg, + const Word16 lg_total, + const Word16 gains[], + const Word16 gains_exp[], + Word16 gains_max_exp, + Word32 y[] ); + +void mdct_noiseShaping_ivas_fx( + Word32 x_fx[], + Word16 *x_e, + const Word16 lg, + const Word16 gains_fx[], + const Word16 gains_exp[] ); + +void mdct_noiseShaping_interp( + Word32 x[], + const Word16 lg, + Word16 gains[], + Word16 gains_exp[] ); + +void PsychAdaptLowFreqDeemph( + Word32 x[], + const Word16 lpcGains[], + const Word16 lpcGains_e[], + Word16 lf_deemph_factors[] ); + +void AdaptLowFreqDeemph( + Word32 x[], + Word16 x_e, + Word16 tcx_lpc_shaped_ari, + Word16 lpcGains[], + Word16 lpcGains_e[], + const Word16 lg, + Word16 lf_deemph_factors[] ); + +void tcx_noise_filling( + Word32 *Q, + Word16 Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ +); + +void tcx_noise_filling_with_shift( + Word32 *Q, + Word16 *Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ +); + +void InitTnsConfigs( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void InitTnsConfigs_ivas_fx( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void SetAllowTnsOnWhite( + STnsConfig tnsConfig[2][2], + const Word8 allowTnsOnWhite ); + +void SetTnsConfig( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + const Word16 isTCX20, + const Word16 isAfterACELP ); + +void tcx_get_gain( + Word32 *x, /* i: spectrum 1 */ + Word16 x_e, /* i: spectrum 1 exponent */ + Word32 *y, /* i: spectrum 2 */ + Word16 y_e, /* i: spectrum 2 exponent */ + Word16 n, /* i: length */ + Word16 *gain, /* o: gain */ + Word16 *gain_e, /* o: gain exponent */ + Word32 *en_y, /* o: energy of y (optional) */ + Word16 *en_y_e /* o: energy of y exponent (optional) */ +); + +void init_TCX_config( + TCX_CONFIG_HANDLE hTcxCfg, + Word16 L_frame, + Word16 fscale, + Word16 L_frameTCX, + Word16 fscaleFB ); + +void resetTecDec_Fx( + TEC_DEC_HANDLE hTecDec ); + +void resetTecEnc_Fx( + TEC_ENC_HANDLE hTECEnc, + Word16 flag ); + +void calcGainTemp_TBE_Fx( + Word32 **pCldfbRealSrc_Fx, + Word32 **pCldfbImagSrc_Fx, + Word16 cldfb_exp, + Word16 *loBuffer_Fx, + const Word16 startPos, /*!< Start position of the current envelope. */ + const Word16 stopPos, /*!< Stop position of the current envelope. */ + const Word16 lowSubband, /* lowSubband */ + Word16 *pGainTemp_m, + Word16 *pGainTemp_e, + const Word16 code ); + +Word16 procTecTfa_TBE_Fx( + Word16 *hb_synth_Fx, + Word16 hb_synth_fx_exp, + Word16 *gain_m, + Word16 *gain_e, + Word16 flat_flag, + Word16 last_core, + Word16 l_subfr, + Word16 code ); + +void calcHiEnvLoBuff_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + const Word16 nSfb, /*!< Number of scalefactors. */ + Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 pCldfbPow_FixScale ); + +void calcLoEnvCheckCorrHiLo_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, + Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 *corrFlag /*int* corrFlag*/ +); + +void tecEnc_TBE_fx( + Word16 *corrFlag, + const Word16 *voicing, + const Word16 coder_type ); + +void set_TEC_TFA_code_fx( + const Word16 corrFlag, + Word16 *tec_flag, + Word16 *tfa_flag ); + +void TCX_MDCT( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void TCX_MDST( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void TCX_MDCT_Inverse( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void TCX_MDST_Inverse_fx( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r /* Q0 */ +); + +void TCX_MDXT_Inverse_fx( + const Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type /* Q0 */ +); + +void edct_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ +); + +void edct_ivas_fx( + const Word32 *x, /* i : input signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length Q0*/ + Word16 *q /* i : Q value of input signal */ +); + +void edst_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ +); + +void edct_16fx( + const Word16 *x, /* i : i signal Qx */ + Word16 *y, /* o : output transform Qx */ + Word16 length, /* i : length */ + Word16 bh, /* bit-headroom */ + const Word16 element_mode ); + +void iedct_short_fx( + const Word32 *in, /* i : i vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 segment_length /* i : length */ +); + +void edxt_fx( + const Word32 *x, /* i : input signal */ + Word32 *y, /* o : output transform */ + const Word16 length, /* i : length */ + const UWord16 kernelType, /* i : kernel type (0 - 3) */ + const UWord16 synthesis /* i : nonzero for inverse */ +); + +void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); +void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); +void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); + +void DoRTFTn_fx( + Word32 *x, /* i/o : real part of i and output data */ + Word32 *y, /* i/o : imaginary part of i and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ +); + +void DoRTFT480_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT320_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT160_fx( + Word32 x[], /* i/o: real part of input and output data */ + Word32 y[] /* i/o: imaginary part of input and output data */ +); + +void DoRTFT128_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT120_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT80_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT40_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT20_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +Word16 RFFTN_fx( + Word32 *data, + const Word16 *sine_table, + const Word16 len, + const Word16 sign ); + +void DoFFT_fx( + Word32 *re2, + Word32 *im2, + const Word16 length ); + +void fft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const Word16 length, /* i : length of fft */ + const Word16 s /* i : sign */ +); + +void rfft_fx( + Word32 *x, /* i/o: values */ + const Word16 *w, /* i : window */ + const Word16 length, /* i : length of fft */ + const Word16 isign /* i : sign */ +); + +void DoRTFTn_fx_ivas( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ +); + + +Word16 find_guarded_bits_fx( const Word32 n ); - void ITF_Apply_fx( - Word32 spectrum[], - Word16 startLine, - Word16 stopLine, - const Word16 *A, - Word16 Q_A, - Word16 curr_order ); - - void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); - - Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - - Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - - Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); - - Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); - - Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - - Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - - Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - - void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); - - Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); - - Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); - - Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); - - Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); - - Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); - - Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); - - Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); - - void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); - - void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); - - void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); - - void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); - - void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); - void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); - - void ResetTnsData( STnsData *pTnsData ); - - void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); - - /*========================================================================================================/ - gp_clips_fx.c - /========================================================================================================*/ - - void init_gp_clip_fx( - Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - ); - - Word16 gp_clip_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 coder_type, /* i : type of coder Q0*/ - const Word16 xn[], /* i : target vector Q_new*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Q_new /* i : scaling factor */ - ); - - void gp_clip_test_isf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ - ); - - void gp_clip_test_gain_pit_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ - Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ - ); - - Word16 Mode2_gp_clip_fx( - const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 coder_type, /* i : type of coder Q0 */ - const Word16 xn[], /* i : target vector Q_xn */ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ - /* mem[0]: Q0 */ - /* mem[1]: 1Q14 */ - /* mem[2]: 8Q7 */ - /* mem[3]: Q0 (integer) */ - /* mem[4]: Q14 */ - /* mem[5]: Q14 */ - const Word16 L_subfr, /* Q0 */ - const Word16 Q_xn /* i : scaling factor of vector xn[] */ - ); - - void gp_clip_test_lsf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 m /* i : dimension of lsf Q0*/ - ); - - void gp_clip_test_lsf_ivas_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ - ); - - /*========================================================================================================/ - nelp_enc_fx.c - /========================================================================================================*/ - - void quantize_uvg_fx( - Word16 *G, - Word16 *iG1, - Word16 *iG2, - Word16 *quantG, - Word16 bandwidth ); - - void nelp_encoder_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - - void nelp_encoder_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - - void swb_bwe_enc_lr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ - ); - - void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ - ); - - void isf_enc_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *isf_new, /* i/o: quantized ISF vector */ - Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ - Word16 *Aq /* o : quantized A(z) for 4 subframes */ - ); - - Word16 detect_transient_fx( - const Word16 *in_fx, /*Q_new */ - const Word16 L, /*Q0*/ - Word16 Q_new, - Encoder_State *st_fx ); - - Word16 tcxGetNoiseFillingTilt( - const Word16 A[], - const Word16 lpcorder, - const Word16 L_frame, - const Word16 mode, - Word16 *noiseTiltFactor ); - - void tcxFormantEnhancement( - Word16 xn_buf[], - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - - void tcxFormantEnhancement_with_shift( - Word16 xn_buf[], - Word16 *xn_buf_e, - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - - void tcxInvertWindowGrouping( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word32 xn_buf[], - Word32 spectrum[], - const Word16 L_frame, - const Word8 fUseTns, - const Word16 last_core, - const Word16 index, - const Word16 frame_cnt, - const Word16 bfi ); - - void permute_fx( - Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ - const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ - ); - - void init_lvq_fx( - Word32 offset_scale1[][MAX_NO_SCALES + 1], - Word32 offset_scale2[][MAX_NO_SCALES + 1], - Word32 offset_scale1_p[][MAX_NO_SCALES + 1], - Word32 offset_scale2_p[][MAX_NO_SCALES + 1], - Word16 no_scales[][2], - Word16 no_scales_p[][2] ); - - Word16 deindex_lvq_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ - Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, /* i : offset for first subvector */ - Word32 *p_offset_scale2, /* i : offset for the second subvector */ - Word16 *p_no_scales ); - - Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ - ); - - Word16 deindex_lvq_cng_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q9*/ - Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - - Word16 deindex_lvq_cng_ivas_fx( - Word16 *index, /* i: index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o: decoded codevector Q9 */ - Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ - Word16 no_bits /* i: number of bits for lattice */ - ); - - Word16 lsp_convert_poly_fx( - Word16 w[], /* i/o: LSP or ISP parameters */ - const Word16 L_frame, /* i : flag for up or down conversion */ - const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ - ); - - void CNG_exc_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 L_frame, /* i : length of the frame */ - Word32 *Enew, /* i/o: decoded SID energy Q6 */ - Word16 *seed, /* i/o: random generator seed */ - Word16 exc[], /* o : current non-enhanced excitation Q_new */ - Word16 exc2[], /* o : current enhanced excitation Q_new */ - Word32 *lp_ener, /* i/o: LP filtered E */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ - Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ - Word16 bwe_exc[], /* o : excitation for SWB TBE */ - const Word16 allow_cn_step, /* i : allow CN step */ - Word16 *last_allow_cn_step, /* i/o: last allow step */ - const Word16 OldQ_exc, /* i : Old excitation scaling */ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 num_ho, /* i : number of selected hangover frames */ - Word32 q_env[], - Word32 *lp_env, - Word32 *old_env, - Word16 *exc_mem, - Word16 *exc_mem1, - Word16 *sid_bw, - Word16 *cng_ener_seed1, - Word16 exc3[], - Word16 Opt_AMR_WB, - const Word16 element_mode /* i : IVAS Element mode */ - ); - - void cng_params_postupd_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer */ - ); - - void cng_params_postupd_ivas_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ - ); - - void cng_params_upd_fx( - const Word16 lsp_new[], /* i : LSP parameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ - ); - - void cng_params_upd_ivas_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate, /* i : Last active bit rate Q0 */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ - ); - - Word16 get_cng_mode( - const Word32 last_active_brate /* i : last active bitrate */ - ); - - /*! r: codec mode */ - Word16 get_codec_mode( - const Word32 total_brate /* i : total bitrate */ - ); - - Word16 getTcxonly( - const Word32 total_brate /* i : total bitrate */ - ); - - Word16 getTcxonly_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ - ); - - Word16 getCtxHm( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_flag /* i : flag to signal the RF mode */ - ); - - Word16 getResq( - const Word32 total_brate /* i : total bitrate */ - ); - - Word16 getTnsAllowed( - const Word32 total_brate, /* i : total bitrate */ - const Word16 igf, /* i : flag indicating IGF activity*/ - const Word16 element_mode /* i : IVAS element mode */ - ); - - Word16 getRestrictedMode( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ - ); - - Word16 getMdctWindowLength_fx( - const Word16 fscale ); - - Word16 sr2fscale_fx( - const Word32 sr_core /* i : internal sampling rate */ - ); - - Word32 getCoreSamplerateMode2( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ - ); - - Word16 getTcxBandwidth( - const Word16 bandwidth ); - - Word16 getIgfPresent_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - Word16 getCnaPresent_fx( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth /* i : audio bandwidth */ - ); - - Word16 getTcxLtp( - const Word32 sr_core /* i : internal sampling rate */ - ); - - Word16 initPitchLagParameters( - const Word32 sr_core, - Word16 *pit_min, - Word16 *pit_fr1, - Word16 *pit_fr1b, - Word16 *pit_fr2, - Word16 *pit_max ); - - Word16 getNumTcxCodedLines( - const Word16 bwidth ); - - Word16 getTcxLpcShapedAri( - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const Word16 element_mode /* i : IVAS element mode */ - ); - - void mdct_window_sine( - PWord16 *window, /* Qx */ - Word16 n /* Q0 */ - ); - - void mdct_window_sine_IVAS_updated( - PWord16 *window, /* Qx */ - const Word32 Fs, /* Q0 */ - const Word16 n, /* Q0 */ - const Word16 window_type, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void mdct_window_aldo( - Word16 *window1, /* Q15 */ - PWord16 *window1_trunc, /* Q15 */ - PWord16 *window2, /* Q15 */ - Word16 n /* Q0 */ - ); - - Word16 getInvFrameLen( - const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ - - void tcx_get_windows( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const Word16 left_mode, /* i: overlap mode of left window half */ - const Word16 right_mode, /* i: overlap mode of right window half */ - Word16 *left_overlap, /* o: left overlap length */ - const PWord16 **left_win, /* o: left overlap window */ - Word16 *right_overlap, /* o: right overlap length */ - const PWord16 **right_win, /* o: right overlap window */ - const Word8 fullband /* i: fullband flag */ - ); - - void WindowSignal( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 offset, /* i : left folding point offset relative to the i signal pointer */ - const Word16 left_overlap_mode, /* i : overlap mode of left window half */ - Word16 right_overlap_mode, /* i : overlap mode of right window half */ - Word16 *left_overlap_length, /* o : TCX window left overlap length */ - Word16 *right_overlap_length, /* o : TCX window right overlap length */ - const Word16 in[], /* i : i signal */ - Word16 *L_frame, /* i/o: frame length */ - Word16 out[], /* o : output windowed signal */ - const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const Word8 fullband /* i : fullband flag */ - ); - - void tcx_windowing_synthesis_current_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 left_rect, /* i: left part is rectangular */ - const Word16 left_mode, /* i: overlap mode of left window half */ - Word16 *acelp_zir, /* i: acelp ZIR */ - const Word16 *old_syn, - const Word16 *syn_overl, - const Word16 *A_zir, - const PWord16 *window_trans, - Word16 acelp_zir_len, - const Word16 acelp_mem_len, - const Word16 last_core_bfi, /* i : last core */ - const Word8 last_is_cng, - const Word16 fullbandScale ); - - void tcx_windowing_synthesis_past_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ - ); - - void lpc2mdct( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 *mdct_gains, - Word16 *mdct_gains_exp, - Word16 *mdct_inv_gains, - Word16 *mdct_inv_gains_exp, - const Word16 length, - const Word16 noInverse ); - - void lpc2mdct_2( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 mdct_gains_fx[], - Word16 mdct_gains_e[], - Word16 mdct_inv_gains_fx[], - Word16 mdct_inv_gains_e[], - const Word16 length ); - - void mdct_shaping( - Word32 x[], - const Word16 lg, - const Word16 gains[], - const Word16 gains_exp[] ); - - void mdct_shaping_16( - const Word16 x[], - const Word16 lg, - const Word16 lg_total, - const Word16 gains[], - const Word16 gains_exp[], - Word16 gains_max_exp, - Word32 y[] ); - - void mdct_noiseShaping_ivas_fx( - Word32 x_fx[], - Word16 *x_e, - const Word16 lg, - const Word16 gains_fx[], - const Word16 gains_exp[] ); - - void mdct_noiseShaping_interp( - Word32 x[], - const Word16 lg, - Word16 gains[], - Word16 gains_exp[] ); - - void PsychAdaptLowFreqDeemph( - Word32 x[], - const Word16 lpcGains[], - const Word16 lpcGains_e[], - Word16 lf_deemph_factors[] ); - - void AdaptLowFreqDeemph( - Word32 x[], - Word16 x_e, - Word16 tcx_lpc_shaped_ari, - Word16 lpcGains[], - Word16 lpcGains_e[], - const Word16 lg, - Word16 lf_deemph_factors[] ); - - void tcx_noise_filling( - Word32 *Q, - Word16 Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ - ); - - void tcx_noise_filling_with_shift( - Word32 *Q, - Word16 *Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ - ); - - void InitTnsConfigs( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void InitTnsConfigs_ivas_fx( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void SetAllowTnsOnWhite( - STnsConfig tnsConfig[2][2], - const Word8 allowTnsOnWhite ); - - void SetTnsConfig( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const Word16 isTCX20, - const Word16 isAfterACELP ); - - void tcx_get_gain( - Word32 *x, /* i: spectrum 1 */ - Word16 x_e, /* i: spectrum 1 exponent */ - Word32 *y, /* i: spectrum 2 */ - Word16 y_e, /* i: spectrum 2 exponent */ - Word16 n, /* i: length */ - Word16 *gain, /* o: gain */ - Word16 *gain_e, /* o: gain exponent */ - Word32 *en_y, /* o: energy of y (optional) */ - Word16 *en_y_e /* o: energy of y exponent (optional) */ - ); - - void init_TCX_config( - TCX_CONFIG_HANDLE hTcxCfg, - Word16 L_frame, - Word16 fscale, - Word16 L_frameTCX, - Word16 fscaleFB ); - - void resetTecDec_Fx( - TEC_DEC_HANDLE hTecDec ); - - void resetTecEnc_Fx( - TEC_ENC_HANDLE hTECEnc, - Word16 flag ); - - void calcGainTemp_TBE_Fx( - Word32 **pCldfbRealSrc_Fx, - Word32 **pCldfbImagSrc_Fx, - Word16 cldfb_exp, - Word16 *loBuffer_Fx, - const Word16 startPos, /*!< Start position of the current envelope. */ - const Word16 stopPos, /*!< Stop position of the current envelope. */ - const Word16 lowSubband, /* lowSubband */ - Word16 *pGainTemp_m, - Word16 *pGainTemp_e, - const Word16 code ); - - Word16 procTecTfa_TBE_Fx( - Word16 *hb_synth_Fx, - Word16 hb_synth_fx_exp, - Word16 *gain_m, - Word16 *gain_e, - Word16 flat_flag, - Word16 last_core, - Word16 l_subfr, - Word16 code ); - - void calcHiEnvLoBuff_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - const Word16 nSfb, /*!< Number of scalefactors. */ - Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 pCldfbPow_FixScale ); - - void calcLoEnvCheckCorrHiLo_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, - Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 *corrFlag /*int* corrFlag*/ - ); - - void tecEnc_TBE_fx( - Word16 *corrFlag, - const Word16 *voicing, - const Word16 coder_type ); - - void set_TEC_TFA_code_fx( - const Word16 corrFlag, - Word16 *tec_flag, - Word16 *tfa_flag ); - - void TCX_MDCT( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void TCX_MDST( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void TCX_MDCT_Inverse( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qy */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void TCX_MDST_Inverse_fx( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r /* Q0 */ - ); - - void TCX_MDXT_Inverse_fx( - const Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const UWord16 kernel_type /* Q0 */ - ); - - void edct_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ - ); - - void edct_ivas_fx( - const Word32 *x, /* i : input signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length Q0*/ - Word16 *q /* i : Q value of input signal */ - ); - - void edst_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ - ); - - void edct_16fx( - const Word16 *x, /* i : i signal Qx */ - Word16 *y, /* o : output transform Qx */ - Word16 length, /* i : length */ - Word16 bh, /* bit-headroom */ - const Word16 element_mode ); - - void iedct_short_fx( - const Word32 *in, /* i : i vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 segment_length /* i : length */ - ); - - void edxt_fx( - const Word32 *x, /* i : input signal */ - Word32 *y, /* o : output transform */ - const Word16 length, /* i : length */ - const UWord16 kernelType, /* i : kernel type (0 - 3) */ - const UWord16 synthesis /* i : nonzero for inverse */ - ); - - void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); - void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); - void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); - - void DoRTFTn_fx( - Word32 *x, /* i/o : real part of i and output data */ - Word32 *y, /* i/o : imaginary part of i and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ - ); - - void DoRTFT480_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT320_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT160_fx( - Word32 x[], /* i/o: real part of input and output data */ - Word32 y[] /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT128_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT120_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT80_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT40_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT20_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - Word16 RFFTN_fx( - Word32 *data, - const Word16 *sine_table, - const Word16 len, - const Word16 sign ); - - void DoFFT_fx( - Word32 *re2, - Word32 *im2, - const Word16 length ); - - void fft_fx( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - const Word16 length, /* i : length of fft */ - const Word16 s /* i : sign */ - ); - - void rfft_fx( - Word32 *x, /* i/o: values */ - const Word16 *w, /* i : window */ - const Word16 length, /* i : length of fft */ - const Word16 isign /* i : sign */ - ); - - void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ - ); - - - Word16 find_guarded_bits_fx( const Word32 n ); - - Word16 L_norm_arr( const Word32 *arr, Word16 size ); - Word16 norm_arr( Word16 *arr, Word16 size ); - Word16 W_norm_arr( Word64 *arr, Word16 size ); - - Word16 get_min_scalefactor( Word32 x, Word32 y ); - - Flag is_zero_arr( Word32 *arr, Word16 size ); - Flag is_zero_arr16( Word16 *arr, Word16 size ); - Flag is_zero_arr64( Word64 *arr, Word16 size ); - - void edct2_fx_ivas( - const Word16 n, - const Word16 isgn, - Word32 *in, - Word32 *a, - const Word16 *ip, - const Word16 *w ); - - void edct2_fx( - Word16 n, - Word16 isgn, - Word16 *in, - Word32 *a, - Word16 *q, - const Word16 *ip, - const Word16 *w ); - - void DoRTFT160_16fx( - Word16 x[], /* i/o : real part of i and output data */ - Word16 y[] /* i/o : imaginary part of i and output data */ - ); - - void DoRTFT320_16fx( - Word16 *x, /* i/o : real part of i and output data */ - Word16 *y /* i/o : imaginary part of i and output data */ - ); - - void DoRTFT128_16fx( - Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ - Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ - ); - - void fft3_fx( - const Word16[], - Word16[], - const Word16 ); - - void ifft3_fx( - const Word16[], - Word16[], - const Word16 ); - - void fft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); - void ifft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); - - void r_fft_fx_lc( - const Word16 *phs_tbl, /* i : Table of phase */ - const Word16 SIZE, /* i : Size of the FFT */ - const Word16 SIZE2, /* i : Size / 2 */ - const Word16 NUM_STAGE, /* i : Number of stage */ - const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - const Word16 isign /* i : 1=fft, otherwize it's ifft */ - ); - - void cldfbAnalysis_fx( - HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ - Word32 **cldfbReal, /*!< Pointer to real subband slots */ - Word32 **cldfbImag, /*!< Pointer to imag subband slots */ - CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - const Word16 *timeIn, /*!< Time signal */ - const Word16 timeIn_e, /*!< Time signal */ - const Word16 nTimeSlots, /*!< Time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ - ); - - void cldfbSynthesis_fx( - HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ - Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ - Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ - const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - Word16 *timeOut, /*!< Time signal */ - const Word16 timeOut_e, /*!< Target exponent for output signal */ - const Word16 nTimeSlots, /*!< number of time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ - ); - - void configureCldfb( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ - const Word32 sampling_rate /* i : sampling rate */ - ); - - ivas_error openCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ - const Word16 type, /* i : analysis or synthesis */ - const Word32 sampling_rate /* i : sampling rate */ - ); - - void resampleCldfb( - HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word16 frameSize, /*!< FrameSize */ - const Word8 firstFrame ); - - Word16 AnalysisPostSpectrumScaling_Fx( - HANDLE_CLDFB_FILTER_BANK cldfbBank, - Word32 **rSubband32, - Word32 **iSubband32, - Word16 **rSubband16, - Word16 **iSubband16, - Word16 *cldfbScale ); - - void analysisCldfbEncoder_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *timeIn, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - - void GetEnergyCldfb( - Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ - Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ - const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ - Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ - Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ - Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ - Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ - Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ - Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ - Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ - Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ - Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ - TEC_ENC_HANDLE hTECEnc ); - - void deleteCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ - - ivas_error cldfb_save_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - - void cldfb_restore_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - - void cldfb_reset_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - - void BITS_ALLOC_init_config_acelp( - const Word32 bit_rate, - const Word16 narrowBand, - const Word16 nb_subfr, - ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ - ); - - Word16 BITS_ALLOC_config_acelp( - const Word16 bits_frame, /*i: remaining bit budget for the frame */ - const Word16 coder_type, /*i: coder type */ - ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ - const Word16 narrowband, - const Word16 nb_subfr ); - - Word16 set_ACELP_flag( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate per channel */ - const Word16 idchan, /* i : Channel id */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 cng_type /* i : CNG type */ - ); - - void syn_12k8_fx( - Word16 L_frame, - const Word16 *Aq, /* i : LP filter coefficients Q12 */ - const Word16 *exc, /* i : i signal Q_exc */ - Word16 *synth, /* o : output signal Q_syn */ - Word16 *mem, /* i/o: initial filter states Q_syn */ - const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ - /* 1 --> update of memory */ - const Word16 Q_exc, /* i : Excitation scaling Q0 */ - const Word16 Q_syn /* i : Synthesis scaling Q0 */ - ); - - /* o : tilt of the code Q15 */ - Word16 est_tilt_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ +Word16 L_norm_arr( const Word32 *arr, Word16 size ); +Word16 norm_arr( Word16 *arr, Word16 size ); +Word16 W_norm_arr( Word64 *arr, Word16 size ); + +Word16 get_min_scalefactor( Word32 x, Word32 y ); + +Flag is_zero_arr( Word32 *arr, Word16 size ); +Flag is_zero_arr16( Word16 *arr, Word16 size ); +Flag is_zero_arr64( Word64 *arr, Word16 size ); + +void edct2_fx_ivas( + const Word16 n, + const Word16 isgn, + Word32 *in, + Word32 *a, + const Word16 *ip, + const Word16 *w ); + +void edct2_fx( + Word16 n, + Word16 isgn, + Word16 *in, + Word32 *a, + Word16 *q, + const Word16 *ip, + const Word16 *w ); + +void DoRTFT160_16fx( + Word16 x[], /* i/o : real part of i and output data */ + Word16 y[] /* i/o : imaginary part of i and output data */ +); + +void DoRTFT320_16fx( + Word16 *x, /* i/o : real part of i and output data */ + Word16 *y /* i/o : imaginary part of i and output data */ +); + +void DoRTFT128_16fx( + Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ + Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ +); + +void fft3_fx( + const Word16[], + Word16[], + const Word16 ); + +void ifft3_fx( + const Word16[], + Word16[], + const Word16 ); + +void fft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); +void ifft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); + +void r_fft_fx_lc( + const Word16 *phs_tbl, /* i : Table of phase */ + const Word16 SIZE, /* i : Size of the FFT */ + const Word16 SIZE2, /* i : Size / 2 */ + const Word16 NUM_STAGE, /* i : Number of stage */ + const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + const Word16 isign /* i : 1=fft, otherwize it's ifft */ +); + +void cldfbAnalysis_fx( + HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ + Word32 **cldfbReal, /*!< Pointer to real subband slots */ + Word32 **cldfbImag, /*!< Pointer to imag subband slots */ + CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + const Word16 *timeIn, /*!< Time signal */ + const Word16 timeIn_e, /*!< Time signal */ + const Word16 nTimeSlots, /*!< Time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ +); + +void cldfbSynthesis_fx( + HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ + Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ + Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ + const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + Word16 *timeOut, /*!< Time signal */ + const Word16 timeOut_e, /*!< Target exponent for output signal */ + const Word16 nTimeSlots, /*!< number of time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ +); + +void configureCldfb( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ + const Word32 sampling_rate /* i : sampling rate */ +); + +ivas_error openCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ + const Word16 type, /* i : analysis or synthesis */ + const Word32 sampling_rate /* i : sampling rate */ +); + +void resampleCldfb( + HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 frameSize, /*!< FrameSize */ + const Word8 firstFrame ); + +Word16 AnalysisPostSpectrumScaling_Fx( + HANDLE_CLDFB_FILTER_BANK cldfbBank, + Word32 **rSubband32, + Word32 **iSubband32, + Word16 **rSubband16, + Word16 **iSubband16, + Word16 *cldfbScale ); + +void analysisCldfbEncoder_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *timeIn, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + +void GetEnergyCldfb( + Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ + Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ + const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ + Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ + Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ + Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ + Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ + Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ + Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ + Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ + Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ + Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ + TEC_ENC_HANDLE hTECEnc ); + +void deleteCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ + +ivas_error cldfb_save_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + +void cldfb_restore_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + +void cldfb_reset_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + +void BITS_ALLOC_init_config_acelp( + const Word32 bit_rate, + const Word16 narrowBand, + const Word16 nb_subfr, + ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ +); + +Word16 BITS_ALLOC_config_acelp( + const Word16 bits_frame, /*i: remaining bit budget for the frame */ + const Word16 coder_type, /*i: coder type */ + ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ + const Word16 narrowband, + const Word16 nb_subfr ); + +Word16 set_ACELP_flag( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate per channel */ + const Word16 idchan, /* i : Channel id */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 cng_type /* i : CNG type */ +); + +void syn_12k8_fx( + Word16 L_frame, + const Word16 *Aq, /* i : LP filter coefficients Q12 */ + const Word16 *exc, /* i : i signal Q_exc */ + Word16 *synth, /* o : output signal Q_syn */ + Word16 *mem, /* i/o: initial filter states Q_syn */ + const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ + /* 1 --> update of memory */ + const Word16 Q_exc, /* i : Excitation scaling Q0 */ + const Word16 Q_syn /* i : Synthesis scaling Q0 */ +); + +/* o : tilt of the code Q15 */ +Word16 est_tilt_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ #ifdef CLEANUP_ACELP_ENC - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #else const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ #endif - ); +); #ifndef CLEANUP_ACELP_ENC - /* o : tilt of the code Q15 */ - Word16 est_tilt_ivas_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ +/* o : tilt of the code Q15 */ +Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #ifndef CLEANUP_ACELP_ENC - , - const Word16 flag_tilt /* i : flag for special tilt */ + , + const Word16 flag_tilt /* i : flag for special tilt */ #endif - ); +); #endif - /* o : tilt of the code */ - Word16 Est_tilt2( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ - ); - - void E_UTIL_voice_factor( - Word16 *exc, /* i : pointer to the excitation frame Q_new */ - Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* i : innovative codebook Q9 */ - Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ - Word16 *tilt_code, /* o : tilt factor Q15 */ - Word16 L_subfr, /* i : subframe length */ - Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ - Word16 Q_new, /* i : excitation buffer format */ - Word16 shift /* i : scaling to get 12bit */ - ); - - void sinq_fx( - const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ - const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ - const Word16 N, /* i : size of output */ - Word16 x[] /* o : output vector Q15*/ - ); - - void window_ola_fx( - Word32 *ImdctOut, - Word16 *auOut, - Word16 *Q_sig, - Word16 *OldauOut, - Word16 *Q_old, - const Word16 L, - const Word16 right_mode, - const Word16 left_mode, - const Word16 old_bfi, - const Word16 oldHqVoicing, - Word16 *oldgapsynth ); - - void core_switching_OLA_fx( - Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ - const Word16 last_L_frame, /* i : last L_frame lengthture */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ - Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ - Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ - const Word16 output_frame, /* i : output frame length */ - const Word16 bwidth, /* i : output bandwidth */ - Word16 *Qsynth, - Word16 *Qsubfr ); - - void window_ola_ext_fx( - const Word32 *ImdstOut, /* i : input */ - Word32 *auOut, /* o : output audio */ - Word32 *OldauOut, /* i/o: audio from previous frame */ - const Word16 L, /* i : length */ - const Word16 right_mode, - const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const UWord16 kernel_type /* i : transform kernel type */ - ); - - void cb_shape_fx( - const Word16 preemphFlag, /* i : flag for pre-emphasis */ - const Word16 pitchFlag, /* i : flag for pitch sharpening */ - const Word16 scramblingFlag, /* i : flag for phase scrambling */ - const Word16 sharpFlag, /* i : flag for formant sharpening */ - const Word16 formantTiltFlag, /* i : flag for formant tilt */ - const Word16 g1, /* i : formant sharpening numerator weighting */ - const Word16 g2, /* i : formant sharpening denominator weighting */ - const Word16 *p_Aq, /* i : LP filter coefficients */ - Word16 *code, /* i/o: signal to shape */ - const Word16 tilt_code, /* i : tilt of code */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ - const Word16 shift, - const Word16 L_subfr /* i : subframe lenght */ - ); - - void longadd( - UWord16 a[], /* i/o: vector of the length lena */ - const UWord16 b[], /* i/o: vector of the length lenb */ - const Word16 lena, /* i/o: length of vector a[] */ - const Word16 lenb /* i/o: length of vector b[] */ - ); - - void longshiftright( - UWord16 a[], /* i : vector of the length lena */ - const Word16 b, /* i : number of bit positions to shift right */ - UWord16 d[], /* o : vector of the length lend */ - Word16 lena, /* i : length of vector a[] */ - const Word16 lend /* i : length of vector d[] */ - ); - - void longshiftleft( - const UWord16 a[], /* i : vector of the length len */ - const Word16 b, /* i : number of bit positions to shift left */ - UWord16 d[], /* o : vector of the length len */ - const Word16 len /* i : length of vector a[] and d[] */ - ); - - void longshr( - UWord32 a[], - Word16 bits, - Word16 len ); - - void bands_and_bit_alloc_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : i signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); - - void fine_gain_pred_fx( - const Word16 *sfm_start, /* i : Sub band start indices */ - const Word16 *sfm_end, /* i : Sub band end indices */ - const Word16 *sfm_size, /* i : Sub band bandwidths */ - const Word16 *i_sort, /* i : Energy sorting indices */ - const Word16 *K, /* i : Number of pulses per band */ - const Word16 *maxpulse, /* i : Maximum pulse per band */ - const Word16 *R, /* i : Bits per sub band Q3 */ - const Word16 num_sfm, /* i : Number of sub bands */ - Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ - Word16 *y, /* i/o: Quantized vector (int) */ - Word16 *fg_pred, /* o : Predicted fine gains Q12 */ - const Word16 core /* i : Core */ - ); - - void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ - ); - - void get_max_pulses_fx( - const Word16 *band_start, /* i : Sub band start indices */ - const Word16 *band_end, /* i : Sub band end indices */ - const Word16 *k_sort, /* i : Indices for sorting by energy */ - const Word16 *npulses, /* i : Pulses per sub band */ - const Word16 BANDS, /* i : Number of bands */ - Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ - Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ - ); - - void fine_gain_dec_fx( - Decoder_State *st, - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ - ); - - /* o : Number of assigned gain bits */ - Word16 assign_gain_bits_fx( - const Word16 core, /* i : HQ core */ - const Word16 BANDS, /* i : Number of bands */ - const Word16 *band_width, /* i : Sub band bandwidth */ - Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *gain_bits_array, /* o : Assigned gain bits */ - Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ - ); - - void freq_dnw_scaling_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 coder_type, /* i : coder type */ - const Word16 noise_lev, /* i : Noise level */ - const Word32 core_brate, /* i : Core bitrate */ - Word16 fy_norm[], /* i/o: Frequency quantized parameter */ - Word16 Qx, /* Q format of fy_norm*/ - const Word16 L_frame /* i : frame length */ - ); +/* o : tilt of the code */ +Word16 Est_tilt2( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ +); + +void E_UTIL_voice_factor( + Word16 *exc, /* i : pointer to the excitation frame Q_new */ + Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* i : innovative codebook Q9 */ + Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ + Word16 *tilt_code, /* o : tilt factor Q15 */ + Word16 L_subfr, /* i : subframe length */ + Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ + Word16 Q_new, /* i : excitation buffer format */ + Word16 shift /* i : scaling to get 12bit */ +); + +void sinq_fx( + const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ + const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ + const Word16 N, /* i : size of output */ + Word16 x[] /* o : output vector Q15*/ +); + +void window_ola_fx( + Word32 *ImdctOut, + Word16 *auOut, + Word16 *Q_sig, + Word16 *OldauOut, + Word16 *Q_old, + const Word16 L, + const Word16 right_mode, + const Word16 left_mode, + const Word16 old_bfi, + const Word16 oldHqVoicing, + Word16 *oldgapsynth ); + +void core_switching_OLA_fx( + Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ + const Word16 last_L_frame, /* i : last L_frame lengthture */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ + Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ + Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ + const Word16 output_frame, /* i : output frame length */ + const Word16 bwidth, /* i : output bandwidth */ + Word16 *Qsynth, + Word16 *Qsubfr ); + +void window_ola_ext_fx( + const Word32 *ImdstOut, /* i : input */ + Word32 *auOut, /* o : output audio */ + Word32 *OldauOut, /* i/o: audio from previous frame */ + const Word16 L, /* i : length */ + const Word16 right_mode, + const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const UWord16 kernel_type /* i : transform kernel type */ +); + +void cb_shape_fx( + const Word16 preemphFlag, /* i : flag for pre-emphasis */ + const Word16 pitchFlag, /* i : flag for pitch sharpening */ + const Word16 scramblingFlag, /* i : flag for phase scrambling */ + const Word16 sharpFlag, /* i : flag for formant sharpening */ + const Word16 formantTiltFlag, /* i : flag for formant tilt */ + const Word16 g1, /* i : formant sharpening numerator weighting */ + const Word16 g2, /* i : formant sharpening denominator weighting */ + const Word16 *p_Aq, /* i : LP filter coefficients */ + Word16 *code, /* i/o: signal to shape */ + const Word16 tilt_code, /* i : tilt of code */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ + const Word16 shift, + const Word16 L_subfr /* i : subframe lenght */ +); + +void longadd( + UWord16 a[], /* i/o: vector of the length lena */ + const UWord16 b[], /* i/o: vector of the length lenb */ + const Word16 lena, /* i/o: length of vector a[] */ + const Word16 lenb /* i/o: length of vector b[] */ +); + +void longshiftright( + UWord16 a[], /* i : vector of the length lena */ + const Word16 b, /* i : number of bit positions to shift right */ + UWord16 d[], /* o : vector of the length lend */ + Word16 lena, /* i : length of vector a[] */ + const Word16 lend /* i : length of vector d[] */ +); + +void longshiftleft( + const UWord16 a[], /* i : vector of the length len */ + const Word16 b, /* i : number of bit positions to shift left */ + UWord16 d[], /* o : vector of the length len */ + const Word16 len /* i : length of vector a[] and d[] */ +); + +void longshr( + UWord32 a[], + Word16 bits, + Word16 len ); + +void bands_and_bit_alloc_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : i signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +void fine_gain_pred_fx( + const Word16 *sfm_start, /* i : Sub band start indices */ + const Word16 *sfm_end, /* i : Sub band end indices */ + const Word16 *sfm_size, /* i : Sub band bandwidths */ + const Word16 *i_sort, /* i : Energy sorting indices */ + const Word16 *K, /* i : Number of pulses per band */ + const Word16 *maxpulse, /* i : Maximum pulse per band */ + const Word16 *R, /* i : Bits per sub band Q3 */ + const Word16 num_sfm, /* i : Number of sub bands */ + Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ + Word16 *y, /* i/o: Quantized vector (int) */ + Word16 *fg_pred, /* o : Predicted fine gains Q12 */ + const Word16 core /* i : Core */ +); + +void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ +); + +void get_max_pulses_fx( + const Word16 *band_start, /* i : Sub band start indices */ + const Word16 *band_end, /* i : Sub band end indices */ + const Word16 *k_sort, /* i : Indices for sorting by energy */ + const Word16 *npulses, /* i : Pulses per sub band */ + const Word16 BANDS, /* i : Number of bands */ + Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ + Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ +); + +void fine_gain_dec_fx( + Decoder_State *st, + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ +); + +/* o : Number of assigned gain bits */ +Word16 assign_gain_bits_fx( + const Word16 core, /* i : HQ core */ + const Word16 BANDS, /* i : Number of bands */ + const Word16 *band_width, /* i : Sub band bandwidth */ + Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *gain_bits_array, /* o : Assigned gain bits */ + Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ +); + +void freq_dnw_scaling_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 coder_type, /* i : coder type */ + const Word16 noise_lev, /* i : Noise level */ + const Word32 core_brate, /* i : Core bitrate */ + Word16 fy_norm[], /* i/o: Frequency quantized parameter */ + 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 */ - 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 */ - ); - void highband_exc_dct_in_ivas_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 */ - ); -#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 */ +); +void highband_exc_dct_in_ivas_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 */ @@ -5156,6330 +5122,6359 @@ 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 lsf_dec_bfi( - const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ - Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ - const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ - Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ - const Word16 lsfBase[], /* i : base for differential lsf coding */ - Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ - const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ - Word16 L_frame, - const Word16 last_good, /*!< i : last good received frame */ - const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ - const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ - Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ - Word16 *lsf_cng, /* Q2.56 */ - Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ - const Word16 Last_GSC_pit_band_idx, - const Word16 Opt_AMR_WB, /* i : IO flag */ - const Word8 tcxonly, - const short bwidth /* i: coded bandwidth */ - ); - - Word16 const *PlcGetLsfBase( - Word16 const lpcQuantization, - Word16 const narrowBand, - Word32 const sr_core ); - - /* Create an instance of type FD_CNG */ - ivas_error createFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - - void initFdCngCom( - HANDLE_FD_CNG_COM hFdCngCom, - Word16 scale ); - - /* Delete the instance of type FD_CNG */ - void deleteFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - - /* Initialize the spectral partitioning */ - void initPartitions( - const Word16 *part_in, - const Word16 npart_in, - const Word16 startBand, - const Word16 stopBand, - Word16 *part_out, - Word16 *npart_out, - Word16 *midband, - Word16 *psize, - Word16 *psize_norm, - Word16 *psize_norm_exp, - Word16 *psize_inv, - const Word16 stopBandFR ); - - /* Noise estimation using Minimum Statistics (MS) */ - void compress_range( - Word32 *in, - Word16 in_exp, - Word16 *out, - const Word16 len ); - - void expand_range( - Word16 *in, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - - void expand_range_fx( - Word32 *in, // Q25 - Word32 *out, // exp:out_exp - Word16 *out_exp, - const Word16 len ); - - void expand_range_var_exp( - Word16 *in, - Word16 in_exp, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - - void minimum_statistics( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ - ); - - void minimum_statistics_fx( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ - Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ - ); - - /* Apply bitrate-dependant scale */ - void apply_scale( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ - ); - - Word16 apply_scale_ind( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ - ); - void apply_scale_ivas_fx( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize, /* i : Size of scale table */ - Word16 *index ); - - /* Compute the power for each partition */ - void bandcombinepow( - const Word32 *bandpow, /* i : Power for each band */ - const Word16 exp_bandpow, /* i : exponent of bandpow */ - const Word16 nband, /* i : Number of bands */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - const Word16 *psize_inv, /* i : Inverse partition sizes */ - Word32 *partpow, /* o : Power for each partition */ - Word16 *exp_partpow ); - - /* Scale partitions (with smoothing) */ - void scalebands( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - - void scalebands_fx( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - - /* STFT analysis filterbank */ - void AnalysisSTFT( - const Word16 *timeDomainInput, /* i : pointer to time signal */ - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - void AnalysisSTFT_fx( - const Word16 *timeDomainInput, - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - /* STFT synthesis filterbank */ - void SynthesisSTFT( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void SynthesisSTFT_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - Word32 sign_l( - const Word32 x /* i : input value of x */ - ); - - void ivas_updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ - ); - - /* Random generator with Gaussian distribution with mean 0 and std 1 */ - Word32 rand_gauss( - Word16 *seed ); - - Word16 rand_gauss_fix( - Word16 *x, - Word16 *seed ); - - void lpc_from_spectrum( - HANDLE_FD_CNG_COM hFdCngCom, - const Word16 start, /*i : start band*/ - const Word16 stop, /*i : stop band*/ - const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ - ); - - void msvq_decoder( - const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook vector dimension */ - const Word16 Idx[], /* i : Indices */ - Word16 *uq /* o : quantized vector */ - ); - - void FdCng_exc( - HANDLE_FD_CNG_COM hs, - Word16 *CNG_mode, - Word16 L_frame, - Word16 *lsp_old, - Word16 first_CNG, - Word16 *lsp_CNG, - Word16 *Aq, /* o: LPC coeffs */ - Word16 *lsp_new, /* o: lsp */ - Word16 *lsf_new, /* o: lsf */ - Word16 *exc, /* o: LP excitation */ - Word16 *exc2, /* o: LP excitation */ - Word16 *bwe_exc /* o: LP excitation for BWE */ - ); - - void direct_transform_fx( - const Word32 in32_fx[], - Word32 out32_fx[], - const Word16 is_transient, - const Word16 L, - Word16 *Q, - const Word16 element_mode ); - - void preecho_sb_fx( - const Word32 brate, /* i Q0 : core bit-rate */ - Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ - Word16 q_sig32, /* i Q value for wtda_audio_fx */ - Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ - Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ - const Word16 framelength, /* i Q0 : frame length */ - Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ - Word16 *smoothmem_fx, /* i/o Q15 : memory */ - Word32 *mean_prev_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ - Word16 *wmold_hb_fx, /* i/o Q15 : memory */ - Word16 *prevflag, /* i/o Q0 : flag */ - Word16 *pastpre, /* i/o Q0 : flag */ - const Word16 bwidth /* i Q0 : bandwidth */ - ); - - void Inverse_Transform( - const Word32 *in_mdct, /* i : i MDCT vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 is_transient, /* i : transient flag */ - const Word16 L, /* i : output frame length */ - const Word16 L_inner, /* i : length of the transform */ - const Word16 element_mode /* i : IVAS element mode */ - ); - - void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ - Word16 *ynrm, /* o : recovered quantization indices Q0*/ - Word16 *normqlg2, /* o : recovered quantized norms Q0*/ - const Word16 nb_sfm /* i : number of SFMs Q0*/ - ); - - Word32 ar_div( Word32 num, Word32 denum ); - - void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); - void ar_encoder_done_fx( PARCODEC arInst ); - void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); - void ar_decoder_done_fx( PARCODEC arInst ); - Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); - - void TCQLSB_fx( - Word16 bcount, - Word32 *abuffer_fx, - Word16 *mbuffer_fx, - Word32 *sbuffer_fx, - Word16 *dpath ); - - void TCQLSBdec_fx( - Word16 *dpath, - Word16 *mbuffer, - Word16 bcount ); - - void RestoreTCQ_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - - void RestoreTCQdec_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - - void InitLSBTCQ_fx( - Word16 *bcount ); - - void SaveTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - - void LoadTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - - Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); - Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); - Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); - - Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); - - void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); - void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); - void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); - void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); - - Word16 GetScale_fx( - Word16 blen, - Word32 bits_fx, - Word32 *surplus_fx ); - - void srt_vec_ind_fx( - const Word32 *linear, - Word32 *srt, - Word16 *I, - Word16 length ); - - void fill_spectrum_fx( - Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ - Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ - const Word16 *R, /* i : number of pulses per band Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - Word16 norm[], /* i : quantization indices for norms Q0 */ - const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ - const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ - const Word16 nf_idx, /* i : noise fill index Q0 */ - const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ - const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ - Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ - Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ - Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ - const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ - const Word16 core_sfm, /* i : index of the end band for core Q0 */ - const Word16 HQ_mode, /* i : HQ mode Q0 */ - Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ - const Word32 L_core_brate, /* i : target bit-rate Q0 */ - Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ - Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ - Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ - const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ - const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ - const Word16 *npulses, /* i : number of pulses per band Q0 */ - const Word16 prev_is_transient, /* i : previous transient flag Q0 */ - Word32 *prev_normq, /* i/o: previous norms Q14 */ - Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ - const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ - const Word16 *sfmsize, /* i : Length of bands Q0 */ - const Word16 *sfm_start, /* i : Start of bands Q0 */ - const Word16 *sfm_end, /* i : End of bands Q0 */ - Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ - const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ - const Word16 num_sfm, /* i : Total number of bands Q0 */ - Word16 *prev_env_Q, - const Word16 num_env_bands, - const Word16 element_mode ); - - void hq_bit_allocation_fx( - const Word32 core_brate, /* i : Core bit-rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - const Word16 hqswb_clas, /* i : HQ class Q0 */ - Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ - const Word16 *normqlg2, /* i : Quantized norms Q0 */ - const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ - const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ - Word16 *noise_level, /* o : HVQ noise level Q15 */ - Word16 *R, /* o : Bit allocation per sub band Q0 */ - Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ - Word16 *sum, /* o : Sum of allocated shape bits Q0 */ - Word16 *core_sfm, /* o : Last coded band in core Q0 */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ - ); - - void map_quant_weight_fx( - const Word16 normqlg2[], /* i : quantized norms Q0*/ - Word16 wnorm[], /* o : weighted norm Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ - ); - - void bitalloc_fx( - Word16 *y, /* i : reordered norm of sub-vectors Q0 */ - Word16 *idx, /* i : reordered sub-vector indices Q0 */ - Word16 sum, /* i : number of available bits Q0 */ - Word16 N, /* i : number of norms Q0 */ - Word16 K, /* i : maximum number of bits per dimension Q0 */ - Word16 *r, /* o : bit-allacation vector Q0 */ - const Word16 *sfmsize, /* i : band length Q0 */ - const Word16 hqswb_clas /* i : signal classification flag Q0 */ - ); - - Word16 BitAllocF_fx( - Word16 *y, /* i : norm of sub-vectors :Q0 */ - Word32 bit_rate, /* i : bitrate :Q0 */ - Word16 B, /* i : number of available bits :Q0 */ - Word16 N, /* i : number of sub-vectors :Q0 */ - Word16 *R, /* o : bit-allocation indicator :Q0 */ - Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ - const Word16 hqswb_clas, /* i : hq swb class */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ - ); - - Word16 BitAllocWB_fx( - Word16 *y, /* i : norm of sub-vectors Q0*/ - Word16 B, /* i : number of available bits Q0*/ - Word16 N, /* i : number of sub-vectors Q0*/ - Word16 *R, /* o : bit-allocation indicator Q0*/ - Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ - ); - - void bitallocsum_fx( - Word16 *R, /* i : bit-allocation vector Q0 */ - const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ - Word16 *sum, /* o : total number of bits allocated Q0 */ - Word16 *Rsubband, /* o : rate per subband Q3 */ - const Word16 num_bits, /* i : number of bits Q0 */ - const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ - const Word16 *sfmsize /* i : band length Q0 */ - ); - - Word16 stab_est_fx( - Word16 etot, /* i : Total energy of the current frame Q8*/ - Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ - Word16 *mem_etot, /* i/o : Total energy memory Q8*/ - Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ - Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ - Word16 *thresh, /* i/o : Detection thresold Q11*/ - Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ - const Word16 vad_flag /* i : VAD flag */ - ); - - void enhancer_fx( - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ - ); - - void enhancer_ivas_fx( - const Word16 codec_mode, /* i : flag indicating Codec Mode */ - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 cbk_index, /* i : */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ - ); - - Word16 E_UTIL_enhancer( - Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - Word16 stab_fac, /* i : LP filter stability measure Q15 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ - Word16 *code, /* i/o: innovation(in: Q9) code_exp */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ - Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ - Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ - Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ - Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ - Word16 coder_type, /* i : coder type */ - Word16 cdk_index, /* i : */ - Word16 L_subfr, /* i : */ - Word16 L_frame, /* i : frame size */ - Word16 Q_new ); - - void phase_dispersion( - const Word32 gain_code, /* i : gain of code 15Q16 */ - const Word16 gain_pit, /* i : gain of pitch Q14 */ - Word16 code[], /* i/o: code vector */ - Word16 *code_e, /* i/o: exponent of code */ - const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ - Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ - Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ - Word16 *prev_state, /* i/o: static memory Q0 */ - Word16 L_subfr /* i : subframe length [40,64] */ - ); - - void tcx_ltp_get_lpc( - Word16 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word16 *A, /* Qx */ - const Word16 order /* Q0 */ - ); - - void tcx_ltp_get_lpc_fx( - Word32 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word32 *A, /* Qx */ - const Word16 order /* Q0 */ - ); - - void predict_signal( - const Word16 excI[], /* i : input excitation buffer Qx*/ - Word16 excO[], /* o : output excitation buffer Qx*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i : fraction of lag Q0*/ - const Word16 frac_max, /* i : max fraction Q0*/ - const Word16 L_subfr /* i : subframe size Q0*/ - ); - - Word16 tcx_ltp_decode_params( - Word16 *ltp_param, /* Q0 */ - Word16 *pitch_int, /* Q0 */ - Word16 *pitch_fr, /* Q0 */ - Word16 *gain, /* Q13 */ - const Word16 pitmin, /* Q0 */ - const Word16 pitfr1, /* Q0 */ - const Word16 pitfr2, /* Q0 */ - const Word16 pitmax, /* Q0 */ - const Word16 pitres /* Q0 */ - ); - - void tcx_ltp_post_fx( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word16 *sig, /* Qx */ - Word16 *tcx_buf /* Qx */ - ); - - void tcx_ltp_post_fx32( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word32 *sig, /* sig_q */ - Word32 *tcx_buf, /* sig_q */ - Word16 sig_q ); - - void Inac_switch_ematch_fx( - Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ - Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ - const Word16 coder_type, /* i : Coding mode */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 L_frame, /* i : Frame lenght */ - const Word16 Q_exc, /* i : input and output format of exc2 */ - const Word16 bfi, /* i : frame lost indicator */ - const Word16 last_core, /* i : Last core used */ - const Word16 last_codec_mode, /* i : Last codec mode */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 element_mode /* i : element mode */ - ); - - /**< out: Q0 | multiplication factor */ - Word16 IGF_ApplyTransFac( - const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ - const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ - ); - - Word16 IGF_MapBitRateToIndex( - const Word32 brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void IGFCommonFuncsCalcSfbEnergyPowerSpec( - const Word16 startSfb, /**< in: Q0 | start sfb index */ - const Word16 stopSfb, /**< in: Q0 | stop sfb index */ - const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ - Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ - Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ - Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ - Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ - ); - - void IGFCommonFuncsMDCTSquareSpec( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ - ); - - void IGFCommonFuncsMDCTSquareSpec_ivas( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ - ); - - Word16 IGFCommonFuncsIGFConfiguration( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - Word16 IGFCommonFuncsIGFGetCFTables_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ - const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ - Word16 *cf_off_se01, /* o : offset for CF table above */ - const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ - const Word16 **cf_off_se02, /* o : offsets for CF tables above */ - const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ - Word16 *cf_off_se10, /* o : offset for CF table above */ - const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ - const Word16 **cf_off_se11 /* o : offsets for CF tables above */ - ); - - Word32 L_multi31x16_X2( - Word16 xh, - Word16 xl, - Word16 y ); - - Word32 mul_sbc_14bits( - Word32 r, /* Q0 */ - Word16 c /* Q0 */ - ); - - void ham_cos_window( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - - void ham_cos_window_ivas( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - - /* o: Q31 */ - Word32 expfp( - const Word16 x, /* i: mantissa Q-e */ - const Word16 x_e ); /* i: exponent Q0 */ - - void powfp_odd2( - const Word16 base, /* Q15 */ - const Word16 exp, /* Q0 */ - Word16 *pout1, /* Q15 */ - Word16 *pout2 ); /* Q15 */ - - void tcx_arith_scale_envelope( - const Word16 L_spec_core, /* i: number of lines to scale Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - const Word32 env[], /* i: unscaled envelope Q16 */ - Word16 target_bits, /* i: number of available bits Q0 */ - const Word16 low_complexity, /* i: low-complexity flag Q0 */ - Word16 s_env[], /* o: scaled envelope Q15-e */ - Word16 *s_env_e /* o: scaled envelope exponent Q0 */ - ); - - void tcx_arith_render_envelope( - const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i: number of spectral lines Q0*/ - const Word16 L_spec, /* Q0 */ - const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o: shaped signal envelope Q16*/ - ); - - /* returns innovation gain Q16 */ - Word32 calc_gain_inov( - const Word16 *code, /* i : algebraic excitation Q9 */ - const Word16 lcode, /* i : Subframe size Q0 */ - Word32 *dotp, /* o : intermediate result Q31-e */ - Word16 *dotp_e /* o : intermediate result exponent Q0 */ - ); - - /////////////////////////////////// - /* Lib_dec */ - ////////////////////////////////// - - void ResetSHBbuffer_Dec_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl /* i : BWE extension layer */ - ); - - void wb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ - Word16 *Q_synth ); - - void swb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ - Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ - Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ - Word16 *Q_white_exc, - Word16 *synth, /* o : SHB synthesis/final synthesis */ - Word16 *Q_synth, - Word16 *pitch_buf ); - - void ivas_dequantizeSHBparams_fx_9_1( - Decoder_State *st_fx, - const Word16 extl, /* i : extension layer */ - Word32 extl_brate, /* i : extensiuon layer bitrate */ - Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ - Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ - Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ - Word16 *uv_flag, /* o : unvoiced flag*/ - Word32 *Q_shb_ener_sf, /* o : Q15 */ - Word16 *Q_shb_res_gshape, /* o : Q14 */ - Word16 *Q_mixFactors, /* o : Q15 */ - Word16 *MSFlag ); - - void fb_tbe_dec_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word16 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp ); - - void fb_tbe_dec_ivas_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word32 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp, - Word16 *fb_synth_ref, - Word16 Q_fb_synth_ref, - Word16 output_frame ); - - void tbe_read_bitstream_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ - ); - - void GenTransition_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 rf_flag, /* i : RF flag */ - Word32 total_bitrate /* i : total bitrate */ - ); - - void GenTransition_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 prev_Qx ); - - void GenTransition_WB_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output, /* o : synthesized transitions signal */ - const Word32 output_Fs /* i : output sampling rate */ - ); - - void GenTransition_WB_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ - ); - - void TBEreset_dec_fx( - Decoder_State *st_fx /* i/o: decoder state structure */ - ); - - void td_bwe_dec_init_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl, /* i : BWE extension layer */ - const Word32 output_Fs /* i : output sampling rate */ - ); - - void lsf_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ - ); - - /*! r: index of the maximum value in the input vector */ - Word16 maximum_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /*! r: index of the minimum value in the input vector */ - Word16 minimum_l( - const Word32 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word32 *min_val /* o : minimum value in the input vector */ - ); - - void v_multc_fx( - const Word32 x[], /* i : Input vector */ - const Word32 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_fx_16( - const Word32 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_fx_16_16( - const Word16 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word16 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ - ); - - void v_add_fx_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_add_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_add_fx_me( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x1_e, /* i : Exponent for input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - const Word16 x2_e, /* i : Exponent for input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 *y_e, /* i : Exponent for output vector */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_add_w64( - const Word64 x1[], /* i : Input vector 1 */ - const Word64 x2[], /* i : Input vector 2 */ - Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_sub_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_sub_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - /*! r: dot product of x[] and y[] */ - Word32 dotp_fx32( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ - ); - - /*! r: dot product of x[] and y[] in case of overflow*/ - Word32 dotp_fx32_o( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q ); - - Word32 dotp_fx32_fac( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q /*stores resultant Q*/ - ); - - Word32 dotp_fx_ivas_fx( - const Word32 x[], /* i : vector x[] */ - Word16 x_e, - const Word32 y[], /* i : vector y[] */ - Word16 y_e, - const Word16 n, /* i : vector length */ - Word16 *out_e ); - - Word32 dotp_fx_guarded( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ - ); - - Word32 dotp_me_fx( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 exp_x, - Word16 exp_y, - Word16 *exp_suma ); - - void lsf_end_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 mode2_flag, /* Q0 */ - const Word16 coder_type_org, /* i : coding type Q0*/ - const Word16 bwidth, /* i : input signal bandwidth Q0*/ - const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ - Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ - Word16 *lpc_param, /* i : LPC parameters Q0*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices, /* o : number of indices Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ - ); - - void lsf_mid_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ - Word16 coder_type, /* i : Coder type Q0*/ - Word16 lsp_mid[] /* o : quantized LSPs Q15*/ - ); - - void CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ - Word16 Aq[], /* o : LP coefficients Q12 */ - Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ - Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ - Word32 *q_env ); - - void swb_CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ - ); - - void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ - ); - - void td_cng_dec_init_fx( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ - ); - - void set_state( - Word16 *state, - Word16 num, - Word16 N ); - - void concealment_init_x( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - - void concealment_init_ivas_fx( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - - void concealment_update_x( - const Word16 bfi, - const Word16 core, - const Word16 tonality, - Word32 *invkoef /*Qinvkoef_scale*/, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - - Word16 Sqrt_x_fast( - Word32 value ); - - Word32 dot_w32_accuracy_x( - Word16 *s1, - Word16 *s2, - Word16 nbits, - Word16 N ); - - Word16 int_div_s_x( - Word16 a, - Word16 b ); - - Word16 GetW32Norm_x( - Word32 *s, - Word16 N ); - - Word16 harmo_x( - Word32 *X, - Word16 Framesize, - Word16 pitch ); - - void LpFilter2_x( - Word16 *x, - Word16 *y, - Word16 N ); - - void sig_tilt_x( - Word16 *s, - Word16 FrameSize, - Word32 *enr1, - Word32 *enr2 ); - - void get_maxConv_and_pitch_x( - Word16 *s_LP, - Word16 s, - Word16 e, - Word16 N, - Word32 *maxConv, - Word16 *maxConv_bits, - Word16 *pitch ); - - Word16 get_voicing_x( - Word16 *s_LP, - Word16 pitch, - Word32 covMax, - Word16 maxConv_bits, - Word16 Framesize ); - - void pitch_modify_x( - Word16 *s_LP, - Word16 *voicing, - Word16 *pitch, - Word16 FrameSize ); - - Word16 Is_Periodic_x( - Word32 *mdct_data, - Word16 cov_max, - Word16 zp, - Word32 ener, - Word32 ener_mean, - Word16 pitch, - Word16 Framesize ); - - Word16 get_conv_relation_x( - Word16 *s_LP, - Word16 shift, - Word16 N ); - - void concealment_decode_fix( - Word16 curr_mode, - Word32 *invkoef, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - - Word32 Spl_Energy_x( - const Word16 *vector, - const Word16 vector_length, - Word16 *scale_factor ); - - void Log10OfEnergy_x( - const Word16 *s, - Word32 *enerlogval, - const Word16 len ); - - void concealment_update2_x( - const Word16 *outx_new, - T_PLCInfo_HANDLE hPlcInfo, - const Word16 FrameSize ); - - Word16 ffr_getSfWord16( - Word16 *vector, /*!< Pointer to i vector */ - Word16 len ); - - void waveform_adj2_fix( - T_PLCInfo_HANDLE hPlcInfo, - Word16 *overlapbuf, - Word16 *outx_new, - const Word16 delay, - const Word16 bfi_cnt, - const Word16 bfi ); - - void concealment_signal_tuning_fx( - Decoder_State *st, - const Word16 bfi, - Word16 *outx_new_fx /*Qoutx_new_fx*/, - const Word16 past_core ); - - void DetectTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - - void RefineTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - - void ivas_RefineTonalComponents_fx( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 secondLastPowerSpectrum_e, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode, - const PsychoacousticParameters *psychParamsCurrent ); - - ivas_error PsychoacousticParameters_Init( - const Word32 sr_core, /* i : sampling rate of core-coder */ - const Word16 nBins, /* i : Number of bins (spectral lines) */ - const Word8 nBands, /* i : Number of spectrum subbands */ - const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ - const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ - PsychoacousticParameters *pPsychParams ); - - ivas_error TonalMDCTConceal_Init( - TonalMDCTConcealPtr self, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ - ); - - ivas_error TonalMDCTConceal_Init_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const UWord16 nSamples, - const UWord16 nSamplesCore, - const UWord16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ - ); - - /* Must be called only when a good frame is recieved - concealment is inactive */ - void TonalMDCTConceal_SaveFreqSignal( - TonalMDCTConcealPtr self, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - Word16 nNewSamples, - Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp ); - - void TonalMDCTConceal_SaveFreqSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - const Word16 nNewSamples, - const Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp, - const Word16 infoIGFStartLine ); - - void TonalMDCTConceal_UpdateState( - TonalMDCTConcealPtr self, - Word16 nNewSamples, - Word32 pitchLag, - Word16 badBlock, - Word8 tonalConcealmentActive ); - - void TonalMDCTConceal_Detect( - const TonalMDCTConcealPtr self, /*IN */ - const Word32 pitchLag, /*IN */ - Word16 *umIndices, /*OUT*/ - Word16 element_mode /* IN */ - ); - - void TonalMDCTConceal_Apply( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 *mdctSpectrum_exp /*IN */ - ); - - void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 mdctSpectrum_exp, /*IN */ - const PsychoacousticParameters *psychParamsCurrent ); - - void TonalMDCTConceal_InsertNoise_ivas_fx( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, - Word16 *mdctSpectrum_exp, - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - const Word16 crossfadeGain, - const Word32 concealment_noise[L_FRAME48k], - const Word16 concealment_noise_e, - const Word32 cngLevelBackgroundTrace_bfi, - const Word16 cngLevelBackgroundTrace_e, - const Word16 crossOverFreq ); - - void TonalMDCTConceal_InsertNoise( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*OUT*/ - Word16 *mdctSpectrum_exp, /*OUT*/ - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - Word16 crossfadeGain, - const Word16 crossOverFreq ); - - void TonalMDCTConceal_SaveTimeSignal( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 nNewSamples ); - - void TonalMDCTConceal_SaveTimeSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 q_timeSignal, - Word16 nNewSamples ); - - void decision_matrix_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ - Word16 *hq_core_type, /* o : HQ core type Q0 */ - Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ - ); - - void hf_synth_init_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ - ); - - void hf_synth_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ - ); - - void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ - ); - - void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ - ); - - void hf_synth_amr_wb_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ - ); - - void hf_synth_amr_wb_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ - ); - - void hf_synth_amr_wb_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az : Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ - Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ - Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ - Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ - Word16 fmerit, /* i : classify parameter from FEC : Q14*/ - const Word16 *hf_gain, /* i : decoded HF gain Q0*/ - const Word16 *voice_factors, /* i : voicing factors : Q15*/ - const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ - const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ - const Word16 *lsf_new, /* i : ISF vector : Q2*/ - const Word16 Q_exc, /* i : exc scaling */ - const Word16 Q_out /* i : Q_syn2-1 */ - ); - - void Init_post_filter_fx( - PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ - ); /* i : core decoder parameters */ - - void nb_post_filt_fx( - const Word16 L_frame, /* i : frame length */ - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *psf_lp_noise, /* i : Long term noise Q8 */ - const Word16 tmp_noise, /* i : noise energy Q0 */ - Word16 *Synth, /* i : 12k8 synthesis Qsyn */ - const Word16 *Aq, /* i : LP filter coefficient Q12 */ - const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ - const Word16 coder_type, /* i : coder_type */ - const Word16 BER_detect, /* i : BER detect flag */ - const Word16 disable_hpf /* i : flag to diabled HPF */ - ); - - void formant_post_filt_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient Q12 */ - Word16 *synth_out, /* i/o: input signal */ - const Word16 L_frame, /* i : frame length */ - const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - const Word32 brate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ - ); - - void Filt_mu_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr /* i : the length of subframe */ - ); - - void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ); - - void scale_st_fx( - const Word16 *sig_in, /* i : postfilter i signal */ - Word16 *sig_out, /* i/o: postfilter o signal */ - Word16 *gain_prec, /* i/o: last value of gain for subframe */ - Word16 L_subfr ); - - void blend_subfr2_fx( - Word16 *sigIn1, /* i : i signal for fade-out */ - Word16 *sigIn2, /* i : i signal for fade-in */ - Word16 *sigOut /* o : output signal */ - ); - - void init_tcx_window_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ - const Word32 sr_core, /* i : SR core */ - const Word32 input_Fs, /* i : input/output SR */ - const Word16 L_frame, /* i : L_frame at sr_core */ - const Word16 L_frameTCX, /* i : L_frame at i/o SR */ - const Word16 mdctWindowLength, /* i : window length at sr_core */ - const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ - const Word16 element_mode /* i : mode of CPE/SCE */ - ); - - void init_tcx_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, /*Q15*/ - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, - const Word16 fscaleFB ); - - void syn_output_fx( - const Word16 codec_mode, /* i : MODE1 or MODE2 */ - Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ - const Word16 output_frame, /* i : output frame length */ - Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ - const Word16 Q_syn2 /* i : Synthesis scaling factor */ - ); - - void unscale_AGC( - const Word16 x[], /* i: 16kHz synthesis Qx */ - const Word16 Qx, /* i: scale factor of x */ - Word16 y[], /* o: output vector Q0 */ - Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ - const Word16 n /* i: vector size */ - ); - - void bass_psfilter_init_fx( - BPF_DEC_HANDLE hBPF /* o : BPF data handle */ - ); - - void bass_psfilter_fx( - BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ - const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ - Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ - const Word16 L_frame, /* i : length of the last frame Q0*/ - Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ - const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ - Word16 v_stab_fx, /* i : stability factor Q15*/ - Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ - const Word16 coder_type, /* i : coder_type Q0*/ - Word16 Q_syn, - Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ - ); - - void addBassPostFilter_fx( - const Word16 *harm_timeIn_Fx, /* timeIn_e */ - Word32 **rAnalysis_Fx, /* Qx - 5 */ - Word32 **iAnalysis_Fx, /* Qx - 5 */ - HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, - Word32 *workBuffer, /* Qx */ - const Word16 timeIn_e, - const Word16 nTimeSlots, /* Q0 */ - const Word16 nTimeSlotsTotal, /* Q0 */ - const Word16 nBandsTotal, /* Q0 */ - CLDFB_SCALE_FACTOR *cldfb_scale ); - - void FEC_exc_estim_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* o : pointer to excitation buffer (with past) */ - Word16 *exc2, /* o : total excitation (for synthesis) */ - Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ - Word16 *pitch_buf, /* o : Floating pitch for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *tmp_tc, /* o : FEC pitch Q6 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *Q_exc, - Word16 *tmp_noise /* o : long-term noise energy Q0 */ - ); - - void pitch_pred_linear_fit( - const Word16 bfi_cnt, /* i: bfi counter Q0 */ - const Word16 last_good, /* i: last classification type Q0 */ - Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ - Word32 *old_fpitch, /* i: Q16*/ - Word32 *T0_out, /* o: estimated close loop pitch Q16*/ - Word16 pit_min, /* i: Minimum pitch lag Q0 */ - Word16 pit_max, /* i: Maximum pitch lag Q0 */ - Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ - Word16 limitation, - Word16 plc_use_future_lag, /* i: Q0 */ - Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ - Word16 nb_subfr /* i: number of ACELP subframes */ - ); - - void get_subframe_pitch( - Word16 nSubframes, /* i: number of subframes Q0 */ - Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ - Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ - Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ - ); - - void PulseResynchronization_fx( - Word16 const *const src_exc, /*i Q15*/ - Word16 *const dst_exc, /*o Q15*/ - Word16 const nFrameLength, /*i Q0 */ - Word16 const nSubframes, /*i Q0 */ - Word32 const pitchStart, /*i Q16*/ - Word32 const pitchEnd /*i Q16*/ - ); - - void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ - ); - - void gsc_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ - Word16 *Q_exc ); - - void GSC_dec_init_fx( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ - ); - - void Es_pred_dec_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ - const Word16 enr_idx, /* i : indice */ - const Word16 nb_bits, /* i : number of bits */ - const Word16 no_ltp /* i : no LTP flag */ - ); - - void gain_dec_tc_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ - ); - - void gain_dec_tc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ - ); - - void gain_dec_mless_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ - ); - - void gain_dec_lbr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 *code_fx, /* i : algebraic excitation Q9 */ - Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes */ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ - const Word16 L_subfr /* i : subfr lenght */ - ); - -#ifndef CLEANUP_ACELP_ENC - void lp_gain_updt_fx( - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ - ); -#endif -#ifdef CLEANUP_ACELP_ENC - void lp_gain_updt_fx( - const Word16 element_mode, /* i : element mode */ -#else -void lp_gain_updt_ivas_fx( -#endif - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ - ); - - /*! r: quantized codebook gain Q16 */ - Word32 gain_dec_gaus_fx( - Word16 index, /* i : quantization index */ - const Word16 bits, /* i : number of bits to quantize */ - const Word16 lowBound, /* i : lower bound of quantizer (dB) */ - const Word16 topBound, /* i : upper bound of quantizer (dB) */ - const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ - ); - - void gain_dec_SQ_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 *code, /* i : algebraic code excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ - Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ - ); - - void gain_dec_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - Word16 *gain_pit, /* o : Quantized pitch gain */ - Word32 *gain_code, /* o : Quantized codeebook gain */ - Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ - Word16 *gain_inov, /* o : unscaled innovation gain */ - const Word16 *code, /* i : algebraic code excitation */ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ - ); - - void transf_cdbk_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ - const Word32 gain_code, /* i : innovative excitation gain (Q16) */ - Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ - Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ - Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ - Word16 *unbits /* o : number of AVQ unused bits */ - ); - - /* o: decoded gain */ - Word16 gain_dequant_fx( - Word16 index, /* i: quantization index */ - const Word16 min, /* i: value of lower limit */ - const Word16 max, /* i: value of upper limit */ - const Word16 bits, /* i: number of bits to dequantize */ - Word16 *expg ); - - void AVQ_demuxdec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ - Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ - const Word16 Nsv, /* i : number of subvectors Q0*/ - Word16 nq[], /* i/o: AVQ nq index Q0*/ - Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ - Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ - ); - - void AVQ_dec_lpc( - Word16 *indx, /* input: index[] (4 bits per words) Q0*/ - Word16 *nvecq, /* output: vector quantized Q0*/ - Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ - - void re8_dec_fx( - Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ - const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ - const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ - ); - - void re8_decode_base_index_fx( - const Word16 n, - UWord16 I, - Word16 *x ); - - void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ - ); - - void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ - Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ - ); - - void re8_PPV_fx( - const Word32 x[], /* i : point in R^8 Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ - ); - - void dec_pit_exc_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx, /* i : Number of subframe considered */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ - ); - - /* o: pitch value Q16 */ - Word32 Mode2_pit_decode( - const Word16 coder_type, /* i: coding model */ - Word16 i_subfr, /* i: subframe index */ - Word16 L_subfr, - Word16 **pt_indice, /* i/o: quantization indices pointer */ - Word16 *T0, /* i/o: close loop integer pitch Q0 */ - Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ - Word16 *T0_res, /* i/o: pitch resolution Q0 */ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ - Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr1b, - Word16 pit_fr2, - Word16 pit_max, - Word16 pit_res_max ); - - void Mode2_abs_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 *T0_res, /* o: pitch resolution Q0 */ - Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr2, - Word16 pit_res_max ); - - void Mode2_delta_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 T0_res, /* i: pitch resolution Q0 */ - Word16 *T0_min, /* i: delta search min Q0 */ - Word16 *T0_min_frac, /* i: delta search min Q0 */ - Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ - ); - - /* o : floating pitch value */ - Word16 pit_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ - ); - - void pit_Q_dec_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 delta, /* i : Half the CL searched interval */ - const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ - ); - - void pit16k_Q_dec_fx( - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ - ); - - void abs_pit_dec_fx( - const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ - Word16 pitch_index, /* i: pitch index */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o: integer pitch lag */ - Word16 *T0_frac /* o: pitch fraction */ - ); - - void delta_pit_dec_fx( - const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - const Word16 pitch_index, /* i : pitch index */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - const Word16 T0_min /* i : delta search min */ - ); - - void limit_T0_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 delta, /* i : Half the close-loop searched interval */ - const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_max /* o : higher pitch limit */ - ); - - void limit_T0_voiced( - const Word16 nbits, - const Word16 res, - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - const Word16 T0_res, /* i : pitch resolution */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_min_frac, /* o : lower pitch limit */ - Word16 *T0_max, /* o : higher pitch limit */ - Word16 *T0_max_frac, /* o : higher pitch limit */ - const Word16 pit_min, /* i : Minimum pitch lag */ - const Word16 pit_max /* i : Maximum pitch lag */ - ); - - void inov_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ - ); - - void inov_decode_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ - ); - - void dec_acelp_4t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 nbbits, /* i : number of bits per codebook */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - const Word16 Opt_AMR_WB ); - - void D_ACELP_decode_43bit_fx( - UWord16 idxs[], - Word16 code[], - Word16 *pulsestrack ); - - void D_ACELP_indexing_fx( - Word16 code[], - PulseConfig config, - Word16 num_tracks, - Word16 index[], - Word16 *BER_detect ); - - void fcb_pulse_track_joint_decode_fx( - UWord16 *idxs, - Word16 wordcnt, - UWord32 *index_n, - Word16 *pulse_num, - Word16 track_num ); - - void dec_acelp_2t32_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[] /* o: algebraic (fixed) codebook excitation */ - ); - - void dec_acelp_1t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ - const Word16 L_subfr /* i : sub frame lenght*/ - ); - - ivas_error acelp_core_switch_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ - Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ - const Word16 output_frame, /* i : input frame length */ - const Word16 core_switching_flag, /* i : core switching flag */ - Word16 *mem_synth, /* o : synthesis to overlap */ - Word16 *Q_syn ); - - ivas_error acelp_core_switch_dec_bfi_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ - ); - - ivas_error acelp_core_switch_dec_bfi_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ - ); - - void pred_lt4( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ - ); - - void pred_lt4_ivas_fx( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word32 *win, /* i : interpolation window Q31*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ - ); - - void pred_lt4_tc_fx( - Word16 exc[], /* i/o: excitation buffer Q0*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i: fraction of lag Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 imp_pos, /* i : glottal impulse position Q0*/ - const Word16 i_subfr /* i : subframe index Q0*/ - ); - - void pvq_decode_frame_fx( - Decoder_State *st_fx, - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ - ); - - Word16 pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - - Word16 ivas_pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, /* Q3 */ - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - - void decode_energies_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 Np, - Word16 *dim_part, - Word16 *bits_part, - Word16 *g_part, /* Q15 */ - Word16 qband, - Word16 *bits_left, - Word16 dim, - const Word16 strict_bits ); - - void rc_dec_init_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 tot_bits /* i : Total bit budget */ - ); - - /* o : Decoded cumulative frequency */ - UWord32 rc_decode_fx( - Word16 *BER_detect, /* o : Bit error detection flag */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Total cumulative frequency */ - ); - - void rc_dec_update_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - - UWord32 cum_freq, /* i : Cumulative frequency */ - UWord32 sym_freq /* i : Symbol frequency */ - ); - - /* o : Decoded value */ - Word32 rc_dec_bits_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 bits /* i : Number of bits */ - ); - - /* o : Decoded value */ - UWord32 rc_dec_uniform_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Maximum value */ - ); - - void rc_dec_finish_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ - ); - - void pvq_decode_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 *xq, /* o: decoded vector (Q15) */ - Word16 *y, /* o: decoded vector (non-scaled int) */ - const Word16 k_val, /* i: number of allocated pulses */ - const Word16 dim, /* i: Length of vector */ - const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ - ); - void nelp_decoder_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ - Word16 *exc, /* o : adapt. excitation exc Q_exc */ - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate Q0 */ - const Word16 coder_type, /* i : coding type Q0 */ - Word16 *gain_buf /* Q14 */ - ); - - void decod_nelp_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ - Word16 *exc_fx, /* o : adapt. excitation exc */ - Word16 *exc2_fx, /* o : adapt. excitation/total exc */ - Word16 *voice_factors, /* o : Voice factor */ - Word16 *bwe_exc, - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate */ - Word16 *gain_buf /*Q14*/ - ); - - void lp_filt_exc_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 codec_mode, /* i : coder mode */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 L_subfr, /* i : subframe size */ - const Word16 L_frame, /* i : frame size */ - Word16 lp_flag, /* i : operation mode signalling */ - Word16 *exc ); - - void FEC_lsf2lsp_interp( - Decoder_State *st, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *Aq, /* o : calculated A(z) for 4 subframes */ - Word16 *lsf, /* o : estimated LSF vector */ - Word16 *lsp /* o : estimated LSP vector */ - ); - - ivas_error createFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - - void initFdCngDec_fx( - DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - const Word16 scale ); - - /* Delete the instance of type FD_CNG */ - void deleteFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - - /* Configure CLDFB-CNG */ - void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ - Word16 bandwidth, - Word32 bitrate, - Word16 L_frame, - const Word16 Last_L_frame, - const Word16 element_mode ); - - Word16 ApplyFdCng_fx( - Word16 *timeDomainInput, /* i : pointer to time domain input */ - Word16 Q, - Word32 *powerSpectrum, - Word16 Q_power_spectrum, - Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ - Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ - Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ - Decoder_State *st, - const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ - Word16 is_music ); - - /* Perform noise estimation */ - void perform_noise_estimation_dec_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain i */ - const Word16 Q, - HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - void perform_noise_estimation_dec_ivas_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain input */ - const Word16 Q, - Word32 *power_spectrum, - Word16 Q_power_spectrum, - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - const Word16 VAD /* i : VAD flag in the decoder */ - ); - - /* Decode the CLDFB-CNG bitstream */ - void FdCng_decodeSID_fx( - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Decoder_State *corest ); /* i/o: decoder state structure */ - - void noisy_speech_detection_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ - const Word16 vad, /* i : VAD flag */ - const Word16 *syn, /* i : i time-domain frame */ - const Word16 Q ); - - void generate_comfort_noise_dec_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ - ); - - void generate_comfort_noise_dec_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ - ); - - void generate_comfort_noise_dec_hf_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec ); - - void generate_comfort_noise_dec_hf_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of input bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ - ); - - /* Generate the comfort noise based on the target noise level */ - void generate_masking_noise_fx( - Word16 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 Q, - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 length, - Word16 core ); - - void generate_masking_noise_update_seed_fx( - HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ - ); - - void generate_masking_noise_mdct_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 L_frame ); - - void generate_masking_noise_mdct_ivas_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); - - ivas_error init_decoder_fx( - Decoder_State *st_fx, /* o : Decoder static variables structure */ - const Word16 idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ - ); - - void reset_preecho_dec_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ - ); - - void destroy_cldfb_decoder_fx( - Decoder_State *st_fx /* o: Decoder static variables structure */ - ); - - void destroy_cldfb_encoder_fx( - Encoder_State *st /* i/o: state structure */ - ); - - Word16 WB_BWE_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *WB_fenv /*Q15*/ - ); - - Word16 wb_bwe_dec_fx( - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *Qpost ); - - /* o : BWE class */ - Word16 swb_bwe_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 core, /* i : core */ - Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ - Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ - const Word16 hr_flag, /* i : high rate flag */ - const Word16 hqswb_clas /* i : HQ BWE class */ - ); - - /*o :Q_syn_hb*/ - Word16 swb_bwe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *Qpost ); - - void fd_bwe_dec_init( - Decoder_State *st_fx, /* i/o: decoder state structure */ - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ - ); - - void hq_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *audio_fx, /* i : input audio signal Q0 */ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ - ); - - void hq_core_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word16 synth[], /* o : output synthesis Q_synth*/ - Word16 *Q_synth, /* o : Q value of synth */ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ - ); - - void HQ_core_dec_init_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ - ); - - void HQ_nbfec_init_fx( - HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ - ); - - - void hq_ecu_fx( - const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ - Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ - Word16 *time_offs, - Word16 *X_sav, - Word16 *Q_spec, /* i/o : Q value of stored spectrum */ - Word16 *num_p, - Word16 *plocs, - Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ - const Word16 env_stab, - Word16 *last_fec, - const Word16 ph_ecu_HqVoicing, - Word16 *ph_ecu_active, /* i : Phase ECU active flag */ - Word16 *gapsynth, - const Word16 prev_bfi, /* i : indicating burst frame error */ - const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ - Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ - Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ - Word16 *beta_mute, /* o : Factor for long-term mute */ - const Word16 output_frame, /* i : frame length */ - Decoder_State *st_fx /* i/o: decoder state structure */ - ); - - void hq_lr_dec_fx( - Decoder_State *st_fx, /* i/o: : decoder state structure */ - Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ - const Word16 inner_frame, /* i : Q0 : inner frame length */ - Word16 num_bits, /* i : Q0 : number of available bits */ - Word16 *is_transient_fx /* o : Q0 : transient flag */ - ); - - /* o : Number of bits Q0*/ - Word16 decode_envelope_indices_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : starting band index Q0*/ - const Word16 num_sfm, /* i : Number of subbands Q0*/ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ - Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ - ); - - void dequantize_norms_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : First SDE encoded norm Q0*/ - const Word16 num_sfm, /* i : Number of norms Q0*/ - const Word16 is_transient, /* i : Transient flag Q0*/ - Word16 *ynrm, /* o : Decoded norm indices Q0*/ - Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ - ); - - void hdecnrm_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* (i) number of norms Q0*/ - Word16 *index ); /* (o) indices of quantized norms Q0*/ - - Word16 decode_huff_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *hufftab, - Word16 *rbits ); - - void hdecnrm_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* Q0 */ - Word16 *index, /* Q0 */ - Word16 *n_length /* Q0 */ - ); - - void hdecnrm_resize_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs Q0*/ - Word16 *index /* (o) norm quantization index vector Q0*/ - ); - - void huff_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : Number of codewords to decode Q0*/ - const Word16 buffer_len, /* i : Number of bits to read Q0*/ - const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ - const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ - const Word16 *offset, /* i : Offset for first codeword Q0*/ - const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ - Word16 *index /* o : Decoded index Q0*/ - ); - - void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms Q0*/ - Word16 *index /* o : indices of quantized norms Q0*/ - ); - - void tcq_core_LR_dec_fx( - Decoder_State *st_fx, - Word16 *inp_vector_fx, /*x5 */ - const Word16 bit_budget, /*Q0 */ - const Word16 BANDS, /*Q0 */ - const Word16 *band_start, /*Q0 */ - const Word16 *band_width, /*Q0 */ - Word32 *Rk_fx, /*Q16*/ - Word16 *npulses, /*Q0 */ - Word16 *k_sort, /*Q0 */ - const Word16 *p2a_flags, /*Q0 */ - const Word16 p2a_bands, /*Q0 */ - const Word16 *last_bitalloc, /*Q0 */ - const Word16 input_frame, /*Q0 */ - const Word16 adjustFlag, /*Q0 */ - const Word16 *is_transient /*Q0 */ - ); - - void HQ_FEC_processing_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ - Word16 is_transient, /* i : Old flag for transient */ - Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ - Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ - Word16 num_Sb, /* i : Number of sub-band group */ - Word16 nb_sfm, /* i : Number of sub-band */ - Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ - Word16 output_frame, /* i : Frame size */ - const Word16 *sfm_start, /* i : Start of bands */ - const Word16 *sfm_end /* i : End of bands */ - ); - - void HQ_FEC_Mem_update_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /*Q12*/ - Word32 *normq_fx, /*Q14*/ - Word16 *ynrm, - Word16 *Num_bands_p, - Word16 is_transient, - Word16 hqswb_clas, - Word16 c_switching_flag, - Word16 nb_sfm, - Word16 num_Sb, - Word16 *mean_en_high_fx, /*Q5*/ - Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - Word16 output_frame ); - - void time_domain_FEC_HQ_fx( - Decoder_State *st_fx, /* i : Decoder State */ - Word32 *wtda_audio_fx, /* i : i */ - Word16 *out_fx, /* o : output audio */ - Word16 mean_en_high_fx, /* i : transient flag */ - const Word16 output_frame, - Word16 *Q_synth ); - - void hq_pred_hb_bws_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *ynrm, /* i : norm quantization index vector Q0*/ - const Word16 length, /* i : frame length Q0*/ - const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ - const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ - ); - - void hq_hr_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ - const Word16 length, /* i : frame length Q0 */ - Word16 num_bits, /* i : number of available bits Q0 */ - Word16 *ynrm, /* o : norm quantization index vector Q0 */ - Word16 *is_transient, /* o : transient flag Q0 */ - Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ - Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ - const Word16 core_switching_flag /* i : Core switching flag Q1 */ - ); - - /* o : Consumed bits */ - Word16 hq_classifier_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : Core bit rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - Word16 *is_transient, /* o : Transient flag Q0 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ - ); - - void hvq_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 num_bits, /* i : Number of available bits */ - const Word32 core_brate, /* i : Core bit-rate */ - const Word16 *ynrm, /* i : Envelope coefficients Q0 */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *noise_level, /* o : Noise level in Q15 */ - Word16 *peak_idx, /* o : Peak position vector */ - Word16 *Npeaks, /* o : Total number of peaks */ - Word32 *coefsq_norm, /* o : Output vector in Q12 */ - const Word16 core ); - - Word16 hvq_pvq_bitalloc_fx( - Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ - const Word32 brate, /* i : bitrate */ - const Word16 bwidth_fx, /* i : Encoded bandwidth */ - const Word16 *ynrm, /* i : Envelope coefficients */ - const Word32 manE_peak, /* i : Peak energy mantissa */ - const Word16 expE_peak, /* i : Peak energy exponent */ - Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ - Word16 *R, /* Q0 i/o: Global bit allocation */ - Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ - Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ - ); - - void hq_configure_bfi_fx( - Word16 *nb_sfm, /* o : Number of sub bands Q0*/ - Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ - Word16 *num_bands_p, /* o : FEC sub bands Q0*/ - const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ - const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ - const Word16 **sfm_end /* o : Subband end coefficients Q0*/ - ); - - void bandwidth_switching_detect_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ - ); - - void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ - ); - - void bw_switching_pre_proc_fx( - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ - ); - - ivas_error core_switching_pre_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ - ); - - ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ - ); - - ivas_error core_switching_post_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ - const Word16 nchan_out, /* i : number of output channels Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ - ); - - void core_switching_hq_prepare_dec_fx( - Decoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 output_frame /* i : output frame length Q0*/ - ); - - ivas_error amr_wb_dec_fx( - Word16 output_sp[], /* o : synthesis output */ - Decoder_State *st_fx /* o : Decoder static variables structure */ - ); - - void amr_wb_dec_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ - ); - - void updt_dec_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 *old_exc_fx, /* i : buffer of excitation */ - const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ - const Word16 Es_pred, /* i : predicited scaled innovation energy */ - const Word16 *Aq, /* i : A(z) quantized for all subframes */ - const Word16 *lsf_new_fx, /* i : current frame LSF vector */ - const Word16 *lsp_new_fx, /* i : current frame LSP vector */ - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ - const Word16 *gain_buf /*Q14*/ - ); - - void updt_IO_switch_dec_fx( - const Word16 output_frame, /* i : output frame length */ - Decoder_State *st_fx /* o : Decoder static variables structure */ - ); - - void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost ); - - void updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ - ); - - void update_decoder_LPD_cng( - Decoder_State *st, - Word16 coder_type, - Word16 *timeDomainBuffer, - Word16 *A, - Word16 *bpf_noise_buf ); - - void FEC_clas_estim_fx( - Decoder_State *st_fx, /* i/o: decoder state handle */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ - const Word16 L_frame, /* i : length of the frame */ - Word16 *clas, /* i/o: frame classification */ - const Word16 coder_type, /* i : coder type */ - const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ - Word16 *syn, /* i : synthesis buffer */ - Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ - Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ - Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ - Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ - Word16 *Last_ener, /* i/o: last_energy frame A*/ - Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ - Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ - Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ - Word16 Q_syn, /* i : Synthesis scaling */ - Word16 *class_para, /* o : classification para. fmerit1 A*/ - Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ - Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ - Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ - Word16 mode, /* i : signal classifier mode B*/ - Word16 bfi, /* i : bad frame indicator B*/ - Word32 last_core_brate, /* i : bitrate of previous frame */ - const Word16 FEC_mode /* i : ACELP FEC mode */ - ); - - Word16 FEC_pos_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ - Word32 *enr_q, /* o : decoded energy in Q0 */ - const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ - ); - - void post_decoder( - Decoder_State *st, - Word16 synth_buf[], /* Q0 */ - Word16 pit_gain[], /* Q14 */ - Word16 pitch[], /* Q0 */ - Word16 signal_out[], /* Q0 */ - Word16 *bpf_noise_buf /* Q0 */ - ); - - void post_decoder_ivas_fx( - Decoder_State *st, - Word16 synth_buf[], // Q0 - Word16 pit_gain[], // Q14 - Word16 pitch[], // Q0 - Word16 signal_out[], // Q0 - Word16 *bpf_noise_buf // Q0 - ); - - void cldfb_synth_set_bandsToZero( - Decoder_State *st, - Word32 **rAnalysis, - Word32 **iAnalysis, - const Word16 nTimeSlots, - const CLDFB_SCALE_FACTOR scaleFactor ); - - void FEC_pitch_estim_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 last_core, /* i : last core */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 clas, /* i : current frame classification */ - const Word16 last_good, /* i : last good clas information */ - const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ - const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ - Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ - Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ - Word16 *upd_cnt, /* i/o: update counter */ - const Word16 coder_type, /* i : coder_type */ - Word16 element_mode /* i : element mode */ - ); - - void FEC_scale_syn_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ - Word16 clas, /* i/o: frame classification */ - const Word16 last_good, /* i: last good frame classification */ - Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ - const Word16 *pitch, /* i: pitch values for each subframe */ - Word32 L_enr_old, /* i: energy at the end of previous frame */ - Word32 L_enr_q, /* i: transmitted energy for current frame */ - const Word16 coder_type, /* i: coder type */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ - Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ - Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ - const Word16 bfi, /* i: current frame BFI */ - const Word32 total_brate, /* i: total bitrate */ - const Word16 prev_bfi, /* i: previous frame BFI */ - const Word32 last_core_brate, /* i: previous frame core bitrate */ - Word16 *exc, /* i/o: excitation signal without enhancement */ - Word16 *exc2, /* i/o: excitation signal with enhancement */ - Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ - Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ - const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ - Word16 *mem_syn, /* o: initial synthesis filter states */ - Word16 Q_exc, - Word16 Q_syn, - const Word16 element_mode, /* i : element mode */ - const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i : force scaling */ - ); - - void LD_music_post_filter_fx( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const Word16 dtc_in[], /* i : i synthesis Qdct */ - Word16 dtc_out[], /* o : output synthesis Qdct */ - const Word32 core_brate, /* i : core bitrate Q0 */ - Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ - const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ - const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ - ); - - void Prep_music_postP_fx( - Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ - Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ - Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ - const Word16 last_core, /* i : last core */ - const Word16 element_mode, /* i : element mode */ - const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ - Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 *qdct /* o : Scaling factor of dct coefficient */ - ); - - void Post_music_postP_fx( - Word16 dct_buffer_in[], /* i/o: excitation buffer */ - Word16 *exc2, /* i/o: Current excitation to be overwriten */ - const Word16 *mem_tmp, /* i : previous frame synthesis memory */ - Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ - const Word16 *Aq, /* i : LPC filter coefficients */ - Word16 *syn, /* i/o: 12k8 synthesis */ - Word16 *Q_exc, /* i : excitation scaling */ - Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ - Word16 *Q_syn, /* i : Current frame synthesis scaling */ - Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ - const Word16 IsIO, /* i : Flag to indicate IO mode */ - Word16 *mem_deemph, /* i/o: speech deemph filter memory */ - Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ - Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ - Word16 *mem_agc, - PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ - const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ - Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ - ); - - void music_postfilt_init( - MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ - ); - - void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class Q0*/ - const Word16 coder_type, /* i : coder type Q0*/ - const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ - Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ - Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ - const Word16 locattack, /* i : Flag for a detected attack Q0*/ - Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ - Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ - Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ - const Word16 Q_syn, /* i : Synthesis scaling */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ - const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ - const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ - const Word16 last_coder_type /* i : Last coder_type Q0*/ - ); - - void decod_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficients */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ - ); - - void CNG_reset_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ - Word16 *voice_factors /* o : voicing factors Q15*/ - ); - - ivas_error ppp_voiced_decoder_fx( - Decoder_State *st_fx, /* i/o: state structure */ - Word16 *out_fx, /* o : residual signal */ - const Word16 *lpc2_fx, /* i : current frame LPC */ - Word16 *exc_fx, /* i : previous frame excitation */ - Word16 *pitch, /* o : floating pitch values for each subframe */ - Word16 bfi /* i : Frame error rate */ - ); - - void sc_vbr_dec_init( - SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ - ); - - ivas_error ppp_quarter_decoder_fx( - DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ - Word16 prevCW_lag_fx, /* i : Previous lag */ - Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ - Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ - Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ - Word16 bfi, /* i : FER flag */ - Word16 *S_fx, /* i : sine table, Q15 */ - Word16 *C_fx, /* i : cosine table, Q15 */ - DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ - Decoder_State *st_fx ); - - void open_decoder_LPD_fx( - Decoder_State *st, - const Word32 total_brate, /* Q0 */ - const Word16 bwidth /* Q0 */ - ); - - void open_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - - void reset_tcx_overl_buf_fx( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ - ); - - void acelp_plc_mdct_transition_fx( - Decoder_State *st /* i/o: Decoder state */ - ); - - void cldfb_reset_memory_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - void tcxltp_dec_init_fx( - TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ - const Word16 ini_frame, /* Q0 */ - const Word16 last_codec_mode, /* Q0 */ - const Word16 element_mode, /* Q0 */ - const Word16 pit_max, /* Q0 */ - const Word32 sr_core ); /* Q0 */ - - /* o : Exponent of SHB synthesis */ - Word16 swb_bwe_dec_hr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ - const Word16 exp, /* i : Exponent of core synthesis */ - Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ - const Word16 output_frame, /* i : frame length */ - const Word16 unbits, /* i : number of core unused bits */ - const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ - ); - - void hr_bwe_dec_init( - HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ - ); - - void swb_hr_noise_fill_fx( - const Word16 is_transient, /* i : transient flag */ - const Word16 spect_start, /* i : spectrum start point */ - const Word16 spect_end, /* i : spectrum end point */ - const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ - const Word16 pitch, /* i : pitch value Q15 */ - const Word16 nq[], /* i : AVQ nq index */ - Word16 Nsv, /* i : number of subband */ - Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ - Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ - Word16 Q_audio ); - - void stat_noise_uv_dec_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ - Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ - Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ - const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ - ); - - void stat_noise_uv_mod_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ - Word16 *exc2, /* i/o: excitation buffer Q_exc */ - Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q15 */ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : input bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ - ); - - void stat_noise_uv_mod_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q=0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ - Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q=15*/ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : i bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ - ); - - Word16 FEC_SinOnset_fx( - Word16 *exc, /* i/o : exc vector to modify */ - Word16 puls_pos, /* i : last pulse position desired */ - const Word16 T0, /* i : Pitch information of the 1 subfr */ - Word32 enr_q, /* i : energy provide by the encoder */ - Word16 *Aq, /* i : A(z) filter Q12 */ - const Word16 L_frame, /* i : frame length */ - const Word16 Qold ); - - Word16 FEC_enhACB_fx( - const Word16 L_frame, /* i : frame length */ - const Word16 last_L_frame, /* i : frame length of previous frame */ - Word16 *exc_io, /* i/o : adaptive codebook memory */ - const Word16 new_pit, /* i : decoded first frame pitch */ - const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ - const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ - ); - - /*! r: do_WI flag */ - Word16 FEC_synchro_exc_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* i/o: exc vector to modify */ - const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ - const Word16 true_puls_pos, /* i : Present pulse location */ - const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ - ); - - void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ - Word16 *gain_buf ); - - void gaus_dec_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* o : unvoiced excitation Q12 */ - Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ - Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ - Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ - Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ - Word16 *voice_fac, /* o : estimated voicing factor Q15 */ - Word16 *gain_pit, /* o : pitch gain Q14 */ - Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ - Word16 *exc, /* o : excitation signal frame */ - Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ - Word16 *exc2, /* o : Scaled excitation signal frame */ - Word16 *bwe_exc_fx, - Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ - Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ - ); - - void gaus_L2_dec( - Word16 *code, /* o : decoded gaussian codevector Q9 */ - Word16 tilt_code, /* i : tilt of code Q15 */ - const Word16 *A, /* i : quantized LPCs Q12 */ - Word16 formant_enh, /* i : formant enhancement factor Q15 */ - Word16 *seed_acelp /*i/o : random seed Q0 */ - ); - - ivas_error decod_gen_voic_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ - ); - - void decod_tran_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ - Word16 *unbits, /* i/o: number of unused bits */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 *gain_buf /*Q14*/ - ); - - void transition_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *exc, /* o : excitation signal */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - Word16 **pt_pitch, /* o : floating pitch values */ - Word16 *position, /* i/o: first glottal impulse position in frame */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *Q_exc /*i/o : scaling of excitation */ - ); - - Word16 tc_classif_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame /* i : length of the frame */ - ); - - ivas_error decod_ppp_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ - Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ - Word16 *exc_fx, /* i/o: current non-enhanced excitation */ - Word16 *exc2_fx, /* i/o: current enhanced excitation */ - Word16 bfi, /* i : bad frame indicator */ - Word16 *gain_buf, /*Q14*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ - ); - - void swb_bwe_dec_lr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis : QsL */ - const Word16 QsL, /* i : Q value of m_core */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ - Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ - Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ - Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ - const Word16 hqswb_clas_fx, /* i : class information : Q0 */ - Word16 lowlength_fx, /* i : Lowband Length : Q0 */ - Word16 highlength_fx, /* i : Highband Length : Q0 */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ - Word16 *prev_frm_hfe2, /* i/o: : Q0 */ - Word16 *prev_stab_hfe2, /* i/o: : Q0 */ - Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ - const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ - Word16 *ni_seed_fx /* i/o: random seed : QsL */ - ); - - Word16 dec_acelp_tcx_frame_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *concealWholeFrame, /* i/o: concealment flag */ - Word16 *pcmBuf, /* o : synthesis */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 *pcmbufFB, /* o : synthesis @output_FS */ - Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 pitch_buf[] /* o : floating pitch for each subframe */ - ); - - void decoder_LPD_fx( - Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ - Word16 signal_outFB[], /* o : synthesis @output_FS */ - Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ - Decoder_State *st, /* i/o: decoder memory state pointer */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 bfi, /* i : BFI flag */ - Word16 *bitsRead, /* o : number of read bits */ - Word16 param[], /* o : buffer of parameters */ - Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ - ); - - void mode_switch_decoder_LPD_fx( - Decoder_State *st, /* Q0 */ - Word16 bandwidth_in, /* Q0 */ - Word32 bitrate, /* Q0 */ - Word16 frame_size_index /* Q0 */ - ); - - void mode_switch_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ - const Word16 frame_size_index, /* i : index determining the frame size Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - - Word16 DecodeIndex( - Decoder_State *st, - const Word16 Bandwidth, /* o : NB, 1: (S)WB */ - Word16 *PeriodicityIndex ); - - Word16 DecodeIndex_fx( - Decoder_State *st, - const Word16 Bandwidth, - Word16 *PeriodicityIndex ); - - void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ - ); - - Word16 lsf_msvq_ma_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ - ); - - Word16 lsf_bctcvq_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ - ); - - Word16 D_lsf_tcxlpc( - const Word16 indices[], /* i : VQ indices Q0*/ - Word16 lsf_q[], /* o : quantized LSF Q1*/ - Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk, /* i : codebook selector Q0*/ - Word16 mem_MA[] /* i : MA memory Q1*/ - ); - - Word16 dec_lsf_tcxlpc( - Decoder_State *st, /* i/o: Decoder state */ - Word16 **indices, /* o : Ptr to VQ indices Q0*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk /* i : codebook selector Q0*/ - ); - - void midlsf_dec( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 idx, /* i: codebook index */ - Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ - const Word16 coder_type, - Word16 *mid_lsf_int, - const Word16 prev_bfi, - const Word16 safety_net ); - - Word16 lsf_ind_is_active( - const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ - const Word16 means[], /*(14Q1*1.28)*/ - const Word16 narrowband, - const Word16 cdk ); - - void IGFSCFDecoderOpen( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ - H_IGF_INFO hIgfInfo, /* i : IGF info handle */ - const Word32 total_brate, - const Word16 bwidth, - const Word16 element_mode, - const Word16 rf_mode ); - - void IGFSCFDecoderReset( - IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ - ); - - void IGFSCFDecoderDecode( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - Decoder_State *st, /* i/o: pointer to decoder state */ - Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, - if 0 on input the decoder will be forced to encode without a reset */ - ); - - Word32 ari_decode_overflow_fx( - Tastat *s ); - - void ari_start_decoding_14bits_fx( - Decoder_State *st, - Tastat *s ); - - Word16 ari_start_decoding_14bits_prm_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - - Word16 ari_decode_14bits_s17_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - - Word16 ari_decode_14bits_s27_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - - Word16 ari_decode_14bits_bit_ext_fx( - Decoder_State *st, - Tastat *s ); - - Word16 ari_decode_14bits_pow_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - Word16 base ); - - Word16 ari_decode_14bits_sign_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - - void getTCXparam_fx( - Decoder_State *st, /* i/o: Decoder State handle */ - Decoder_State *st0, /* i : bitstream */ - CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - Word16 param[], /* o : decoded parameters Q0 */ - const Word16 bits_common, /* i : number of common bits Q0 */ - const Word16 start_bit_pos, /* i : position of the start bit Q0 */ - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ - Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ - Word16 nTnsBitsTCX10[2], /*Q0*/ - const Word16 pre_past_flag /*Q0*/ - ); - - void dec_prm_fx( - Word16 *coder_type, - Word16 param[], /* (o) : decoded parameters */ - Word16 param_lpc[], /* (o) : LPC parameters */ - Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ - Decoder_State *st, - Word16 L_frame, - Word16 *bitsRead ); - - void getLPCparam_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Word16 param_lpc[], /* o : LTP parameters Q0 */ - Decoder_State *st0, /* i : bitstream */ - const Word16 ch, /* i : channel Q0 */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ - ); - - void UnmapIndex( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word16 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ - ); - - void ConfigureContextHm( - const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ - const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ - const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ - const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ - ); - - Word16 CountIndexBits( - Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ - Word16 PeriodicityIndex /* Q0 */ - ); - - Word32 tcx_hm_render( - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ - ); - - void tcx_hm_modify_envelope( - Word16 gain, /* i: HM gain Q11 */ - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - Word16 L_frame /* i: number of spectral lines Q0 */ - ); - - Word16 ReadTnsData( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - - void ReadTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - - Word16 DecodeTnsData( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - - Word16 DecodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - - void GetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void const *pParameter, - Word16 **pStream, - Word16 *pnSize, - Word16 *pnBits ); - - void GetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, // Q0 - void const *pParameter, // Q0 - Word16 **pStream, // Q0 - Word16 *pnSize, // Q0 - Word16 *pnBits // Q0 - ); - - void EncodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream Q0*/ - Word16 *pnSize, /* o : number of written parameters Q0*/ - Word16 *pnBits /* o : number of written bits Q0*/ - ); - - void SetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - - void SetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - - void WriteToBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - void ReadFromBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - - void ReadFromBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - - void IGFDecReadData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ - ); - - void IGFDecReadLevel( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ - ); - - void IGFDecApplyMono( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ - ); - - void IGFDecApplyMono_ivas( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ - Word16 element_mode /**< in: | IVAS element mode */ - ); - - void IGFDecApplyStereo( - const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ - const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ - Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ - Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ - Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ - Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ - const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 *coreMsMask, - const Word16 restrict_hopsize, - const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping ); - - void IGFDecSetMode( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void IGFDecSetMode_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void IGFDecUpdateInfo( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 igfGridIdx /**< in: | IGF grid index */ - ); - - void IGFDecUpdateInfo_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const Word16 subFrameIdx, /* i : subframe index */ - const Word16 igfGridIdx /* i : IGF grid index */ - ); - - void IGFDecCopyLPCFlatSpectrum( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ - ); - - void IGFDecCopyLPCFlatSpectrum_fx( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ - ); - - void IGFDecStoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ - ); - - void IGFDecRestoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ - ); - - void IGFDecRestoreTCX10SubFrameData_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word16 subFrameIdx /* i : index of subframe */ - ); - - void init_igf_dec( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ - ); - - Word16 dlpc_avq_fx( - Word16 *index, /* (i) Quantization indices */ - Word16 *LSF_Q, /* (o) Quantized LSF vectors */ - Word16 numlpc, /* (i) Number of sets of lpc */ - Word32 sr_core ); - - Word16 decode_lpc_avq_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ - ); - - Word16 decode_lpc_avq_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc, /* o : lpc parameters */ - const Word16 ch, /* i : channel */ - const Word16 element_mode, /* i : element mode */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ - ); - - void vlpc_1st_dec( - Word16 index, /* i : codebook index */ - Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ - - void vlpc_2st_dec( - Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ - Word16 *indx, /* i : index[] (4 bits per words) */ - Word16 mode, /* i : 0=abs, >0=rel */ - Word32 sr_core ); - - void lsf_weight_2st( - const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ - const Word16 mode /* input: operational mode Q0 */ - ); - - /* Returns: index of next coefficient */ - Word16 get_next_coeff_mapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - /* Returns: index of next coefficient */ - Word16 get_next_coeff_unmapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - Word16 update_mixed_context( - Word16 ctx, /* Q0 */ - Word16 a /* Q0 */ - ); - - Word32 update_mixed_context_ivas_fx( - Word32 ctx, /* Q0 */ - Word16 a /* Q0 */ - ); - - typedef Word16 ( *get_next_coeff_function )( - Word16 ii[2], /* i/o: coefficient indexes */ - Word16 *pp, /* o : peak(1)/hole(0) indicator */ - Word16 *idx, /* o : index in unmapped domain */ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - Word16 ACcontextMapping_decode2_no_mem_s17_LC( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o: decoded spectrum */ - Word16 nt, /* i: size of spectrum */ - Word16 nbbits, /* i: bit budget */ - Word16 resQMaxBits, /* i: residual coding maximum bits*/ - CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ - ); - - Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o : decoded spectrum */ - const Word16 nt, /* i : size of spectrum */ - const Word16 nbbits, /* i : bit budget */ - const Word16 resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ - ); - - void reconfig_decoder_LPD_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 bits_frame, /* i : bit budget Q0*/ - Word16 bwidth, /* i : audio bandwidth Q0*/ - Word32 total_brate, /* i : total bitrate Q0*/ - Word16 L_frame_old /* i : frame length Q0*/ - ); - - void reconfig_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bits_frame, /* i : bit budget Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word16 L_frame_old /* i : frame length Q0*/ - ); - - void minimumStatistics_fx( - Word16 *noiseLevelMemory, /* Q15, internal state */ - Word16 *noiseLevelIndex, /* Q0, internal state */ - Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ - Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ - Word16 *lastFrameLevel, /* Q15, level of the last frame */ - Word16 currentFrameLevel, /* Q15, level of the current frame */ - Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ - Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ - Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ - Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ - Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ - - /*10Q5*/ - Word16 getLevelSynDeemph_fx( - Word16 h1Init[], /* i: i value or vector to be processed Q15 */ - Word16 const A[], /* i: LPC coefficients Qx */ - Word16 const lpcorder, /* i: LPC order Q0 */ - Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ - Word16 const preemph_fac, /* i: preemphasis factor Q15 */ - Word16 const numLoops, /* i: number of loops Q0 */ - Word16 *Exp /* o: exponent of return value Q15 */ - ); - - void genPlcFiltBWAdap_fx( - Word32 const sr_core, /*mem_syn >rescaling done */ - Word16 *pitch_buffer, - Word16 *voice_factors, - Word16 *bwe_exc ); - - void decoder_acelp_fx( - Decoder_State *st, - Word16 prm[], /* i : parameters */ - Word16 A[], /* i : coefficients NxAz[M+1] */ - ACELP_config acelp_cfg, /* i : ACELP config */ - Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ - Word16 *pT, /* out: pitch for all subframe Q0 */ - Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ - Word16 stab_fac, /* i : stability of isf */ - Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ - Word16 *voice_factors, /* out: voicing factors */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *bwe_exc /* out: excitation for SWB TBE */ - ); - - void decode_acelp_gains_fx( - Word16 *code, - Word16 gains_mode, - Word16 mean_ener_code, - Word16 *gain_pit, - Word32 *gain_code, - Word16 **pt_indice, - Word16 *past_gpit, - Word32 *past_gcode, - Word16 *gain_inov, - Word16 L_subfr, - Word16 *code2, - Word32 *gain_code2 ); - - void d_gain_pred_fx( - Word16 nrg_mode, /* i : NRG mode */ - Word16 *Es_pred, /* o : predicited scaled innovation energy */ - Word16 **pt_indice /* i/o: pointer to the buffer of indices */ - ); - - ivas_error evs_dec_fx( - Decoder_State *st_fx, /* i/o : Decoder state structure */ - Word16 output_sp[], /* o : output synthesis signal */ - FRAME_MODE frameMode /* i : Decoder frame mode */ - ); - - void fft_cldfb_fx( - Word32 *data, /* i/o: input/output vector */ - const Word16 size /* size of fft operation */ - ); - - void stereo_dft_dec_analyze_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 *input_fx, /* i : input signal q*/ - Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ - const Word16 chan, /* i : channel number Q0*/ - const Word16 input_frame, /* i : input frame size Q0*/ - const Word16 output_frame, /* i : output frame size Q0*/ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ - const Word16 k_offset, /* i : offset of DFT Q0*/ - const Word16 delay, /* i : delay in samples FOR input signal Q0*/ - Word16 *q, - Word16 *q_DFT ); - - void set32_fx( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ - ); - - void delay_signal_q_adj_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay, /* i : delay in samples */ - const Word16 q_x, - const Word16 q_mem ); - - Word32 anint_fx( - const Word32 x, /* i: Round to the nearest integer */ - const Word16 exp /* i: Exponent for round step */ - ); - - Word32 ceil_fx( - const Word32 x, /* i: number to ceil */ - const Word16 exp /* i: Exponent for ceil step */ - ); - - void v_add_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_shr_16( - const Word16 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word16 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ - ); - - void v_shr( - const Word32 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word32 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ - ); - - void cldfbAnalysis_ts_fx( - const Word32 *timeIn_fx, /* i : time buffer */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, - Word16 *q_cldfb ); - - Word16 floor_log_2( - Word32 num ); - - void cldfbAnalysis_ts_fx_var_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - - void cldfbAnalysis_ts_fx_fixed_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - - void configureCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const Word32 sampling_rate /* i : sampling rate */ - ); - - void dec_acelp_fast_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 cdk_index, /* i : codebook index */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - const Word16 L_subfr /* i : subframe length */ - ); - - void tcx5SpectrumInterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - - void tcx5SpectrumDeinterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - - void tcx5TnsGrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum ); - - void tcx5TnsUngrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum, - const Word16 enc_dec ); - - void bpf_pitch_coherence_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ - ); - - /* fft_rel.c */ - -#define SIZE_256 256 -#define NUM_STAGE_256 7 -#define SIZE2_256 ( SIZE_256 / 2 ) - - void cldfbAnalysis_ivas_fx( - const Word32 *timeIn_fx, /* i : time buffer Qx */ - Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ - Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ - ); - - void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ - const Word16 out_shift, /* i : scale for output buffer */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ - ); - - void addBassPostFilter_ivas_fx( - const Word32 *harm_timeIn_fx, - const Word16 samplesToProcess, - Word32 **rAnalysis_fx, - Word32 **iAnalysis_fx, - HANDLE_CLDFB_FILTER_BANK cldfb ); - - /* o : Q22*/ - Word32 ism_dequant_meta_fx( - const Word16 idx, /* i : quantizer index */ - const Word32 borders_fx[], /* i : level borders Q22*/ - const Word32 q_step_fx, /* i : quantization step Q22 */ - const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ - const Word16 cbsize /* i : codebook size */ - ); - - void save_synthesis_hq_fec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ - const Word32 output_fx[], /* i : decoded synthesis */ - const Word16 output_frame, /* i : decoded synthesis */ - const Word16 Qpostd, /* i : Q value of delayed signal */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ - ); - - void calculate_nbits_meta_fx( - const Word16 nchan_ism, - Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 - Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 - const Word16 numSf, - const Word16 numCodingBands, - Word16 *bits_ism, - const Word16 idx_sep_obj, - const Word16 ism_imp ); - - void ivas_get_stereo_panning_gains_fx( - const Word16 aziDeg, - const Word16 eleDeg, - Word16 panningGains[2] ); - - ivas_error openCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - const Word16 enc_dec ); /* i : encoder/decoder flag */ - - Word32 rand_gauss_fx( - Word32 *x, - Word16 *seed, - Word16 q ); - - void resampleCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate ); - - void generate_masking_noise_dirac_ivas_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ - Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ - Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ - const Word16 slot_index, /* i : CLDFB slot index */ - const Word16 cna_flag, /* i : CNA flag for LB and HB */ - const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ - Word16 q_input, - Word16 *q_cldfb ); - - void IMDCT_fx( - Word32 *x, - Word16 x_e, - Word16 *old_syn_overl, - Word16 *syn_Overl_TDAC, - Word16 *xn_buf, - const Word16 *tcx_aldo_window_1, - const PWord16 *tcx_aldo_window_1_trunc, - const PWord16 *tcx_aldo_window_2, - const PWord16 *tcx_mdct_window_half, - const PWord16 *tcx_mdct_window_minimum, - const PWord16 *tcx_mdct_window_trans, - Word16 tcx_mdct_window_half_length, - Word16 tcx_mdct_window_min_length, - Word16 index, - Word16 left_rect, - Word16 tcx_offset, - Word16 overlap, - Word16 L_frame, - Word16 L_frameTCX, - Word16 L_spec_TCX5, - Word16 L_frame_glob, - Word16 frame_cnt, - Word16 bfi, - Word16 *old_out, - Word16 *Q_old_wtda, - Decoder_State *st, - Word16 fullbandScale, - Word16 *acelp_zir ); - - void IMDCT_ivas_fx( - Word32 *x_fx, - Word16 q_x, - Word16 *old_syn_overl_fx, - Word16 *Q_old_syn_overl_fx, - Word16 *syn_Overl_TDAC_fx, - Word16 *Q_syn_Overl_TDAC_fx, - Word16 *xn_buf_fx, - Word16 q_xn_buf_fx, - const Word16 *tcx_aldo_window_1_fx, - const PWord16 *tcx_aldo_window_1_trunc_fx, - const PWord16 *tcx_aldo_window_2_fx, - const PWord16 *tcx_mdct_window_half_fx, - const PWord16 *tcx_mdct_window_minimum_fx, - const PWord16 *tcx_mdct_window_trans_fx, - const Word16 tcx_mdct_window_half_length, - const Word16 tcx_mdct_window_min_length, - Word16 index, - const UWord16 kernel_type, /* i : TCX transform kernel type */ - const Word16 left_rect, - const Word16 tcx_offset, - const Word16 overlap, - const Word16 L_frame, - const Word16 L_frameTCX, - const Word16 L_spec_TCX5, - const Word16 L_frame_glob, - const Word16 frame_cnt, - const Word16 bfi, - Word16 *old_out_fx, - Word16 *q_old_out_fx, - const Word16 FB_flag, - Decoder_State *st, - const Word16 fullbandScale, - Word16 *acelp_zir_fx, - Word16 *q_acelp_zir_fx, - Word16 *pq_win ); - - void v_mult16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, - const Word32 total_brate, - const Word16 L_frame, - const Word16 last_L_frame, - const Word16 element_mode ); - - Word32 sum2_f_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ - ); - - Word32 sum2_f_16_gb_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - - Word32 sum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - - Word16 vq_dec_lvq_ivas_fx( - Word16 sf_flag, /* i : safety net flag */ - Word16 x[], /* o : Decoded vector Q(x2.56)*/ - Word16 indices[], /* i : Indices */ - Word16 stages, /* i : Number of stages */ - Word16 N, /* i : Vector dimension */ - Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ - Word16 no_bits /* (i): no. bits for lattice */ - ); - - Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ - ); - - void deleteCldfb_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ - ); - - void fd_bwe_dec_init_fx( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ - ); - - void stereo_dft_dec_open( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 nchan_transport /* i : number of transport channels */ - ); - - void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ); - - UWord32 mvl2s_r( - const Word32 x[], /* i : input vector */ - const Word16 q, - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ - ); - - void decoder_tcx_post_ivas_fx( - Decoder_State *st_fx, - Word16 *synth, - Word16 *synthFB, - Word16 Q_syn, - Word16 *A, - Word16 bfi, - Word16 MCT_flag ); - - void con_tcx_ivas_fx( - Decoder_State *st, /* i/o: coder memory state */ - Word16 synth[], /* i/o: synth[] Q0 */ - const Word16 coh, /* i : coherence of stereo signal */ - Word16 *noise_seed, /* i/o: noise seed for stereo */ - const Word16 only_left, /* i : TD-PLC only in left channel */ - const Word16 *A_cng /* i : CNG LP filter coefficients */ - ); - - void ivas_mdct_core_reconstruct_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ - Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ - Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - Word16 q_x, - Word16 e_sig[CPE_CHANNELS] ); - - void ari_start_encoding_14bits_ivas_fx( - Tastat *s ); - - void tcx_scalar_quantization_ivas_fx( - Word32 *x, /* i: input coefficients */ - Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ - Word16 L_frame, /* i: frame length */ - Word16 gain, /* i: quantization gain */ - Word16 gain_e, /* i: quantization gain exponent */ - Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ - const Word16 alfe_flag ); - - Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( - Word16 *x, /* Spectral coefficients Q0*/ - const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ - Word16 *lastnz_out, /* Q0 */ - Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ - const Word16 target, /* Target bits Q0*/ - Word16 *stop, /* Q0 */ - Word16 mode, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ - ); - - /* Qx*/ - Word16 usdequant_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta /* i: quantization step Qy*/ - ); - - /* Qx*/ - Word32 usdequant32_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word32 delta /* i: quantization step Qy*/ - ); - - /* o: index of the winning codeword */ - Word16 usquant_fx( - const Word16 x, /* i: scalar value to quantize Qx*/ - Word16 *xq, /* o: quantized value Qx*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta, /* i: quantization step Qx-1*/ - const Word16 cbsize /* i: codebook size */ - ); - - /* o : Sum */ - Word32 Dot_product( - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg /* i : vector length */ - ); - - /* o : dot product of x[] and y[] */ - Word32 dotp_fx( - const Word16 x[], /* i : vector x[] */ - const Word16 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 *exp /* (o) : exponent of result (0..+30) */ - ); - - /* o : sum of all squared vector elements Q(2x+1)*/ - Word32 sum2_fx_mod( - const Word16 *vec, /* i : i vector Qx*/ - const Word16 lvec /* i : length of i vector */ - ); - - void Copy_Scale_sig( - const Word16 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Scale_sig32( - Word32 x[], /* i/o: signal to scale Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_16_32_DEPREC( - const Word16 x[], /* i : signal to scale i Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_16_32_r( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_16_32_no_sat( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_32_16( - const Word32 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Random_Fill( - Word16 *seed, /* i/o: random seed */ - Word16 n, /* i : number of values */ - Word16 *y, /* o : output values */ - Word16 scaling /* i : scaling of values */ - ); - - /* o : mean of vector */ - Word16 mean_fx( - const Word16 *vec_fx, /* i : i vector */ - const Word16 lvec_fx /* i : length of i vector */ - ); - - /* o : mean of vector Qx */ - Word16 mean_no_sat_fx( - const Word16 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx /* i : length of input vector */ - ); - - /* o : mean of vector Qx */ - Word32 mean_no_sat_Word32_fx( - const Word32 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx, /* i : length of input vector */ - const Word16 gb ); - void sort( - UWord16 *x, /* i/o: Vector to be sorted */ - UWord16 len /* i/o: vector length */ - ); - - void sort_fx( - Word16 *r, /* i/o: Vector to be sorted in place */ - Word16 lo, /* i : Low limit of sorting range */ - Word16 up /* I : High limit of sorting range */ - ); - - void sort_32_fx( - Word32 *r, /* i/o: Vector to be sorted in place */ - const Word16 lo, /* i : Low limit of sorting range */ - const Word16 up /* I : High limit of sorting range */ - ); - - /* o : index of the minimum value in the input vector */ - Word16 minimum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *min_fx /* o : minimum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *max_fx /* o : maximum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_exp_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 *exp_vec, /* i : exponents of input vector */ - const Word16 lvec_fx /* i : length of input vector */ - ); - - /* o : index of the maximum abs value in the input vector */ - Word16 maximum_abs_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max_val /* o : maximum value in the input vector */ - ); - - /* o : index of the minimum value in the input vector */ - Word16 minimum_abs32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ - ); - - /* o : index of the minimum value in the input vector */ - Word16 minimum_32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_abs_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /*! r: index of the maximum value in the input vector */ - Word16 maximum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max /* o : maximum value in the input vector */ - ); - - /*! r: index of the minimum value in the input vector */ - Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ - ); - - Word16 Exp16Array( - const Word16 n, /* (i): Array size */ - const Word16 *sx /* (i): Data array */ - ); - - Word16 Exp32Array( - const Word16 n, /* (i): Array size */ - const Word32 *sx /* (i): Data array */ - ); - - /* o : sum of all vector elements Qx*/ - Word32 sum16_32_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - /* o : sum of all vector elements Qx*/ - Word32 sum32_sat( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - /* o: variance of vector Qx+16*/ - Word32 var_fx_32( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ - ); - - /* o: variance of vector Qx+16*/ - Word32 var_fx_32in_32out( - const Word32 *x, /* i: input vector Qx*/ - Word16 *Qx, - const Word16 len, /* i: length of inputvector */ - const Word16 gb ); - - /* o: variance of vector Qx*/ - Word16 var_fx( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ - ); - - /* o: variance of vector Qx*/ - Word16 std_fx( - const Word16 x[], /* i: input vector */ - const Word16 len /* i: length of the input vector */ - ); - - /* o : the dot product x'*A*x */ - Word32 dot_product_mat_fx( - const Word16 *x, /* i : vector x Q15 */ - const Word32 *A, /* i : matrix A Q0*/ - const Word16 m /* i : vector & matrix size */ - ); - - void Vr_subt( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 N /* i : Vector lenght */ - ); - - /* o: index of the winning codevector */ - Word16 vquant_ivas_fx( - Word32 x[], /* i: vector to quantize Q25 */ - const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ - Word32 xq[], /* o: quantized vector Q25 */ - const Word32 cb[], /* i: codebook Q25 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ - ); - - /* o: index of the winning codevector */ - Word16 vquant_fx( - Word16 x[], /* i: vector to quantize Q13 */ - const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ - Word16 xq[], /* o: quantized vector Q13 */ - const Word16 cb[], /* i: codebook Q13 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ - ); - - Word16 w_vquant_fx( - Word16 x[], /* i: vector to quantize in Q10 */ - Word16 Qx, - const Word16 weights[], /* i: error weights in Q0 */ - Word16 xq[], /* o: quantized vector in Q15 */ - const Word16 cb[], /* i: codebook in Q15 */ - const Word16 cbsize, /* i: codebook size */ - const Word16 rev_vect /* i: reverse codebook vectors */ - ); - - /* o : return index with max energy value in vector Q0 */ - Word16 emaximum_fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word16 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ - ); - - /* o : return index with max energy value in vector Q0 */ - Word16 emaximum_32fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word32 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ - ); - - /* o : mean of the elements of the vector */ - Word32 Mean32( - const Word32 in[], /* i : input vector */ - const Word16 L /* i : length of input vector */ - ); - - /* o : sum of all vector elements Qx*/ - Word32 sum32_fx( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - /* o : sum of all vector elements Qx*/ - Word16 sum16_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - Word16 own_random2_fx( - Word16 seed ); - - void iDiv_and_mod_32( - const Word32 Numer, /* i : 32 bits numerator */ - const Word16 Denom, /* i : 16 bits denominator */ - Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ - Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ - const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ - ); - - void pz_filter_sp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word16 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - - Word32 root_a_fx( - Word32 a, - Word16 Q_a, - Word16 *exp_out ); - - Word32 root_a_over_b_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - - Word32 root_a_over_b_ivas_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - - void fir_fx( - const Word16 x[], /* i : input vector Qx*/ - const Word16 h[], /* i : impulse response of the FIR filter Q12*/ - Word16 y[], /* o : output vector (result of filtering) Qx*/ - Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ - const Word16 L, /* i : input vector size */ - const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ - const Word16 upd, /* i : 1 = update the memory, 0 = not */ - Word16 shift /* i : difference between Q15 and scaling of h[] */ - ); - - void v_add_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_shr_32( - Word32 x1[], /* i : Input vector 1 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N, /* i : Vector length */ - Word16 shift /*shift value*/ - ); - - void v_sub_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_add_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_sub_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - /* o: index of the winning codeword */ - Word16 squant_fx( - const Word16 x, /* i: scalar value to quantize */ - Word16 *xq, /* o: quantized value */ - const Word16 cb[], /* i: codebook */ - const Word16 cbsize /* i: codebook size */ - ); - - Word16 squant_int_fx( - UWord8 x, /* i : scalar value to quantize */ - UWord8 *xq, /* o : quantized value */ - const UWord8 *cb, /* i : codebook */ - const Word16 cbsize /* i : codebook size */ - ); - - void pz_filter_dp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word32 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - - void Copy_Scale_sig32_16( - const Word32 *src, /* i : signal to scale Qx */ - Word16 *dst, /* o : scaled signal Qx */ - Word16 len, /* i : size of x[] Q0 */ - Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ - - void v_multc_att( - const Word16 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word16 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_att32( - const Word32 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_att3232( - const Word32 x[], /* i : Input vector Qx */ - const Word32 att, /* i : Constant Q32, <= MAX_32 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ - ); - - void v_L_mult_1616( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_L_mult_3216( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void add_vec_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 Qx1, /* i : SCaling of input 1 */ - const Word16 x2[], /* i : Input vector 2 */ - const Word16 Qx2, /* i : SCaling of input 1 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 Qy, /* i : SCaling of output 1 */ - const Word16 N /* i : Vector lenght */ - ); - - /* o: Result (Normalized) */ - Word32 Add_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ - ); - - /* o: Result (Normalized) */ - Word32 Mul_flt32_Q15( - Word32 value, /* i: Pseudo_float Value */ - Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ - Word16 frac /* i: Q15 value */ - ); - - /* o: Result (Normalized) */ - Word32 Div_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ - ); - - /* o: Result (Normalized) */ - Word32 Calc_Energy_Autoscaled( - const Word16 *signal, /* i: Signal */ - Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ - Word16 len, /* i: Frame Length */ - Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ - ); - - Word16 Find_Max_Norm16( - const Word16 *src, - Word16 len ); - - Word16 Find_Max_Norm32( - const Word32 *src, - Word16 len ); - - /* o: Result in Q31 */ - Word32 Sqrt_Ratio32( - Word32 L_val1, /* i: Mantisa of Val1 */ - Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ - Word32 L_val2, /* i: Mantisa of Val2 */ - Word16 exp2, /* i: Exp of Val2 (same as exp1) */ - Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ - ); - - /* result in Q'15 + 'exp' */ - Word16 Invert16( - Word16 val, - Word16 *exp ); - - Word16 find_rem( - Word16 n, - Word16 m, - Word16 *r ); - - Word32 find_remd( - Word32 n, - Word32 m, - Word32 *r ); - - Word16 rint_new_fx( - Word32 x /*Q16 */ - ); - - Word16 erb_diff_search_fx( - Word16 *prev_erb, - const Word16 *curr_erb, - Word16 *dif_erb, - Word16 *pow_spec, - const Word16 *cb_fx, - Word16 cb_size, - Word16 cb_dim, - Word16 offset ); - - void Acelp_dec_total_exc( - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - const Word16 gain_code16, /* i : Gain code Q0 */ - const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ - const Word16 i_subfr, /* i ; subfr */ - const Word16 *code_fx, /* i : code in Q9 */ - const Word16 L_subfr /* i : Subframne lenght */ - ); - - UWord32 UL_inverse( - const UWord32 UL_val, - Word16 *exp ); - - UWord32 UL_div( - const UWord32 UL_num, - const UWord32 UL_den ); - - Word16 ratio( - const Word32 numer, - const Word32 denom, - Word16 *expo ); - - void hp400_12k8_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ - ); - - void hp400_12k8_ivas_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ - ); - - Word16 dot_prod_satcontr( - const Word16 *x, - const Word16 *y, - Word16 qx, - Word16 qy, - Word16 *qo, - Word16 len ); - - void E_UTIL_f_convolve( - const Word16 x[], - const Word16 h[], - Word16 y[], - const Word16 size ); - - void floating_point_add( - Word32 *mx, /* io: mantissa of the addend Q31 */ - Word16 *ex, /* io: exponent of the addend Q0 */ - const Word32 my, /* i: mantissa of the adder Q31 */ - const Word16 ey /* i: exponent of the adder Q0 */ - ); - - void delay_signal_fx( - Word16 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word16 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ - ); - - void delay_signal32_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ - ); - - Word16 lin_interp_ivas_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ - ); - - Word16 lin_interp_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ - ); - - Word16 ceil_log_2( - UWord64 val ); - - Word32 imax_pos_fx( - const Word32 *y /* i : Input vector for peak interpolation Qx*/ - ); - - void msvq_enc_ivas_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ - const Word16 Q_cb, /* i : Codebook Q */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ - const Word16 u_e, /* i : Exponent for Vector to be encoded */ - const Word16 *levels, /* i : Number of levels in each stage */ - const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ - const Word16 stages, /* i : Number of stages */ - const Word16 w[], /* i : Weights Q8 */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 applyDCT_flag, /* i : applyDCT flag */ - Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ - Word16 Idx[] /* o : Indices */ - ); - - void msvq_dec_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 Idx[], /* i : Indices */ - const Word16 applyIDCT_flag, /* i : applyIDCT flag */ - const Word32 *invTrfMatrix, /* i : synthesis matrix */ - Word32 *uq, /* o : quantized vector */ - Word16 *uq_ind, /* o : quantized vector (fixed point) */ - Word16 exp ); - - void dec_FDCNG_MSVQ_stage1_fx( - Word16 j_full, /* i : index full range */ - Word16 n, /* i : dimension to generate */ - const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ - const DCTTYPE idcttype, /* i : specify which IDCT */ - Word32 *uq, /* o : synthesized stage1 vector Q20 */ - Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ - ); - - void dctT2_N_apply_matrix_fx( - const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ - Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ - const Word16 dct_dim, /* i : dct processing dim possibly truncated */ - const Word16 fdcngvq_dim, /* i : fdcng domain length */ - const Word32 *matrix, /* i : IDCT matrix */ - const Word16 matrix_row_dim, /* i : */ - const DCTTYPE dcttype /* i : matrix operation type */ - ); - - Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - - Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - - void v_mult_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_sub_s16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_sub32_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void ivas_swb_tbe_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ - Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ - Word16 *Q_white_exc ); - - Word16 swb_bwe_dec_fx32( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ - Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ - Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ - Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - Word16 output_frame /* i : frame length */ - ); - - ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs */ - Word16 synth_fx16[], /* o : synthesis */ - Word16 save_hb_synth_fx16[], /* o : HB synthesis */ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word16 *unbits, /* o : number of unused bits */ - Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 read_sid_info /* i : read SID info flag */ - ); - - void wtda_fx32( - const Word32 *new_audio, /* i : input audio Q11 */ - Word32 *wtda_audio, /* o : windowed audio Q11 */ - Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ - const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const Word16 L /* i : length */ - ); - - ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ); - - void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - - void hp20_fx_32_opt( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - - void getTCXMode_ivas_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ - ); - - void getTCXWindowing_ivas_fx( - const Word16 core, /* i : current frame mode */ - const Word16 last_core, /* i : last frame mode */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ - ); - - Word16 ari_start_decoding_14bits_prm_ivas_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - - void generate_masking_noise_ivas_fx( - Word32 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 *exp_out, /* o : time-domain signal exp */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 length, /* i : frame size */ - const Word16 core, /* i : core */ - const Word16 return_noise, /* i : noise is returned instead of added */ - const Word16 secondary, /* i : flag to indicate secondary noise generation */ - const Word16 element_mode, /* i : element mode */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void SynthesisSTFT_dirac_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 samples_out, - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - void generate_stereo_masking_noise_fx( - Word16 *syn, /* i/o: time-domain signal */ - Word16 Q_syn, - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void SynthesisSTFT_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void FdCng_decodeSID_ivas_fx( - Decoder_State *st /* i/o: decoder state structure */ - ); - - void cldfb_restore_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - ivas_error cldfb_save_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ - ); - - Word16 sr2fscale( - const Word32 sr_core /* i : internal sampling rate */ - ); - - void Copy_Scale_sig32( - const Word32 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ - Word16 *Q_shb_spch, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ - ); - - void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ - ); - - void updt_enc_common_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Q_new /* i : CUrrent frame scaling */ - ); - - /* o : Q(2x - 31 - gb) */ - Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb /* i : guard bits */ - ); - - Word32 sum2_16_exp_fx( - const Word16 *vec, /* i : input vector Q(15 - exp) */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ - ); - - Word32 sum2_32_exp_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ - ); - - Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - - void ProcessStereoIGF_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ - Word16 q_pITFMDCTSpectrum_1, - Word16 q_pITFMDCTSpectrum_2, - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - - void IGFEncApplyStereo_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - - void IGFSaveSpectrumForITF_ivas_fx( - IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - const Word32 *pITFSpectrum, /* i : MDCT spectrum */ - Word16 exp_pITFSpectrum ); - - Word16 IGFEncWriteBitstream_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /* i : ptr to bitOffset counter */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ - ); - - Word16 IGFSCFEncoderEncode_ivas_fx( - IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ - Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ - ); - - Word16 ari_encode_14bits_ext_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s, - Word32 symbol, /* Q0 */ - UWord16 const *cum_freq /* Q0 */ - ); - - Word16 ari_encode_14bits_sign_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word32 bits, /* Q0 */ - Tastat *s, - Word16 sign /* Q0 */ - ); - - Word16 ari_done_encoding_14bits_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s ); - - void IGFEncConcatenateBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const Word16 bsBits, /* i : number of IGF bits written to list of indices */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ - ); - - void hq_generic_hf_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ - Word16 length ); - - Word16 ari_decode_14bits_pow_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - UWord16 base ); - - Word16 ari_decode_14bits_sign_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - - void lsf_syn_mem_backup_ivas_fx( - Encoder_State *st_fx, /* i: state structure */ - Word16 *btilt_code_fx, /* i: tilt code Q15 */ - Word32 *gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *next_force_sf_bck_fx, /* o: */ - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ - Word16 *pstreaklen ); - - ivas_error config_acelp1_fx( - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word32 total_brate, /* i : total bitrate */ - const Word32 core_brate_inp, /* i : core bitrate */ - const Word16 core, /* i : core */ - const Word16 extl, /* i : extension layer */ - const Word32 extl_brate, /* i : extension layer bitrate */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const Word16 signaling_bits, /* i : number of signaling bits */ - const Word16 coder_type, /* i : coder type */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 tc_subfr, /* i : TC subfr ID */ - const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ - Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ - Word16 *unbits, /* o : number of unused bits */ - const Word16 element_mode, /* i : element mode */ - Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 idchan, /* i : stereo channel ID */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); - -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) -#define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) -#define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ ); -#endif - -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - ivas_error push_next_indice_( - const char *caller, -#else -ivas_error push_next_indice( -#endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ - ); - -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - ivas_error push_next_bits_( - const char *caller, #else -ivas_error push_next_bits( +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( + const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ + Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ + const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ + Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ + const Word16 lsfBase[], /* i : base for differential lsf coding */ + Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ + const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ + Word16 L_frame, + const Word16 last_good, /*!< i : last good received frame */ + const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ + const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ + Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ + Word16 *lsf_cng, /* Q2.56 */ + Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ + const Word16 Last_GSC_pit_band_idx, + const Word16 Opt_AMR_WB, /* i : IO flag */ + const Word8 tcxonly, + const short bwidth /* i: coded bandwidth */ +); + +Word16 const *PlcGetLsfBase( + Word16 const lpcQuantization, + Word16 const narrowBand, + Word32 const sr_core ); + +/* Create an instance of type FD_CNG */ +ivas_error createFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + +void initFdCngCom( + HANDLE_FD_CNG_COM hFdCngCom, + Word16 scale ); + +/* Delete the instance of type FD_CNG */ +void deleteFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + +/* Initialize the spectral partitioning */ +void initPartitions( + const Word16 *part_in, + const Word16 npart_in, + const Word16 startBand, + const Word16 stopBand, + Word16 *part_out, + Word16 *npart_out, + Word16 *midband, + Word16 *psize, + Word16 *psize_norm, + Word16 *psize_norm_exp, + Word16 *psize_inv, + const Word16 stopBandFR ); + +/* Noise estimation using Minimum Statistics (MS) */ +void compress_range( + Word32 *in, + Word16 in_exp, + Word16 *out, + const Word16 len ); + +void expand_range( + Word16 *in, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + +void expand_range_fx( + Word32 *in, // Q25 + Word32 *out, // exp:out_exp + Word16 *out_exp, + const Word16 len ); + +void expand_range_var_exp( + Word16 *in, + Word16 in_exp, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + +void minimum_statistics( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ + Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ +); + +void minimum_statistics_fx( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ + Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 enc_dec, /* i : encoder/decoder indicator */ + const Word16 element_mode /* i : IVAS element mode type */ +); + +/* Apply bitrate-dependant scale */ +void apply_scale( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ +); + +Word16 apply_scale_ind( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ +); +void apply_scale_ivas_fx( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize, /* i : Size of scale table */ + Word16 *index ); + +/* Compute the power for each partition */ +void bandcombinepow( + const Word32 *bandpow, /* i : Power for each band */ + const Word16 exp_bandpow, /* i : exponent of bandpow */ + const Word16 nband, /* i : Number of bands */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + const Word16 *psize_inv, /* i : Inverse partition sizes */ + Word32 *partpow, /* o : Power for each partition */ + Word16 *exp_partpow ); + +/* Scale partitions (with smoothing) */ +void scalebands( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + +void scalebands_fx( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + +/* STFT analysis filterbank */ +void AnalysisSTFT( + const Word16 *timeDomainInput, /* i : pointer to time signal */ + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ +); + +void AnalysisSTFT_fx( + const Word16 *timeDomainInput, + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ +); + +/* STFT synthesis filterbank */ +void SynthesisSTFT( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +void SynthesisSTFT_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +Word32 sign_l( + const Word32 x /* i : input value of x */ +); + +void ivas_updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word32 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ +); + +/* Random generator with Gaussian distribution with mean 0 and std 1 */ +Word32 rand_gauss( + Word16 *seed ); + +Word16 rand_gauss_fix( + Word16 *x, + Word16 *seed ); + +void lpc_from_spectrum( + HANDLE_FD_CNG_COM hFdCngCom, + const Word16 start, /*i : start band*/ + const Word16 stop, /*i : stop band*/ + const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ +); + +void msvq_decoder( + const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook vector dimension */ + const Word16 Idx[], /* i : Indices */ + Word16 *uq /* o : quantized vector */ +); + +void FdCng_exc( + HANDLE_FD_CNG_COM hs, + Word16 *CNG_mode, + Word16 L_frame, + Word16 *lsp_old, + Word16 first_CNG, + Word16 *lsp_CNG, + Word16 *Aq, /* o: LPC coeffs */ + Word16 *lsp_new, /* o: lsp */ + Word16 *lsf_new, /* o: lsf */ + Word16 *exc, /* o: LP excitation */ + Word16 *exc2, /* o: LP excitation */ + Word16 *bwe_exc /* o: LP excitation for BWE */ +); + +void direct_transform_fx( + const Word32 in32_fx[], + Word32 out32_fx[], + const Word16 is_transient, + const Word16 L, + Word16 *Q, + const Word16 element_mode ); + +void preecho_sb_fx( + const Word32 brate, /* i Q0 : core bit-rate */ + Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ + Word16 q_sig32, /* i Q value for wtda_audio_fx */ + Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ + Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ + const Word16 framelength, /* i Q0 : frame length */ + Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ + Word16 *smoothmem_fx, /* i/o Q15 : memory */ + Word32 *mean_prev_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ + Word16 *wmold_hb_fx, /* i/o Q15 : memory */ + Word16 *prevflag, /* i/o Q0 : flag */ + Word16 *pastpre, /* i/o Q0 : flag */ + const Word16 bwidth /* i Q0 : bandwidth */ +); + +void Inverse_Transform( + const Word32 *in_mdct, /* i : i MDCT vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 is_transient, /* i : transient flag */ + const Word16 L, /* i : output frame length */ + const Word16 L_inner, /* i : length of the transform */ + const Word16 element_mode /* i : IVAS element mode */ +); + +void recovernorm_fx( + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ +); + +Word32 ar_div( Word32 num, Word32 denum ); + +void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); +void ar_encoder_done_fx( PARCODEC arInst ); +void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); +void ar_decoder_done_fx( PARCODEC arInst ); +Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); + +void TCQLSB_fx( + Word16 bcount, + Word32 *abuffer_fx, + Word16 *mbuffer_fx, + Word32 *sbuffer_fx, + Word16 *dpath ); + +void TCQLSBdec_fx( + Word16 *dpath, + Word16 *mbuffer, + Word16 bcount ); + +void RestoreTCQ_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + +void RestoreTCQdec_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + +void InitLSBTCQ_fx( + Word16 *bcount ); + +void SaveTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + +void LoadTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + +Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); +Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); +Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); + +Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); + +void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); +void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); +void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); +void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); + +Word16 GetScale_fx( + Word16 blen, + Word32 bits_fx, + Word32 *surplus_fx ); + +void srt_vec_ind_fx( + const Word32 *linear, + Word32 *srt, + Word16 *I, + Word16 length ); + +void fill_spectrum_fx( + Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ + Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ + const Word16 *R, /* i : number of pulses per band Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + Word16 norm[], /* i : quantization indices for norms Q0 */ + const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ + const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ + const Word16 nf_idx, /* i : noise fill index Q0 */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ + const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ + Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ + const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ + const Word16 core_sfm, /* i : index of the end band for core Q0 */ + const Word16 HQ_mode, /* i : HQ mode Q0 */ + Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ + const Word32 L_core_brate, /* i : target bit-rate Q0 */ + Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ + Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ + Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ + const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ + const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ + const Word16 *npulses, /* i : number of pulses per band Q0 */ + const Word16 prev_is_transient, /* i : previous transient flag Q0 */ + Word32 *prev_normq, /* i/o: previous norms Q14 */ + Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ + const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ + const Word16 *sfmsize, /* i : Length of bands Q0 */ + const Word16 *sfm_start, /* i : Start of bands Q0 */ + const Word16 *sfm_end, /* i : End of bands Q0 */ + Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ + const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + Word16 *prev_env_Q, + const Word16 num_env_bands, + const Word16 element_mode ); + +void hq_bit_allocation_fx( + const Word32 core_brate, /* i : Core bit-rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + const Word16 hqswb_clas, /* i : HQ class Q0 */ + Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ + const Word16 *normqlg2, /* i : Quantized norms Q0 */ + const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ + const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ + Word16 *noise_level, /* o : HVQ noise level Q15 */ + Word16 *R, /* o : Bit allocation per sub band Q0 */ + Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ + Word16 *sum, /* o : Sum of allocated shape bits Q0 */ + Word16 *core_sfm, /* o : Last coded band in core Q0 */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ +); + +void map_quant_weight_fx( + const Word16 normqlg2[], /* i : quantized norms Q0*/ + Word16 wnorm[], /* o : weighted norm Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ +); + +void bitalloc_fx( + Word16 *y, /* i : reordered norm of sub-vectors Q0 */ + Word16 *idx, /* i : reordered sub-vector indices Q0 */ + Word16 sum, /* i : number of available bits Q0 */ + Word16 N, /* i : number of norms Q0 */ + Word16 K, /* i : maximum number of bits per dimension Q0 */ + Word16 *r, /* o : bit-allacation vector Q0 */ + const Word16 *sfmsize, /* i : band length Q0 */ + const Word16 hqswb_clas /* i : signal classification flag Q0 */ +); + +Word16 BitAllocF_fx( + Word16 *y, /* i : norm of sub-vectors :Q0 */ + Word32 bit_rate, /* i : bitrate :Q0 */ + Word16 B, /* i : number of available bits :Q0 */ + Word16 N, /* i : number of sub-vectors :Q0 */ + Word16 *R, /* o : bit-allocation indicator :Q0 */ + Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ + const Word16 hqswb_clas, /* i : hq swb class */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ +); + +Word16 BitAllocWB_fx( + Word16 *y, /* i : norm of sub-vectors Q0*/ + Word16 B, /* i : number of available bits Q0*/ + Word16 N, /* i : number of sub-vectors Q0*/ + Word16 *R, /* o : bit-allocation indicator Q0*/ + Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ +); + +void bitallocsum_fx( + Word16 *R, /* i : bit-allocation vector Q0 */ + const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ + Word16 *sum, /* o : total number of bits allocated Q0 */ + Word16 *Rsubband, /* o : rate per subband Q3 */ + const Word16 num_bits, /* i : number of bits Q0 */ + const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ + const Word16 *sfmsize /* i : band length Q0 */ +); + +Word16 stab_est_fx( + Word16 etot, /* i : Total energy of the current frame Q8*/ + Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ + Word16 *mem_etot, /* i/o : Total energy memory Q8*/ + Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ + Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ + Word16 *thresh, /* i/o : Detection thresold Q11*/ + Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ + const Word16 vad_flag /* i : VAD flag */ +); + +void enhancer_fx( + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ +); + +void enhancer_ivas_fx( + const Word16 codec_mode, /* i : flag indicating Codec Mode */ + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 cbk_index, /* i : */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ +); + +Word16 E_UTIL_enhancer( + Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + Word16 stab_fac, /* i : LP filter stability measure Q15 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ + Word16 *code, /* i/o: innovation(in: Q9) code_exp */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ + Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ + Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ + Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ + Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ + Word16 coder_type, /* i : coder type */ + Word16 cdk_index, /* i : */ + Word16 L_subfr, /* i : */ + Word16 L_frame, /* i : frame size */ + Word16 Q_new ); + +void phase_dispersion( + const Word32 gain_code, /* i : gain of code 15Q16 */ + const Word16 gain_pit, /* i : gain of pitch Q14 */ + Word16 code[], /* i/o: code vector */ + Word16 *code_e, /* i/o: exponent of code */ + const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ + Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ + Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ + Word16 *prev_state, /* i/o: static memory Q0 */ + Word16 L_subfr /* i : subframe length [40,64] */ +); + +void tcx_ltp_get_lpc( + Word16 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word16 *A, /* Qx */ + const Word16 order /* Q0 */ +); + +void tcx_ltp_get_lpc_fx( + Word32 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word32 *A, /* Qx */ + const Word16 order /* Q0 */ +); + +void predict_signal( + const Word16 excI[], /* i : input excitation buffer Qx*/ + Word16 excO[], /* o : output excitation buffer Qx*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i : fraction of lag Q0*/ + const Word16 frac_max, /* i : max fraction Q0*/ + const Word16 L_subfr /* i : subframe size Q0*/ +); + +Word16 tcx_ltp_decode_params( + Word16 *ltp_param, /* Q0 */ + Word16 *pitch_int, /* Q0 */ + Word16 *pitch_fr, /* Q0 */ + Word16 *gain, /* Q13 */ + const Word16 pitmin, /* Q0 */ + const Word16 pitfr1, /* Q0 */ + const Word16 pitfr2, /* Q0 */ + const Word16 pitmax, /* Q0 */ + const Word16 pitres /* Q0 */ +); + +void tcx_ltp_post_fx( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word16 *sig, /* Qx */ + Word16 *tcx_buf /* Qx */ +); + +void tcx_ltp_post_fx32( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word32 *sig, /* sig_q */ + Word32 *tcx_buf, /* sig_q */ + Word16 sig_q ); + +void Inac_switch_ematch_fx( + Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ + Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ + Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ + const Word16 coder_type, /* i : Coding mode */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 L_frame, /* i : Frame lenght */ + const Word16 Q_exc, /* i : input and output format of exc2 */ + const Word16 bfi, /* i : frame lost indicator */ + const Word16 last_core, /* i : Last core used */ + const Word16 last_codec_mode, /* i : Last codec mode */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 element_mode /* i : element mode */ +); + +/**< out: Q0 | multiplication factor */ +Word16 IGF_ApplyTransFac( + const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ + const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ +); + +Word16 IGF_MapBitRateToIndex( + const Word32 brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void IGFCommonFuncsCalcSfbEnergyPowerSpec( + const Word16 startSfb, /**< in: Q0 | start sfb index */ + const Word16 stopSfb, /**< in: Q0 | stop sfb index */ + const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ + Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ + Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ + Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ + Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ +); + +void IGFCommonFuncsMDCTSquareSpec( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ +); + +void IGFCommonFuncsMDCTSquareSpec_ivas( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ +); + +Word16 IGFCommonFuncsIGFConfiguration( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +Word16 IGFCommonFuncsIGFGetCFTables_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ + const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ + Word16 *cf_off_se01, /* o : offset for CF table above */ + const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ + const Word16 **cf_off_se02, /* o : offsets for CF tables above */ + const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ + Word16 *cf_off_se10, /* o : offset for CF table above */ + const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ + const Word16 **cf_off_se11 /* o : offsets for CF tables above */ +); + +Word32 L_multi31x16_X2( + Word16 xh, + Word16 xl, + Word16 y ); + +Word32 mul_sbc_14bits( + Word32 r, /* Q0 */ + Word16 c /* Q0 */ +); + +void ham_cos_window( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + +void ham_cos_window_ivas( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + +/* o: Q31 */ +Word32 expfp( + const Word16 x, /* i: mantissa Q-e */ + const Word16 x_e ); /* i: exponent Q0 */ + +void powfp_odd2( + const Word16 base, /* Q15 */ + const Word16 exp, /* Q0 */ + Word16 *pout1, /* Q15 */ + Word16 *pout2 ); /* Q15 */ + +void tcx_arith_scale_envelope( + const Word16 L_spec_core, /* i: number of lines to scale Q0 */ + Word16 L_frame, /* i: number of lines Q0 */ + const Word32 env[], /* i: unscaled envelope Q16 */ + Word16 target_bits, /* i: number of available bits Q0 */ + const Word16 low_complexity, /* i: low-complexity flag Q0 */ + Word16 s_env[], /* o: scaled envelope Q15-e */ + Word16 *s_env_e /* o: scaled envelope exponent Q0 */ +); + +void tcx_arith_render_envelope( + const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i: number of spectral lines Q0*/ + const Word16 L_spec, /* Q0 */ + const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o: shaped signal envelope Q16*/ +); + +/* returns innovation gain Q16 */ +Word32 calc_gain_inov( + const Word16 *code, /* i : algebraic excitation Q9 */ + const Word16 lcode, /* i : Subframe size Q0 */ + Word32 *dotp, /* o : intermediate result Q31-e */ + Word16 *dotp_e /* o : intermediate result exponent Q0 */ +); + +/////////////////////////////////// +/* Lib_dec */ +////////////////////////////////// + +void ResetSHBbuffer_Dec_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl /* i : BWE extension layer */ +); + +void wb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ + Word16 *Q_synth ); + +void swb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ + Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ + Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ + Word16 *Q_white_exc, + Word16 *synth, /* o : SHB synthesis/final synthesis */ + Word16 *Q_synth, + Word16 *pitch_buf ); + +void ivas_dequantizeSHBparams_fx_9_1( + Decoder_State *st_fx, + const Word16 extl, /* i : extension layer */ + Word32 extl_brate, /* i : extensiuon layer bitrate */ + Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ + Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ + Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ + Word16 *uv_flag, /* o : unvoiced flag*/ + Word32 *Q_shb_ener_sf, /* o : Q15 */ + Word16 *Q_shb_res_gshape, /* o : Q14 */ + Word16 *Q_mixFactors, /* o : Q15 */ + Word16 *MSFlag ); + +void fb_tbe_dec_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word16 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp ); + +void fb_tbe_dec_ivas_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word32 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp, + Word16 *fb_synth_ref, + Word16 Q_fb_synth_ref, + Word16 output_frame ); + +void tbe_read_bitstream_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +); + +void GenTransition_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 rf_flag, /* i : RF flag */ + Word32 total_bitrate /* i : total bitrate */ +); + +void GenTransition_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 prev_Qx ); + +void GenTransition_WB_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output, /* o : synthesized transitions signal */ + const Word32 output_Fs /* i : output sampling rate */ +); + +void GenTransition_WB_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ +); + +void TBEreset_dec_fx( + Decoder_State *st_fx /* i/o: decoder state structure */ +); + +void td_bwe_dec_init_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl, /* i : BWE extension layer */ + const Word32 output_Fs /* i : output sampling rate */ +); + +void lsf_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ + Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ +); + +/*! r: index of the maximum value in the input vector */ +Word16 maximum_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +Word16 minimum_l( + const Word32 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word32 *min_val /* o : minimum value in the input vector */ +); + +void v_multc_fx( + const Word32 x[], /* i : Input vector */ + const Word32 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_fx_16( + const Word32 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_fx_16_16( + const Word16 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word16 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +); + +void v_add_fx_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_add_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_add_fx_me( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x1_e, /* i : Exponent for input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + const Word16 x2_e, /* i : Exponent for input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 *y_e, /* i : Exponent for output vector */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_add_w64( + const Word64 x1[], /* i : Input vector 1 */ + const Word64 x2[], /* i : Input vector 2 */ + Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_sub_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_sub_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +/*! r: dot product of x[] and y[] */ +Word32 dotp_fx32( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ +); + +/*! r: dot product of x[] and y[] in case of overflow*/ +Word32 dotp_fx32_o( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q ); + +Word32 dotp_fx32_fac( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q /*stores resultant Q*/ +); + +Word32 dotp_fx_ivas_fx( + const Word32 x[], /* i : vector x[] */ + Word16 x_e, + const Word32 y[], /* i : vector y[] */ + Word16 y_e, + const Word16 n, /* i : vector length */ + Word16 *out_e ); + +Word32 dotp_fx_guarded( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ +); + +Word32 dotp_me_fx( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 exp_x, + Word16 exp_y, + Word16 *exp_suma ); + +void lsf_end_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 mode2_flag, /* Q0 */ + const Word16 coder_type_org, /* i : coding type Q0*/ + const Word16 bwidth, /* i : input signal bandwidth Q0*/ + const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ + Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ + Word16 *lpc_param, /* i : LPC parameters Q0*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ +); + +void lsf_mid_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ + Word16 coder_type, /* i : Coder type Q0*/ + Word16 lsp_mid[] /* o : quantized LSPs Q15*/ +); + +void CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 last_element_mode, /* i : last element mode Q0 */ + Word16 Aq[], /* o : LP coefficients Q12 */ + Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ + Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ + Word16 *allow_cn_step, /* o : allow CN step Q0 */ + Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ + Word32 *q_env ); + +void swb_CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ +); + +void swb_CNG_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ +); + +void td_cng_dec_init_fx( + DEC_CORE_HANDLE st /* i/o: decoder state structure */ +); + +void set_state( + Word16 *state, + Word16 num, + Word16 N ); + +void concealment_init_x( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + +void concealment_init_ivas_fx( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + +void concealment_update_x( + const Word16 bfi, + const Word16 core, + const Word16 tonality, + Word32 *invkoef /*Qinvkoef_scale*/, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + +Word16 Sqrt_x_fast( + Word32 value ); + +Word32 dot_w32_accuracy_x( + Word16 *s1, + Word16 *s2, + Word16 nbits, + Word16 N ); + +Word16 int_div_s_x( + Word16 a, + Word16 b ); + +Word16 GetW32Norm_x( + Word32 *s, + Word16 N ); + +Word16 harmo_x( + Word32 *X, + Word16 Framesize, + Word16 pitch ); + +void LpFilter2_x( + Word16 *x, + Word16 *y, + Word16 N ); + +void sig_tilt_x( + Word16 *s, + Word16 FrameSize, + Word32 *enr1, + Word32 *enr2 ); + +void get_maxConv_and_pitch_x( + Word16 *s_LP, + Word16 s, + Word16 e, + Word16 N, + Word32 *maxConv, + Word16 *maxConv_bits, + Word16 *pitch ); + +Word16 get_voicing_x( + Word16 *s_LP, + Word16 pitch, + Word32 covMax, + Word16 maxConv_bits, + Word16 Framesize ); + +void pitch_modify_x( + Word16 *s_LP, + Word16 *voicing, + Word16 *pitch, + Word16 FrameSize ); + +Word16 Is_Periodic_x( + Word32 *mdct_data, + Word16 cov_max, + Word16 zp, + Word32 ener, + Word32 ener_mean, + Word16 pitch, + Word16 Framesize ); + +Word16 get_conv_relation_x( + Word16 *s_LP, + Word16 shift, + Word16 N ); + +void concealment_decode_fix( + Word16 curr_mode, + Word32 *invkoef, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + +Word32 Spl_Energy_x( + const Word16 *vector, + const Word16 vector_length, + Word16 *scale_factor ); + +void Log10OfEnergy_x( + const Word16 *s, + Word32 *enerlogval, + const Word16 len ); + +void concealment_update2_x( + const Word16 *outx_new, + T_PLCInfo_HANDLE hPlcInfo, + const Word16 FrameSize ); + +Word16 ffr_getSfWord16( + Word16 *vector, /*!< Pointer to i vector */ + Word16 len ); + +void waveform_adj2_fix( + T_PLCInfo_HANDLE hPlcInfo, + Word16 *overlapbuf, + Word16 *outx_new, + const Word16 delay, + const Word16 bfi_cnt, + const Word16 bfi ); + +void concealment_signal_tuning_fx( + Decoder_State *st, + const Word16 bfi, + Word16 *outx_new_fx /*Qoutx_new_fx*/, + const Word16 past_core ); + +void DetectTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + +void RefineTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + +void ivas_RefineTonalComponents_fx( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 secondLastPowerSpectrum_e, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode, + const PsychoacousticParameters *psychParamsCurrent ); + +ivas_error PsychoacousticParameters_Init( + const Word32 sr_core, /* i : sampling rate of core-coder */ + const Word16 nBins, /* i : Number of bins (spectral lines) */ + const Word8 nBands, /* i : Number of spectrum subbands */ + const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ + const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ + PsychoacousticParameters *pPsychParams ); + +ivas_error TonalMDCTConceal_Init( + TonalMDCTConcealPtr self, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ +); + +ivas_error TonalMDCTConceal_Init_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const UWord16 nSamples, + const UWord16 nSamplesCore, + const UWord16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ +); + +/* Must be called only when a good frame is recieved - concealment is inactive */ +void TonalMDCTConceal_SaveFreqSignal( + TonalMDCTConcealPtr self, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + Word16 nNewSamples, + Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp ); + +void TonalMDCTConceal_SaveFreqSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + const Word16 nNewSamples, + const Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp, + const Word16 infoIGFStartLine ); + +void TonalMDCTConceal_UpdateState( + TonalMDCTConcealPtr self, + Word16 nNewSamples, + Word32 pitchLag, + Word16 badBlock, + Word8 tonalConcealmentActive ); + +void TonalMDCTConceal_Detect( + const TonalMDCTConcealPtr self, /*IN */ + const Word32 pitchLag, /*IN */ + Word16 *umIndices, /*OUT*/ + Word16 element_mode /* IN */ +); + +void TonalMDCTConceal_Apply( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 *mdctSpectrum_exp /*IN */ +); + +void TonalMDCTConceal_Apply_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 mdctSpectrum_exp, /*IN */ + const PsychoacousticParameters *psychParamsCurrent ); + +void TonalMDCTConceal_InsertNoise_ivas_fx( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, + Word16 *mdctSpectrum_exp, + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + const Word16 crossfadeGain, + const Word32 concealment_noise[L_FRAME48k], + const Word16 concealment_noise_e, + const Word32 cngLevelBackgroundTrace_bfi, + const Word16 cngLevelBackgroundTrace_e, + const Word16 crossOverFreq ); + +void TonalMDCTConceal_InsertNoise( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*OUT*/ + Word16 *mdctSpectrum_exp, /*OUT*/ + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + Word16 crossfadeGain, + const Word16 crossOverFreq ); + +void TonalMDCTConceal_SaveTimeSignal( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 nNewSamples ); + +void TonalMDCTConceal_SaveTimeSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 q_timeSignal, + Word16 nNewSamples ); + +void decision_matrix_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ + Word16 *hq_core_type, /* o : HQ core type Q0 */ + Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ +); + +void hf_synth_init_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ +); + +void hf_synth_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ +); + +void hf_synth_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ +); + +void hf_synth_ivas_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ +); + +void hf_synth_amr_wb_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ +); + +void hf_synth_amr_wb_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ +); + +void hf_synth_amr_wb_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az : Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ + Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ + Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ + Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ + Word16 fmerit, /* i : classify parameter from FEC : Q14*/ + const Word16 *hf_gain, /* i : decoded HF gain Q0*/ + const Word16 *voice_factors, /* i : voicing factors : Q15*/ + const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ + const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ + const Word16 *lsf_new, /* i : ISF vector : Q2*/ + const Word16 Q_exc, /* i : exc scaling */ + const Word16 Q_out /* i : Q_syn2-1 */ +); + +void Init_post_filter_fx( + PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ +); /* i : core decoder parameters */ + +void nb_post_filt_fx( + const Word16 L_frame, /* i : frame length */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *psf_lp_noise, /* i : Long term noise Q8 */ + const Word16 tmp_noise, /* i : noise energy Q0 */ + Word16 *Synth, /* i : 12k8 synthesis Qsyn */ + const Word16 *Aq, /* i : LP filter coefficient Q12 */ + const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ + const Word16 coder_type, /* i : coder_type */ + const Word16 BER_detect, /* i : BER detect flag */ + const Word16 disable_hpf /* i : flag to diabled HPF */ +); + +void formant_post_filt_fx( + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *synth_in, /* i : 12k8 synthesis */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ + Word16 *synth_out, /* i/o: input signal */ + const Word16 L_frame, /* i : frame length */ + const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ + const Word32 brate, /* (i) : bit-rate */ + const Word16 off_flag /* i : off flag */ +); + +void Filt_mu_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr /* i : the length of subframe */ +); + +void Filt_mu_ivas_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr, /* i : the length of subframe */ + const Word16 extl ); + +void scale_st_fx( + const Word16 *sig_in, /* i : postfilter i signal */ + Word16 *sig_out, /* i/o: postfilter o signal */ + Word16 *gain_prec, /* i/o: last value of gain for subframe */ + Word16 L_subfr ); + +void blend_subfr2_fx( + Word16 *sigIn1, /* i : i signal for fade-out */ + Word16 *sigIn2, /* i : i signal for fade-in */ + Word16 *sigOut /* o : output signal */ +); + +void init_tcx_window_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ + const Word32 sr_core, /* i : SR core */ + const Word32 input_Fs, /* i : input/output SR */ + const Word16 L_frame, /* i : L_frame at sr_core */ + const Word16 L_frameTCX, /* i : L_frame at i/o SR */ + const Word16 mdctWindowLength, /* i : window length at sr_core */ + const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ + const Word16 element_mode /* i : mode of CPE/SCE */ +); + +void init_tcx_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, /*Q15*/ + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, + const Word16 fscaleFB ); + +void syn_output_fx( + const Word16 codec_mode, /* i : MODE1 or MODE2 */ + Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ + const Word16 output_frame, /* i : output frame length */ + Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ + const Word16 Q_syn2 /* i : Synthesis scaling factor */ +); + +void unscale_AGC( + const Word16 x[], /* i: 16kHz synthesis Qx */ + const Word16 Qx, /* i: scale factor of x */ + Word16 y[], /* o: output vector Q0 */ + Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ + const Word16 n /* i: vector size */ +); + +void bass_psfilter_init_fx( + BPF_DEC_HANDLE hBPF /* o : BPF data handle */ +); + +void bass_psfilter_fx( + BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ + const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ + Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ + const Word16 L_frame, /* i : length of the last frame Q0*/ + Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ + const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ + Word16 v_stab_fx, /* i : stability factor Q15*/ + Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ + const Word16 coder_type, /* i : coder_type Q0*/ + Word16 Q_syn, + Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ +); + +void addBassPostFilter_fx( + const Word16 *harm_timeIn_Fx, /* timeIn_e */ + Word32 **rAnalysis_Fx, /* Qx - 5 */ + Word32 **iAnalysis_Fx, /* Qx - 5 */ + HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, + Word32 *workBuffer, /* Qx */ + const Word16 timeIn_e, + const Word16 nTimeSlots, /* Q0 */ + const Word16 nTimeSlotsTotal, /* Q0 */ + const Word16 nBandsTotal, /* Q0 */ + CLDFB_SCALE_FACTOR *cldfb_scale ); + +void FEC_exc_estim_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* o : pointer to excitation buffer (with past) */ + Word16 *exc2, /* o : total excitation (for synthesis) */ + Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ + Word16 *pitch_buf, /* o : Floating pitch for each subframe */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *tmp_tc, /* o : FEC pitch Q6 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *lsf_new, /* i : ISFs at the end of the frame */ + Word16 *Q_exc, + Word16 *tmp_noise /* o : long-term noise energy Q0 */ +); + +void pitch_pred_linear_fit( + const Word16 bfi_cnt, /* i: bfi counter Q0 */ + const Word16 last_good, /* i: last classification type Q0 */ + Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ + Word32 *old_fpitch, /* i: Q16*/ + Word32 *T0_out, /* o: estimated close loop pitch Q16*/ + Word16 pit_min, /* i: Minimum pitch lag Q0 */ + Word16 pit_max, /* i: Maximum pitch lag Q0 */ + Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ + Word16 limitation, + Word16 plc_use_future_lag, /* i: Q0 */ + Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ + Word16 nb_subfr /* i: number of ACELP subframes */ +); + +void get_subframe_pitch( + Word16 nSubframes, /* i: number of subframes Q0 */ + Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ + Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ + Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ +); + +void PulseResynchronization_fx( + Word16 const *const src_exc, /*i Q15*/ + Word16 *const dst_exc, /*o Q15*/ + Word16 const nFrameLength, /*i Q0 */ + Word16 const nSubframes, /*i Q0 */ + Word32 const pitchStart, /*i Q16*/ + Word32 const pitchEnd /*i Q16*/ +); + +void decod_audio_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ +); + +void gsc_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ + Word16 *Q_exc ); + +void GSC_dec_init_fx( + GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ +); + +void Es_pred_dec_fx( + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + const Word16 enr_idx, /* i : indice */ + const Word16 nb_bits, /* i : number of bits */ + const Word16 no_ltp /* i : no LTP flag */ +); + +void gain_dec_tc_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ +); + +void gain_dec_tc_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ +); + +void gain_dec_mless_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ +); + +void gain_dec_lbr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 *code_fx, /* i : algebraic excitation Q9 */ + Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes */ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ + const Word16 L_subfr /* i : subfr lenght */ +); + +void lp_gain_updt_fx( +#ifdef CLEANUP_ACELP_ENC + const Word16 element_mode, /* i : element mode */ +#else + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ +); +void lp_gain_updt_ivas_fx( +#endif + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ +); + +/*! r: quantized codebook gain Q16 */ +Word32 gain_dec_gaus_fx( + Word16 index, /* i : quantization index */ + const Word16 bits, /* i : number of bits to quantize */ + const Word16 lowBound, /* i : lower bound of quantizer (dB) */ + const Word16 topBound, /* i : upper bound of quantizer (dB) */ + const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ +); + +void gain_dec_SQ_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 *code, /* i : algebraic code excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ + Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ +); + +void gain_dec_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + Word16 *gain_pit, /* o : Quantized pitch gain */ + Word32 *gain_code, /* o : Quantized codeebook gain */ + Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ + Word16 *gain_inov, /* o : unscaled innovation gain */ + const Word16 *code, /* i : algebraic code excitation */ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ +); + +void transf_cdbk_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ + const Word32 gain_code, /* i : innovative excitation gain (Q16) */ + Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ + Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ + Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ + Word16 *unbits /* o : number of AVQ unused bits */ +); + +/* o: decoded gain */ +Word16 gain_dequant_fx( + Word16 index, /* i: quantization index */ + const Word16 min, /* i: value of lower limit */ + const Word16 max, /* i: value of upper limit */ + const Word16 bits, /* i: number of bits to dequantize */ + Word16 *expg ); + +void AVQ_demuxdec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ + Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ + const Word16 Nsv, /* i : number of subvectors Q0*/ + Word16 nq[], /* i/o: AVQ nq index Q0*/ + Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ + Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ +); + +void AVQ_dec_lpc( + Word16 *indx, /* input: index[] (4 bits per words) Q0*/ + Word16 *nvecq, /* output: vector quantized Q0*/ + Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ + +void re8_dec_fx( + Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ + const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ + const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ +); + +void re8_decode_base_index_fx( + const Word16 n, + UWord16 I, + Word16 *x ); + +void re8_k2y_fx( + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ +); + +void re8_vor_fx( + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ +); + +void re8_PPV_fx( + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ +); + +void dec_pit_exc_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +); + +/* o: pitch value Q16 */ +Word32 Mode2_pit_decode( + const Word16 coder_type, /* i: coding model */ + Word16 i_subfr, /* i: subframe index */ + Word16 L_subfr, + Word16 **pt_indice, /* i/o: quantization indices pointer */ + Word16 *T0, /* i/o: close loop integer pitch Q0 */ + Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ + Word16 *T0_res, /* i/o: pitch resolution Q0 */ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ + Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr1b, + Word16 pit_fr2, + Word16 pit_max, + Word16 pit_res_max ); + +void Mode2_abs_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 *T0_res, /* o: pitch resolution Q0 */ + Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr2, + Word16 pit_res_max ); + +void Mode2_delta_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 T0_res, /* i: pitch resolution Q0 */ + Word16 *T0_min, /* i: delta search min Q0 */ + Word16 *T0_min_frac, /* i: delta search min Q0 */ + Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ +); + +/* o : floating pitch value */ +Word16 pit_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ +); + +void pit_Q_dec_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 delta, /* i : Half the CL searched interval */ + const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ +); + +void pit16k_Q_dec_fx( + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ +); + +void abs_pit_dec_fx( + const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ + Word16 pitch_index, /* i: pitch index */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o: integer pitch lag */ + Word16 *T0_frac /* o: pitch fraction */ +); + +void delta_pit_dec_fx( + const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ + const Word16 pitch_index, /* i : pitch index */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + const Word16 T0_min /* i : delta search min */ +); + +void limit_T0_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 delta, /* i : Half the close-loop searched interval */ + const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ + const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_max /* o : higher pitch limit */ +); + +void limit_T0_voiced( + const Word16 nbits, + const Word16 res, + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + const Word16 T0_res, /* i : pitch resolution */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_min_frac, /* o : lower pitch limit */ + Word16 *T0_max, /* o : higher pitch limit */ + Word16 *T0_max_frac, /* o : higher pitch limit */ + const Word16 pit_min, /* i : Minimum pitch lag */ + const Word16 pit_max /* i : Maximum pitch lag */ +); + +void inov_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ +); + +void inov_decode_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ +); + +void dec_acelp_4t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 nbbits, /* i : number of bits per codebook */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + const Word16 Opt_AMR_WB ); + +void D_ACELP_decode_43bit_fx( + UWord16 idxs[], + Word16 code[], + Word16 *pulsestrack ); + +void D_ACELP_indexing_fx( + Word16 code[], + PulseConfig config, + Word16 num_tracks, + Word16 index[], + Word16 *BER_detect ); + +void fcb_pulse_track_joint_decode_fx( + UWord16 *idxs, + Word16 wordcnt, + UWord32 *index_n, + Word16 *pulse_num, + Word16 track_num ); + +void dec_acelp_2t32_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[] /* o: algebraic (fixed) codebook excitation */ +); + +void dec_acelp_1t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ + const Word16 L_subfr /* i : sub frame lenght*/ +); + +ivas_error acelp_core_switch_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ + Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ + const Word16 output_frame, /* i : input frame length */ + const Word16 core_switching_flag, /* i : core switching flag */ + Word16 *mem_synth, /* o : synthesis to overlap */ + Word16 *Q_syn ); + +ivas_error acelp_core_switch_dec_bfi_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ +); + +ivas_error acelp_core_switch_dec_bfi_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ +); + +void pred_lt4( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +); + +void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +); + +void pred_lt4_tc_fx( + Word16 exc[], /* i/o: excitation buffer Q0*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i: fraction of lag Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 imp_pos, /* i : glottal impulse position Q0*/ + const Word16 i_subfr /* i : subframe index Q0*/ +); + +void pvq_decode_frame_fx( + Decoder_State *st_fx, + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ +); + +Word16 pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + +Word16 ivas_pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, /* Q3 */ + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + +void decode_energies_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 Np, + Word16 *dim_part, + Word16 *bits_part, + Word16 *g_part, /* Q15 */ + Word16 qband, + Word16 *bits_left, + Word16 dim, + const Word16 strict_bits ); + +void rc_dec_init_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 tot_bits /* i : Total bit budget */ +); + +/* o : Decoded cumulative frequency */ +UWord32 rc_decode_fx( + Word16 *BER_detect, /* o : Bit error detection flag */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Total cumulative frequency */ +); + +void rc_dec_update_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + + UWord32 cum_freq, /* i : Cumulative frequency */ + UWord32 sym_freq /* i : Symbol frequency */ +); + +/* o : Decoded value */ +Word32 rc_dec_bits_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 bits /* i : Number of bits */ +); + +/* o : Decoded value */ +UWord32 rc_dec_uniform_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Maximum value */ +); + +void rc_dec_finish_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ +); + +void pvq_decode_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 *xq, /* o: decoded vector (Q15) */ + Word16 *y, /* o: decoded vector (non-scaled int) */ + const Word16 k_val, /* i: number of allocated pulses */ + const Word16 dim, /* i: Length of vector */ + const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ +); +void nelp_decoder_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ + Word16 *exc, /* o : adapt. excitation exc Q_exc */ + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate Q0 */ + const Word16 coder_type, /* i : coding type Q0 */ + Word16 *gain_buf /* Q14 */ +); + +void decod_nelp_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ + Word16 *exc_fx, /* o : adapt. excitation exc */ + Word16 *exc2_fx, /* o : adapt. excitation/total exc */ + Word16 *voice_factors, /* o : Voice factor */ + Word16 *bwe_exc, + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate */ + Word16 *gain_buf /*Q14*/ +); + +void lp_filt_exc_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 codec_mode, /* i : coder mode */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 L_subfr, /* i : subframe size */ + const Word16 L_frame, /* i : frame size */ + Word16 lp_flag, /* i : operation mode signalling */ + Word16 *exc ); + +void FEC_lsf2lsp_interp( + Decoder_State *st, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *Aq, /* o : calculated A(z) for 4 subframes */ + Word16 *lsf, /* o : estimated LSF vector */ + Word16 *lsp /* o : estimated LSP vector */ +); + +ivas_error createFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + +void initFdCngDec_fx( + DEC_CORE_HANDLE st, /* i/o: decoder state structure */ + const Word16 scale ); + +/* Delete the instance of type FD_CNG */ +void deleteFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + +/* Configure CLDFB-CNG */ +void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ + Word16 bandwidth, + Word32 bitrate, + Word16 L_frame, + const Word16 Last_L_frame, + const Word16 element_mode ); + +Word16 ApplyFdCng_fx( + Word16 *timeDomainInput, /* i : pointer to time domain input */ + Word16 Q, + Word32 *powerSpectrum, + Word16 Q_power_spectrum, + Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ + Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ + Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ + Decoder_State *st, + const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ + Word16 is_music ); + +/* Perform noise estimation */ +void perform_noise_estimation_dec_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain i */ + const Word16 Q, + HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ +); + +void perform_noise_estimation_dec_ivas_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain input */ + const Word16 Q, + Word32 *power_spectrum, + Word16 Q_power_spectrum, + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + const Word16 VAD /* i : VAD flag in the decoder */ +); + +/* Decode the CLDFB-CNG bitstream */ +void FdCng_decodeSID_fx( + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Decoder_State *corest ); /* i/o: decoder state structure */ + +void noisy_speech_detection_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ + const Word16 vad, /* i : VAD flag */ + const Word16 *syn, /* i : i time-domain frame */ + const Word16 Q ); + +void generate_comfort_noise_dec_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ +); + +void generate_comfort_noise_dec_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ +); + +void generate_comfort_noise_dec_hf_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec ); + +void generate_comfort_noise_dec_hf_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of input bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ +); + +/* Generate the comfort noise based on the target noise level */ +void generate_masking_noise_fx( + Word16 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 Q, + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 length, + Word16 core ); + +void generate_masking_noise_update_seed_fx( + HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ +); + +void generate_masking_noise_mdct_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 L_frame ); + +void generate_masking_noise_mdct_ivas_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); + +ivas_error init_decoder_fx( + Decoder_State *st_fx, /* o : Decoder static variables structure */ + const Word16 idchan, /* i : channel ID */ + const MC_MODE mc_mode /* i : MC mode */ +); + +void reset_preecho_dec_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ +); + +void destroy_cldfb_decoder_fx( + Decoder_State *st_fx /* o: Decoder static variables structure */ +); + +void destroy_cldfb_encoder_fx( + Encoder_State *st /* i/o: state structure */ +); + +Word16 WB_BWE_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *WB_fenv /*Q15*/ +); + +Word16 wb_bwe_dec_fx( + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *voice_factors_fx, /* i : voicing factors Q15 */ + const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *Qpost ); + +/* o : BWE class */ +Word16 swb_bwe_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 core, /* i : core */ + Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ + Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ + const Word16 hr_flag, /* i : high rate flag */ + const Word16 hqswb_clas /* i : HQ BWE class */ +); + +/*o :Q_syn_hb*/ +Word16 swb_bwe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *Qpost ); + +void fd_bwe_dec_init( + Decoder_State *st_fx, /* i/o: decoder state structure */ + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ +); + +void hq_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *audio_fx, /* i : input audio signal Q0 */ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ +); + +void hq_core_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word16 synth[], /* o : output synthesis Q_synth*/ + Word16 *Q_synth, /* o : Q value of synth */ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ +); + +void HQ_core_dec_init_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ +); + +void HQ_nbfec_init_fx( + HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ +); + + +void hq_ecu_fx( + const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ + Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ + Word16 *time_offs, + Word16 *X_sav, + Word16 *Q_spec, /* i/o : Q value of stored spectrum */ + Word16 *num_p, + Word16 *plocs, + Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ + const Word16 env_stab, + Word16 *last_fec, + const Word16 ph_ecu_HqVoicing, + Word16 *ph_ecu_active, /* i : Phase ECU active flag */ + Word16 *gapsynth, + const Word16 prev_bfi, /* i : indicating burst frame error */ + const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ + Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ + Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ + Word16 *beta_mute, /* o : Factor for long-term mute */ + const Word16 output_frame, /* i : frame length */ + Decoder_State *st_fx /* i/o: decoder state structure */ +); + +void hq_lr_dec_fx( + Decoder_State *st_fx, /* i/o: : decoder state structure */ + Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ + const Word16 inner_frame, /* i : Q0 : inner frame length */ + Word16 num_bits, /* i : Q0 : number of available bits */ + Word16 *is_transient_fx /* o : Q0 : transient flag */ +); + +/* o : Number of bits Q0*/ +Word16 decode_envelope_indices_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : starting band index Q0*/ + const Word16 num_sfm, /* i : Number of subbands Q0*/ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ + Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ +); + +void dequantize_norms_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : First SDE encoded norm Q0*/ + const Word16 num_sfm, /* i : Number of norms Q0*/ + const Word16 is_transient, /* i : Transient flag Q0*/ + Word16 *ynrm, /* o : Decoded norm indices Q0*/ + Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ +); + +void hdecnrm_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 numNorms, /* (i) number of norms Q0*/ + Word16 *index ); /* (o) indices of quantized norms Q0*/ + +Word16 decode_huff_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *hufftab, + Word16 *rbits ); + +void hdecnrm_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* Q0 */ + Word16 *index, /* Q0 */ + Word16 *n_length /* Q0 */ +); + +void hdecnrm_resize_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ +); + +void huff_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : Number of codewords to decode Q0*/ + const Word16 buffer_len, /* i : Number of bits to read Q0*/ + const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ + const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ + const Word16 *offset, /* i : Offset for first codeword Q0*/ + const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ + Word16 *index /* o : Decoded index Q0*/ +); + +void hdecnrm_tran_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ +); + +void tcq_core_LR_dec_fx( + Decoder_State *st_fx, + Word16 *inp_vector_fx, /*x5 */ + const Word16 bit_budget, /*Q0 */ + const Word16 BANDS, /*Q0 */ + const Word16 *band_start, /*Q0 */ + const Word16 *band_width, /*Q0 */ + Word32 *Rk_fx, /*Q16*/ + Word16 *npulses, /*Q0 */ + Word16 *k_sort, /*Q0 */ + const Word16 *p2a_flags, /*Q0 */ + const Word16 p2a_bands, /*Q0 */ + const Word16 *last_bitalloc, /*Q0 */ + const Word16 input_frame, /*Q0 */ + const Word16 adjustFlag, /*Q0 */ + const Word16 *is_transient /*Q0 */ +); + +void HQ_FEC_processing_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ + Word16 is_transient, /* i : Old flag for transient */ + Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ + Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ + Word16 num_Sb, /* i : Number of sub-band group */ + Word16 nb_sfm, /* i : Number of sub-band */ + Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ + Word16 output_frame, /* i : Frame size */ + const Word16 *sfm_start, /* i : Start of bands */ + const Word16 *sfm_end /* i : End of bands */ +); + +void HQ_FEC_Mem_update_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /*Q12*/ + Word32 *normq_fx, /*Q14*/ + Word16 *ynrm, + Word16 *Num_bands_p, + Word16 is_transient, + Word16 hqswb_clas, + Word16 c_switching_flag, + Word16 nb_sfm, + Word16 num_Sb, + Word16 *mean_en_high_fx, /*Q5*/ + Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ + Word16 output_frame ); + +void time_domain_FEC_HQ_fx( + Decoder_State *st_fx, /* i : Decoder State */ + Word32 *wtda_audio_fx, /* i : i */ + Word16 *out_fx, /* o : output audio */ + Word16 mean_en_high_fx, /* i : transient flag */ + const Word16 output_frame, + Word16 *Q_synth ); + +void hq_pred_hb_bws_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *ynrm, /* i : norm quantization index vector Q0*/ + const Word16 length, /* i : frame length Q0*/ + const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ + const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ +); + +void hq_hr_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ + const Word16 length, /* i : frame length Q0 */ + Word16 num_bits, /* i : number of available bits Q0 */ + Word16 *ynrm, /* o : norm quantization index vector Q0 */ + Word16 *is_transient, /* o : transient flag Q0 */ + Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ + Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ + const Word16 core_switching_flag /* i : Core switching flag Q1 */ +); + +/* o : Consumed bits */ +Word16 hq_classifier_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : Core bit rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + Word16 *is_transient, /* o : Transient flag Q0 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ +); + +void hvq_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 num_bits, /* i : Number of available bits */ + const Word32 core_brate, /* i : Core bit-rate */ + const Word16 *ynrm, /* i : Envelope coefficients Q0 */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *noise_level, /* o : Noise level in Q15 */ + Word16 *peak_idx, /* o : Peak position vector */ + Word16 *Npeaks, /* o : Total number of peaks */ + Word32 *coefsq_norm, /* o : Output vector in Q12 */ + const Word16 core ); + +Word16 hvq_pvq_bitalloc_fx( + Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ + const Word32 brate, /* i : bitrate */ + const Word16 bwidth_fx, /* i : Encoded bandwidth */ + const Word16 *ynrm, /* i : Envelope coefficients */ + const Word32 manE_peak, /* i : Peak energy mantissa */ + const Word16 expE_peak, /* i : Peak energy exponent */ + Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ + Word16 *R, /* Q0 i/o: Global bit allocation */ + Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ + Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ +); + +void hq_configure_bfi_fx( + Word16 *nb_sfm, /* o : Number of sub bands Q0*/ + Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ + Word16 *num_bands_p, /* o : FEC sub bands Q0*/ + const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ + const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ + const Word16 **sfm_end /* o : Subband end coefficients Q0*/ +); + +void bandwidth_switching_detect_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +); + +void bandwidth_switching_detect_ivas_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +); + +void bw_switching_pre_proc_fx( + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + Decoder_State *st_fx /* i/o: decoder state structure */ +); + +ivas_error core_switching_pre_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 output_frame /* i : frame length Q0*/ +); + +ivas_error core_switching_post_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ +); + +ivas_error core_switching_post_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ + const Word16 nchan_out, /* i : number of output channels Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ +); + +void core_switching_hq_prepare_dec_fx( + Decoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 output_frame /* i : output frame length Q0*/ +); + +ivas_error amr_wb_dec_fx( + Word16 output_sp[], /* o : synthesis output */ + Decoder_State *st_fx /* o : Decoder static variables structure */ +); + +void amr_wb_dec_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ +); + +void updt_dec_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 *old_exc_fx, /* i : buffer of excitation */ + const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ + const Word16 Es_pred, /* i : predicited scaled innovation energy */ + const Word16 *Aq, /* i : A(z) quantized for all subframes */ + const Word16 *lsf_new_fx, /* i : current frame LSF vector */ + const Word16 *lsp_new_fx, /* i : current frame LSP vector */ + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ + const Word16 *gain_buf /*Q14*/ +); + +void updt_IO_switch_dec_fx( + const Word16 output_frame, /* i : output frame length */ + Decoder_State *st_fx /* o : Decoder static variables structure */ +); + +void updt_bw_switching_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ + const Word16 Qpost ); + +void updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word16 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ +); + +void update_decoder_LPD_cng( + Decoder_State *st, + Word16 coder_type, + Word16 *timeDomainBuffer, + Word16 *A, + Word16 *bpf_noise_buf ); + +void FEC_clas_estim_fx( + Decoder_State *st_fx, /* i/o: decoder state handle */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ + const Word16 L_frame, /* i : length of the frame */ + Word16 *clas, /* i/o: frame classification */ + const Word16 coder_type, /* i : coder type */ + const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ + Word16 *syn, /* i : synthesis buffer */ + Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ + Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ + Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ + Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ + Word16 *Last_ener, /* i/o: last_energy frame A*/ + Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ + Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ + Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ + Word16 Q_syn, /* i : Synthesis scaling */ + Word16 *class_para, /* o : classification para. fmerit1 A*/ + Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ + Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ + Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ + Word16 mode, /* i : signal classifier mode B*/ + Word16 bfi, /* i : bad frame indicator B*/ + Word32 last_core_brate, /* i : bitrate of previous frame */ + const Word16 FEC_mode /* i : ACELP FEC mode */ +); + +Word16 FEC_pos_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ + Word32 *enr_q, /* o : decoded energy in Q0 */ + const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ +); + +void post_decoder( + Decoder_State *st, + Word16 synth_buf[], /* Q0 */ + Word16 pit_gain[], /* Q14 */ + Word16 pitch[], /* Q0 */ + Word16 signal_out[], /* Q0 */ + Word16 *bpf_noise_buf /* Q0 */ +); + +void post_decoder_ivas_fx( + Decoder_State *st, + Word16 synth_buf[], // Q0 + Word16 pit_gain[], // Q14 + Word16 pitch[], // Q0 + Word16 signal_out[], // Q0 + Word16 *bpf_noise_buf // Q0 +); + +void cldfb_synth_set_bandsToZero( + Decoder_State *st, + Word32 **rAnalysis, + Word32 **iAnalysis, + const Word16 nTimeSlots, + const CLDFB_SCALE_FACTOR scaleFactor ); + +void FEC_pitch_estim_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 last_core, /* i : last core */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 clas, /* i : current frame classification */ + const Word16 last_good, /* i : last good clas information */ + const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ + const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ + Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ + Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ + Word16 *upd_cnt, /* i/o: update counter */ + const Word16 coder_type, /* i : coder_type */ + Word16 element_mode /* i : element mode */ +); + +void FEC_scale_syn_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ + Word16 clas, /* i/o: frame classification */ + const Word16 last_good, /* i: last good frame classification */ + Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ + const Word16 *pitch, /* i: pitch values for each subframe */ + Word32 L_enr_old, /* i: energy at the end of previous frame */ + Word32 L_enr_q, /* i: transmitted energy for current frame */ + const Word16 coder_type, /* i: coder type */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ + Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ + Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ + const Word16 bfi, /* i: current frame BFI */ + const Word32 total_brate, /* i: total bitrate */ + const Word16 prev_bfi, /* i: previous frame BFI */ + const Word32 last_core_brate, /* i: previous frame core bitrate */ + Word16 *exc, /* i/o: excitation signal without enhancement */ + Word16 *exc2, /* i/o: excitation signal with enhancement */ + Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ + Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ + const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ + Word16 *mem_syn, /* o: initial synthesis filter states */ + Word16 Q_exc, + Word16 Q_syn, + const Word16 element_mode, /* i : element mode */ + const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ + const Word16 force_scaling /* i : force scaling */ +); + +void LD_music_post_filter_fx( + MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ + const Word16 dtc_in[], /* i : i synthesis Qdct */ + Word16 dtc_out[], /* o : output synthesis Qdct */ + const Word32 core_brate, /* i : core bitrate Q0 */ + Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ + const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ + const Word16 Last_coder_type, /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ +); + +void Prep_music_postP_fx( + Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ + Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ + Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ + const Word16 last_core, /* i : last core */ + const Word16 element_mode, /* i : element mode */ + const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ + Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ + const Word16 Q_exc, /* i : excitation scaling */ + Word16 *qdct /* o : Scaling factor of dct coefficient */ +); + +void Post_music_postP_fx( + Word16 dct_buffer_in[], /* i/o: excitation buffer */ + Word16 *exc2, /* i/o: Current excitation to be overwriten */ + const Word16 *mem_tmp, /* i : previous frame synthesis memory */ + Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ + const Word16 *Aq, /* i : LPC filter coefficients */ + Word16 *syn, /* i/o: 12k8 synthesis */ + Word16 *Q_exc, /* i : excitation scaling */ + Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ + Word16 *Q_syn, /* i : Current frame synthesis scaling */ + Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ + const Word16 IsIO, /* i : Flag to indicate IO mode */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory */ + Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ + Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ + Word16 *mem_agc, + PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ + const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ + Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ +); + +void music_postfilt_init( + MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ +); + +void improv_amr_wb_gs_fx( + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 locattack, /* i : Flag for a detected attack Q0*/ + Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ + Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ +); + +void decod_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficients */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ +); + +void CNG_reset_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ + Word16 *voice_factors /* o : voicing factors Q15*/ +); + +ivas_error ppp_voiced_decoder_fx( + Decoder_State *st_fx, /* i/o: state structure */ + Word16 *out_fx, /* o : residual signal */ + const Word16 *lpc2_fx, /* i : current frame LPC */ + Word16 *exc_fx, /* i : previous frame excitation */ + Word16 *pitch, /* o : floating pitch values for each subframe */ + Word16 bfi /* i : Frame error rate */ +); + +void sc_vbr_dec_init( + SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ +); + +ivas_error ppp_quarter_decoder_fx( + DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ + Word16 prevCW_lag_fx, /* i : Previous lag */ + Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ + Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ + Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ + Word16 bfi, /* i : FER flag */ + Word16 *S_fx, /* i : sine table, Q15 */ + Word16 *C_fx, /* i : cosine table, Q15 */ + DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ + Decoder_State *st_fx ); + +void open_decoder_LPD_fx( + Decoder_State *st, + const Word32 total_brate, /* Q0 */ + const Word16 bwidth /* Q0 */ +); + +void open_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + +void reset_tcx_overl_buf_fx( + TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ +); + +void acelp_plc_mdct_transition_fx( + Decoder_State *st /* i/o: Decoder state */ +); + +void cldfb_reset_memory_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +void tcxltp_dec_init_fx( + TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ + const Word16 ini_frame, /* Q0 */ + const Word16 last_codec_mode, /* Q0 */ + const Word16 element_mode, /* Q0 */ + const Word16 pit_max, /* Q0 */ + const Word32 sr_core ); /* Q0 */ + +/* o : Exponent of SHB synthesis */ +Word16 swb_bwe_dec_hr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ + const Word16 exp, /* i : Exponent of core synthesis */ + Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ + const Word16 output_frame, /* i : frame length */ + const Word16 unbits, /* i : number of core unused bits */ + const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ +); + +void hr_bwe_dec_init( + HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ +); + +void swb_hr_noise_fill_fx( + const Word16 is_transient, /* i : transient flag */ + const Word16 spect_start, /* i : spectrum start point */ + const Word16 spect_end, /* i : spectrum end point */ + const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ + const Word16 pitch, /* i : pitch value Q15 */ + const Word16 nq[], /* i : AVQ nq index */ + Word16 Nsv, /* i : number of subband */ + Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ + Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ + Word16 Q_audio ); + +void stat_noise_uv_dec_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ + Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ + Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ + const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ +); + +void stat_noise_uv_mod_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ + Word16 *exc2, /* i/o: excitation buffer Q_exc */ + Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q15 */ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : input bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ +); + +void stat_noise_uv_mod_ivas_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ +); + +Word16 FEC_SinOnset_fx( + Word16 *exc, /* i/o : exc vector to modify */ + Word16 puls_pos, /* i : last pulse position desired */ + const Word16 T0, /* i : Pitch information of the 1 subfr */ + Word32 enr_q, /* i : energy provide by the encoder */ + Word16 *Aq, /* i : A(z) filter Q12 */ + const Word16 L_frame, /* i : frame length */ + const Word16 Qold ); + +Word16 FEC_enhACB_fx( + const Word16 L_frame, /* i : frame length */ + const Word16 last_L_frame, /* i : frame length of previous frame */ + Word16 *exc_io, /* i/o : adaptive codebook memory */ + const Word16 new_pit, /* i : decoded first frame pitch */ + const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ + const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ +); + +/*! r: do_WI flag */ +Word16 FEC_synchro_exc_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* i/o: exc vector to modify */ + const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ + const Word16 true_puls_pos, /* i : Present pulse location */ + const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ +); + +void decod_unvoiced_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + Word16 *gain_buf ); + +void gaus_dec_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* o : unvoiced excitation Q12 */ + Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ + Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ + Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ + Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ + Word16 *voice_fac, /* o : estimated voicing factor Q15 */ + Word16 *gain_pit, /* o : pitch gain Q14 */ + Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ + Word16 *exc, /* o : excitation signal frame */ + Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ + Word16 *exc2, /* o : Scaled excitation signal frame */ + Word16 *bwe_exc_fx, + Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ + Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ +); + +void gaus_L2_dec( + Word16 *code, /* o : decoded gaussian codevector Q9 */ + Word16 tilt_code, /* i : tilt of code Q15 */ + const Word16 *A, /* i : quantized LPCs Q12 */ + Word16 formant_enh, /* i : formant enhancement factor Q15 */ + Word16 *seed_acelp /*i/o : random seed Q0 */ +); + +ivas_error decod_gen_voic_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 sharpFlag_fx, /* i : formant sharpening flag */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 do_WI_fx, /* i : do interpolation after a FER */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + Word16 *unbits, /* number of unused bits */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +); + +void decod_tran_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ + Word16 *unbits, /* i/o: number of unused bits */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 *gain_buf /*Q14*/ +); + +void transition_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 tc_subfr, /* i : TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *exc, /* o : excitation signal */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + Word16 **pt_pitch, /* o : floating pitch values */ + Word16 *position, /* i/o: first glottal impulse position in frame */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *Q_exc /*i/o : scaling of excitation */ +); + +Word16 tc_classif_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame /* i : length of the frame */ +); + +ivas_error decod_ppp_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ + Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ + Word16 *exc_fx, /* i/o: current non-enhanced excitation */ + Word16 *exc2_fx, /* i/o: current enhanced excitation */ + Word16 bfi, /* i : bad frame indicator */ + Word16 *gain_buf, /*Q14*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ +); + +void swb_bwe_dec_lr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis : QsL */ + const Word16 QsL, /* i : Q value of m_core */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ + Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ + Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ + Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ + const Word16 hqswb_clas_fx, /* i : class information : Q0 */ + Word16 lowlength_fx, /* i : Lowband Length : Q0 */ + Word16 highlength_fx, /* i : Highband Length : Q0 */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ + Word16 *prev_frm_hfe2, /* i/o: : Q0 */ + Word16 *prev_stab_hfe2, /* i/o: : Q0 */ + Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ + const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ + Word16 *ni_seed_fx /* i/o: random seed : QsL */ +); + +Word16 dec_acelp_tcx_frame_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *concealWholeFrame, /* i/o: concealment flag */ + Word16 *pcmBuf, /* o : synthesis */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 *pcmbufFB, /* o : synthesis @output_FS */ + Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 pitch_buf[] /* o : floating pitch for each subframe */ +); + +void decoder_LPD_fx( + Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ + Word16 signal_outFB[], /* o : synthesis @output_FS */ + Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ + Decoder_State *st, /* i/o: decoder memory state pointer */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 bfi, /* i : BFI flag */ + Word16 *bitsRead, /* o : number of read bits */ + Word16 param[], /* o : buffer of parameters */ + Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ +); + +void mode_switch_decoder_LPD_fx( + Decoder_State *st, /* Q0 */ + Word16 bandwidth_in, /* Q0 */ + Word32 bitrate, /* Q0 */ + Word16 frame_size_index /* Q0 */ +); + +void mode_switch_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ + const Word16 frame_size_index, /* i : index determining the frame size Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + +Word16 DecodeIndex( + Decoder_State *st, + const Word16 Bandwidth, /* o : NB, 1: (S)WB */ + Word16 *PeriodicityIndex ); + +Word16 DecodeIndex_fx( + Decoder_State *st, + const Word16 Bandwidth, + Word16 *PeriodicityIndex ); + +void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ +); + +Word16 lsf_msvq_ma_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ +); + +Word16 lsf_bctcvq_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ +); + +Word16 D_lsf_tcxlpc( + const Word16 indices[], /* i : VQ indices Q0*/ + Word16 lsf_q[], /* o : quantized LSF Q1*/ + Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk, /* i : codebook selector Q0*/ + Word16 mem_MA[] /* i : MA memory Q1*/ +); + +Word16 dec_lsf_tcxlpc( + Decoder_State *st, /* i/o: Decoder state */ + Word16 **indices, /* o : Ptr to VQ indices Q0*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk /* i : codebook selector Q0*/ +); + +void midlsf_dec( + const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 idx, /* i: codebook index */ + Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ + const Word16 coder_type, + Word16 *mid_lsf_int, + const Word16 prev_bfi, + const Word16 safety_net ); + +Word16 lsf_ind_is_active( + const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ + const Word16 means[], /*(14Q1*1.28)*/ + const Word16 narrowband, + const Word16 cdk ); + +void IGFSCFDecoderOpen( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ + H_IGF_INFO hIgfInfo, /* i : IGF info handle */ + const Word32 total_brate, + const Word16 bwidth, + const Word16 element_mode, + const Word16 rf_mode ); + +void IGFSCFDecoderReset( + IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ +); + +void IGFSCFDecoderDecode( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + Decoder_State *st, /* i/o: pointer to decoder state */ + Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, + if 0 on input the decoder will be forced to encode without a reset */ +); + +Word32 ari_decode_overflow_fx( + Tastat *s ); + +void ari_start_decoding_14bits_fx( + Decoder_State *st, + Tastat *s ); + +Word16 ari_start_decoding_14bits_prm_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + +Word16 ari_decode_14bits_s17_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + +Word16 ari_decode_14bits_s27_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + +Word16 ari_decode_14bits_bit_ext_fx( + Decoder_State *st, + Tastat *s ); + +Word16 ari_decode_14bits_pow_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + Word16 base ); + +Word16 ari_decode_14bits_sign_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + +void getTCXparam_fx( + Decoder_State *st, /* i/o: Decoder State handle */ + Decoder_State *st0, /* i : bitstream */ + CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ + Word16 param[], /* o : decoded parameters Q0 */ + const Word16 bits_common, /* i : number of common bits Q0 */ + const Word16 start_bit_pos, /* i : position of the start bit Q0 */ + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ + Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ + Word16 nTnsBitsTCX10[2], /*Q0*/ + const Word16 pre_past_flag /*Q0*/ +); + +void dec_prm_fx( + Word16 *coder_type, + Word16 param[], /* (o) : decoded parameters */ + Word16 param_lpc[], /* (o) : LPC parameters */ + Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ + Decoder_State *st, + Word16 L_frame, + Word16 *bitsRead ); + +void getLPCparam_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Word16 param_lpc[], /* o : LTP parameters Q0 */ + Decoder_State *st0, /* i : bitstream */ + const Word16 ch, /* i : channel Q0 */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ +); + +void UnmapIndex( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word16 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ +); + +void ConfigureContextHm( + const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ + const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ + const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ + const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ +); + +Word16 CountIndexBits( + Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ + Word16 PeriodicityIndex /* Q0 */ +); + +Word32 tcx_hm_render( + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ +); + +void tcx_hm_modify_envelope( + Word16 gain, /* i: HM gain Q11 */ + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + Word16 L_frame /* i: number of spectral lines Q0 */ +); + +Word16 ReadTnsData( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +void ReadTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +Word16 DecodeTnsData( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +Word16 DecodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +void GetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void const *pParameter, + Word16 **pStream, + Word16 *pnSize, + Word16 *pnBits ); + +void GetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, // Q0 + void const *pParameter, // Q0 + Word16 **pStream, // Q0 + Word16 *pnSize, // Q0 + Word16 *pnBits // Q0 +); + +void EncodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream Q0*/ + Word16 *pnSize, /* o : number of written parameters Q0*/ + Word16 *pnBits /* o : number of written bits Q0*/ +); + +void SetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + +void SetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + +void WriteToBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + +void ReadFromBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + +void ReadFromBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + +void IGFDecReadData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +); + +void IGFDecReadLevel( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +); + +void IGFDecApplyMono( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ +); + +void IGFDecApplyMono_ivas( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ + Word16 element_mode /**< in: | IVAS element mode */ +); + +void IGFDecApplyStereo( + const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ + const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ + Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ + Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ + Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ + Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ + const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 *coreMsMask, + const Word16 restrict_hopsize, + const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ + const Word16 bfi_apply_damping ); + +void IGFDecSetMode( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void IGFDecSetMode_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void IGFDecUpdateInfo( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 igfGridIdx /**< in: | IGF grid index */ +); + +void IGFDecUpdateInfo_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ + const Word16 subFrameIdx, /* i : subframe index */ + const Word16 igfGridIdx /* i : IGF grid index */ +); + +void IGFDecCopyLPCFlatSpectrum( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ +); + +void IGFDecCopyLPCFlatSpectrum_fx( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ +); + +void IGFDecStoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ +); + +void IGFDecRestoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ +); + +void IGFDecRestoreTCX10SubFrameData_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word16 subFrameIdx /* i : index of subframe */ +); + +void init_igf_dec( + IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ +); + +Word16 dlpc_avq_fx( + Word16 *index, /* (i) Quantization indices */ + Word16 *LSF_Q, /* (o) Quantized LSF vectors */ + Word16 numlpc, /* (i) Number of sets of lpc */ + Word32 sr_core ); + +Word16 decode_lpc_avq_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc /* o : lpc parameters */ +); + +Word16 decode_lpc_avq_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc, /* o : lpc parameters */ + const Word16 ch, /* i : channel */ + const Word16 element_mode, /* i : element mode */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ +); + +void vlpc_1st_dec( + Word16 index, /* i : codebook index */ + Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ + +void vlpc_2st_dec( + Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ + Word16 *indx, /* i : index[] (4 bits per words) */ + Word16 mode, /* i : 0=abs, >0=rel */ + Word32 sr_core ); + +void lsf_weight_2st( + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 mode /* input: operational mode Q0 */ +); + +/* Returns: index of next coefficient */ +Word16 get_next_coeff_mapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +/* Returns: index of next coefficient */ +Word16 get_next_coeff_unmapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +Word16 update_mixed_context( + Word16 ctx, /* Q0 */ + Word16 a /* Q0 */ +); + +Word32 update_mixed_context_ivas_fx( + Word32 ctx, /* Q0 */ + Word16 a /* Q0 */ +); + +typedef Word16 ( *get_next_coeff_function )( + Word16 ii[2], /* i/o: coefficient indexes */ + Word16 *pp, /* o : peak(1)/hole(0) indicator */ + Word16 *idx, /* o : index in unmapped domain */ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +Word16 ACcontextMapping_decode2_no_mem_s17_LC( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o: decoded spectrum */ + Word16 nt, /* i: size of spectrum */ + Word16 nbbits, /* i: bit budget */ + Word16 resQMaxBits, /* i: residual coding maximum bits*/ + CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ +); + +Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o : decoded spectrum */ + const Word16 nt, /* i : size of spectrum */ + const Word16 nbbits, /* i : bit budget */ + const Word16 resQMaxBits, /* i : residual coding maximum bits */ + CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ +); + +void reconfig_decoder_LPD_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 bits_frame, /* i : bit budget Q0*/ + Word16 bwidth, /* i : audio bandwidth Q0*/ + Word32 total_brate, /* i : total bitrate Q0*/ + Word16 L_frame_old /* i : frame length Q0*/ +); + +void reconfig_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bits_frame, /* i : bit budget Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word16 L_frame_old /* i : frame length Q0*/ +); + +void minimumStatistics_fx( + Word16 *noiseLevelMemory, /* Q15, internal state */ + Word16 *noiseLevelIndex, /* Q0, internal state */ + Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ + Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ + Word16 *lastFrameLevel, /* Q15, level of the last frame */ + Word16 currentFrameLevel, /* Q15, level of the current frame */ + Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ + Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ + Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ + Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ + Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ + +/*10Q5*/ +Word16 getLevelSynDeemph_fx( + Word16 h1Init[], /* i: i value or vector to be processed Q15 */ + Word16 const A[], /* i: LPC coefficients Qx */ + Word16 const lpcorder, /* i: LPC order Q0 */ + Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ + Word16 const preemph_fac, /* i: preemphasis factor Q15 */ + Word16 const numLoops, /* i: number of loops Q0 */ + Word16 *Exp /* o: exponent of return value Q15 */ +); + +void genPlcFiltBWAdap_fx( + Word32 const sr_core, /*mem_syn >rescaling done */ + Word16 *pitch_buffer, + Word16 *voice_factors, + Word16 *bwe_exc ); + +void decoder_acelp_fx( + Decoder_State *st, + Word16 prm[], /* i : parameters */ + Word16 A[], /* i : coefficients NxAz[M+1] */ + ACELP_config acelp_cfg, /* i : ACELP config */ + Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ + Word16 *pT, /* out: pitch for all subframe Q0 */ + Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ + Word16 stab_fac, /* i : stability of isf */ + Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ + Word16 *voice_factors, /* out: voicing factors */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *bwe_exc /* out: excitation for SWB TBE */ +); + +void decode_acelp_gains_fx( + Word16 *code, + Word16 gains_mode, + Word16 mean_ener_code, + Word16 *gain_pit, + Word32 *gain_code, + Word16 **pt_indice, + Word16 *past_gpit, + Word32 *past_gcode, + Word16 *gain_inov, + Word16 L_subfr, + Word16 *code2, + Word32 *gain_code2 ); + +void d_gain_pred_fx( + Word16 nrg_mode, /* i : NRG mode */ + Word16 *Es_pred, /* o : predicited scaled innovation energy */ + Word16 **pt_indice /* i/o: pointer to the buffer of indices */ +); + +ivas_error evs_dec_fx( + Decoder_State *st_fx, /* i/o : Decoder state structure */ + Word16 output_sp[], /* o : output synthesis signal */ + FRAME_MODE frameMode /* i : Decoder frame mode */ +); + +void fft_cldfb_fx( + Word32 *data, /* i/o: input/output vector */ + const Word16 size /* size of fft operation */ +); + +void stereo_dft_dec_analyze_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 *input_fx, /* i : input signal q*/ + Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ + const Word16 chan, /* i : channel number Q0*/ + const Word16 input_frame, /* i : input frame size Q0*/ + const Word16 output_frame, /* i : output frame size Q0*/ + const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ + const Word16 k_offset, /* i : offset of DFT Q0*/ + const Word16 delay, /* i : delay in samples FOR input signal Q0*/ + Word16 *q, + Word16 *q_DFT ); + +void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void delay_signal_q_adj_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay, /* i : delay in samples */ + const Word16 q_x, + const Word16 q_mem ); + +Word32 anint_fx( + const Word32 x, /* i: Round to the nearest integer */ + const Word16 exp /* i: Exponent for round step */ +); + +Word32 ceil_fx( + const Word32 x, /* i: number to ceil */ + const Word16 exp /* i: Exponent for ceil step */ +); + +void v_add_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_shr_16( + const Word16 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word16 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ +); + +void v_shr( + const Word32 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word32 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ +); + +void cldfbAnalysis_ts_fx( + const Word32 *timeIn_fx, /* i : time buffer */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, + Word16 *q_cldfb ); + +Word16 floor_log_2( + Word32 num ); + +void cldfbAnalysis_ts_fx_var_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + +void cldfbAnalysis_ts_fx_fixed_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + +void configureCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ + const Word32 sampling_rate /* i : sampling rate */ +); + +void dec_acelp_fast_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 cdk_index, /* i : codebook index */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + const Word16 L_subfr /* i : subframe length */ +); + +void tcx5SpectrumInterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + +void tcx5SpectrumDeinterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + +void tcx5TnsGrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum ); + +void tcx5TnsUngrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum, + const Word16 enc_dec ); + +void bpf_pitch_coherence_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ +); + +/* fft_rel.c */ + +#define SIZE_256 256 +#define NUM_STAGE_256 7 +#define SIZE2_256 ( SIZE_256 / 2 ) + +void cldfbAnalysis_ivas_fx( + const Word32 *timeIn_fx, /* i : time buffer Qx */ + Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ + Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ +); + +void cldfbSynthesis_ivas_fx( + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ + const Word16 out_shift, /* i : scale for output buffer */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ +); + +void addBassPostFilter_ivas_fx( + const Word32 *harm_timeIn_fx, + const Word16 samplesToProcess, + Word32 **rAnalysis_fx, + Word32 **iAnalysis_fx, + HANDLE_CLDFB_FILTER_BANK cldfb ); + +/* o : Q22*/ +Word32 ism_dequant_meta_fx( + const Word16 idx, /* i : quantizer index */ + const Word32 borders_fx[], /* i : level borders Q22*/ + const Word32 q_step_fx, /* i : quantization step Q22 */ + const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ + const Word16 cbsize /* i : codebook size */ +); + +void save_synthesis_hq_fec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ + const Word32 output_fx[], /* i : decoded synthesis */ + const Word16 output_frame, /* i : decoded synthesis */ + const Word16 Qpostd, /* i : Q value of delayed signal */ + CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ +); + +void calculate_nbits_meta_fx( + const Word16 nchan_ism, + Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 + Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 + const Word16 numSf, + const Word16 numCodingBands, + Word16 *bits_ism, + const Word16 idx_sep_obj, + const Word16 ism_imp ); + +void ivas_get_stereo_panning_gains_fx( + const Word16 aziDeg, + const Word16 eleDeg, + Word16 panningGains[2] ); + +ivas_error openCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + const Word16 enc_dec ); /* i : encoder/decoder flag */ + +Word32 rand_gauss_fx( + Word32 *x, + Word16 *seed, + Word16 q ); + +void resampleCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate ); + +void generate_masking_noise_dirac_ivas_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ + Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ + Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ + const Word16 slot_index, /* i : CLDFB slot index */ + const Word16 cna_flag, /* i : CNA flag for LB and HB */ + const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ + Word16 q_input, + Word16 *q_cldfb ); + +void IMDCT_fx( + Word32 *x, + Word16 x_e, + Word16 *old_syn_overl, + Word16 *syn_Overl_TDAC, + Word16 *xn_buf, + const Word16 *tcx_aldo_window_1, + const PWord16 *tcx_aldo_window_1_trunc, + const PWord16 *tcx_aldo_window_2, + const PWord16 *tcx_mdct_window_half, + const PWord16 *tcx_mdct_window_minimum, + const PWord16 *tcx_mdct_window_trans, + Word16 tcx_mdct_window_half_length, + Word16 tcx_mdct_window_min_length, + Word16 index, + Word16 left_rect, + Word16 tcx_offset, + Word16 overlap, + Word16 L_frame, + Word16 L_frameTCX, + Word16 L_spec_TCX5, + Word16 L_frame_glob, + Word16 frame_cnt, + Word16 bfi, + Word16 *old_out, + Word16 *Q_old_wtda, + Decoder_State *st, + Word16 fullbandScale, + Word16 *acelp_zir ); + +void IMDCT_ivas_fx( + Word32 *x_fx, + Word16 q_x, + Word16 *old_syn_overl_fx, + Word16 *Q_old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, + Word16 *Q_syn_Overl_TDAC_fx, + Word16 *xn_buf_fx, + Word16 q_xn_buf_fx, + const Word16 *tcx_aldo_window_1_fx, + const PWord16 *tcx_aldo_window_1_trunc_fx, + const PWord16 *tcx_aldo_window_2_fx, + const PWord16 *tcx_mdct_window_half_fx, + const PWord16 *tcx_mdct_window_minimum_fx, + const PWord16 *tcx_mdct_window_trans_fx, + const Word16 tcx_mdct_window_half_length, + const Word16 tcx_mdct_window_min_length, + Word16 index, + const UWord16 kernel_type, /* i : TCX transform kernel type */ + const Word16 left_rect, + const Word16 tcx_offset, + const Word16 overlap, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 L_spec_TCX5, + const Word16 L_frame_glob, + const Word16 frame_cnt, + const Word16 bfi, + Word16 *old_out_fx, + Word16 *q_old_out_fx, + const Word16 FB_flag, + Decoder_State *st, + const Word16 fullbandScale, + Word16 *acelp_zir_fx, + Word16 *q_acelp_zir_fx, + Word16 *pq_win ); + +void v_mult16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, + const Word32 total_brate, + const Word16 L_frame, + const Word16 last_L_frame, + const Word16 element_mode ); + +Word32 sum2_f_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ +); + +Word32 sum2_f_16_gb_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + +Word32 sum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + +Word16 vq_dec_lvq_ivas_fx( + Word16 sf_flag, /* i : safety net flag */ + Word16 x[], /* o : Decoded vector Q(x2.56)*/ + Word16 indices[], /* i : Indices */ + Word16 stages, /* i : Number of stages */ + Word16 N, /* i : Vector dimension */ + Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ + Word16 no_bits /* (i): no. bits for lattice */ +); + +Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ +); + +void deleteCldfb_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ +); + +void fd_bwe_dec_init_fx( + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ +); + +void stereo_dft_dec_open( + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_transport /* i : number of transport channels */ +); + +void ivas_bw_switching_pre_proc_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + Word32 *old_syn_12k8_16k_fx, + Word16 Q, + Word16 Q_audio ); + +UWord32 mvl2s_r( + const Word32 x[], /* i : input vector */ + const Word16 q, + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ +); + +void decoder_tcx_post_ivas_fx( + Decoder_State *st_fx, + Word16 *synth, + Word16 *synthFB, + Word16 Q_syn, + Word16 *A, + Word16 bfi, + Word16 MCT_flag ); + +void con_tcx_ivas_fx( + Decoder_State *st, /* i/o: coder memory state */ + Word16 synth[], /* i/o: synth[] Q0 */ + const Word16 coh, /* i : coherence of stereo signal */ + Word16 *noise_seed, /* i/o: noise seed for stereo */ + const Word16 only_left, /* i : TD-PLC only in left channel */ + const Word16 *A_cng /* i : CNG LP filter coefficients */ +); + +void ivas_mdct_core_reconstruct_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ + Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ + Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + Word16 q_x, + Word16 e_sig[CPE_CHANNELS] ); + +void ari_start_encoding_14bits_ivas_fx( + Tastat *s ); + +void tcx_scalar_quantization_ivas_fx( + Word32 *x, /* i: input coefficients */ + Word16 x_e, /* i: exponent */ + Word16 *xq, /* o: quantized coefficients */ + Word16 L_frame, /* i: frame length */ + Word16 gain, /* i: quantization gain */ + Word16 gain_e, /* i: quantization gain exponent */ + Word16 offset, /* i: rounding offset (deadzone) */ + Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ + const Word16 alfe_flag ); + +Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( + Word16 *x, /* Spectral coefficients Q0*/ + const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ + Word16 *lastnz_out, /* Q0 */ + Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ + const Word16 target, /* Target bits Q0*/ + Word16 *stop, /* Q0 */ + Word16 mode, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ +); + +/* Qx*/ +Word16 usdequant_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i: quantization step Qy*/ +); + +/* Qx*/ +Word32 usdequant32_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word32 delta /* i: quantization step Qy*/ +); + +/* o: index of the winning codeword */ +Word16 usquant_fx( + const Word16 x, /* i: scalar value to quantize Qx*/ + Word16 *xq, /* o: quantized value Qx*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i: quantization step Qx-1*/ + const Word16 cbsize /* i: codebook size */ +); + +/* o : Sum */ +Word32 Dot_product( + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg /* i : vector length */ +); + +/* o : dot product of x[] and y[] */ +Word32 dotp_fx( + const Word16 x[], /* i : vector x[] */ + const Word16 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 *exp /* (o) : exponent of result (0..+30) */ +); + +/* o : sum of all squared vector elements Q(2x+1)*/ +Word32 sum2_fx_mod( + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ +); + +void Copy_Scale_sig( + const Word16 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Scale_sig32( + Word32 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_16_32_DEPREC( + const Word16 x[], /* i : signal to scale i Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_16_32_r( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_16_32_no_sat( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_32_16( + const Word32 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Random_Fill( + Word16 *seed, /* i/o: random seed */ + Word16 n, /* i : number of values */ + Word16 *y, /* o : output values */ + Word16 scaling /* i : scaling of values */ +); + +/* o : mean of vector */ +Word16 mean_fx( + const Word16 *vec_fx, /* i : i vector */ + const Word16 lvec_fx /* i : length of i vector */ +); + +/* o : mean of vector Qx */ +Word16 mean_no_sat_fx( + const Word16 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx /* i : length of input vector */ +); + +/* o : mean of vector Qx */ +Word32 mean_no_sat_Word32_fx( + const Word32 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx, /* i : length of input vector */ + const Word16 gb ); +void sort( + UWord16 *x, /* i/o: Vector to be sorted */ + UWord16 len /* i/o: vector length */ +); + +void sort_fx( + Word16 *r, /* i/o: Vector to be sorted in place */ + Word16 lo, /* i : Low limit of sorting range */ + Word16 up /* I : High limit of sorting range */ +); + +void sort_32_fx( + Word32 *r, /* i/o: Vector to be sorted in place */ + const Word16 lo, /* i : Low limit of sorting range */ + const Word16 up /* I : High limit of sorting range */ +); + +/* o : index of the minimum value in the input vector */ +Word16 minimum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *min_fx /* o : minimum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *max_fx /* o : maximum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_exp_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 *exp_vec, /* i : exponents of input vector */ + const Word16 lvec_fx /* i : length of input vector */ +); + +/* o : index of the maximum abs value in the input vector */ +Word16 maximum_abs_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max_val /* o : maximum value in the input vector */ +); + +/* o : index of the minimum value in the input vector */ +Word16 minimum_abs32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ +); + +/* o : index of the minimum value in the input vector */ +Word16 minimum_32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_abs_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the maximum value in the input vector */ +Word16 maximum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ +); + +Word16 Exp16Array( + const Word16 n, /* (i): Array size */ + const Word16 *sx /* (i): Data array */ +); + +Word16 Exp32Array( + const Word16 n, /* (i): Array size */ + const Word32 *sx /* (i): Data array */ +); + +/* o : sum of all vector elements Qx*/ +Word32 sum16_32_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +/* o : sum of all vector elements Qx*/ +Word32 sum32_sat( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +/* o: variance of vector Qx+16*/ +Word32 var_fx_32( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ +); + +/* o: variance of vector Qx+16*/ +Word32 var_fx_32in_32out( + const Word32 *x, /* i: input vector Qx*/ + Word16 *Qx, + const Word16 len, /* i: length of inputvector */ + const Word16 gb ); + +/* o: variance of vector Qx*/ +Word16 var_fx( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ +); + +/* o: variance of vector Qx*/ +Word16 std_fx( + const Word16 x[], /* i: input vector */ + const Word16 len /* i: length of the input vector */ +); + +/* o : the dot product x'*A*x */ +Word32 dot_product_mat_fx( + const Word16 *x, /* i : vector x Q15 */ + const Word32 *A, /* i : matrix A Q0*/ + const Word16 m /* i : vector & matrix size */ +); + +void Vr_subt( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 N /* i : Vector lenght */ +); + +/* o: index of the winning codevector */ +Word16 vquant_ivas_fx( + Word32 x[], /* i: vector to quantize Q25 */ + const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ + Word32 xq[], /* o: quantized vector Q25 */ + const Word32 cb[], /* i: codebook Q25 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ +); + +/* o: index of the winning codevector */ +Word16 vquant_fx( + Word16 x[], /* i: vector to quantize Q13 */ + const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ + Word16 xq[], /* o: quantized vector Q13 */ + const Word16 cb[], /* i: codebook Q13 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ +); + +Word16 w_vquant_fx( + Word16 x[], /* i: vector to quantize in Q10 */ + Word16 Qx, + const Word16 weights[], /* i: error weights in Q0 */ + Word16 xq[], /* o: quantized vector in Q15 */ + const Word16 cb[], /* i: codebook in Q15 */ + const Word16 cbsize, /* i: codebook size */ + const Word16 rev_vect /* i: reverse codebook vectors */ +); + +/* o : return index with max energy value in vector Q0 */ +Word16 emaximum_fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word16 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ +); + +/* o : return index with max energy value in vector Q0 */ +Word16 emaximum_32fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word32 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ +); + +/* o : mean of the elements of the vector */ +Word32 Mean32( + const Word32 in[], /* i : input vector */ + const Word16 L /* i : length of input vector */ +); + +/* o : sum of all vector elements Qx*/ +Word32 sum32_fx( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +/* o : sum of all vector elements Qx*/ +Word16 sum16_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +Word16 own_random2_fx( + Word16 seed ); + +void iDiv_and_mod_32( + const Word32 Numer, /* i : 32 bits numerator */ + const Word16 Denom, /* i : 16 bits denominator */ + Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ + Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ + const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ +); + +void pz_filter_sp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word16 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + +Word32 root_a_fx( + Word32 a, + Word16 Q_a, + Word16 *exp_out ); + +Word32 root_a_over_b_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + +Word32 root_a_over_b_ivas_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + +void fir_fx( + const Word16 x[], /* i : input vector Qx*/ + const Word16 h[], /* i : impulse response of the FIR filter Q12*/ + Word16 y[], /* o : output vector (result of filtering) Qx*/ + Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ + const Word16 L, /* i : input vector size */ + const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ + const Word16 upd, /* i : 1 = update the memory, 0 = not */ + Word16 shift /* i : difference between Q15 and scaling of h[] */ +); + +void v_add_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_shr_32( + Word32 x1[], /* i : Input vector 1 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N, /* i : Vector length */ + Word16 shift /*shift value*/ +); + +void v_sub_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_add_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_sub_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +/* o: index of the winning codeword */ +Word16 squant_fx( + const Word16 x, /* i: scalar value to quantize */ + Word16 *xq, /* o: quantized value */ + const Word16 cb[], /* i: codebook */ + const Word16 cbsize /* i: codebook size */ +); + +Word16 squant_int_fx( + UWord8 x, /* i : scalar value to quantize */ + UWord8 *xq, /* o : quantized value */ + const UWord8 *cb, /* i : codebook */ + const Word16 cbsize /* i : codebook size */ +); + +void pz_filter_dp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word32 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + +void Copy_Scale_sig32_16( + const Word32 *src, /* i : signal to scale Qx */ + Word16 *dst, /* o : scaled signal Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ + +void v_multc_att( + const Word16 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word16 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_att32( + const Word32 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_att3232( + const Word32 x[], /* i : Input vector Qx */ + const Word32 att, /* i : Constant Q32, <= MAX_32 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); + +void v_L_mult_1616( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_L_mult_3216( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void add_vec_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 Qx1, /* i : SCaling of input 1 */ + const Word16 x2[], /* i : Input vector 2 */ + const Word16 Qx2, /* i : SCaling of input 1 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 Qy, /* i : SCaling of output 1 */ + const Word16 N /* i : Vector lenght */ +); + +/* o: Result (Normalized) */ +Word32 Add_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ +); + +/* o: Result (Normalized) */ +Word32 Mul_flt32_Q15( + Word32 value, /* i: Pseudo_float Value */ + Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ + Word16 frac /* i: Q15 value */ +); + +/* o: Result (Normalized) */ +Word32 Div_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ +); + +/* o: Result (Normalized) */ +Word32 Calc_Energy_Autoscaled( + const Word16 *signal, /* i: Signal */ + Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ + Word16 len, /* i: Frame Length */ + Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ +); + +Word16 Find_Max_Norm16( + const Word16 *src, + Word16 len ); + +Word16 Find_Max_Norm32( + const Word32 *src, + Word16 len ); + +/* o: Result in Q31 */ +Word32 Sqrt_Ratio32( + Word32 L_val1, /* i: Mantisa of Val1 */ + Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i: Mantisa of Val2 */ + Word16 exp2, /* i: Exp of Val2 (same as exp1) */ + Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ +); + +/* result in Q'15 + 'exp' */ +Word16 Invert16( + Word16 val, + Word16 *exp ); + +Word16 find_rem( + Word16 n, + Word16 m, + Word16 *r ); + +Word32 find_remd( + Word32 n, + Word32 m, + Word32 *r ); + +Word16 rint_new_fx( + Word32 x /*Q16 */ +); + +Word16 erb_diff_search_fx( + Word16 *prev_erb, + const Word16 *curr_erb, + Word16 *dif_erb, + Word16 *pow_spec, + const Word16 *cb_fx, + Word16 cb_size, + Word16 cb_dim, + Word16 offset ); + +void Acelp_dec_total_exc( + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + const Word16 gain_code16, /* i : Gain code Q0 */ + const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ + const Word16 i_subfr, /* i ; subfr */ + const Word16 *code_fx, /* i : code in Q9 */ + const Word16 L_subfr /* i : Subframne lenght */ +); + +UWord32 UL_inverse( + const UWord32 UL_val, + Word16 *exp ); + +UWord32 UL_div( + const UWord32 UL_num, + const UWord32 UL_den ); + +Word16 ratio( + const Word32 numer, + const Word32 denom, + Word16 *expo ); + +void hp400_12k8_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ +); + +void hp400_12k8_ivas_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ +); + +Word16 dot_prod_satcontr( + const Word16 *x, + const Word16 *y, + Word16 qx, + Word16 qy, + Word16 *qo, + Word16 len ); + +void E_UTIL_f_convolve( + const Word16 x[], + const Word16 h[], + Word16 y[], + const Word16 size ); + +void floating_point_add( + Word32 *mx, /* io: mantissa of the addend Q31 */ + Word16 *ex, /* io: exponent of the addend Q0 */ + const Word32 my, /* i: mantissa of the adder Q31 */ + const Word16 ey /* i: exponent of the adder Q0 */ +); + +void delay_signal_fx( + Word16 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word16 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ +); + +void delay_signal32_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ +); + +Word16 lin_interp_ivas_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ +); + +Word16 lin_interp_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ +); + +Word16 ceil_log_2( + UWord64 val ); + +Word32 imax_pos_fx( + const Word32 *y /* i : Input vector for peak interpolation Qx*/ +); + +void msvq_enc_ivas_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ + const Word16 Q_cb, /* i : Codebook Q */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ + const Word16 u_e, /* i : Exponent for Vector to be encoded */ + const Word16 *levels, /* i : Number of levels in each stage */ + const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ + const Word16 stages, /* i : Number of stages */ + const Word16 w[], /* i : Weights Q8 */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 applyDCT_flag, /* i : applyDCT flag */ + Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ + Word16 Idx[] /* o : Indices */ +); + +void msvq_dec_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 Idx[], /* i : Indices */ + const Word16 applyIDCT_flag, /* i : applyIDCT flag */ + const Word32 *invTrfMatrix, /* i : synthesis matrix */ + Word32 *uq, /* o : quantized vector */ + Word16 *uq_ind, /* o : quantized vector (fixed point) */ + Word16 exp ); + +void dec_FDCNG_MSVQ_stage1_fx( + Word16 j_full, /* i : index full range */ + Word16 n, /* i : dimension to generate */ + const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ + const DCTTYPE idcttype, /* i : specify which IDCT */ + Word32 *uq, /* o : synthesized stage1 vector Q20 */ + Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ +); + +void dctT2_N_apply_matrix_fx( + const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ + Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ + const Word16 dct_dim, /* i : dct processing dim possibly truncated */ + const Word16 fdcngvq_dim, /* i : fdcng domain length */ + const Word32 *matrix, /* i : IDCT matrix */ + const Word16 matrix_row_dim, /* i : */ + const DCTTYPE dcttype /* i : matrix operation type */ +); + +Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + +Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + +void v_mult_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_sub_s16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_sub32_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +void ivas_swb_tbe_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ + const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ + Word16 Q_exc, + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *Q_white_exc ); + +Word16 swb_bwe_dec_fx32( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ + Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ + Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ +); + +ivas_error acelp_core_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 output_fx[], /* o : synthesis @internal Fs */ + Word16 synth_fx16[], /* o : synthesis */ + Word16 save_hb_synth_fx16[], /* o : HB synthesis */ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word16 *unbits, /* o : number of unused bits */ + Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const Word16 last_element_mode, /* i : last element mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 read_sid_info /* i : read SID info flag */ +); + +void wtda_fx32( + const Word32 *new_audio, /* i : input audio Q11 */ + Word32 *wtda_audio, /* o : windowed audio Q11 */ + Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ + const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ + const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const Word16 L /* i : length */ +); + +ivas_error core_switching_pre_dec_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 output_frame, /* i : frame length */ + const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 last_element_mode, /* i : last_element_mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + Word16 Q_old_synthFB, + Word16 *Q_olapBufferSynth, + Word16 *Q_olapBufferSynth2 ); + +void hp20_fx_32( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + +void hp20_fx_32_opt( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + +void getTCXMode_ivas_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Decoder_State *st0, /* i : bitstream */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +); + +void getTCXWindowing_ivas_fx( + const Word16 core, /* i : current frame mode */ + const Word16 last_core, /* i : last frame mode */ + const Word16 element_mode, /* i : element mode */ + TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ + Decoder_State *st0 /* i : bitstream */ +); + +Word16 ari_start_decoding_14bits_prm_ivas_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + +void generate_masking_noise_ivas_fx( + Word32 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 *exp_out, /* o : time-domain signal exp */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 length, /* i : frame size */ + const Word16 core, /* i : core */ + const Word16 return_noise, /* i : noise is returned instead of added */ + const Word16 secondary, /* i : flag to indicate secondary noise generation */ + const Word16 element_mode, /* i : element mode */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ +); + +void SynthesisSTFT_dirac_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 samples_out, + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ +); + +void generate_stereo_masking_noise_fx( + Word16 *syn, /* i/o: time-domain signal */ + Word16 Q_syn, + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 fadeOut, /* i : only fade out of previous state */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ +); + +void SynthesisSTFT_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +void FdCng_decodeSID_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +); + +void cldfb_restore_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +ivas_error cldfb_save_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +); + +Word16 sr2fscale( + const Word32 sr_core /* i : internal sampling rate */ +); + +void Copy_Scale_sig32( + const Word32 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void swb_pre_proc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ + Word16 *Q_shb_spch, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ + Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ +); + +void core_encode_update_ivas_fx( + Encoder_State *st /* i/o: Encoder state structure */ +); + +void updt_enc_common_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 Q_new /* i : CUrrent frame scaling */ +); + +/* o : Q(2x - 31 - gb) */ +Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb /* i : guard bits */ +); + +Word32 sum2_16_exp_fx( + const Word16 *vec, /* i : input vector Q(15 - exp) */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ +); + +Word32 sum2_32_exp_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ +); + +Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + +void ProcessStereoIGF_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ + Word16 q_pITFMDCTSpectrum_1, + Word16 q_pITFMDCTSpectrum_2, + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + +void IGFEncApplyStereo_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + +void IGFSaveSpectrumForITF_ivas_fx( + IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + const Word32 *pITFSpectrum, /* i : MDCT spectrum */ + Word16 exp_pITFSpectrum ); + +Word16 IGFEncWriteBitstream_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ +); + +Word16 IGFSCFEncoderEncode_ivas_fx( + IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ + Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ +); + +Word16 ari_encode_14bits_ext_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s, + Word32 symbol, /* Q0 */ + UWord16 const *cum_freq /* Q0 */ +); + +Word16 ari_encode_14bits_sign_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word32 bits, /* Q0 */ + Tastat *s, + Word16 sign /* Q0 */ +); + +Word16 ari_done_encoding_14bits_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s ); + +void IGFEncConcatenateBitstream( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + const Word16 bsBits, /* i : number of IGF bits written to list of indices */ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ +); + +void hq_generic_hf_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ + Word16 length ); + +Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ); + +Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + +void lsf_syn_mem_backup_ivas_fx( + Encoder_State *st_fx, /* i: state structure */ + Word16 *btilt_code_fx, /* i: tilt code Q15 */ + Word32 *gc_threshold_fx, /* i: Q16 */ + Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ + Word16 *next_force_sf_bck_fx, /* o: */ + Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ + Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ + Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ + Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ + Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *streaklimit, /* Q15 */ + Word16 *pstreaklen ); + +ivas_error config_acelp1_fx( + const Word16 enc_dec, /* i : encoder/decoder flag */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 core_brate_inp, /* i : core bitrate */ + const Word16 core, /* i : core */ + const Word16 extl, /* i : extension layer */ + const Word32 extl_brate, /* i : extension layer bitrate */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ + ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ + const Word16 signaling_bits, /* i : number of signaling bits */ + const Word16 coder_type, /* i : coder type */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 tc_subfr, /* i : TC subfr ID */ + const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ + Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ + Word16 *unbits, /* o : number of unused bits */ + const Word16 element_mode, /* i : element mode */ + Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 idchan, /* i : stereo channel ID */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +#define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) +#define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ ); +#endif + +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +ivas_error push_next_indice_( + const char *caller, +#else +ivas_error push_next_indice( +#endif + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +ivas_error push_next_bits_( + const char *caller, +#else +ivas_error push_next_bits( #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ - ); - - /*! r: index of next coefficient */ - Word16 get_next_coeff_mapped_ivas_fx( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - void RCcontextMapping_encode2_no_mem_s17_LCS_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - Word16 lastnz, /* Q0 */ - const Word16 nbbits, /* Q0 */ - const Word16 resQMaxBits, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg ); - - void writeTCXparam_fx( - Encoder_State *st, /* i/o: Encoder State handle */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ - Word16 param[], /* i : parameters */ - const Word16 nbits_header, - const Word16 nbits_start, - const Word16 nbits_lpc, - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ - Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ - const Word16 target_bitsTCX10[2], - const Word16 pre_past_flag ); - - void calculate_hangover_attenuation_gain_ivas_fx( - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ - ); - - void init_coder_ace_plus_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ - const Word32 igf_brate, /* i : IGF configuration bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ - ); - - void core_coder_reconfig_ivas_fx( - Encoder_State *st, - const Word32 last_total_brate ); - - void core_coder_mode_switch_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word32 last_total_brate, /* i : last bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ - ); - - void configureFdCngEnc_ivas_fx( - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, /* Q0 */ - const Word32 total_brate /* Q0 */ - ); - - Word16 getTcxonly_ivas_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ - ); - - void SetModeIndex_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ - ); - - void IGFEncSetMode_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word32 total_brate, /* i : encoder total bitrate */ - const Word16 bwidth, /* i : encoder audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void init_tcx_cfg_ivas_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag ); - - Word16 msvq_stage1_dct_search_fx( - const Word32 *u_fx, /* i : target exp : u_e */ - const Word16 u_e, /* i : exp for target Q0 */ - const Word16 N, /* i : target length and IDCT synthesis length */ - const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ - const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ - const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ - Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ - const Word16 *midQ_truncQ_fx, /* i : midQ vector */ - const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ - const Word16 n_segm, /* i : number of segments */ - const Word16 *cols_per_segment, /* i : remaining length per segment */ - const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ - const Word16 *entries_per_segment, /* i : number of rows per segment */ - const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ - const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ - const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ - const Word16 npost_check, /* i : number of neigbours to check , should be even */ - Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ - Word16 *indices_st1_local, /* o : selected cand indices */ - Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ - Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ - Word16 *dist1_ptr_e ); - - Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( - const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ - const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ - const Word32 *u_fx, /* i : target signal */ - const Word16 u_e, /* i : exp for target signal */ - const Word16 maxC_st1, /* i : number of candidates in stage1 */ - Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ - Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ - ); - - void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ - ); - - ivas_error IGF_Reconfig_fx( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ +); + +/*! r: index of next coefficient */ +Word16 get_next_coeff_mapped_ivas_fx( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +void RCcontextMapping_encode2_no_mem_s17_LCS_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + Word16 lastnz, /* Q0 */ + const Word16 nbbits, /* Q0 */ + const Word16 resQMaxBits, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg ); + +void writeTCXparam_fx( + Encoder_State *st, /* i/o: Encoder State handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ + Word16 param[], /* i : parameters */ + const Word16 nbits_header, + const Word16 nbits_start, + const Word16 nbits_lpc, + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ + Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ + const Word16 target_bitsTCX10[2], + const Word16 pre_past_flag ); + +void calculate_hangover_attenuation_gain_ivas_fx( + Encoder_State *st, /* i : encoder state structure */ + Word16 *att, /* o : attenuation factor */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ +); + +void init_coder_ace_plus_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word32 igf_brate, /* i : IGF configuration bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +); + +void core_coder_reconfig_ivas_fx( + Encoder_State *st, + const Word32 last_total_brate ); + +void core_coder_mode_switch_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word32 last_total_brate, /* i : last bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +); + +void configureFdCngEnc_ivas_fx( + HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, /* Q0 */ + const Word32 total_brate /* Q0 */ +); + +Word16 getTcxonly_ivas_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ +); + +void SetModeIndex_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ +); + +void IGFEncSetMode_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word32 total_brate, /* i : encoder total bitrate */ + const Word16 bwidth, /* i : encoder audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void init_tcx_cfg_ivas_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag ); + +Word16 msvq_stage1_dct_search_fx( + const Word32 *u_fx, /* i : target exp : u_e */ + const Word16 u_e, /* i : exp for target Q0 */ + const Word16 N, /* i : target length and IDCT synthesis length */ + const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ + Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ + const Word16 *midQ_truncQ_fx, /* i : midQ vector */ + const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ + const Word16 n_segm, /* i : number of segments */ + const Word16 *cols_per_segment, /* i : remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ + const Word16 *entries_per_segment, /* i : number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ + const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ + const Word16 npost_check, /* i : number of neigbours to check , should be even */ + Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ + Word16 *indices_st1_local, /* o : selected cand indices */ + Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ + Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ + Word16 *dist1_ptr_e ); + +Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( + const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ + const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ + const Word32 *u_fx, /* i : target signal */ + const Word16 u_e, /* i : exp for target signal */ + const Word16 maxC_st1, /* i : number of candidates in stage1 */ + Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ + Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ +); + +void FEC_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ + const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ + const Word16 coder_type, /* i : type of coder Q0*/ + Word16 clas, /* i : signal clas for current frame Q0*/ + const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ + const Word16 *res, /* i : LP residual signal frame Qx*/ + Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ + const Word16 L_frame, /* i : Frame length Q0*/ + const Word32 total_brate, /* i : total codec bitrate Q0*/ + const Word16 Q_synth /* i : input scaling */ +); + +ivas_error IGF_Reconfig_fx( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void core_switching_post_enc_ivas_fx( + Encoder_State *st /* i/o: encoder state structure */ #ifndef CLEANUP_ACELP_ENC - , - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ - Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new + , + Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ + Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ + Word16 A_fx[], /* i : unquant. LP filter coefs. */ + Word16 Q_new #endif - ); - - void residu_ivas_fx( - const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ - const Word16 a_exp, - const Word16 m, /* i : order of LP filter */ - const Word32 *x, /* i : input signal (usually speech) Qx*/ - Word32 *y, /* o : output signal (usually residual) Qx*/ - const Word16 l /* i : size of filtering */ - ); - - void WriteToBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - - /*===========================================================================================*/ - /*----------------------------------------------------------------------------------* - * MODE1 prototypes - *----------------------------------------------------------------------------------*/ - - /*! r: output random value */ - Word16 own_random( - Word16 *seed /* i/o: random seed */ - ); - - /*! r: sum of all vector elements */ - Word16 sum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ - ); - - void set_c( - Word8 y[], /* i/o: Vector to set */ - const Word8 a, /* i : Value to set the vector to */ - const Word32 N /* i : Length of the vector */ - ); - - void set_s( - Word16 y[], /* i/o: Vector to set */ - const Word16 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ - ); - - void set_l( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Length of the vector */ - ); - - void set_zero_fx( - Word32 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ - ); - - void set_zero2_fx( - Word32 *vec, /* o : input vector */ - const Word32 lvec /* i : length of the vector */ - ); - - void set16_zero_fx( - Word16 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ - ); - - void mvs2s( - const Word16 x[], /* i : input vector */ - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ - ); - - void mvl2l( - const Word32 x[], /* i : input vector */ - Word32 y[], /* o : output vector */ - const Word16 n /* i : vector size */ - ); - - Word16 maximumAbs_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /*! r: index of the minimum value in the input vector */ - Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ - ); - - void sort_l( - Word32 *x, /* i/o: Vector to be sorted */ - Word16 len /* i/o: vector length */ - ); - - ivas_error push_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 id, /* i : ID of the indice */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ - ); - - ivas_error push_next_indice_( +); + +void residu_ivas_fx( + const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ + const Word16 a_exp, + const Word16 m, /* i : order of LP filter */ + const Word32 *x, /* i : input signal (usually speech) Qx*/ + Word32 *y, /* o : output signal (usually residual) Qx*/ + const Word16 l /* i : size of filtering */ +); + +void WriteToBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + +void WriteToBitstream_ivas_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + +/*===========================================================================================*/ +/*----------------------------------------------------------------------------------* + * MODE1 prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: output random value */ +Word16 own_random( + Word16 *seed /* i/o: random seed */ +); + +/*! r: sum of all vector elements */ +Word16 sum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ +); + +void set_c( + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word32 N /* i : Length of the vector */ +); + +void set_s( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void set_l( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ +); + +void set_zero_fx( + Word32 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); + +void set_zero2_fx( + Word32 *vec, /* o : input vector */ + const Word32 lvec /* i : length of the vector */ +); + +void set16_zero_fx( + Word16 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); + +void mvs2s( + const Word16 x[], /* i : input vector */ + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ +); + +void mvl2l( + const Word32 x[], /* i : input vector */ + Word32 y[], /* o : output vector */ + const Word16 n /* i : vector size */ +); + +Word16 maximumAbs_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ +); + +void sort_l( + Word32 *x, /* i/o: Vector to be sorted */ + Word16 len /* i/o: vector length */ +); + +ivas_error push_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 id, /* i : ID of the indice */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +ivas_error push_next_indice_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ - ); + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); - ivas_error push_next_bits_( +ivas_error push_next_bits_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ - ); - - /*! r: maximum number of indices */ - Word16 get_ivas_max_num_indices_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ - ); - - /*! r: maximum number of indices */ - Word16 get_BWE_max_num_indices( - const Word32 extl_brate /* i : extensiona layer bitrate */ - ); - - /*! r: maximum number of indices */ - Word16 get_ivas_max_num_indices_metadata_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ - ); - ivas_error ind_list_realloc( - INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ - const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ - Encoder_Struct *st_ivas /* i : IVAS encoder structure */ - ); - - ivas_error check_ind_list_limits( - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ - ); - - void move_indices( - INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ - INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const Word16 nb_indices /* i : number of moved indices */ - ); - - /*! r: index of the indice in the list, -1 if not found */ - Word16 find_indice( - BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const Word16 id, /* i : ID of the indice */ - UWord16 *value, /* o : value of the quantized indice */ - Word16 *nb_bits /* o : number of bits used to quantize the indice */ - ); - - /*! r: number of deleted indices */ - UWord16 delete_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 id /* i : ID of the indice */ - ); - - /*! r: value of the indice */ - UWord16 get_indice_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 pos, /* i : absolute position in the bitstream */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ - ); - - void reset_indices_dec( - Decoder_State *st /* i/o: decoder state structure */ - ); - - Word16 rate2EVSmode( - const Word32 brate, /* i : bitrate */ - Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ - ); - - /*! r: 1 = OK, 0 = something wrong */ - ivas_error read_indices_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - UWord16 bit_stream[], /* i : bitstream buffer */ - UWord16 num_bits, /* i : number of bits in bitstream */ - Word16 *prev_ft_speech, - Word16 *CNG, - Word16 bfi /* i : bad frame indicator */ - ); - - void ivas_set_bitstream_pointers( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - ); - - Decoder_State **reset_elements( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - ); - - void convertSerialToBytestream_fx( - const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ - const UWord16 num_bits, /* i : number of bits in the input bitstream */ - UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ - ); - - void mdct_switching_dec_fx( - Decoder_State *st /* i/o: decoder state structure */ - ); - - Word16 print_disclaimer( - FILE *fPtr ); - - void preemph_ivas_fx( - Word32 *signal, /* i/o: signal Qx*/ - const Word16 mu, /* i : preemphasis factor Q15*/ - const Word16 L, /* i : vector size Q0*/ - Word32 *mem /* i/o: memory (x[-1]) Qx*/ - ); - - void create_offset( - UWord32 *offset_scale1, - UWord32 *offset_scale2, - const Word16 mode, - const Word16 prediction_flag ); - - void BASOP_cfft_ivas( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - Word16 s, /* i : stride real and imag part */ - Word16 *scale /* i : scalefactor */ - ); - - Word32 ar_div_ivas( - Word32 num, - Word32 denum ); - - Word32 Mult_32_16( - Word32 a, - Word16 b ); - - Word32 Mult_32_32( - Word32 a, - Word32 b ); + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +/*! r: maximum number of indices */ +Word16 get_BWE_max_num_indices( + const Word32 extl_brate /* i : extensiona layer bitrate */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_metadata_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); +ivas_error ind_list_realloc( + INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ + const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ + Encoder_Struct *st_ivas /* i : IVAS encoder structure */ +); + +ivas_error check_ind_list_limits( + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +); + +void move_indices( + INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ + INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ + const Word16 nb_indices /* i : number of moved indices */ +); + +/*! r: index of the indice in the list, -1 if not found */ +Word16 find_indice( + BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ + const Word16 id, /* i : ID of the indice */ + UWord16 *value, /* o : value of the quantized indice */ + Word16 *nb_bits /* o : number of bits used to quantize the indice */ +); + +/*! r: number of deleted indices */ +UWord16 delete_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 id /* i : ID of the indice */ +); + +/*! r: value of the indice */ +UWord16 get_indice_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 pos, /* i : absolute position in the bitstream */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +); + +void reset_indices_dec( + Decoder_State *st /* i/o: decoder state structure */ +); + +Word16 rate2EVSmode( + const Word32 brate, /* i : bitrate */ + Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ +); + +/*! r: 1 = OK, 0 = something wrong */ +ivas_error read_indices_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + UWord16 bit_stream[], /* i : bitstream buffer */ + UWord16 num_bits, /* i : number of bits in bitstream */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ +); + +void ivas_set_bitstream_pointers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +Decoder_State **reset_elements( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void convertSerialToBytestream_fx( + const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ + const UWord16 num_bits, /* i : number of bits in the input bitstream */ + UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ +); + +void mdct_switching_dec_fx( + Decoder_State *st /* i/o: decoder state structure */ +); + +Word16 print_disclaimer( + FILE *fPtr ); + +void preemph_ivas_fx( + Word32 *signal, /* i/o: signal Qx*/ + const Word16 mu, /* i : preemphasis factor Q15*/ + const Word16 L, /* i : vector size Q0*/ + Word32 *mem /* i/o: memory (x[-1]) Qx*/ +); + +void create_offset( + UWord32 *offset_scale1, + UWord32 *offset_scale2, + const Word16 mode, + const Word16 prediction_flag ); + +void BASOP_cfft_ivas( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + Word16 s, /* i : stride real and imag part */ + Word16 *scale /* i : scalefactor */ +); + +Word32 ar_div_ivas( + Word32 num, + Word32 denum ); + +Word32 Mult_32_16( + Word32 a, + Word16 b ); + +Word32 Mult_32_32( + Word32 a, + Word32 b ); #ifdef DEBUGGING - void read_next_force( - int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ - FILE *f_force, /* i : force switching profile (0 if N/A) */ - int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ - ); +void read_next_force( + int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ + FILE *f_force, /* i : force switching profile (0 if N/A) */ + int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ +); #endif - ivas_error init_encoder_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ - ); - - ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - const Word16 Q_new ); - - void flip_and_downmix_generic_fx32( - Word32 input[], /* i : input spectrum Qx*/ - Word32 output[], /* o : output spectrum Qx*/ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ - ); - - /* o : Q(2x - 31 - gb) */ - Word16 quant_2p_2N1_fx( - const Word16 pos1, /* i: position of the pulse 1 */ - const Word16 pos2, /* i: position of the pulse 2 */ - const Word16 N /* i: number of bits FOR position */ - ); - - void bands_and_bit_alloc_ivas_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); - - void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ - Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ - const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ - const Word16 tilt_fact, /* i : tilt factor Q15 */ - Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ - Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ - const Word16 gamma, /* i : weighting factor Q15 */ - const Word16 L_look /* i : look-ahead Q0*/ - ); - - Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - const Word16 target, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem ); - - Word16 RCcontextMapping_encode2_estimate_bandWise_fx( - Word16 *x, /* Q0 */ - const Word16 start_line, /* Q0 */ - const Word16 end_line, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ - ); - - /*! r: Q15 */ - Word16 expfp_evs_fx( - const Word16 x, /* i : mantissa Q15-e */ - const Word16 x_e /* i : exponent Q0 */ - ); - - void tcx_arith_render_envelope_ivas_fx( - const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i : number of spectral lines Q0*/ - const Word16 L_spec, /* i : length of the coded spectrum Q0*/ - const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o : shaped signal envelope Q16*/ - ); - - void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ - ); - - void UnmapIndex_fx( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word8 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ - ); +ivas_error init_encoder_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ +); + +ivas_error acelp_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + const Word16 Q_new ); + +void flip_and_downmix_generic_fx32( + Word32 input[], /* i : input spectrum Qx*/ + Word32 output[], /* o : output spectrum Qx*/ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ +); + +/* o : Q(2x - 31 - gb) */ +Word16 quant_2p_2N1_fx( + const Word16 pos1, /* i: position of the pulse 1 */ + const Word16 pos2, /* i: position of the pulse 2 */ + const Word16 N /* i: number of bits FOR position */ +); + +void bands_and_bit_alloc_ivas_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ + Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ + const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ + const Word16 tilt_fact, /* i : tilt factor Q15 */ + Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ + Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ + const Word16 gamma, /* i : weighting factor Q15 */ + const Word16 L_look /* i : look-ahead Q0*/ +); + +Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + const Word16 target, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem ); + +Word16 RCcontextMapping_encode2_estimate_bandWise_fx( + Word16 *x, /* Q0 */ + const Word16 start_line, /* Q0 */ + const Word16 end_line, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ +); + +/*! r: Q15 */ +Word16 expfp_evs_fx( + const Word16 x, /* i : mantissa Q15-e */ + const Word16 x_e /* i : exponent Q0 */ +); + +void tcx_arith_render_envelope_ivas_fx( + const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i : number of spectral lines Q0*/ + const Word16 L_spec, /* i : length of the coded spectrum Q0*/ + const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o : shaped signal envelope Q16*/ +); + +void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ +); + +void UnmapIndex_fx( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word8 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ +); #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) - Word32 tcx_hm_render_fx( - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ - ); - - void tcx_hm_modify_envelope_fx( - const Word16 gain, /* i: HM gain Q11 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - const Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - const Word16 L_frame /* i: number of spectral lines Q0 */ - ); - - void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ - ); - - void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ - ); - - void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ - ); - - void writeLPCparam( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ - ); - - void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); - void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); - void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); - void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); - - Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); - - Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); - Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - void ResetTnsData_flt( - STnsData *pTnsData ); - - void ClearTnsFilterCoefficients_flt( - STnsFilter *pTnsFilter ); - - void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - Word16 *pnBits /* o : number of written bits */ - ); - - Word16 DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const Word16 *stream, - Word16 *pnSize, - STnsData *pTnsData ); - - void WriteTnsData( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const Word16 *stream, /* i : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - BSTR_ENC_HANDLE hBstr, /* o : bitstream */ - Word16 *pnBits /* o : number of written bits */ - ); - - void ReadTnsData_ivas( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - - void analysisCldfbEncoder_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *timeIn, /*q11*/ - Word16 timeInq, /*q0*/ - Word16 samplesToProcess, /*q0*/ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 *ppBuf_Ener, - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - - ivas_error openCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ - ); - - void resampleCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate /* i : new samplerate to operate */ - ); - - ivas_error cldfb_save_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - /*! r: flag indicating a valid bitrate */ - Word16 is_EVS_bitrate( - const Word32 ivas_total_brate, /* i : EVS total bitrate */ - Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ - ); - - ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ - ); - - /*===========================================================================================*/ +Word32 tcx_hm_render_fx( + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ +); + +void tcx_hm_modify_envelope_fx( + const Word16 gain, /* i: HM gain Q11 */ + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + const Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + const Word16 L_frame /* i: number of spectral lines Q0 */ +); + +void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ +); + +void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ +); + +void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ +); + +void writeLPCparam( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ +); + +void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); +void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); +void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); +void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); + +Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); +Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); +Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); + +Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); +Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +void ResetTnsData_flt( + STnsData *pTnsData ); + +void ClearTnsFilterCoefficients_flt( + STnsFilter *pTnsFilter ); + +void EncodeTnsData( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + Word16 *pnBits /* o : number of written bits */ +); + +Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +void WriteTnsData( + const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ + const Word16 *stream, /* i : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + BSTR_ENC_HANDLE hBstr, /* o : bitstream */ + Word16 *pnBits /* o : number of written bits */ +); + +void ReadTnsData_ivas( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +void analysisCldfbEncoder_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *timeIn, /*q11*/ + Word16 timeInq, /*q0*/ + Word16 samplesToProcess, /*q0*/ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 *ppBuf_Ener, + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + +ivas_error openCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +); + +void resampleCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate /* i : new samplerate to operate */ +); + +ivas_error cldfb_save_memory_ivas( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +/*! r: flag indicating a valid bitrate */ +Word16 is_EVS_bitrate( + const Word32 ivas_total_brate, /* i : EVS total bitrate */ + Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ +); + +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +); + +/*===========================================================================================*/ #endif diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 7073ee69d..610b9cae0 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -242,7 +242,7 @@ void tbe_celp_exc( #endif #ifdef CLEANUP_ACELP_ENC -void tbe_celp_exc( +void tbe_celp_exc_fx( #else void tbe_celp_exc_ivas( #endif diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 9a4c5536e..049626e59 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -936,10 +936,6 @@ static void decod_gen_voic_core_switch_fx( gain_dec_mless_fx( st_fx, L_frame, GENERIC, 0, -1, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code ); } - /* _ (Word16*) gain_pit : quantized pitch gain (Q14) */ - /* _ (Word32*) gain_code : quantized codebook gain (Q16) */ - /* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */ - /* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */ #ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc, L_SUBFR ); /*Q15*/ #else diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 9870d45cb..9c1cd74ac 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -354,7 +354,7 @@ void decoder_acelp_fx( IF( st->igf != 0 ) { #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); + tbe_celp_exc_fx( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); #else tbe_celp_exc( st->L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); #endif diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 983f6d8e6..0288e3d85 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -175,7 +175,7 @@ ivas_error decod_gen_voic_fx( } #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); + tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #endif diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index f2764e6e3..43a948bba 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -170,30 +170,26 @@ void decod_tran_fx( /* update LP filtered gains for the case of frame erasures */ #ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st_fx->element_mode, i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); + + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); + move16(); #else IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); -#ifndef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); move16(); -#endif } ELSE { lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); -#ifndef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); move16(); -#endif } #endif -#ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); - move16(); -#endif - /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index fffead087..c145610f8 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -1259,6 +1259,7 @@ Word32 gain_dec_gaus_fx( L_enr_q = L_mult( index, stepSize ); /* Q0 * QstepSize_Exp -> QstepSize_Exp+1 */ L_enr_q = L_shl( L_enr_q, sub( 24 - 1, stepSize_Exp ) ); /* QstepSize_Exp+1 -> Q24 */ L_enr_q = L_add( L_enr_q, L_shl( L_deposit_h( lowBound ), 8 ) ); /* Q24 */ + /*------------------------------------------------------------* * gain = pow(10.0, enr/20) * = pow(2, 3.321928*enr/20) @@ -1416,7 +1417,6 @@ void gain_dec_amr_wb_fx( Word32 L_tmp; Word16 expg, exp_gcode0, fracg; - /**gain_inov = 1.0f/ (float)sqrt( ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR );*/ L_tmp = Dot_product12( code, code, L_SUBFR, &expg ); /*Q31 - expg*/ @@ -1465,6 +1465,7 @@ void gain_dec_amr_wb_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0, 21771 ); /* *0.166096 in Q17 -> Q27 */ L_tmp = L_shr( L_tmp, 9 + 2 ); /* From Q27 to Q16 */ L_Extract( L_tmp, &exp_gcode0, &fracg ); /* Extract exponent of gcode0 */ @@ -1510,12 +1511,14 @@ void gain_dec_amr_wb_fx( past_qua_en[i] = past_qua_en[i - 1]; move16(); } + /*past_qua_en[0] = (float)(20.0*log10(qua_en));*/ /*----------------------------------------------------------* * past_qua_en[0] = 20*log10(t_qua_gain[indice*2+1]) * = 6.0206*log2(t_qua_gain[indice*2+1]) * = 6.0206*(log2(t_qua_gain[indice*2+1]Q11 -11) *----------------------------------------------------------*/ + tmp = norm_l( qua_en ); fracg = Log2_norm_lc( L_shl( qua_en, tmp ) ); expg = sub( 30, tmp ); @@ -1529,6 +1532,7 @@ void gain_dec_amr_wb_fx( /*-----------------------------------------------------------------* * Normalized code gain *-----------------------------------------------------------------*/ + /**norm_gain_code = *gain_code / *gain_inov;*/ expg = sub( norm_s( *gain_inov ), 1 ); expg = s_max( expg, 0 ); diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index a25e259c0..5f5912fb1 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -268,7 +268,7 @@ void decod_gen_2sbfr_fx( IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) && !( st->tdm_LRTD_flag ) ) ) { #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); + tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); #else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); #endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 9fa47424f..5a2916434 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -499,13 +499,8 @@ ivas_error acelp_core_enc_fx( } ELSE IF( EQ_16( coder_type, TRANSITION ) ) { -#ifdef CLEANUP_ACELP_ENC - tc_subfr_fx = encod_tran_ivas_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, - exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ -#else tc_subfr_fx = encod_tran_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ -#endif } ELSE IF( hSC_VBR->ppp_mode ) { @@ -533,13 +528,8 @@ ivas_error acelp_core_enc_fx( hTdCngEnc->burst_ho_cnt = 0; move16(); /* VOICED frames in SC-VBR when bumped up*/ -#ifdef CLEANUP_ACELP_ENC encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#else - encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, - exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#endif } } ELSE IF( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_24k40 ) ) ) @@ -551,13 +541,8 @@ ivas_error acelp_core_enc_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ -#ifdef CLEANUP_ACELP_ENC - encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, - exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#else encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#endif } /* update st->mem_syn1 for ACELP core switching */ @@ -1373,7 +1358,11 @@ ivas_error acelp_core_enc_ivas_fx( } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { +#ifdef CLEANUP_ACELP_ENC + encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); +#else encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); +#endif } ELSE IF( ppp_mode ) { diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 5e9dc4cd8..98ab17afb 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -377,7 +377,6 @@ static void encod_gen_voic_core_switch_fx( * ACELP subframe loop *------------------------------------------------------------------*/ - Copy( res, exc, L_SUBFR ); /* Q1 */ IF( EQ_16( L_frame, L_FRAME16k ) ) @@ -422,6 +421,7 @@ static void encod_gen_voic_core_switch_fx( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ + lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */ lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ @@ -445,6 +445,7 @@ static void encod_gen_voic_core_switch_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ + IF( EQ_16( L_frame, L_FRAME ) ) { gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 3195a0b60..0fbd01b3a 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -263,7 +263,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); + tbe_celp_exc_fx( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); #else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); #endif diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index e5e12159f..89566c413 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -240,11 +240,7 @@ void encod_gen_voic_fx( *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ -#ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); -#else tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); -#endif /*-----------------------------------------------------------------* * Find adaptive exitation @@ -295,14 +291,9 @@ void encod_gen_voic_fx( * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); -#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift ); -#endif /*-----------------------------------------------------------------* * Gain encoding @@ -565,7 +556,7 @@ void encod_gen_voic_ivas_fx( shift_wsp = add( Q_new, shift ); #ifdef CLEANUP_ACELP_ENC test(); - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) ) #else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) #endif @@ -649,7 +640,7 @@ void encod_gen_voic_ivas_fx( move16(); #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); + tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index f98b21729..bd9c429b2 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -385,13 +385,8 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#ifdef CLEANUP_ACELP_ENC - 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, Q_new ); -#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 } ELSE #endif @@ -400,13 +395,8 @@ void enc_pit_exc_fx( * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC - 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, 0 ); -#else 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 ); -#endif } #endif @@ -429,24 +419,14 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#ifdef CLEANUP_ACELP_ENC - 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, Q_new ); -#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 } ELSE #endif { -#ifdef CLEANUP_ACELP_ENC - 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, 0 ); -#else 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 ); -#endif } #endif diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 0d0d7a2d2..975f62337 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -187,13 +187,8 @@ Word16 encod_tran_fx( * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); -#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); -#endif test(); test(); @@ -425,7 +420,7 @@ Word16 encod_tran_fx( #endif #ifdef CLEANUP_ACELP_ENC -Word16 encod_tran_ivas_fx( +Word16 encod_tran_fx( #else Word16 encod_tran_ivas_fx( #endif @@ -535,7 +530,7 @@ Word16 encod_tran_ivas_fx( shift_wsp = add( Q_new, shift ); #ifdef CLEANUP_ACELP_ENC test(); - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) ) #else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) #endif @@ -565,9 +560,6 @@ Word16 encod_tran_ivas_fx( Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); 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 ); } ELSE #endif @@ -585,11 +577,11 @@ Word16 encod_tran_ivas_fx( } Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); - - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn, L_SUBFR, shift ); } + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn, L_SUBFR, shift ); + /*-----------------------------------------------------------------* * TC: subframe determination & * adaptive/glottal part of excitation construction diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index c5de16ceb..a1da64adf 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -400,7 +400,7 @@ Word16 inov_encode_ivas_fx( } #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) #endif { maximum_abs_16_fx( xn2, L_subfr, &max_xn2 ); @@ -632,7 +632,7 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) #endif { Qh2 = sub( 14, norm_s( h2[0] ) ); diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 970e5001f..b1018b917 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -290,7 +290,7 @@ void encod_gen_2sbfr_fx( Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13 #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); + tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); #else tbe_celp_exc_ivas( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); #endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index dcfb5e4c0..ce74ed5a5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1880,6 +1880,7 @@ void encod_nelp_ivas_fx( Word16 shift ); Word16 encod_tran_fx( +#ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -1900,6 +1901,7 @@ Word16 encod_tran_fx( ); Word16 encod_tran_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -2074,8 +2076,8 @@ ivas_error encod_ppp_ivas_fx( Word16 Q_new, Word16 shift ); -#ifndef CLEANUP_ACELP_ENC void encod_gen_voic_fx( +#ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : i speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -2093,10 +2095,7 @@ void encod_gen_voic_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 shift, Word16 Q_new ); -#endif -#ifdef CLEANUP_ACELP_ENC -void encod_gen_voic_fx( -#else + void encod_gen_voic_ivas_fx( #endif Encoder_State *st_fx, /* i/o: state structure */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index fce2df6c5..5ec3fe688 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -20,6 +20,7 @@ static void tc_enc_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_su static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); #endif + /*==========================================================================*/ /* FUNCTION : void transition_enc_fx () */ /*--------------------------------------------------------------------------*/ @@ -165,7 +166,7 @@ void transition_enc_fx( *clip_gain = 0; move16(); #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { g_corr_fx[0] = MAX16B /* 1.0f in Q15 */; move16(); @@ -413,7 +414,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -470,7 +471,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -543,7 +544,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -577,7 +578,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -623,7 +624,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -868,7 +869,7 @@ void transition_enc_fx( *clip_gain = 0; move16(); #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { g_corr_fx[0] = 328 /* 0.01f in Q15 */; move16(); @@ -901,7 +902,7 @@ void transition_enc_fx( { /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } -- GitLab From 2ee982b866830a48c0ad77348e64e9be0bbd2f7e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 12:09:15 +0100 Subject: [PATCH 249/750] avoid defined-function macros --- apps/renderer.c | 5 --- lib_com/ari_hm_fx.c | 3 +- lib_com/cnst.h | 3 ++ lib_com/ivas_tools_fx.c | 2 +- lib_com/modif_fs_fx.c | 10 ++---- lib_com/preemph_fx.c | 35 +++++++++++++++++- lib_com/prot_fx.h | 51 ++++++++------------------- lib_com/stat_noise_uv_mod_fx.c | 4 +-- lib_com/swb_tbe_com_fx.c | 36 ++++++------------- lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/dec_higher_acelp_fx.c | 3 +- lib_dec/ivas_stereo_dft_dec_fx.c | 8 ++++- lib_dec/waveadjust_fec_dec_fx.c | 10 +++--- lib_enc/acelp_core_enc_fx.c | 2 +- lib_enc/analy_sp_fx.c | 19 +++++++--- lib_enc/enc_higher_acelp_fx.c | 6 ++-- lib_enc/ext_sig_ana_fx.c | 10 +++--- lib_enc/hq_hr_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 24 +++++-------- lib_enc/ivas_core_pre_proc_fx.c | 26 +++++--------- lib_enc/ivas_dirac_enc_fx.c | 2 +- lib_enc/ivas_front_vad_fx.c | 14 ++++---- lib_enc/ivas_ism_metadata_enc_fx.c | 2 +- lib_enc/ivas_osba_enc_fx.c | 2 +- lib_enc/speech_music_classif_fx.c | 5 +-- lib_enc/updt_enc_fx.c | 4 ++- lib_rend/lib_rend_fx.c | 4 +-- 27 files changed, 142 insertions(+), 152 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 464a9f893..a5c24ee66 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -87,11 +87,6 @@ static #define SEP_FOLDER '/' #endif -#ifndef _WIN32 -#define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) -#define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) -#endif - /*------------------------------------------------------------------------------------------* * Local structures diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c index 87af1a8eb..e35416e5f 100644 --- a/lib_com/ari_hm_fx.c +++ b/lib_com/ari_hm_fx.c @@ -2,7 +2,6 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ - #include #include #include "options.h" @@ -11,7 +10,7 @@ #include "rom_com.h" #include "prot_fx.h" -#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) + void UnmapIndex( const Word16 PeriodicityIndex, /* Q0 */ const Word16 Bandwidth, /* Q0 */ diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 036602ddc..43c20a27a 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -985,6 +985,9 @@ enum * TCX constants *---------------------------------------------------------------*/ +#define TCX_IMDCT_SCALE 15 +#define TCX_IMDCT_HEADROOM 1 + #define NBITS_TCX_GAIN 7 #define NOISE_FILL_RANGES 1 diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 8cf54ec92..685508404 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -605,7 +605,7 @@ void v_mult_mat_fx( pt_y++; } - MVR2R_WORD32( tmp_y, y, Nc ); /*Qx - guardbits*/ + Copy32( tmp_y, y, Nc ); /*Qx - guardbits*/ } diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 9420d6523..97f4ef413 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -168,7 +168,6 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q { autocorr_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 ); - t1 = L_Comp( r_fx_h[1], r_fx_l[1] ); /* R[1] in Q31 */ t2 = L_abs( t1 ); /* abs R[1] */ t0 = L_deposit_l( 0 ); @@ -181,12 +180,10 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q t0 = L_negate( t0 ); /* R[1]/R[0] */ } - mu_preemph_fx = extract_h( t0 ); /*r_fx[1] / r_fx[0]; */ mem_preemph_fx = signal_ana_fx[mem_len_ana + lg - LEN_WIN_SSS - 1]; move16(); - PREEMPH_FX( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); - + preemph_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); /* Autocorrelations */ autocorr_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, M, r_fx_h, r_fx_l, &Q_r, @@ -449,7 +446,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ { autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 ); - t1 = L_Comp( r_fx_h[1], r_fx_l[1] ); /* R[1] in Q31 */ t2 = L_abs( t1 ); /* abs R[1] */ t0 = L_deposit_l( 0 ); @@ -462,12 +458,10 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ t0 = L_negate( t0 ); /* R[1]/R[0] */ } - mu_preemph_fx = extract_h( t0 ); /*r_fx[1] / r_fx[0]; */ mem_preemph_fx = signal_ana_fx[mem_len_ana + lg - LEN_WIN_SSS - 1]; move16(); - PREEMPH_FX( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); - + preemph_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); /* Autocorrelations */ autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), M, r_fx_h, r_fx_l, &Q_r, diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c index 9631c6859..46c8ccc36 100644 --- a/lib_com/preemph_fx.c +++ b/lib_com/preemph_fx.c @@ -8,11 +8,44 @@ #include "wmc_auto.h" /*-------------------------------------------------------------* - * preemph_copy_fx() + * preemph_fx() * * Preemphasis: filtering through 1 - mu z^-1 *-------------------------------------------------------------*/ +void preemph_fx( + Word16 x[], /* i/o: input/output signal Qx */ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +) +{ + Word16 i, temp; + + temp = x[lg - 1]; /* Qx */ + move16(); + + FOR( i = lg - 1; i > 0; i-- ) + { + x[i] = msu_r_sat( L_deposit_h( x[i] ), x[i - 1], mu ); /* Qx */ + move16(); + } + + x[0] = msu_r_sat( L_deposit_h( x[0] ), *mem, mu ); /* Qx */ + move16(); + + *mem = temp; /* Qx */ + move16(); + + return; +} + +/*-------------------------------------------------------------* + * preemph_copy_fx() + * + * Preemphasis + copy: filtering through 1 - mu z^-1 + *-------------------------------------------------------------*/ + void preemph_copy_fx( const Word16 x[], /* i : input signal Qx */ Word16 y[], /* o : output signal Qx */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 577451b04..951434cd5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -33,13 +33,6 @@ #ifndef PROT_FX2_H #define PROT_FX2_H -/*----------------------------------------------------------------------------------* - * Prototypes of RAM counting tool macros - *----------------------------------------------------------------------------------*/ - -#define MVR2R_WORD32( x, y, n ) Copy32( x, y, n ) -#define MVR2R_WORD16( x, y, n ) Copy( x, y, n ) - #include #include #include @@ -59,36 +52,19 @@ #include "complex_basop.h" -#define TCX_IMDCT_SCALE 15 -#define TCX_IMDCT_HEADROOM 1 - - /*----------------------------------------------------------------------------------* * Prototypes of global macros *----------------------------------------------------------------------------------*/ -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef ABSVAL -#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) ) -#endif - -#ifndef SQR -#define SQR( a ) ( ( a ) * ( a ) ) -#endif - #ifndef SWAP #define SWAP( a, b ) \ { \ tempr = ( a ); \ ( a ) = ( b ); \ ( b ) = tempr; \ + move32(); \ + move32(); \ + move32(); \ } #endif @@ -99,6 +75,9 @@ u__p = x; \ x = y; \ y = u__p; \ + move32(); \ + move32(); \ + move32(); \ } #endif @@ -2698,9 +2677,12 @@ void lag_wind_32( Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */ ); -// preemp_fx.c -#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) ) -#define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx2( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) ) +void preemph_fx( + Word16 x[], /* i/o: input/output signal Qx */ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +); void preemph_copy_fx( const Word16 x[], /* i : i signal Qx */ @@ -9309,12 +9291,6 @@ void bpf_pitch_coherence_ivas_fx( const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ ); -/* fft_rel.c */ - -#define SIZE_256 256 -#define NUM_STAGE_256 7 -#define SIZE2_256 ( SIZE_256 / 2 ) - void cldfbAnalysis_ivas_fx( const Word32 *timeIn_fx, /* i : time buffer Qx */ Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ @@ -11304,7 +11280,8 @@ void UnmapIndex_fx( Word32 *Lag /* Q0 */ ); -#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) +//#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) +#define GET_ADJ2( T, L, F ) ( sub( shl( L, F ), T ) ) Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index ad87695e8..f9eff00b4 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -158,7 +158,7 @@ void stat_noise_uv_mod_fx( { exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ - PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); + preemph_fx( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); } } @@ -458,7 +458,7 @@ void stat_noise_uv_mod_ivas_fx( { exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ - PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); + preemph_fx( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); } } diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index c9d307ef2..c4499d8fa 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -2395,9 +2395,7 @@ prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; move16(); *Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 ); move16(); -deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); -/* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */ -/* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */ +deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); // Q_bwe_exc-NOISE_QADJ { IF( EQ_16( coder_type, UNVOICED ) ) { @@ -2412,9 +2410,7 @@ deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); move16(); /* exc16kWhtnd: Q_bwe_exc */ } - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); - /* i/o: exc16kWhtnd (Q_bwe_exc) */ - /* i/o: tbe_premph (Q_bwe_exc) */ + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE { @@ -2494,9 +2490,7 @@ deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); - /* exc16kWhtnd: Q_bwe_exc; - tbe_premph: Q_bwe_exc*/ + preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc } } } @@ -3369,8 +3363,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } - // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph); - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc + + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE { @@ -3395,9 +3389,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc - /* i/o: exc16kWhtnd (Q_bwe_exc) */ - /* i/o: tbe_premph (Q_bwe_exc) */ + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE { @@ -3478,9 +3470,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc - /* exc16kWhtnd: Q_bwe_exc; - tbe_premph: Q_bwe_exc*/ + preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc } } } @@ -4396,8 +4386,8 @@ void GenShapedSHBExcitation_ivas_dec_fx( move16(); } } - // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph); - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); + + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); } ELSE { @@ -4417,9 +4407,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( exc16kWhtnd[k] = mult_r_sat( White_exc16k[k], scale ); move16(); } - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); - /* i/o: exc16kWhtnd (Q_exc16kWhtnd) */ - /* i/o: tbe_premph (Q_exc16kWhtnd) */ + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_exc16kWhtnd } ELSE { @@ -4499,9 +4487,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( temp2 = add( temp, shl( temp1, -1 ) ); /* shift right by 1 to avoid overflow */ temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); - /* exc16kWhtnd: Q_exc16kWhtnd; - tbe_premph: Q_exc16kWhtnd*/ + preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_exc16kWhtnd } } } diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index e163662c8..dd89d78d5 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -968,7 +968,7 @@ ivas_error acelp_core_dec_fx( tmpF_fx = *old_exc_s_fx; st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */ move16(); - PREEMPH_FX( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); + preemph_fx( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M ); Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */ Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index e6cc62e23..5e02f9913 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -197,7 +197,8 @@ void transf_cdbk_dec_fx( st_fx->last_code_preq = code_preQ[L_SUBFR - 1]; // q_Code_preQ move16(); - PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &st_fx->mem_preemp_preQ_fx ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &st_fx->mem_preemp_preQ_fx ); + /*--------------------------------------------------------------* * Compute normalized prequantizer excitation gain for FEC * diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 72527526a..491dcca1c 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -3766,8 +3766,11 @@ void stereo_dft_dec_sid_coh_fx( get_next_indice_fx( st, 1 ); ( *nb_bits )++; } + return; } + + void stereo_dft_dequantize_itd_fx( Word16 *ind, /* Q0 */ Word32 *out_fx, /* Q15 */ @@ -3784,13 +3787,16 @@ void stereo_dft_dequantize_itd_fx( { itd = imult1616( -1, itd ); /* Q0 */ } - assert( ( ABSVAL( itd ) <= STEREO_DFT_ITD_MAX ) && ( ABSVAL( itd ) >= STEREO_DFT_ITD_MIN ) ); + assert( ( abs_s( itd ) <= STEREO_DFT_ITD_MAX ) && ( abs_s( itd ) >= STEREO_DFT_ITD_MIN ) ); /*Convert back @ fs*/ *out_fx = L_mult( itd, divide3232( output_Fs, STEREO_DFT_ITD_FS << 1 ) ); /*Q15*/ move32(); + return; } + + /*------------------------------------------------------------------------- * stereo_dft_dec_read_BS() * diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index f72dfde5c..b103b4c93 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -924,7 +924,7 @@ void concealment_decode_fix( IF( EQ_16( curr_mode, 1 ) ) { /* copy the data of the last frame */ - MVR2R_WORD32( hPlcInfo->data_reci2_fx, invkoef, N ); + Copy32( hPlcInfo->data_reci2_fx, invkoef, N ); *invkoef_scale = hPlcInfo->data_reci2_scale; move16(); /* sign randomization */ @@ -1404,7 +1404,7 @@ static Word16 waveform_adj_fix( /* maximum pitch lag is 3/4 Framesize; pitch125_data is reused for temporary storage, since outdata2 (holding the pcm data of the last good frame) is still needed and overlapbuf overlaps outdata2 */ - Copy( &sbuf[Framesize / 4], pitch125_data, shr( imult1616( 3, Framesize ), 2 ) ); + Copy( &sbuf[shr( Framesize, 2 )], pitch125_data, shr( imult1616( 3, Framesize ), 2 ) ); hPlcInfo->nsapp_gain_fx = 0; move16(); @@ -1416,10 +1416,10 @@ static Word16 waveform_adj_fix( add_noise( sbuf, &( hPlcInfo->outx_new_n1_fx ), outdata2, tmp, &( hPlcInfo->nsapp_gain_fx ), &( hPlcInfo->nsapp_gain_n_fx ), 1 ); /* save current (noisy) output from IMDCT */ - MVR2R_WORD16( outx_new, hPlcInfo->data_noise, tmp ); + Copy( outx_new, hPlcInfo->data_noise, tmp ); /* overlapbuf can now be filled with sbuf, needed for subsequently lost frames */ - Copy( pitch125_data, &overlapbuf[Framesize / 4], shr( imult1616( 3, Framesize ), 2 ) ); + Copy( pitch125_data, &overlapbuf[shr( Framesize, 2 )], shr( imult1616( 3, Framesize ), 2 ) ); } FOR( i = 0; i < Framesize; i++ ) { @@ -1482,7 +1482,7 @@ void waveform_adj2_fix( /* save current (noisy) output from IMDCT */ IF( bfi ) { - MVR2R_WORD16( outx_new, noise_ptr, size ); + Copy( outx_new, noise_ptr, size ); } } test(); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 0596b2f2d..f92e13aeb 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1255,7 +1255,7 @@ ivas_error acelp_core_enc_ivas_fx( /* Prepare ACB memory from last HQ frame */ tmpF_fx = hLPDmem->old_exc[0]; move16(); - PREEMPH_FX( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx ); + preemph_fx( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx ); Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M ); /* Q_new */ Scale_sig( st->hLPDmem->mem_syn, M, sub( st->hLPDmem->q_mem_syn, Q_new ) ); Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 ); diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 6909c512d..e7d09c786 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -20,6 +20,15 @@ static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, static void ivas_find_enr( Word16 *data, Word16 q_data, Word32 *band, Word16 *q_band, Word32 *ptE, Word16 *q_ptE, Word64 *LEtot, const Word16 min_band, const Word16 max_band, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies ); +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +#define SIZE_256 256 +#define NUM_STAGE_256 7 +#define SIZE2_256 ( SIZE_256 / 2 ) + + /*-------------------------------------------------------------------* * analy_sp_fx() * @@ -404,7 +413,7 @@ static void find_enr_dft_ivas_fx( move16(); L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, q_Bin_E ); - MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E + Copy32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E *q_ptE = *q_Bin_E; move16(); @@ -593,10 +602,10 @@ void ivas_analy_sp_fx( hCPE->hStereoDft->DFT_fx_e[0] = sub( hCPE->hStereoDft->DFT_fx_e[0], exp ); move16(); find_enr_dft_ivas_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, q_fr_bands, lf_E, q_lf_E, &LEtot, min_band, max_band, Bin_E, q_Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ) ); - MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); - MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); - MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS ); - MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); + Copy32( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); + Copy32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); + Copy32( band_energies, band_energies + NB_BANDS, NB_BANDS ); + Copy32( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); /* Average total log energy over both half-frames */ *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/; diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 82296aa4a..9d62a8657 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -330,7 +330,7 @@ void transf_cdbk_enc_fx( st_fx->last_nq_preQ = nq[7]; move16(); - PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); /*--------------------------------------------------------------* * For inactive segments @@ -710,7 +710,7 @@ void transf_cdbk_enc_ivas_fx( st_fx->last_code_preq = shr( code_preQ[L_SUBFR - 1], 9 ); // Q0 move16(); - PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); /*--------------------------------------------------------------* * For inactive segments @@ -775,7 +775,7 @@ static void find_cn_fx( Copy( xn, tmp_fl + M, L_SUBFR ); /* Qx */ tmp = 0; move16(); - PREEMPH_FX( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp ); + preemph_fx( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp ); syn_filt_s_lc_fx( 0, Ap, tmp_fl + M, tmp_fl + M, L_SUBFR ); Residu3_lc_fx( p_Aq, M, tmp_fl + M, cn, L_SUBFR, 1 ); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index c3958e543..b28c7f558 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -424,7 +424,7 @@ void core_signal_analysis_high_bitrate_fx( interleaveBuf[2 * i + 1] = spectrum[frameno][tcx5SizeFB + i]; /* exp(spectrum_e) */ move32(); } - MVR2R_WORD32( interleaveBuf, spectrum[frameno], tcx10SizeFB ); + Copy32( interleaveBuf, spectrum[frameno], tcx10SizeFB ); } /*--------------------------------------------------------------* @@ -454,7 +454,7 @@ void core_signal_analysis_high_bitrate_fx( } /* Copy memory */ - MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M ); /* Q15 */ + Copy( lsp_new, st->lspold_enc_fx, M ); /* Q15 */ } } @@ -599,7 +599,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( { Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); // Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same - PREEMPH_FX( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1 + preemph_fx( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1 } /* Rescale Memory */ @@ -1221,7 +1221,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( interleaveBuf[2 * i + 1] = hTcxEnc->spectrum_fx[frameno][tcx5SizeFB + i]; /* hTcxEnc->spectrum_e */ move32(); } - MVR2R_WORD32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB ); + Copy32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB ); } /*--------------------------------------------------------------* @@ -1259,7 +1259,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { /* Copy memory */ - MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M ); + Copy( lsp_new, st->lspold_enc_fx, M ); } return; diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 7f18bd48a..d9a1dd5b7 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -477,7 +477,7 @@ void hq_hr_enc_ivas_fx( ivas_de_interleave_spectrum_fx( t_audio_q_fx, length ); } - MVR2R_WORD32( t_audio_q_fx, t_audio_fx, length ); + Copy32( t_audio_q_fx, t_audio_fx, length ); return; } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index f6aa5e904..38c5abd23 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -596,13 +596,11 @@ ivas_error pre_proc_front_ivas_fx( st->mem_preemph_DFT_fx_q_inp = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */ move16(); - // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); dummy_fx = st->mem_preemph_fx_q_inp; move16(); - // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx ); - PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx ); + preemph_copy_32fx2( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx ); preemp_start_idx = new_inp_12k8_fx - STEREO_DFT_OVL_12k8; move16(); preemp_len = STEREO_DFT_OVL_12k8 + L_FRAME; @@ -617,8 +615,7 @@ ivas_error pre_proc_front_ivas_fx( st->mem_preemph_fx_q_inp = st->mem_preemph_DFT_fx_q_inp; /* st->q_inp */ move16(); Copy_Scale_sig( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( st->q_inp, Q_inp_const ) ); /* st->q_inp */ - // PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx_q_inp ); preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); move16(); preemp_len = STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT; @@ -635,19 +632,16 @@ ivas_error pre_proc_front_ivas_fx( { Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); move16(); - // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx_q_inp ); preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8; preemp_len = length_12k8; move16(); } - // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); dummy_fx = st->mem_preemph_fx_q_inp; /* st->q_inp */ move16(); - // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); - PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); + preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); test(); IF( preemp_start_idx && preemp_len ) @@ -664,12 +658,10 @@ ivas_error pre_proc_front_ivas_fx( } ELSE /* IVAS_SCE or IVAS_CPE_MDCT */ { - // PREEMPH_FX( new_inp_12k8_fx, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); dummy_fx = st->mem_preemph_fx_q_inp; move16(); - // PREEMPH_FX( new_inp_12k8_fx + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx ); - PREEMPH_32FX( new_inp_12k8_fx + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx ); + preemph_copy_32fx2( new_inp_12k8_fx + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx ); preemp_start_idx = new_inp_12k8_fx; preemp_len = L_FRAME + L_FILT; move16(); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 7ba122dbd..9857c3e12 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -965,13 +965,11 @@ ivas_error ivas_compute_core_buffers_fx( { Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); /* Q(-1) */ } - // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); - PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); - // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx); - PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx - STEREO_DFT_OVL_16k; move16(); preemp_len = STEREO_DFT_OVL_16k + L_FRAME16k; @@ -983,9 +981,8 @@ ivas_error ivas_compute_core_buffers_fx( { st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx; move16(); - Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */ - // PREEMPH_FX(new_inp_16k_fx - L_MEM_RECALC_16K - (STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx); - PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */ + Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); move16(); preemp_len = STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k; @@ -1001,8 +998,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 length_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS ); move16(); - // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k - length_16k, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx); - PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k - length_16k; preemp_len = length_16k; move16(); @@ -1012,12 +1008,10 @@ ivas_error ivas_compute_core_buffers_fx( { Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */ } - // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); - PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); - // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx); - PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */ IF( preemp_start_idx && preemp_len ) { preemp_len = add( preemp_len, add( L_FRAME16k + L_FILT16k, lMemRecalc_16k ) ); @@ -1032,12 +1026,10 @@ ivas_error ivas_compute_core_buffers_fx( } ELSE IF( EQ_16( element_mode, IVAS_SCE ) ) { - // PREEMPH_FX(new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); - PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); - // PREEMPH_FX(new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx); - PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx; preemp_len = L_FRAME16k + L_FILT16k; move16(); diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index e9fd93723..91c44fcf7 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -231,7 +231,7 @@ ivas_error ivas_dirac_enc_reconfigure( } ELSE { - MVR2R_WORD16( DirAC_block_grouping_5ms_MDFT, hDirAC->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); + Copy( DirAC_block_grouping_5ms_MDFT, hDirAC->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); } return error; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 6f1f7f5bf..f58f48e97 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -221,7 +221,7 @@ ivas_error front_vad_fx( /* Move previous frame 12k8 signal */ - MVR2R_WORD16( hFrontVad->buffer_12k8_fx + L_FFT, hFrontVad->buffer_12k8_fx, L_FFT / 2 ); + Copy( hFrontVad->buffer_12k8_fx + L_FFT, hFrontVad->buffer_12k8_fx, L_FFT / 2 ); /* Resample to 12k8 */ modify_Fs_ivas_fx( sts[n]->input_fx, input_frame, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2, INT_FS_12k8, hFrontVad->mem_decim_fx, ( sts[0]->max_bwidth == NB ), &Qband, &mem_decim_size ); @@ -232,7 +232,7 @@ ivas_error front_vad_fx( hFrontVad->q_mem_preemph_fx = add( Q_inp, Qband ); move16(); - PREEMPH_FX( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx ); + preemph_fx( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx ); Q_new = s_min( add( add( Q_inp, Qband ), Q_add ), Q_buffer[n] ); scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, sub( Q_new, Q_buffer[n] ) ); /* Q_new */ @@ -339,13 +339,12 @@ ivas_error front_vad_fx( IF( PS_out_fx != NULL ) { - MVR2R_WORD32( PS_fx, PS_out_fx, L_FRAME / 2 ); + Copy32( PS_fx, PS_out_fx, L_FRAME / 2 ); } IF( Bin_E_out_fx != NULL ) { - - MVR2R_WORD16( lgBin_E_fx, Bin_E_out_fx, L_FRAME / 2 ); + Copy( lgBin_E_fx, Bin_E_out_fx, L_FRAME / 2 ); } pop_wmops(); @@ -528,7 +527,7 @@ ivas_error front_vad_spar_fx( inp_12k8_fx = hFrontVad->buffer_12k8_fx; - MVR2R_WORD16( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); + Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); wsp_fx = old_wsp_fx + L_WSP_MEM; st->core_brate = -1; /* updated in dtx() */ @@ -730,8 +729,9 @@ ivas_error front_vad_spar_fx( lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_32fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame ); - MVR2R_WORD16( st->pitch, st->pitch, 3 ); + Copy( st->pitch, st->pitch, 3 ); vad_param_updt_fx( st, st->pitch[1], corr_shift_fx, corr_shift_fx, A_fx, &hFrontVad, 1 ); + /* 1st stage speech/music classification (GMM model) */ /* run only to get 'high_lpn_flag' parameter */ SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index f13b24b63..5876f130f 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -1074,7 +1074,7 @@ static void encode_radius_fx( nbits_diff_radius = 1; move16(); } - ELSE IF( LE_16( ABSVAL( diff ), ISM_MAX_RADIUS_DIFF_IDX ) ) + ELSE IF( LE_16( abs_s( diff ), ISM_MAX_RADIUS_DIFF_IDX ) ) { idx_radius = 2; // shl( 1, 1 ); move16(); diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 5f0ec3319..f2b6dac64 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -414,7 +414,7 @@ void ivas_osba_enc_fx( /*keep the delay buffer up to date*/ FOR( n = 0; n < nchan_ism; n++ ) { - MVR2R_WORD32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s ); // Q_data + Copy32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s ); // Q_data } /* Convert ISM to SBA */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index b1e9751e8..a60539047 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2003,7 +2003,7 @@ Word16 ivas_smc_gmm_fx( temp32_log = Mpy_32_32( temp32_log, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/ *pFV_fx++ = L_shr( temp32_log, Q5 ); // logf( ps_sta + 1e-5f ); move32(); - MVR2R_WORD32( &PS_norm_fx[LOWEST_FBIN], hSpMusClas->past_PS_fx, HIGHEST_FBIN - LOWEST_FBIN ); + Copy32( &PS_norm_fx[LOWEST_FBIN], hSpMusClas->past_PS_fx, HIGHEST_FBIN - LOWEST_FBIN ); /* save ps_diff and ps_sta features for XTALK and UNCLR classifier */ IF( hStereoClassif != NULL ) @@ -2108,7 +2108,8 @@ Word16 ivas_smc_gmm_fx( } /* update */ - MVR2R_WORD32( FV_fx, hSpMusClas->prev_FV_fx, N_SMC_FEATURES ); + Copy32( FV_fx, hSpMusClas->prev_FV_fx, N_SMC_FEATURES ); + /*------------------------------------------------------------------* * Non-linear power transformation (boxcox) on certain features *------------------------------------------------------------------*/ diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 62af228a0..2eb3e1a17 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -193,11 +193,13 @@ void updt_IO_switch_enc_fx( hTdCngEnc->old_enr_index = s_min( mult( shl( hTdCngEnc->old_enr_index, 1 ), 32459 ), 127 ); /*32459 = 2/(STEP_SID/STEP_AMR_WB_SID)*/ move16(); } + /* Perform preemphasis of the old input signal @16kHz */ st->mem_preemph16k_fx = 0; move16(); - PREEMPH_FX( st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k_fx ) ); + preemph_fx( st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k_fx ) ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, st->prev_Q_new ); + /* reset TD BWE buffers */ set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); set16_fx( hBWE_TD->old_speech_wb_fx, 0, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 9a1dbfe5b..dce05b983 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6367,7 +6367,7 @@ static ivas_error rotateFrameMc_fx( /* move gains to gains_prev */ FOR( i = 0; i < nchan; i++ ) { - MVR2R_WORD32( gains[i], gains_prev[i], nchan ); + Copy32( gains[i], gains_prev[i], nchan ); } } @@ -7444,7 +7444,7 @@ static ivas_error renderLfeToBinaural_fx( v_multc_fx( lfeInput, gain_fx, tmpLfeBuffer + num_cpy_smpl_prev_frame, num_cpy_smpl_cur_frame ); /* Qx - 1 */ /* Save remaining LFE samples of current frame for next frame */ - MVR2R_WORD32( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer_fx, num_cpy_smpl_prev_frame ); + Copy32( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer_fx, num_cpy_smpl_prev_frame ); r_shift = sub( sub( in_q, 1 ), out_q ); IF( r_shift != 0 ) -- GitLab From 5da38eed351c9c4b5e2456108b8f576d44e34b73 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 12:18:18 +0100 Subject: [PATCH 250/750] avoid defined-function macros --- lib_com/ivas_cnst.h | 2 +- lib_util/ivas_rtp_pi_data.c | 9 --------- lib_util/render_config_reader.c | 18 ++++++++---------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e6bb49689..aa50abf1c 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -561,7 +561,7 @@ typedef enum #define STEREO_DFT_ITD_FS 32000 #define STEREO_DFT_ITD_MAX 160 /*samples @ 32000*/ #define STEREO_DFT_ITD_MAX_ANA 200 -#define STEREO_DFT_ITD_MIN max( STEREO_DFT_ITD_MAX - 256 + 1, 1 ) /*STEREO_DFT_ITD_MAX-pow(2,STEREO_DFT_ITD_NBITS-1)+1*/ +#define STEREO_DFT_ITD_MIN s_max( STEREO_DFT_ITD_MAX - 256 + 1, 1 ) /*STEREO_DFT_ITD_MAX-pow(2,STEREO_DFT_ITD_NBITS-1)+1*/ #define STEREO_DFT_ITD_NBITS 9 /* 1 bit for sign, the rest for the absolute value*/ #define STEREO_DFT_ITD_MODE_NBITS 1 diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 6d93dc1f8..238804f75 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -37,15 +37,6 @@ #include "cnst.h" -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - - /* Generic PI data packing/unpacking functions */ typedef ivas_error ( *PACK_PI_FN )( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ); typedef ivas_error ( *UNPACK_PI_FN )( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ); diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 89fd65058..26291be99 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -87,14 +87,6 @@ #define FALSE 0 #endif -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - /*------------------------------------------------------------------------------------------* * Local Type definitions @@ -661,8 +653,14 @@ static ivas_error read_bin_code_word( /* First read minLen bits, then add one bit per iteration to find the correct value */ for ( n = 0; n < size; n++ ) { - minLen = min( minLen, pLengths[n] ); - maxLen = max( maxLen, pLengths[n] ); + if ( minLen < pLengths[n] ) + { + minLen = pLengths[n]; + } + if ( pLengths[n] > maxLen ) + { + maxLen = pLengths[n]; + } } for ( len = minLen; len <= maxLen; len++ ) { -- GitLab From f873cf7b7dc7460f8b01a60098fb1205ae0b8eee Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 13:04:30 +0100 Subject: [PATCH 251/750] avoid defined-function macros --- apps/renderer.c | 4 +-- lib_com/ivas_rotation_com_fx.c | 2 +- lib_com/ivas_spar_com_fx.c | 30 ++++++++++--------- lib_com/ivas_spar_com_quant_util_fx.c | 6 ++-- lib_dec/igf_dec_fx.c | 16 +++++----- lib_dec/ivas_post_proc_fx.c | 2 +- lib_dec/ivas_stereo_ica_dec_fx.c | 11 +++---- lib_dec/tonalMDCTconcealment_fx.c | 4 +-- lib_isar/isar_PredEncoder.c | 4 +-- lib_isar/isar_lc3plus_enc.c | 16 +++++----- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/isar_lcld_encoder.c | 18 +++++------ lib_isar/isar_splitRendererPLC.c | 12 ++++---- lib_isar/isar_splitRendererPost.c | 16 +++++----- lib_isar/isar_splitRendererPre.c | 12 ++++---- lib_isar/lib_isar_post_rend.c | 7 ++--- .../ivas_dirac_dec_binaural_functions_fx.c | 4 +-- lib_rend/ivas_output_init_fx.c | 4 +-- lib_util/ivas_rtp_pi_data.c | 4 +++ lib_util/obj_edit_file_reader.c | 9 +++++- 20 files changed, 96 insertions(+), 87 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index a5c24ee66..f92bafcac 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -655,8 +655,8 @@ static void setupWithSingleFormatInput( /* It is allowed on CLI to have no metadata for an ISM input - skip opening if string contains "NULL" */ char charBuf[FILENAME_MAX]; - strncpy( charBuf, args.inMetadataFilePaths[i], min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1 ); - charBuf[min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1] = '\0'; + strncpy( charBuf, args.inMetadataFilePaths[i], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); + charBuf[RENDERER_MAX_CLI_ARG_LENGTH - 1] = '\0'; to_upper( charBuf ); if ( strncmp( charBuf, "NULL", 4 ) == 0 ) { diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 199af90d3..2377e272b 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -200,7 +200,7 @@ void Quat2EulerDegree_fx( Word32 tmp8 = W_extract_l( W_shr( W_mult0_32_32( quat.w_fx, quat.y_fx ), Q22 ) ); // Q22 Word32 tmp9 = W_extract_l( W_shr( W_mult0_32_32( quat.z_fx, quat.x_fx ), Q22 ) ); // Q22 p_fx = L_shl( L_sub( tmp8, tmp9 ), 1 ); - p_fx = max( L_negate( ONE_IN_Q22 ), min( ONE_IN_Q22, p_fx ) ); // Q22 + p_fx = L_max( L_negate( ONE_IN_Q22 ), L_min( ONE_IN_Q22, p_fx ) ); // Q22 Word32 p_fx_sq = W_extract_l( W_shr( W_mult0_32_32( p_fx, p_fx ), Q22 ) ); Word16 res_exp = 0; diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 4b70d277a..6ca8fcc3f 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -3843,7 +3843,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( Word32 **ppMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH]; Word32 *pMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; Word16 q_ppMixer_mat = 0; - Word32 en_ratio_fac_fx, diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; + Word32 en_ratio_fac_fx; + Word16 diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; Word16 active_w; move16(); move16(); @@ -3862,11 +3863,11 @@ void ivas_get_spar_md_from_dirac_enc_fx( foa_ch = FOA_CHANNELS; move16(); diff_norm_order1_fx = 3; - move32(); + move16(); diff_norm_order2_fx = 5; - move32(); + move16(); diff_norm_order3_fx = 7; - move32(); + move16(); FOR( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ ) { @@ -3898,7 +3899,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[s_min( diff_norm_order1_fx, s_max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[1] = 0; @@ -3909,7 +3910,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[s_min( diff_norm_order2_fx, s_max( 0, ( s_min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[2] = 0; @@ -3919,7 +3920,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[2] = L_add( P_norm_fx[2], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[s_min( diff_norm_order3_fx, s_max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); len = s_max( 0, sub( foa_ch, ndm ) ); FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) @@ -4291,7 +4292,8 @@ void ivas_get_spar_md_from_dirac_fx( Word32 **ppMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH]; Word32 *pMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; Word16 q_ppMixer_mat = 0; - Word32 en_ratio_fac_fx, diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; + Word32 en_ratio_fac_fx; + Word16 diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; Word16 active_w; move16(); move16(); @@ -4310,11 +4312,11 @@ void ivas_get_spar_md_from_dirac_fx( foa_ch = FOA_CHANNELS; move16(); diff_norm_order1_fx = 3; - move32(); + move16(); diff_norm_order2_fx = 5; - move32(); + move16(); diff_norm_order3_fx = 7; - move32(); + move16(); FOR( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ ) { @@ -4346,7 +4348,7 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[s_min( diff_norm_order1_fx, s_max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[1] = 0; @@ -4357,7 +4359,7 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[s_min( diff_norm_order2_fx, s_max( 0, ( s_min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[2] = 0; @@ -4367,7 +4369,7 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[2] = L_add( P_norm_fx[2], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[s_min( diff_norm_order3_fx, s_max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); len = s_max( 0, sub( foa_ch, ndm ) ); FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 7ea6feb05..93a62acd2 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -346,11 +346,11 @@ void ivas_map_prior_coeffs_quant( { ivas_quant_strat_t qs = pSpar_md_cfg->quant_strat[qsi]; ivas_quant_strat_t prev_qs = pSpar_md_cfg->quant_strat[pSpar_md_cfg->prev_quant_idx]; - Word32 one_by_q_lvl_PR_fx = one_by_q_level[max( ( prev_qs.PR.q_levels[0] - 1 ), 1 )]; /*q31*/ + Word32 one_by_q_lvl_PR_fx = one_by_q_level[s_max( ( prev_qs.PR.q_levels[0] - 1 ), 1 )]; /*q31*/ move32(); - Word32 one_by_q_lvl_C_fx = one_by_q_level[max( ( prev_qs.C.q_levels[0] - 1 ), 1 )]; /*q31*/ + Word32 one_by_q_lvl_C_fx = one_by_q_level[s_max( ( prev_qs.C.q_levels[0] - 1 ), 1 )]; /*q31*/ move32(); - Word32 one_by_q_lvl_P_r_fx = one_by_q_level[max( ( prev_qs.P_r.q_levels[0] - 1 ), 1 )]; /*q31*/ + Word32 one_by_q_lvl_P_r_fx = one_by_q_level[s_max( ( prev_qs.P_r.q_levels[0] - 1 ), 1 )]; /*q31*/ move32(); FOR( i = 0; i < nB; i++ ) { diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index e7fec9492..fba40748c 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1838,11 +1838,11 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( tb = 0; tb < hopsize; tb++ ) { /* calculate of the current sfb width */ - width = sub( hGrid->swb_offset[min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ - hGrid->swb_offset[min( sfb + tb, stop_sfb )] ); + width = sub( hGrid->swb_offset[s_min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ + hGrid->swb_offset[s_min( sfb + tb, stop_sfb )] ); - tmp = dS[min( sfb + tb, stop_sfb - 1 )]; - tmp_e = dS_e[min( sfb + tb, stop_sfb - 1 )]; + tmp = dS[s_min( sfb + tb, stop_sfb - 1 )]; + tmp_e = dS_e[s_min( sfb + tb, stop_sfb - 1 )]; move16(); move16(); @@ -2507,11 +2507,11 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( tb = 0; tb < hopsize; tb++ ) { /* calculate of the current sfb width */ - width = sub( hGrid->swb_offset[min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ - hGrid->swb_offset[min( sfb + tb, stop_sfb )] ); + width = sub( hGrid->swb_offset[s_min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ + hGrid->swb_offset[s_min( sfb + tb, stop_sfb )] ); - tmp = dS[min( sfb + tb, stop_sfb - 1 )]; - tmp_e = dS_e[min( sfb + tb, stop_sfb - 1 )]; + tmp = dS[s_min( sfb + tb, stop_sfb - 1 )]; + tmp_e = dS_e[s_min( sfb + tb, stop_sfb - 1 )]; move16(); move16(); diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 02be03d21..b23cced7f 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -584,7 +584,7 @@ void stereo_dft_dec_core_switching_fx( IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) { Word16 numZeros = (Word16) ( NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ) ); /*Q0*/ - Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )]; + Word32 tmp_fade_fx[STEREO_DFT_ALLPASS_FADELEN_16k /*max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )*/]; Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/ hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_out_fx32; diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index b6bdb559b..fc02a8ba4 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -350,13 +350,10 @@ void stereo_tca_scale_R_channel_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - Word64 local_value; - // to be deleted next MR - // hCPE->hStereoDftDmx->prevTargetGain *= 2.0f; - // hCPE->hStereoDftDmx->prevTargetGain = min( hCPE->hStereoDftDmx->prevTargetGain, powf( 10, ( ( 1 << STEREO_BITS_TCA_GD ) - 1 ) * STEREO_TCA_GDSTEP + STEREO_TCA_GDMIN ) ); - local_value = W_shl( hCPE->hStereoDftDmx->prevTargetGain_fx, 1 ); /* Q29 */ - hCPE->hStereoDftDmx->prevTargetGain_fx = (Word32) min( local_value, MAX_TARGET_GAIN_Q29 ); /* Q29 */ - hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */ + Word32 local_value; + local_value = L_shl( hCPE->hStereoDftDmx->prevTargetGain_fx, 1 ); /* Q29 */ + hCPE->hStereoDftDmx->prevTargetGain_fx = L_min( local_value, MAX_TARGET_GAIN_Q29 ); /* Q29 */ + hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */ move32(); flat_old = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index eec8198bf..93a5ab064 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -209,8 +209,8 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( /* just the second half of the second last pcm output is needed */ set16_fx( hTonalMDCTConc->timeDataBuffer, 0, ( 3 * L_FRAME_MAX ) / 2 ); - hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * min( L_FRAME_MAX, nSamples ) / 2 )]; - hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )]; + hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * s_min( L_FRAME_MAX, nSamples ) / 2 )]; + hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - s_min( L_FRAME_MAX, nSamples )]; /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index c933e7f36..4a75ca0d8 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -464,7 +464,7 @@ void ComputePredictors_fx( Word16 w_norm3 = W_norm( W_temp2 ); W_temp2 = W_shr( W_temp2, 32 - w_norm3 ); pfRxxImag_fx[1] = W_extract_l( W_temp2 ); - Word16 final_w_norm = min( w_norm1, min( w_norm2, w_norm3 ) ); + Word16 final_w_norm = s_min( w_norm1, s_min( w_norm2, w_norm3 ) ); pfRxxReal_fx[0] = L_shr( pfRxxReal_fx[0], w_norm1 - final_w_norm ); // Q8 + final_w_norm pfRxxReal_fx[1] = L_shr( pfRxxReal_fx[1], w_norm2 - final_w_norm ); // Q8 + final_w_norm pfRxxImag_fx[1] = L_shr( pfRxxImag_fx[1], w_norm3 - final_w_norm ); // Q8 + final_w_norm @@ -541,7 +541,7 @@ void ComputePredictors_fx( // fGain_fx = sub(sub(32767, extract_h(Mpy_32_32(fA1Real_fx, fA1Real_fx))), extract_h(Mpy_32_32(fA1Imag_fx, fA1Imag_fx))); // fGain_fx = extract_l(L_shl(L_temp, 2*sf_r)); fGain_fx = extract_l( L_temp ); - fGain_fx = max( 1, fGain_fx ); + fGain_fx = L_max( 1, fGain_fx ); fGain_fx = Inv16( extract_l( fGain_fx ), &exp ); // Q15 - exp // fGain_fx = L_shl(fGain_fx, exp); //Q15 // fBitGain = 0.65f * log2f(fGain) * (float)(iNumBlocksPerPredCoef)-(float)(PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS); // Wrong fix (iNumBlocks-1) diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 60121a11f..54dd6df23 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -48,11 +48,11 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, switch ( config.lc3plus_frame_duration_us ) { case 10000: - return min( per_channel_bitrate, 500000 ); + return L_min( per_channel_bitrate, 500000 ); case 5000: - return min( per_channel_bitrate, 600000 ); + return L_min( per_channel_bitrate, 600000 ); case 2500: - return min( per_channel_bitrate, 672000 ); + return L_min( per_channel_bitrate, 672000 ); default: assert( false && "unreachable" ); } @@ -62,13 +62,13 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, { case 48000: case 32000: - return min( per_channel_bitrate, 320000 ); + return L_min( per_channel_bitrate, 320000 ); case 24000: - return min( per_channel_bitrate, 314400 ); + return L_min( per_channel_bitrate, 314400 ); case 16000: - return min( per_channel_bitrate, 221600 ); + return L_min( per_channel_bitrate, 221600 ); case 8000: - return min( per_channel_bitrate, 114400 ); + return L_min( per_channel_bitrate, 114400 ); default: assert( false && "unreachable" ); } @@ -558,7 +558,7 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( FOR( UWord32 iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) { ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel; - handle->pcm_conversion_buffer[iSampleInt16] = (Word16) max( INT16_MIN, min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) ); + handle->pcm_conversion_buffer[iSampleInt16] = (Word16) L_max( INT16_MIN, L_min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) ); } ftdIndex = iMediaTime * handle->num_encs + iEnc; diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 8bb931e3f..6770b6359 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1100,7 +1100,7 @@ Word32 DecodeLCLDFrame( } IF( NE_32( real_max, 0 ) || NE_32( imag_max, 0 ) ) { - exp = min( exp2, exp1 ); + exp = s_min( exp2, exp1 ); *Q_out = add( *Q_out, sub( exp, 3 ) ); FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) { diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 760d653f5..e3296db25 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -968,12 +968,12 @@ static Word32 MSModeCalculation_fx( iFBOffset++; } - Q_en_tmp = min( Q_en_tmp, W_norm( fLeftEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fRightEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fMidEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fSideEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovReal_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovImag_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fLeftEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fRightEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fMidEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fSideEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fLRCovReal_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fLRCovImag_fx64 ) ); Q_en_tmp = sub( Q_en_tmp, 2 ); fLeftEnergy_fx = W_extract_h( W_shl( fLeftEnergy_fx64, Q_en_tmp ) ); fRightEnergy_fx = W_extract_h( W_shl( fRightEnergy_fx64, Q_en_tmp ) ); @@ -996,7 +996,7 @@ static Word32 MSModeCalculation_fx( fSideEnergyPred_fx = L_add( fSideEnergy_fx, L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergy_fx ), L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) ); - fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 ); + fSideEnergyPred_fx = L_max( fSideEnergyPred_fx, 0 ); ppiMSPredCoefs[MS_PRED_ONLY][b] = iPred; move32(); @@ -1054,7 +1054,7 @@ static Word32 MSModeCalculation_fx( fSideEnergyPred_fx = L_add( fSideEnergyPred_fx, L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergyPred_fx ), L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) ); - fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 ); + fSideEnergyPred_fx = L_max( fSideEnergyPred_fx, 0 ); /* -= fPred * fPred * fMidEnergyPred doesn't work because fPred is quantized and does not match MS/MM exactly */ ppiMSPredCoefs[MS_PHASE_AND_PRED][b] = iPred; move32(); @@ -1125,7 +1125,7 @@ static Word32 MSModeCalculation_fx( { piMsPredInfoBits[iMSPredType] = CountMSBits( iNumBands, MS_PRED, ppiMSPredFlags[iMSPredType], ppiMSPredPhase[iMSPredType], ppiMSPredCoefs[iMSPredType] ); // pfMSPredBitGain[iMSPredType] = max( pfMSPredBitGain[iMSPredType] - piMsPredInfoBits[iMSPredType], 0.0f ); - pfMSPredBitGain_fx[iMSPredType] = max( pfMSPredBitGain_fx[iMSPredType] - L_shl( piMsPredInfoBits[iMSPredType], q_pfMSPredBitGain_fx ), 0 ); + pfMSPredBitGain_fx[iMSPredType] = L_max( pfMSPredBitGain_fx[iMSPredType] - L_shl( piMsPredInfoBits[iMSPredType], q_pfMSPredBitGain_fx ), 0 ); } /* find the best M/S Pred type */ diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 8c096da3d..418242d60 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -308,8 +308,8 @@ static void adaptive_polar_ext_plc_fx( fac_ph_real_fx = L_deposit_h( getCosWord16R2( dth16 ) ); fac_ph_imag_fx = L_deposit_h( getSineWord16R2( dth16 ) ); ///* calculate complex evolution factor */ - fac_real_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_real_fx ); // Qdrho_exp - fac_imag_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_imag_fx ); // Qdrho_exp + fac_real_fx = Mpy_32_32( L_min( L_shl( 1, drho_q ), drho_32 ), fac_ph_real_fx ); // Qdrho_exp + fac_imag_fx = Mpy_32_32( L_min( L_shl( 1, drho_q ), drho_32 ), fac_ph_imag_fx ); // Qdrho_exp #if START_VAL_AVG_LEN > 1 /* Calculate start value FOR evolution from last samples of previous frame */ fac_powj_real_fx = fac_real_fx; @@ -488,11 +488,11 @@ static void adaptive_polar_ext_plc_fx( IF( EQ_16( drho_q, 31 ) ) { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( ONE_IN_Q31, drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } ELSE { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( L_shl( 1, drho_q ), drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e ); @@ -600,11 +600,11 @@ static void adaptive_polar_ext_plc_fx( IF( EQ_16( drho_q, 31 ) ) { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( ONE_IN_Q31, drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } ELSE { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( L_shl( 1, drho_q ), drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e ); rat_real_fx = W_mult_32_32( rat_real32_fx, abs2inv_fx ); diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index dbefc4386..bb3a57a66 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1108,7 +1108,7 @@ static Word32 get_interp_fact_fx( IF( LT_32( interp_fact_fx, 0 ) ) { - d_fx = max( -( MAX_EXTRAPOLATION_ANGLE_Q22 ), ( min( ( MAX_EXTRAPOLATION_ANGLE_Q22 ), d_fx ) ) ); + d_fx = L_max( -( MAX_EXTRAPOLATION_ANGLE_Q22 ), ( L_min( ( MAX_EXTRAPOLATION_ANGLE_Q22 ), d_fx ) ) ); move32(); n_fx = L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_32( n_fx, Q31_BY_360 ), 7 ) ) ) ); move32(); @@ -1358,8 +1358,8 @@ static void interpolate_pred_matrix_fx( { FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) { - max_exp_re = max( max_exp_re, buff_exp_re[i][j] ); - max_exp_im = max( max_exp_im, buff_exp_im[i][j] ); + max_exp_re = s_max( max_exp_re, buff_exp_re[i][j] ); + max_exp_im = s_max( max_exp_im, buff_exp_im[i][j] ); } } FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) @@ -1500,7 +1500,7 @@ static void interpolate_rend_md_fx( Word16 exp_tmp1 = 0; Word32 tmp1 = BASOP_Util_Add_Mant32Exp( gd1_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 ); pitch_gain_l_fx = tmp1; - pitch_gain_l_fx = max( 0, pitch_gain_l_fx ); + pitch_gain_l_fx = L_max( 0, pitch_gain_l_fx ); exp_pitch_gain_l = exp_tmp1; diff_fx = L_sub( gd3_fx, gd4_fx ); @@ -1512,7 +1512,7 @@ static void interpolate_rend_md_fx( exp_tmp1 = 0; tmp1 = BASOP_Util_Add_Mant32Exp( gd3_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 ); pitch_gain_r_fx = tmp1; - pitch_gain_r_fx = max( 0, pitch_gain_r_fx ); + pitch_gain_r_fx = L_max( 0, pitch_gain_r_fx ); exp_pitch_gain_r = exp_tmp1; FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) @@ -1532,8 +1532,8 @@ static void interpolate_rend_md_fx( { FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) { - max_exp_re = max( max_exp_re, exp_mat_re[i][j] ); - max_exp_im = max( max_exp_im, exp_mat_im[i][j] ); + max_exp_re = s_max( max_exp_re, exp_mat_re[i][j] ); + max_exp_im = s_max( max_exp_im, exp_mat_im[i][j] ); } } @@ -1655,7 +1655,7 @@ void isar_SplitRenderer_PostRenderer( { index_slot = slot_idx; /* TODO: can be cleaned up */ fade_fx = fade_table_fx[slot_idx]; - fade_fx = min( fade_fx, MAX_16 ); + fade_fx = s_min( fade_fx, MAX_16 ); FOR( b = 0; b < num_md_bands; b++ ) { FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 7255e7716..df66a0517 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -349,7 +349,7 @@ static void ComputePredMat_fx( { FOR( j = 0; j < 2; j++ ) { - max_exp = max( max_exp, buff_exp[i][j] ); + max_exp = s_max( max_exp, buff_exp[i][j] ); } } @@ -637,8 +637,8 @@ static void ComputeBandedCrossCov_fx( { FOR( Word16 j = 0; j < num_chs; j++ ) { - max_cov_re = max( max_cov_re, exp_buff_re[i][j] ); - max_cov_im = max( max_cov_im, exp_buff_im[i][j] ); + max_cov_re = s_max( max_cov_re, exp_buff_re[i][j] ); + max_cov_im = s_max( max_cov_im, exp_buff_im[i][j] ); } } FOR( Word16 i = 0; i < num_chs; i++ ) @@ -789,8 +789,8 @@ static void ComputeBandedCov_fx( { FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) { - exp_max_re = max( exp_max_re, exp_buff_re[i][j] ); - exp_max_im = max( exp_max_im, exp_buff_im[i][j] ); + exp_max_re = s_max( exp_max_re, exp_buff_re[i][j] ); + exp_max_im = s_max( exp_max_im, exp_buff_im[i][j] ); } } @@ -1101,7 +1101,7 @@ static void get_lr_gains( Word16 max_gd_exp = MIN16B; FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - max_gd_exp = max( max_gd_exp, exp_gd_tmp_buf[i] ); + max_gd_exp = s_max( max_gd_exp, exp_gd_tmp_buf[i] ); } exp_gd_tmp = max_gd_exp; diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 61b4c02cb..1f0b01a83 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -310,8 +310,7 @@ static Word32 limitRendererOutput_fx( /* Apply clipping to buffer in case the limiter let through some samples > 1.0f */ FOR( i = 0; i < output_frame * num_channels; ++i ) { - - output[i] = min( max( L_shl( INT16_MIN, q_factor ), output[i] ), L_shl( INT16_MAX, q_factor ) ); + output[i] = L_min( L_max( L_shl( INT16_MIN, q_factor ), output[i] ), L_shl( INT16_MAX, q_factor ) ); } return numClipping; @@ -490,7 +489,7 @@ static ivas_error updateSplitPostRendPanGains( IF( GT_16( hRendCfg->codec_frame_size_ms, 0 ) ) { iNumLCLDIterationsPerFrame = (Word16) config.isar_frame_duration_us / ( 1000 * hRendCfg->codec_frame_size_ms ); - iNumLCLDIterationsPerFrame = max( 1, iNumLCLDIterationsPerFrame ); + iNumLCLDIterationsPerFrame = s_max( 1, iNumLCLDIterationsPerFrame ); iNumBlocksPerFrame = CLDFB_NO_COL_MAX * hRendCfg->codec_frame_size_ms / 20; } ELSE @@ -1003,7 +1002,7 @@ ivas_error ISAR_POST_REND_GetDelay( { latency_ns += IVAS_FB_DEC_DELAY_NS; } - max_latency_ns = max( max_latency_ns, latency_ns ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); } } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0152bf465..96865c640 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -6574,7 +6574,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( IF( GT_32( totalTargetEne, 0 ) ) { - tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, max( EPSILON_FX, totalTargetEne ), &temp_q ); + tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, L_max( EPSILON_FX, totalTargetEne ), &temp_q ); temp_q = sub( sub( Q31, temp_q ), sub( sub( Q31, Q28 ), sub( Q31, subQ ) ) ); @@ -6607,7 +6607,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( IF( enableCentering ) { temp1 = abs_s( sub( panEnesIn[ismDirIndex][0], panEnesOut[ismDirIndex][0] ) ); // 2*sub(enes) -> Q14 - centeringFactor = max( 0, sub( temp1, ONE_IN_Q14 ) ); // Q14 + centeringFactor = s_max( 0, sub( temp1, ONE_IN_Q14 ) ); // Q14 FOR( ch = 0; ch < 2; ch++ ) { diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 053cb43c1..487a5441f 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -387,7 +387,7 @@ Word16 ivas_get_nchan_buffers_dec_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { - nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); + nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); IF( st_ivas->hOutSetup.separateChannelEnabled ) { @@ -408,7 +408,7 @@ Word16 ivas_get_nchan_buffers_dec_fx( test(); IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); + nchan_out_buff = s_max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); } return nchan_out_buff; diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 238804f75..c4e377bae 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -37,6 +37,10 @@ #include "cnst.h" +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + /* Generic PI data packing/unpacking functions */ typedef ivas_error ( *PACK_PI_FN )( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ); typedef ivas_error ( *UNPACK_PI_FN )( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ); diff --git a/lib_util/obj_edit_file_reader.c b/lib_util/obj_edit_file_reader.c index 2d9a2fd6e..fee43f23c 100644 --- a/lib_util/obj_edit_file_reader.c +++ b/lib_util/obj_edit_file_reader.c @@ -33,9 +33,16 @@ the United Nations Convention on Contracts on the International Sales of Goods. #include #include #include "obj_edit_file_reader.h" -#include "prot_fx.h" +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + /*-----------------------------------------------------------------------* * ObjectEditFileReader_open() * -- GitLab From ddc29d8e1fbf80222825ca0b69b3fad0b559cecc Mon Sep 17 00:00:00 2001 From: marc emerit Date: Tue, 6 Jan 2026 14:15:32 +0100 Subject: [PATCH 252/750] aligm with main float --- apps/decoder.c | 26 +++----- apps/renderer.c | 4 ++ lib_dec/ivas_init_dec_fx.c | 22 +++---- lib_dec/lib_dec.h | 5 -- lib_dec/lib_dec_fx.c | 14 +---- lib_rend/ivas_hrtf_fx.c | 7 ++- lib_rend/ivas_prot_rend_fx.h | 7 +++ lib_rend/ivas_reverb_fx.c | 116 +++++++++++++++++++++++++++++++++++ lib_rend/ivas_stat_rend.h | 2 +- lib_rend/lib_rend_fx.c | 7 +-- lib_util/hrtf_file_reader.c | 14 +++++ lib_util/hrtf_file_reader.h | 14 +++++ 12 files changed, 182 insertions(+), 56 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 7e9113933..3578da864 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3901,8 +3901,7 @@ static ivas_error load_hrtf_from_file( { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; - Word16 initFromRom; - if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics, &initFromRom ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) #endif @@ -3912,30 +3911,25 @@ static ivas_error load_hrtf_from_file( } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - if ( initFromRom ) - { - if ( ( error = load_reverb_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) + if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #else if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); + return error; + } + else { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); - return error; - } - else - { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - destroy_hrtf_statistics( hHrtfStatistics ); + destroy_hrtf_statistics( hHrtfStatistics ); #else destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); #endif - } } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA } -#endif } return IVAS_ERR_OK; diff --git a/apps/renderer.c b/apps/renderer.c index 4ce0b10f7..70e68c757 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1102,7 +1102,11 @@ int main( fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" ); goto cleanup; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) +#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index a554e3a87..d698a8969 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1800,22 +1800,17 @@ ivas_error ivas_init_decoder_fx( { /* Init HRTF statistics */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - if ( st_ivas->hHrtfStatistics == NULL ) + /* Allocate HRTF and init statistics */ + IF( NE_32( ( error = ivas_reverb_HRTF_statistics_open_fx( &( st_ivas->hHrtfStatistics ), output_Fs ) ), IVAS_ERR_OK ) ) { - /* Allocate HRTF statistics */ - IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( st_ivas->hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; } - /* Init HRTF statistics */ - IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) -#endif { return error; } +#endif /* Get default reverb values based on format, if custom values were not given */ IF( EQ_16( st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0 ) ) @@ -3554,6 +3549,10 @@ void ivas_destroy_dec_fx( ivas_combined_orientation_close_fx( &st_ivas->hCombinedOrientationData ); /* Time Domain binaural renderer handle */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); + ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); +#else IF( st_ivas->hBinRendererTd != NULL ) { ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); @@ -3561,14 +3560,11 @@ void ivas_destroy_dec_fx( IF( st_ivas->hHrtfTD != NULL ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); -#else BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); -#endif } +#endif /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close_fx( &st_ivas->hHrtfCrend ); diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 3d60a042d..58c33c92d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -440,11 +440,6 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( ivas_error IVAS_DEC_GetHrtfStatisticsHandle( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA - , /* o : HRTF statistics handle */ - Word16 *intialisedFromRom /* o : int16_t handle */ -#endif - ); ivas_error IVAS_DEC_HRTF_binary_open( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 3e4cd017d..5bd3a62ec 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2479,28 +2479,16 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( ivas_error IVAS_DEC_GetHrtfStatisticsHandle( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA - , /* o : HRTF statistics handle */ - Word16 *intialisedFromRom /* o : int16_t handle */ -#endif -) + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics ) { test(); test(); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA - IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL || intialisedFromRom == NULL ) -#else IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) -#endif { return IVAS_ERR_WRONG_PARAMS; } *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA - *intialisedFromRom = hIvasDec->st_ivas->hHrtfStatistics->fromROM; -#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 7854afbbb..5db9b7532 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -404,7 +404,7 @@ void ivas_HRTF_fastconv_binary_close_fx( /*-----------------------------------------------------------------------* - * ivas_HRTF_parambin_binary_open() + * ivas_HRTF_parambin_binary_open_fx() * * Allocate HRTF binary handle for parametric binauralizer *-----------------------------------------------------------------------*/ @@ -425,7 +425,7 @@ ivas_error ivas_HRTF_parambin_binary_open_fx( /*-----------------------------------------------------------------------* - * ivas_HRTF_parambin_binary_close() + * ivas_HRTF_parambin_binary_close_fx() * * Close HRTF binary handle for parametric binauralizer *-----------------------------------------------------------------------*/ @@ -511,7 +511,7 @@ void ivas_HRTF_statistics_close_fx( return; } - +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /*-----------------------------------------------------------------------* * ivas_HRTF_statistics_init() * @@ -719,3 +719,4 @@ ivas_error ivas_HRTF_statistics_init_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistic return IVAS_ERR_OK; } +#endif diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index fe2dada8a..e81960f94 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1003,6 +1003,13 @@ void ivas_binaural_reverb_processSubframe_fx( Word32 outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_reverb_HRTF_statistics_open_fx( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* o : HRTF statistics handle */ + const Word32 output_Fs /* i : output sampling rate */ +); +#endif + ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index ba4159ba8..5d1e287a0 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -34,6 +34,9 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +#include "ivas_rom_binaural_crend_head.h" +#endif #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include @@ -130,7 +133,120 @@ typedef struct ivas_reverb_params_t static ivas_error calc_jot_t60_coeffs_fx( Word16 *pH_dB_fx, Word16 pH_dB_exp, const UWord16 nrFrequencies, Word16 *pFrequencies_fx, Word16 *pCoeffA_fx, Word16 *pCoeffB_fx, const Word16 fNyquist_fx ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + +/*------------------------------------------------------------------------- + * ivas_reverb_HRTF_statistics_open() + * + * Open and initialize HRTF statistics handle from ROM tables + *------------------------------------------------------------------------*/ + +ivas_error ivas_reverb_HRTF_statistics_open_fx( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* o : HRTF statistics handle */ + const Word32 output_Fs /* i : output sampling rate */ +) +{ + if ( *hHrtfStatistics != NULL ) + { + if ( ( *hHrtfStatistics )->fromROM == TRUE ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF statistics allocated but not initialized from binary file!\n" ); + } + + /* HRTF statistics loaded from binary file */ + return IVAS_ERR_OK; + } + + if ( ( *hHrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); + } + + SWITCH( output_Fs ) + { + case 48000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_48kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + case 32000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_32kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + case 16000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_16kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q26 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + default: + ( *hHrtfStatistics )->average_energy_l = NULL; + ( *hHrtfStatistics )->average_energy_r = NULL; + ( *hHrtfStatistics )->inter_aural_coherence = NULL; + BREAK; + } + ( *hHrtfStatistics )->fromROM = TRUE; +#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD + ( *hHrtfStatistics )->fromROM = FALSE; // TODO: temporary hack until HRTF statistics ROM tables are converted from Word16 to Word32 +#endif + return IVAS_ERR_OK; +} +#endif /*------------------------------------------------------------------------- * wrap_rad_fx() * diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f06fcee67..ba5ee6f4e 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1163,10 +1163,10 @@ typedef struct typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct { Word32 SampleRate; /* Sample rate of the HR filter */ +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA Word16 NumPos; Word16 NumElev; Word32 Dist_fx; -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA Word32 *ItdSet_p_fx; #endif Word16 FiltLength; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index dfdd04f60..eaed6ebf5 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -3926,15 +3926,12 @@ ivas_error IVAS_REND_Open( #ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( hIvasRend->hHrtfs.hHrtfStatistics == NULL ) { - /* Allocate HRTF statistics */ - IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + /* Allocate and init HRTF statistics */ + IF( NE_32( ( error = ivas_reverb_HRTF_statistics_open_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) { return error; } } - - /* Init HRTF statistics */ - IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) #endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 5f1b47235..a65ad85c2 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -954,6 +954,19 @@ static ivas_error load_reverb_from_binary( return IVAS_ERR_OK; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*---------------------------------------------------------------------* + * load_HrtfStatistics_from_binary() + * + * Load HRTF binary data into the HRTF handle for TD and Crend renderers + *---------------------------------------------------------------------*/ + +ivas_error load_HrtfStatistics_from_binary( + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + const Word32 sampleRate, /* i : sample rate */ + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ +) +#else /*---------------------------------------------------------------------* * load_reverb_binary() * @@ -965,6 +978,7 @@ ivas_error load_reverb_binary( const Word32 sampleRate, /* i : sample rate */ const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) +#endif { if ( hrtfReader == NULL || hrtfReader->file == NULL || hHrtfStatistics == NULL ) { diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index d1f97a191..ea539a24e 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -105,6 +105,19 @@ ivas_error load_TDrend_HRTF_binary( const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*---------------------------------------------------------------------* + * load_HrtfStatistics_from_binary() + * + * Load reverb binary data into the HRTF handle + *---------------------------------------------------------------------*/ + +ivas_error load_HrtfStatistics_from_binary( + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + const Word32 sampleRate, /* i : sample rate */ + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ +); +#else /*---------------------------------------------------------------------* * load_reverb_binary() * @@ -116,6 +129,7 @@ ivas_error load_reverb_binary( const Word32 sampleRate, /* i : sample rate */ const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); +#endif /*---------------------------------------------------------------------* * load_Crend_HRTF_from_binary() -- GitLab From 0e8ed3443a70131fbd6bb18c16d6dbac64736861 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 14:31:06 +0100 Subject: [PATCH 253/750] fix --- lib_enc/enc_gen_voic_fx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 89566c413..cead9d24c 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -685,6 +685,14 @@ void encod_gen_voic_ivas_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ + st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ + } +#endif + /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames *-----------------------------------------------------------------*/ -- GitLab From ba2472fa636e88f3ce3bbe81f22a8d6e4b85c290 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 6 Jan 2026 15:24:24 +0100 Subject: [PATCH 254/750] Fix missing update of low-rate pitch gain in the S/M classifier --- lib_com/options.h | 1 + lib_enc/enc_gen_voic_fx.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..86d85731c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index bfe50a588..79ca13c7a 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -645,6 +645,11 @@ void encod_gen_voic_ivas_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } +#ifdef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN + /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ + 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*/ +#endif + /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames *-----------------------------------------------------------------*/ -- GitLab From 7e16d3d637eff8687dc186e907b04e210954f6c6 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 6 Jan 2026 15:34:49 +0100 Subject: [PATCH 255/750] correction of class spec --- lib_enc/enc_gen_voic_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 79ca13c7a..1cf5c793e 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -647,7 +647,7 @@ void encod_gen_voic_ivas_fx( #ifdef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ - 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*/ + st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #endif /*-----------------------------------------------------------------* -- GitLab From 44d943ad94dd2fc853a8c732fb4ea324150c5601 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Tue, 6 Jan 2026 16:28:39 +0100 Subject: [PATCH 256/750] bug fix (asan fix) --- apps/decoder.c | 15 ++++++++++----- lib_util/hrtf_file_reader.c | 36 ++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 3578da864..e8cd5a267 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3891,19 +3891,21 @@ static ivas_error load_hrtf_from_file( } } } +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA } +#endif #ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #else - if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) #endif { fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3913,7 +3915,7 @@ static ivas_error load_hrtf_from_file( #ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #else - if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) + if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) @@ -3926,13 +3928,16 @@ static ivas_error load_hrtf_from_file( #ifdef FIX_2249_MEMORY_LEAK_IN_SBA destroy_hrtf_statistics( hHrtfStatistics ); #else - destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); + destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); #endif } } } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +} +#endif - return IVAS_ERR_OK; +return IVAS_ERR_OK; } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index a65ad85c2..a21569f8d 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -297,7 +297,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &modelITD->elevDim3, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) ); #else modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) ); #endif @@ -316,7 +316,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &modelITD->azimDim3, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); #else modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ #endif @@ -335,7 +335,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &modelITD->W_dyn_fx, tmp * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &modelITD->W_dyn_fx, tmp * sizeof( Word32 ) ); #else modelITD->W_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); #endif @@ -383,7 +383,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( Word32 ) ); #else modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); #endif @@ -426,7 +426,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) ); #else modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); #endif @@ -526,7 +526,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->K, sizeof( Word16 ), 1, f_hrtf ); fread( &model->elevDim3, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); #else model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); #endif @@ -568,7 +568,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->azimDim3_dyn[i], sizeof( Word16 ), 1, f_hrtf ); fread( &model->azim_start_idx_dyn[i], sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); #else model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); #endif @@ -588,7 +588,7 @@ static ivas_error TDREND_LoadBSplineBinary( } fread( &model->AlphaN, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) ); #else model->AlphaL_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); #endif @@ -610,7 +610,7 @@ static ivas_error TDREND_LoadBSplineBinary( model->AlphaL_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) ); #else model->AlphaR_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); #endif @@ -653,7 +653,7 @@ static ivas_error TDREND_LoadBSplineBinary( { fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->azimBsShape_dyn_fx[i], tmp * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->azimBsShape_dyn_fx[i], tmp * sizeof( Word32 ) ); #else model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) ); #endif @@ -722,7 +722,7 @@ static ivas_error TDREND_LoadBSplineBinary( v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->elevBsShape_dyn_fx, tmp * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) ); #else model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); #endif @@ -742,7 +742,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->elevSegSamples, sizeof( Word16 ), 1, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->EL_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->EL_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); #else model->EL_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); #endif @@ -758,7 +758,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( (Word32 *) model->EL_dyn_fx, sizeof( Word32 ), model->AlphaN * HRTF_MODEL_N_SECTIONS, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &model->ER_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &model->ER_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); #else model->ER_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); #endif @@ -792,8 +792,8 @@ static ivas_error TDREND_LoadBSplineBinary( HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModL_fx, model->K * sizeof( float ) ); - ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModR_fx, model->K * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModL_fx, model->K * sizeof( Word32 ) ); + ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModR_fx, model->K * sizeof( Word32 ) ); #else HrFiltSet_p->ModelEval.hrfModL_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); HrFiltSet_p->ModelEval.hrfModR_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); @@ -911,9 +911,9 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_l_dyn, lr_iac_len * sizeof( float ) ); - ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_r_dyn, lr_iac_len * sizeof( float ) ); - ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->inter_aural_coherence_dyn, lr_iac_len * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_l_dyn, lr_iac_len * sizeof( Word32 ) ); + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_r_dyn, lr_iac_len * sizeof( Word32 ) ); + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->inter_aural_coherence_dyn, lr_iac_len * sizeof( Word32 ) ); #else hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); -- GitLab From dc6e57749916320958e3a82b1ca76617331ce5f2 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 7 Jan 2026 09:53:58 +0100 Subject: [PATCH 257/750] move macro to non-BE section --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 86d85731c..e4b766b7f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ -#define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ /* #################### End BE switches ################################## */ @@ -120,6 +119,7 @@ #define FIX_1466_EXTREND /* FhG: float issue 1466: enable rendering of mono/stereo to other formats in the external renderer */ #define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ +#define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 244c69c86332bb09111e4fdf527ac23a72d7ac8c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 Jan 2026 13:12:16 +0100 Subject: [PATCH 258/750] edit --- lib_dec/lsf_dec_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 03595e6d5..d336b8ab0 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -236,10 +236,12 @@ void lsf_dec_fx( } lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, st_fx->sr_core ); } + /*-------------------------------------------------------------------------------------* * Mid-frame LSF decoding * LSP interpolation and conversion of LSPs to A(z) *-------------------------------------------------------------------------------------*/ + IF( st_fx->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ -- GitLab From 60854255b6ff660ab6c88cb6ac08adadd6294001 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 Jan 2026 13:14:18 +0100 Subject: [PATCH 259/750] clang-format --- lib_dec/lsf_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index d336b8ab0..bfb92005a 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -241,7 +241,7 @@ void lsf_dec_fx( * Mid-frame LSF decoding * LSP interpolation and conversion of LSPs to A(z) *-------------------------------------------------------------------------------------*/ - + IF( st_fx->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ -- GitLab From 5182446781d5c99c0c4161a19dc78d0fb9ae4fa5 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 7 Jan 2026 13:29:31 +0100 Subject: [PATCH 260/750] - add warning message when renderer frame size is modififed in ISAR - simplify logic around ivas_limiter_dec() --- apps/decoder.c | 8 ++++++++ lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 401a26761..2060094bf 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -452,6 +452,14 @@ int main( fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + +#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR + if ( !arg.renderConfigEnabled && ( arg.renderFramesize != asked_frame_size ) ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); + } +#endif + } /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..25037c799 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 26f0f52e7..e1dc9a13c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1632,6 +1632,12 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } + +#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); +#endif +#else IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER @@ -1642,6 +1648,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); } +#endif ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, pcmBuf_out ); } @@ -4990,6 +4997,11 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } +#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); +#endif +#else IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER @@ -5003,6 +5015,7 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } +#endif } return IVAS_ERR_OK; -- GitLab From db51476e65b2cea886a6a08de554467c32b59ac9 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 7 Jan 2026 13:33:56 +0100 Subject: [PATCH 261/750] clang format --- apps/decoder.c | 1 - lib_dec/lib_dec_fx.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 2060094bf..978257800 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -459,7 +459,6 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } #endif - } /*------------------------------------------------------------------------------------------* diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e1dc9a13c..f26c769c5 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5016,9 +5016,9 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } #endif -} + } -return IVAS_ERR_OK; + return IVAS_ERR_OK; } -- GitLab From 591f04b229c21a509fc8471bba5a4a150638c700 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 7 Jan 2026 15:03:57 +0100 Subject: [PATCH 262/750] fix wrong placement of #endif --- lib_dec/lib_dec_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f26c769c5..dc7083799 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5012,11 +5012,10 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) { ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); } +#endif ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } -#endif - } return IVAS_ERR_OK; } -- GitLab From 330e4f47dbe8932e27d2b76876a8989662432c3e Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 7 Jan 2026 15:14:53 +0100 Subject: [PATCH 263/750] correct indentation --- lib_dec/lib_dec_fx.c | 65 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index dc7083799..1e97c9ca8 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4966,55 +4966,58 @@ static ivas_error ivas_dec_voip_get_samples_common return error; } } - ELSE{ + ELSE + { /* render IVAS frames directly to the output buffer */ - IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ){ + IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + { return error; + } + } + + *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } - *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); -} -} - -IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) -{ - Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; - Word16 i; - - /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) + IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) { - return error; - } + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; + Word16 i; - /* Synthesise PCM output if split PCM */ - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ + IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) { - scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 + return error; } + /* Synthesise PCM output if split PCM */ + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 + } + #ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif #else - IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) - { + IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + { #ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); - } + } + ELSE + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + } #endif - ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); + } } return IVAS_ERR_OK; -- GitLab From a65cbf68faea5a12e0659c3faa20780f35b3a28e Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 7 Jan 2026 15:18:53 +0100 Subject: [PATCH 264/750] clang format --- lib_dec/lib_dec_fx.c | 68 +++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 1e97c9ca8..e6124911e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4966,61 +4966,59 @@ static ivas_error ivas_dec_voip_get_samples_common return error; } } - ELSE - { + ELSE{ /* render IVAS frames directly to the output buffer */ - IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) - { + IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ){ return error; - } - } - - *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } - IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) + *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); +} +} + +IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) +{ + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; + Word16 i; + + /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ + IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) { - Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; - Word16 i; + return error; + } - /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) + /* Synthesise PCM output if split PCM */ + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - return error; + scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } - /* Synthesise PCM output if split PCM */ - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 - } - #ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif #else - IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) - { + IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + { #ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); - } + } + ELSE + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + } #endif - ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); - } + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } -- GitLab From 30d24adf96ebd4c643b4e9115a07fc31df72d093 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 7 Jan 2026 10:23:45 -0500 Subject: [PATCH 265/750] find target improvement --- lib_com/options.h | 1 + lib_enc/find_tar_fx.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..cf6fac866 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -134,6 +134,7 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ +#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 5b3ab4792..f6408d096 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -173,7 +173,12 @@ void find_targets_ivas_fx( { Word16 i; Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */ +#ifndef OPT_2308_FIND_TARGET Word16 scale, scaleq, j, d, s, s2, tmp; +#else + Word16 scale, scaleq, j, d, s, tmp; + Word32 s2; +#endif Word16 Aqs[M + 1]; Word32 h1_32[6 * L_SUBFR]; Word16 sf; @@ -233,17 +238,27 @@ void find_targets_ivas_fx( { Copy( p_Aq, Aqs, M + 1 ); /* Q12 */ s = add( scaleq, 1 ); +#ifndef OPT_2308_FIND_TARGET s2 = shr( 16384, d ); +#else + s2 = L_shr( ( 16384 << 16 ), d ); +#endif } ELSE { Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */ s = add( scale, 1 ); +#ifndef OPT_2308_FIND_TARGET s2 = 16384; move16(); +#else + s2 = ( 16384 << 16 ); + move32(); +#endif } set32_fx( h1_32, 0, L_subfr ); +#ifndef OPT_2308_FIND_TARGET FOR( i = 0; i < M; i++ ) { Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ @@ -273,7 +288,38 @@ void find_targets_ivas_fx( h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ move32(); } +#else + FOR( i = 0; i < M; i++ ) + { + Ltmp64 = W_mult_32_16( s2, Ap[i] ); /* Q27 */ + FOR( j = 1; j <= i; j++ ) + { + Ltmp64 = W_msu_32_16( Ltmp64, L_shl_sat( h1_32[i - j], s ), Aqs[j] ); /* Q27 */ + } + h1_32[i] = W_sat_m( Ltmp64 ); /* Q27 */ + move32(); + } + + Ltmp64 = W_mult_32_16( s2, Ap[i]); /* Q27 */ + FOR( j = 1; j <= M; j++ ) + { + Ltmp64 = W_msu_32_16( Ltmp64, L_shl_sat( h1_32[i - j], s ), Aqs[j] ); /* Q27 */ + } + h1_32[M] = W_sat_m( Ltmp64 ); /* Q27 */ + move32(); + + FOR( i = M + 1; i < L_subfr; i++ ) + { + Ltmp64 = W_msu_32_16( 0, L_shl_sat( h1_32[i - 1], s ), Aqs[1] ); /* Q27 */ + FOR( j = 2; j <= M; j++ ) + { + Ltmp64 = W_msu_32_16( Ltmp64, L_shl_sat( h1_32[i - j], s ), Aqs[j] ); /* Q27 */ + } + h1_32[i] = W_sat_m( Ltmp64 ); /* Q27 */ + move32(); + } +#endif sf = sub( L_norm_arr( h1_32, L_subfr ), 1 ); Copy_Scale_sig32_16( h1_32, h1, L_subfr, sf ); // Q11 + sf -- GitLab From 4ecbc5df9b8cd0a8cf59881a6ea5874c7f302e49 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 7 Jan 2026 10:29:55 -0500 Subject: [PATCH 266/750] fix clang --- lib_enc/find_tar_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index f6408d096..a315c4301 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -300,7 +300,7 @@ void find_targets_ivas_fx( move32(); } - Ltmp64 = W_mult_32_16( s2, Ap[i]); /* Q27 */ + Ltmp64 = W_mult_32_16( s2, Ap[i] ); /* Q27 */ FOR( j = 1; j <= M; j++ ) { Ltmp64 = W_msu_32_16( Ltmp64, L_shl_sat( h1_32[i - j], s ), Aqs[j] ); /* Q27 */ -- GitLab From d7f61056faa03fada02ef45d51d867db53481f38 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 Jan 2026 19:33:22 +0100 Subject: [PATCH 267/750] inov_decode_ivas_fx() leftover --- lib_com/prot_fx.h | 3 ++- lib_dec/inov_dec_fx.c | 3 ++- lib_dec/ivas_td_low_rate_dec_fx.c | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8f3f5eca5..8285b23b0 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7129,6 +7129,7 @@ void inov_decode_fx( const Word16 L_subfr /* i : subframe length Q0 */ ); +#ifndef CLEANUP_ACELP_ENC void inov_decode_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate Q0 */ @@ -7142,7 +7143,7 @@ void inov_decode_ivas_fx( Word16 *code, /* o : algebraic excitation Q12 */ const Word16 L_subfr /* i : subframe length Q0 */ ); - +#endif void dec_acelp_4t64_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 nbbits, /* i : number of bits per codebook */ diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index 4d44e5b5b..30479dd04 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -191,7 +191,7 @@ void inov_decode_fx( cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); return; } - +#ifndef CLEANUP_ACELP_ENC /*======================================================================*/ /* FUNCTION : inov_decode_ivas_fx() */ /*-----------------------------------------------------------------------*/ @@ -376,3 +376,4 @@ void inov_decode_ivas_fx( cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); return; } +#endif diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 5f5912fb1..92d6d3153 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -297,7 +297,11 @@ void decod_gen_2sbfr_fx( * Innovation decoding *--------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_decode_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR ); +#else inov_decode_ivas_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR ); +#endif /*--------------------------------------------------------------* * Gain decoding -- GitLab From c6cb784dc9415c2c63a4e967fdaf4cae7d6455b6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 8 Jan 2026 10:55:52 +0100 Subject: [PATCH 268/750] move ivas_binRenderer_internal_fx.c from lib_dec to lib_rend --- Workspace_msvc/lib_dec.vcxproj | 1 - Workspace_msvc/lib_rend.vcxproj | 1 + {lib_dec => lib_rend}/ivas_binRenderer_internal_fx.c | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {lib_dec => lib_rend}/ivas_binRenderer_internal_fx.c (100%) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index fdc38e780..81461f72d 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -209,7 +209,6 @@ - diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index b76f3211c..4dba9d236 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -138,6 +138,7 @@ + diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_rend/ivas_binRenderer_internal_fx.c similarity index 100% rename from lib_dec/ivas_binRenderer_internal_fx.c rename to lib_rend/ivas_binRenderer_internal_fx.c -- GitLab From 57662438ef1f1d8b123420fff4e5203a8bd1f5d1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 8 Jan 2026 14:08:20 +0100 Subject: [PATCH 269/750] fix gp_clip_test_lsf_fx() --- lib_enc/lsf_enc_fx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index f075d4cb7..4fc0777c7 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -148,7 +148,19 @@ void lsf_enc_fx( lsp2lsf_fx( lsp_new, lsf_new, M, int_fs ); /* check resonance for pitch clipping algorithm */ +#ifdef HARM_LSF_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 ); + } + ELSE + { + gp_clip_test_lsf_ivas_fx( st_fx->element_mode, st_fx->core_brate, lsf_new, st_fx->clip_var_fx, 0 ); + } +#else gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 ); +#endif + /* Find the number of bits for LSF quantization */ nBits = 0; -- GitLab From 9de23193ddd20b1f89be0d7d2248d9ef75b6e83c Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 8 Jan 2026 15:09:59 +0100 Subject: [PATCH 270/750] Move the move16() --- lib_com/hvq_pvq_bitalloc_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c index 58d918abd..2e01a7361 100644 --- a/lib_com/hvq_pvq_bitalloc_fx.c +++ b/lib_com/hvq_pvq_bitalloc_fx.c @@ -42,6 +42,7 @@ Word16 hvq_pvq_bitalloc_fx( #ifdef FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR *n_sel_bands = 0; + move16(); #endif IF( EQ_16( bwidth_fx, FB ) ) @@ -113,8 +114,8 @@ Word16 hvq_pvq_bitalloc_fx( #ifndef FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR *n_sel_bands = 0; -#endif move16(); +#endif envSum = 0; move16(); E_max = L_deposit_l( 0 ); -- GitLab From be5d56f7e2540123932b7debb9e42a585fbfa54e Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 8 Jan 2026 16:28:39 +0100 Subject: [PATCH 271/750] formatting --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 976fdb89f..df87bf7f9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,6 +90,7 @@ #define FIX_2248_EVS_ASSERT /* VA: Include _sat in an EVS related part of the code */ #define FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ #define FIX_2268_OOB_INDEXING_IN_IFFT /* VA: Fix for issue 2268, to silence clang18 */ + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ -- GitLab From e68cb3c42e26dfc2518645494f74ee55a6398c1f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 8 Jan 2026 19:30:10 +0100 Subject: [PATCH 272/750] address reviewer's comments --- lib_com/options.h | 2 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 73 ++++++++++++++++---------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 467e6d1ac..e4f294e71 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ -#define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */() +#define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index e34edea7b..a377b5841 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1241,7 +1241,9 @@ void ivas_sba_dirac_stereo_dec_fx( Word16 dtx_flag, fd_cng_flag; Word16 sba_mono_flag; Word16 memOffset; +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word32 output_Fs; +#endif Word32 tmp_buf[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; Word32 tmp_synth[L_FRAME16k]; Word32 hb_gain[NB_DIV]; @@ -1257,19 +1259,12 @@ void ivas_sba_dirac_stereo_dec_fx( #ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 mcmasa; - mcmasa = 0; + mcmasa = EQ_32( st_ivas->ivas_format, MC_FORMAT); move16(); - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) - { - mcmasa = 1; - move16(); - } -#endif output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC hCPE = st_ivas->hCPE[0]; hSCE = st_ivas->hSCE[0]; hStereoDft = hCPE->hStereoDft; @@ -1293,11 +1288,7 @@ void ivas_sba_dirac_stereo_dec_fx( } FOR( i = 0; i < CPE_CHANNELS; i++ ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( output[i], output_frame, s ); // Q(11+s) -#else - Scale_sig32( output[i], L_FRAME48k, s ); // Q(11+s) -#endif } hStereoDft->q_dft = add( Q11, s ); move16(); @@ -1321,21 +1312,13 @@ void ivas_sba_dirac_stereo_dec_fx( IF( hCPE->hCoreCoder[0] != NULL ) { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, output_frame, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#else - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#endif hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; move16(); } IF( hStereoDft != NULL ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC IF( LE_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) -#else - IF( LE_16( st_ivas->nchan_transport, 1 ) ) -#endif { st = hCPE->hCoreCoder[0]; test(); @@ -1383,25 +1366,21 @@ void ivas_sba_dirac_stereo_dec_fx( } } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC IF( NE_32( st_ivas->ivas_format, SBA_FORMAT ) ) { scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft } -#endif scale_sig32( hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hStereoDft->q_dft, hStereoDft->q_ap_fade_mem_fx ) ); // q_dft hStereoDft->q_ap_fade_mem_fx = hStereoDft->q_dft; move16(); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC test(); if ( st_ivas->hSpar != NULL && EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30; move16(); } -#endif IF( hSCE != NULL ) { @@ -1437,22 +1416,38 @@ void ivas_sba_dirac_stereo_dec_fx( set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX ); } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - hSCE = st_ivas->hSCE[0]; - hCPE = st_ivas->hCPE[0]; - hStereoDft = hCPE->hStereoDft; -#endif +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC q = hStereoDft->q_dft; move16(); q_dft[0] = hStereoDft->q_dft; move16(); q_dft[1] = hStereoDft->q_dft; move16(); +#else + hSCE = st_ivas->hSCE[0]; + hCPE = st_ivas->hCPE[0]; + hStereoDft = hCPE->hStereoDft; + + q = hCPE->hStereoDft->q_dft; + move16(); + q_dft[0] = hCPE->hStereoDft->q_dft; + move16(); + q_dft[1] = hCPE->hStereoDft->q_dft; + move16(); +#endif +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ +#else + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ +#endif IF( hSCE != NULL ) { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ +#else + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ +#endif hSCE->q_prev_hb_synth_fx = hStereoDft->q_dft; move16(); } @@ -1480,10 +1475,17 @@ void ivas_sba_dirac_stereo_dec_fx( move16(); ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); + test(); test(); +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); +#else + hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); +#endif + stereo_dft_dec_update_fx( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); + IF( GT_16( st_ivas->nchan_transport, 1 ) ) { stereo_dft_dec_analyze_fx( hCPE, output[0], DFT, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, &q, &q_dft[0] ); @@ -1523,8 +1525,13 @@ void ivas_sba_dirac_stereo_dec_fx( } /* DFT Stereo upmix */ +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); +#else + stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, + st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); +#endif /* DFT synthesis */ stereo_dft_dec_synthesize_fx( hCPE, DFT, 0, output[0], output_frame ); @@ -1582,10 +1589,18 @@ void ivas_sba_dirac_stereo_dec_fx( set32_fx( output[ch], 0, output_frame ); } +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ +#else + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ +#endif IF( hSCE != NULL ) { +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ +#else + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ +#endif hSCE->q_prev_hb_synth_fx = Q11; move16(); } -- GitLab From 03d07e29afc7f7c9206ed83e3f8df8bec5e7d2de Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 8 Jan 2026 19:45:36 +0100 Subject: [PATCH 273/750] clang-format --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index be2e14979..e5308b737 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1288,7 +1288,7 @@ void ivas_sba_dirac_stereo_dec_fx( #if 0 // ToDo: this is a bug for output_Fs = 16 or 32 -> deactivated for the moment to keep BE s = s_min( s, L_norm_arr( output[i], output_frame ) - Q11 ) /* Guard bits */; #else - s = s_min( s, L_norm_arr( output[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ + s = s_min( s, L_norm_arr( output[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ #endif } FOR( i = 0; i < CPE_CHANNELS; i++ ) @@ -1317,7 +1317,7 @@ void ivas_sba_dirac_stereo_dec_fx( IF( hCPE->hCoreCoder[0] != NULL ) { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, output_frame, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, output_frame, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; move16(); } @@ -1597,7 +1597,7 @@ void ivas_sba_dirac_stereo_dec_fx( #ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ #else - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ #endif IF( hSCE != NULL ) { -- GitLab From a8424b8abb0e43d21866fdc09534f079f93e957b Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 8 Jan 2026 19:57:19 +0100 Subject: [PATCH 274/750] add missing compilation switch --- lib_dec/ivas_jbm_dec_fx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 66b3044a4..af4bcf407 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -673,7 +673,11 @@ ivas_error ivas_dec_fx( ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC FOR( i = 0; i < CPE_CHANNELS; i++ ) +#else + FOR( i = 0; i < 2; i++ ) +#endif { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } @@ -804,13 +808,21 @@ ivas_error ivas_dec_fx( hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 output_q = Q11; +#else + Word16 output_q = 11; +#endif move16(); IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); +#ifdef REMOVE_UNUSED_CODE_IVAS_DEC output_q = Q8; +#else + output_q = 8; +#endif move16(); } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) -- GitLab From c9b88ee873d6aeff8fa07e4566c6de0b342b70eb Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 9 Jan 2026 10:52:38 +0100 Subject: [PATCH 275/750] add missing aligment with main float --- lib_rend/ivas_hrtf_fx.c | 4 +++- lib_rend/ivas_prot_rend_fx.h | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 5db9b7532..118c94e32 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -33,11 +33,13 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_rom_binaural_crend_head.h" #include "ivas_prot_rend_fx.h" #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA +#include "ivas_rom_binaural_crend_head.h" +#endif /*-----------------------------------------------------------------------* * ivas_HRTF_td_binary_open() diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 738da8733..f6416f109 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -652,6 +652,7 @@ void ivas_HRTF_CRend_binary_close_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA #ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_error ivas_HRTF_statistics_init_from_rom_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ @@ -663,16 +664,14 @@ ivas_error ivas_HRTF_statistics_init_fx( const Word32 sampleRate /* i : Sample rate */ ); #endif - -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA -void ivas_HRTF_statistics_close_fx( - HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ -); #endif - #ifdef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_statistics_binary_close_fx( HRTFS_STATISTICS **hHrtfStatistics ); /* i/o: HRTF statistics structure */ +#else +void ivas_HRTF_statistics_close_fx( + HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ +); #endif ivas_error ivas_HRTF_statistics_binary_open_fx( -- GitLab From b5f700be073fbb68f171cb8fddb19414b64499f5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 11:10:03 +0100 Subject: [PATCH 276/750] REMOVE_CAM_FROM_IVAS --- lib_com/options.h | 1 + lib_enc/decision_matrix_enc_fx.c | 5 ++++- lib_enc/enc_prm_fx.c | 7 +++++-- lib_enc/evs_enc_fx.c | 8 ++++++++ lib_enc/ivas_core_enc_fx.c | 3 ++- lib_enc/prot_fx_enc.h | 6 ++++-- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 532a00be2..0895b0fdb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,6 +112,7 @@ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ +#define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index 086b6e86a..f73a524ce 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -752,13 +752,15 @@ void signalling_enc_fx( } /*---------------------------------------------------------------------* - * signalling_enc_rf() + * signaling_enc_rf() * * write channel-aware signalling information into the bitstream *---------------------------------------------------------------------*/ + void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ) +#ifndef REMOVE_CAM_FROM_IVAS { Word16 i; Word16 sfr; @@ -833,6 +835,7 @@ void signaling_enc_rf_fx( void signalling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ) +#endif { Word16 i; Word16 sfr; diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 6a861b8af..d0b050ac0 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -93,13 +93,14 @@ static void enc_prm_hm_ivas_fx( } } + /*-----------------------------------------------------------------* - * Function enc_prm_rf_fx() * + * Function enc_prm_rf_fx() * * ~~~~~~~~~~~~~~~~~~~~~~ * * * * encode RF parameters for ACELP and TCX partial copy * *-----------------------------------------------------------------*/ - +#ifndef REMOVE_CAM_FROM_IVAS void enc_prm_rf_ivas_fx( Encoder_State *st, const Word16 rf_frame_type, /* Q0 */ @@ -271,6 +272,8 @@ void enc_prm_rf_ivas_fx( /* write RF frame type last in the bitstream */ push_next_indice( hBstr, rf_frame_type, 3 ); } +#endif + void enc_prm_rf_fx( Encoder_State *st, const Word16 rf_frame_type, /* Q0 */ diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 416c2f4e9..34336ef79 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -531,7 +531,15 @@ ivas_error evs_enc_fx( * Channel-aware mode - write signaling information into the bitstream *---------------------------------------------------------------------*/ +#ifdef REMOVE_CAM_FROM_IVAS + signaling_enc_rf_fx( st ); + + /*---------------------------------------------------------------------* + * Updates + *---------------------------------------------------------------------*/ +#else signalling_enc_rf_fx( st ); +#endif updt_enc_common_fx( st, Etot, Q_new ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 2ee800325..e74701f16 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -827,12 +827,13 @@ ivas_error ivas_core_enc_fx( st->q_inp = q_inp[1]; move16(); +#ifndef REMOVE_CAM_FROM_IVAS /*---------------------------------------------------------------------* * Channel-aware mode - write signaling information into the bitstream *---------------------------------------------------------------------*/ signaling_enc_rf_fx( st ); - +#endif /*---------------------------------------------------------------------* * Common updates *---------------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 13d11e72b..29cff05f6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2765,11 +2765,12 @@ void enc_prm_rf_fx( const Word16 rf_frame_type, const Word16 fec_offset ); +#ifndef REMOVE_CAM_FROM_IVAS void enc_prm_rf_ivas_fx( Encoder_State *st, const Word16 rf_frame_type, const Word16 fec_offset ); - +#endif void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, @@ -2966,10 +2967,11 @@ void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ); +#ifndef REMOVE_CAM_FROM_IVAS void signalling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ); - +#endif void IGFEncResetTCX10BitCounter_fx( const IGF_ENC_INSTANCE_HANDLE hInstance /**< in: | instance handle of IGF Encoder */ ); -- GitLab From 23a1066ce85c6be79c42c020fb6b492f6dff0fd3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 9 Jan 2026 13:25:47 +0100 Subject: [PATCH 277/750] init pointer array regardless of having samples to flush or not --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec_fx.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 6a07f86b9..31079e8db 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,7 @@ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ +#define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 093dc841f..0bac13b87 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2461,12 +2461,23 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS]; Word16 nchan_in, nchan_out; +#ifdef FIX_1486_INIT_OUTPUT_POINTERS + int16_t ch_idx; +#endif + IF( !st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_OK; } +#ifdef FIX_1486_INIT_OUTPUT_POINTERS + FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) + { + p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; + } +#endif + *nSamplesRendered = 0; move16(); hTcBuffer = st_ivas->hTcBuffer; @@ -2492,7 +2503,9 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( n_slots_still_available ) { +#ifndef FIX_1486_INIT_OUTPUT_POINTERS Word16 ch_idx; +#endif /* render available full slots (with new lower granularity) */ FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) @@ -2522,10 +2535,12 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); +#ifndef FIX_1486_INIT_OUTPUT_POINTERS FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) { p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; } +#endif test(); IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) -- GitLab From c8cf06f9bad903f3d272d1bb376aee320a762ea2 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 9 Jan 2026 13:37:09 +0100 Subject: [PATCH 278/750] proper init of SPAR MD params --- lib_com/options.h | 1 + lib_dec/ivas_spar_md_dec_fx.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 6a07f86b9..3b08df3e6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,7 @@ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ +#define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 64c4375a5..dee18eda4 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -630,6 +630,13 @@ ivas_error ivas_spar_md_dec_init( } hMdDec->first_valid_frame = 1; move16(); + +#ifdef FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE + hMdDec->spar_md.res_ind = 0; + hMdDec->spar_md.prior_dyn_active_w_flag = 0; + move16(); + move16(); +#endif return IVAS_ERR_OK; } -- GitLab From 866ddacfa502afd1afd96434961b2c36c2f8fca0 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 9 Jan 2026 13:39:36 +0100 Subject: [PATCH 279/750] clang format --- lib_dec/ivas_spar_md_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index dee18eda4..e90f69550 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -630,13 +630,13 @@ ivas_error ivas_spar_md_dec_init( } hMdDec->first_valid_frame = 1; move16(); - + #ifdef FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE hMdDec->spar_md.res_ind = 0; hMdDec->spar_md.prior_dyn_active_w_flag = 0; - move16(); - move16(); -#endif + move16(); + move16(); +#endif return IVAS_ERR_OK; } -- GitLab From 1e96b4bcbea1f1aaeb6b1f7e432229f734ca79d7 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 9 Jan 2026 14:38:08 +0100 Subject: [PATCH 280/750] remove unused code --- apps/renderer.c | 16 ++++++++++++++++ lib_com/options.h | 1 + lib_rend/lib_rend.h | 2 ++ lib_rend/lib_rend_fx.c | 9 +++++++++ 4 files changed, 28 insertions(+) diff --git a/apps/renderer.c b/apps/renderer.c index 70e68c757..c494ee0f1 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -172,7 +172,9 @@ typedef struct int16_t numInMetadataFiles; char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#ifndef FIX_1494_SET_SPLITBFI_UNUSED char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#endif char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -223,7 +225,9 @@ typedef enum CmdLnOptionId_listFormats, CmdLnOptionId_inputGain, CmdLnOptionId_outputMetadata, +#ifndef FIX_1494_SET_SPLITBFI_UNUSED CmdLnOptionId_SplitRendBFIFile, +#endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, CmdLnOptionId_framing, @@ -282,12 +286,14 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "om", .description = "coded metadata file for BINAURAL_SPLIT_PCM output mode", }, +#ifndef FIX_1494_SET_SPLITBFI_UNUSED { .id = CmdLnOptionId_SplitRendBFIFile, .match = "post_rend_bfi_file", .matchShort = "prbfi", .description = "Split rendering option: bfi file", }, +#endif { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", @@ -763,7 +769,9 @@ int main( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[RENDERER_MAX_INPUT_CHANNELS]; IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[RENDERER_MAX_INPUT_CHANNELS]; int16_t cldfb_in_flag, CLDFBframeSize_smpls; +#ifndef FIX_1494_SET_SPLITBFI_UNUSED SplitRendBFIFileReader *splitRendBFIReader = NULL; +#endif Vector3PairFileReader *referenceVectorReader = NULL; hrtfFileReader *hrtfFileReader = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL; @@ -893,11 +901,13 @@ int main( } } +#ifndef FIX_1494_SET_SPLITBFI_UNUSED if ( !isEmptyString( args.splitRendBFIFilePath ) ) { convert_backslash( args.splitRendBFIFilePath ); SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } +#endif if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -2183,7 +2193,9 @@ cleanup: } split_rend_reader_writer_close( &hSplitRendFileReadWrite ); +#ifndef FIX_1494_SET_SPLITBFI_UNUSED SplitRendBFIFileReader_close( &splitRendBFIReader ); +#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { @@ -2785,7 +2797,9 @@ static CmdlnArgs defaultArgs( clearString( args.headRotationFilePath ); clearString( args.outMetadataFilePath ); +#ifndef FIX_1494_SET_SPLITBFI_UNUSED clearString( args.splitRendBFIFilePath ); +#endif clearString( args.referenceVectorFilePath ); clearString( args.referenceRotationFilePath ); clearString( args.customHrtfFilePath ); @@ -2892,10 +2906,12 @@ static void parseOption( assert( numOptionValues == 1 ); strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; +#ifndef FIX_1494_SET_SPLITBFI_UNUSED case CmdLnOptionId_SplitRendBFIFile: assert( numOptionValues == 1 ); strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; +#endif case CmdLnOptionId_referenceVectorFile: assert( numOptionValues == 1 ); strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index 6a07f86b9..85843d709 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,7 @@ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ +#define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 5e202001a..ff8ce19bd 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -344,9 +344,11 @@ ivas_error IVAS_REND_SetReferenceVector( const IVAS_VECTOR3 refPos /* i : Reference position */ ); +#ifndef FIX_1494_SET_SPLITBFI_UNUSED ivas_error IVAS_REND_SetSplitRendBFI( IVAS_REND_HANDLE hIvasRend, const Word16 bfi); +#endif ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index eaed6ebf5..c0882c664 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -94,7 +94,9 @@ typedef struct const EFAP_WRAPPER *pEfapOutWrapper; IVAS_REND_HeadRotData *pHeadRotData; // for now removing the const qualifier TODO: will modify later const RENDER_CONFIG_HANDLE *hhRendererConfig; +#ifndef FIX_1494_SET_SPLITBFI_UNUSED const Word16 *pSplitRendBFI; +#endif const SPLIT_REND_WRAPPER *pSplitRendWrapper; const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData; const IVAS_DefaultReverbSize *pSelectedRoomReverbSize; @@ -216,7 +218,9 @@ struct IVAS_REND EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; +#ifndef FIX_1494_SET_SPLITBFI_UNUSED Word16 splitRendBFI; +#endif SPLIT_REND_WRAPPER *splitRendWrapper; IVAS_REND_AudioBuffer splitRendEncBuffer; IVAS_REND_HeadRotData headRotData; @@ -1365,7 +1369,9 @@ static rendering_context getRendCtx( ctx.pEfapOutWrapper = &hIvasRend->efapOutWrapper; ctx.pHeadRotData = &hIvasRend->headRotData; ctx.hhRendererConfig = &hIvasRend->hRendererConfig; +#ifndef FIX_1494_SET_SPLITBFI_UNUSED ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; +#endif ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper; ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; ctx.pSelectedRoomReverbSize = &hIvasRend->selectedRoomReverbSize; @@ -5758,6 +5764,7 @@ ivas_error IVAS_REND_DisableHeadRotation( return IVAS_ERR_OK; } +#ifndef FIX_1494_SET_SPLITBFI_UNUSED /*-------------------------------------------------------------------* * IVAS_REND_SetSplitRendBFI() @@ -5775,6 +5782,8 @@ ivas_error IVAS_REND_SetSplitRendBFI( return IVAS_ERR_OK; } +#endif + /*-------------------------------------------------------------------* * IVAS_REND_SetOrientationTrackingMode() -- GitLab From 614bfd0cb538889ea51326bc04b11e73ca1c3db1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 9 Jan 2026 14:54:31 +0100 Subject: [PATCH 281/750] take correct frame-length into account for guard-bit calculation --- apps/renderer.c | 4 ++++ lib_com/options.h | 1 + 2 files changed, 5 insertions(+) diff --git a/apps/renderer.c b/apps/renderer.c index 70e68c757..0e499863c 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1646,8 +1646,12 @@ int main( ObjectPositionBuffer mtdBuffer; outBuffer.pq_fact = &outBuffer.q_factor; +#ifdef FIX_2257_INCR_GUARD_BITS + Word16 gd_bits = find_guard_bits( frameSize_smpls ); +#else Word16 subframe_len = (Word16) ( args.sampleRate / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); Word16 gd_bits = find_guard_bits( subframe_len ); +#endif Word16 prev_q_fact = Q11; while ( 1 ) { diff --git a/lib_com/options.h b/lib_com/options.h index 6a07f86b9..795d1c4bd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,6 +129,7 @@ #define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ +#define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ /* ##################### End NON-BE switches ########################### */ -- GitLab From dd3ca45a41516f5d32f65b72c0dcdb576084b7b2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 17:38:16 +0100 Subject: [PATCH 282/750] fix FIX_2313_HF_RESET_16KHZ --- lib_com/options.h | 1 + lib_dec/core_switching_dec_fx.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..95d94587a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,6 +133,7 @@ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ +#define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz outputs */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index d1040cb80..600f43f3e 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2246,7 +2246,11 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); test(); +#ifdef FIX_2313_HF_RESET_16KHZ + IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#else IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#endif { hf_synth_reset_fx( st->hBWE_zero ); set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); @@ -2568,7 +2572,11 @@ ivas_error core_switching_pre_dec_ivas_fx( } test(); +#ifdef FIX_2313_HF_RESET_16KHZ + IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#else IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#endif { hf_synth_reset_fx( st->hBWE_zero ); set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); @@ -2618,7 +2626,11 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); test(); +#ifdef FIX_2313_HF_RESET_16KHZ + IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#else IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#endif { hf_synth_reset_fx( st->hBWE_zero ); set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -- GitLab From 8b6bd6f85d49f254f3d648a84661097e19c07634 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 17:52:22 +0100 Subject: [PATCH 283/750] HARM_CORE_SW, decoder step 1 --- lib_com/options.h | 2 + lib_com/prot_fx.h | 34 +- lib_dec/amr_wb_dec_fx.c | 4 + lib_dec/core_switching_dec_fx.c | 588 +++++++++++++++++++++++--------- lib_dec/evs_dec_fx.c | 8 + lib_dec/ivas_core_dec_fx.c | 24 ++ 6 files changed, 495 insertions(+), 165 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..9518e3168 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,6 +117,8 @@ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ #define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ +#define HARM_CORE_SW + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index abb050c02..41d1ad5ae 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7794,19 +7794,41 @@ void hq_configure_bfi_fx( void bandwidth_switching_detect_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ); +#ifndef HARM_CORE_SW void bandwidth_switching_detect_ivas_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ); - +#endif void bw_switching_pre_proc_fx( +#ifdef HARM_CORE_SW + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + Word16 *old_syn_12k8_16k_fx16, + Word32 *old_syn_12k8_16k_fx32, + Word16 Q +#else const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ Decoder_State *st_fx /* i/o: decoder state structure */ +#endif ); ivas_error core_switching_pre_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ +#ifdef HARM_CORE_SWaa + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 output_frame, /* i : frame length */ + const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 last_element_mode, /* i : last_element_mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 Q_old_synthFB, + Word16 *Q_olapBufferSynth, + Word16 *Q_olapBufferSynth2 +#else + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 output_frame /* i : frame length Q0*/ +#endif ); ivas_error core_switching_post_dec_fx( @@ -9548,6 +9570,7 @@ void stereo_dft_dec_open( const Word16 nchan_transport /* i : number of transport channels */ ); +#ifndef HARM_CORE_SW void ivas_bw_switching_pre_proc_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word32 last_element_brate, /* i : last element bitrate */ @@ -9555,7 +9578,7 @@ void ivas_bw_switching_pre_proc_fx( Word32 *old_syn_12k8_16k_fx, Word16 Q, Word16 Q_audio ); - +#endif UWord32 mvl2s_r( const Word32 x[], /* i : input vector */ const Word16 q, @@ -10411,6 +10434,7 @@ void wtda_fx32( const Word16 L /* i : length */ ); +#ifndef HARM_CORE_SWaa ivas_error core_switching_pre_dec_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ @@ -10421,7 +10445,7 @@ ivas_error core_switching_pre_dec_ivas_fx( Word16 Q_old_synthFB, Word16 *Q_olapBufferSynth, Word16 *Q_olapBufferSynth2 ); - +#endif void hp20_fx_32( Word32 signal_fx[], const Word16 lg, diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index d7dcf5b03..8a6917374 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -172,7 +172,11 @@ ivas_error amr_wb_dec_fx( } /* Updates in case of EVS -> AMR-WB IO switching */ +#ifdef HARM_CORE_SWaa + IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index d1040cb80..695ddb64f 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -11,6 +11,15 @@ #include "ivas_prot_fx.h" +#ifdef HARM_CORE_SW +/*---------------------------------------------------------------------* + * Local prototypes + *---------------------------------------------------------------------*/ + +static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); +static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); + +#else /*---------------------------------------------------------------------* * bandwidth_switching_detect_fx() * @@ -134,6 +143,7 @@ void bandwidth_switching_detect_fx( return; } +#endif /*---------------------------------------------------------------------* * Calc_freq_ener_fx() @@ -167,6 +177,7 @@ static Word32 Calc_freq_ener_fx( return enerLL_fx; } + /*---------------------------------------------------------------------* * bw_switching_pre_proc_fx() * @@ -174,8 +185,17 @@ static Word32 Calc_freq_ener_fx( *---------------------------------------------------------------------*/ void bw_switching_pre_proc_fx( - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ +#ifdef HARM_CORE_SW + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + Word16 *old_syn_12k8_16k_fx16, + Word32 *old_syn_12k8_16k_fx32, + Word16 Q +#else + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + Decoder_State *st_fx /* i/o: decoder state structure */ +#endif ) { Word16 i; @@ -184,6 +204,28 @@ void bw_switching_pre_proc_fx( IF( st_fx->element_mode > EVS_MONO ) { +#ifdef HARM_CORE_SW + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st_fx->core == ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) && st_fx->hBWE_FD != NULL && !( LE_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) + { + /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ + Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; + Copy_Scale_sig_32_16( old_syn_12k8_16k_fx32, old_syn_12k8_16k_tmp_16fx, st_fx->L_frame, sub( -1, Q ) ); + st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st_fx->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 + move16(); + } + + return; +#endif } test(); @@ -194,13 +236,22 @@ void bw_switching_pre_proc_fx( * Calculate tilt of the ACELP core synthesis *----------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_fx16, -1, st_fx->L_frame ), 3 ) ); /* Q11 */ +#else st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3 ) ); /* Q11 */ +#endif move16(); + /*-------------------------------------------------------------------------------* * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis *-------------------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + edct_16fx( old_syn_12k8_16k_fx16, syn_dct_fx, L_FRAME, 6, st_fx->element_mode ); +#else edct_16fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, 6, st_fx->element_mode ); +#endif L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME / 2; i++ ) @@ -294,7 +345,7 @@ void bw_switching_pre_proc_fx( return; } - +#ifndef HARM_CORE_SWaa /*---------------------------------------------------------------------* * core_switching_pre_dec_fx() * @@ -866,6 +917,7 @@ ivas_error core_switching_pre_dec_fx( return error; } +#endif /*---------------------------------------------------------------------* * core_switching_post_dec() @@ -2164,22 +2216,48 @@ static void smoothTransitionDtxToTcx_fx( * * Preprocessing/preparation for ACELP/HQ core switching *---------------------------------------------------------------------*/ + +#ifdef HARM_CORE_SWaa +ivas_error core_switching_pre_dec_fx( +#else ivas_error core_switching_pre_dec_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ const Word16 nchan_out, /* i : number of output channels */ const Word16 last_element_mode, /* i : last_element_mode */ const Word32 last_element_brate, /* i : last element bitrate */ +#ifdef HARM_CORE_SWaa + const Word16 Q_old_synthFB, +#else Word16 Q_old_synthFB, +#endif Word16 *Q_olapBufferSynth, Word16 *Q_olapBufferSynth2 ) { Word32 tmp_fx; /*Q-12*/ Word16 i, oldLenClasBuff, newLenClasBuff; ivas_error error; +#ifdef HARM_CORE_SW + Word16 tmp, exp = Q25; + Word32 L_tmp; +#else Word16 exp = 25; +#endif move16(); + BPF_DEC_HANDLE hBPF; + TD_BWE_DEC_HANDLE hBWE_TD; + FD_BWE_DEC_HANDLE hBWE_FD; + HQ_DEC_HANDLE hHQ_core; + TCX_DEC_HANDLE hTcxDec; + + hBWE_TD = st->hBWE_TD; + hBWE_FD = st->hBWE_FD; + hHQ_core = st->hHQ_core; + hBPF = st->hBPF; + hTcxDec = st->hTcxDec; + error = IVAS_ERR_OK; move32(); @@ -2189,9 +2267,9 @@ ivas_error core_switching_pre_dec_ivas_fx( test(); IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) { - st->mem_deemph_fx = st->syn[M]; + st->mem_deemph_fx = st->syn[M]; /* Q_syn */ move16(); - set16_fx( st->agc_mem_fx, 0, 2 ); + set16_fx( st->agc_mem_fx, 0, 2 ); /* Q0 */ Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */ Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/ @@ -2203,12 +2281,12 @@ ivas_error core_switching_pre_dec_ivas_fx( Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ - set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ + set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ } - IF( st->hBPF != NULL ) + IF( hBPF != NULL ) { - st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ - st->hBPF->pst_mem_deemp_err_fx = 0; + hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ + hBPF->pst_mem_deemp_err_fx = 0; move16(); move16(); } @@ -2218,23 +2296,23 @@ ivas_error core_switching_pre_dec_ivas_fx( /* reset old HB synthesis buffer */ IF( EQ_16( st->last_L_frame, L_FRAME ) ) { - st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); + st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); } ELSE { - st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); + st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); } move16(); set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); test(); - IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) ) + IF( hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) ) { - st->hBWE_TD->prev_hb_synth_fx_exp = 31; + hBWE_TD->prev_hb_synth_fx_exp = 31; move16(); /* reset BWE memories */ - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); /* Q_exc */ + hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); } @@ -2246,35 +2324,42 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); test(); +#ifdef HARM_CORE_SWaa // !!!!! + IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#else IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#endif { hf_synth_reset_fx( st->hBWE_zero ); +#ifdef HARM_CORE_SW + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment +#endif set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } - IF( st->hBWE_FD != NULL ) + IF( hBWE_FD != NULL ) { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } - IF( st->hHQ_core != NULL ) + IF( hHQ_core != NULL ) { - set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); + set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); + set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); + set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - st->hHQ_core->last_max_pos_pulse = 0; + hHQ_core->last_max_pos_pulse = 0; move16(); IF( GT_32( st->output_Fs, 16000 ) ) { - set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); + set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } /* pre-echo */ - st->hHQ_core->pastpre = 0; + hHQ_core->pastpre = 0; move16(); } @@ -2293,20 +2378,24 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_core = HQ_CORE; move16(); - Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 +#ifdef HARM_CORE_SW + Copy( hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /* st->q_prev_synth_buffer_fx */ +#else + Copy32( hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + // Copy_Scale_sig_32_16( hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 +#endif } - IF( st->hHQ_core != NULL ) + IF( hHQ_core != NULL ) { - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - st->hHQ_core->last_max_pos_pulse = 0; + set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); + hHQ_core->last_max_pos_pulse = 0; move16(); - set16_fx( st->hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - st->hHQ_core->prev_frm_hfe2 = 0; - st->hHQ_core->prev_stab_hfe2 = 0; + set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); + hHQ_core->prev_frm_hfe2 = 0; + hHQ_core->prev_stab_hfe2 = 0; move16(); move16(); } @@ -2317,66 +2406,116 @@ ivas_error core_switching_pre_dec_ivas_fx( Word16 delay_comp; /*switch off Hq Voicing as it was not updated in MODE2*/ - IF( st->hHQ_core != NULL ) + IF( hHQ_core != NULL ) { - st->hHQ_core->oldHqVoicing = 0; - st->hHQ_core->HqVoicing = 0; + hHQ_core->oldHqVoicing = 0; + hHQ_core->HqVoicing = 0; move16(); move16(); } - delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); - /*TODO To be tested:control not entering the block*/ - test(); - test(); - IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); + +#ifdef HARM_CORE_SW + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ - assert( 0 ); - Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH]; - Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; - Word32 syn_Overl_fx[320]; - Word32 fer_samples_fx[960]; - Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); - Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); + test(); + test(); + IF( !st->last_con_tcx && st->last_core_bfi == ACELP_CORE && EQ_16( st->core, HQ_CORE ) ) + { + Word16 no_col; + Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH]; + Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; + CLDFB_SCALE_FACTOR scaleFactor; + Word32 workBuffer[128 * 3]; + FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) + { + set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); + realBuffer[i] = realBufferTmp[i]; + move32(); + imagBuffer[i] = imagBufferTmp[i]; + move32(); + } - FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) - { - set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer_fx[i] = realBufferTmp_fx[i]; - imagBuffer_fx[i] = imagBufferTmp_fx[i]; - } + no_col = s_min( st->cldfbAna->no_col, idiv1616( sub( add( delay_comp, st->cldfbAna->no_channels ), 1 ), st->cldfbAna->no_channels ) ); /* Q0 */ - /* CLDFB analysis of the synthesis at internal sampling rate */ - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* CLDFB analysis of the synthesis at internal sampling rate */ + IF( ( error = cldfb_save_memory( st->cldfbAna ) ) != IVAS_ERR_OK ) + { + return error; + } + cldfbAnalysis_fx( st->cldfbAna, realBuffer, imagBuffer, &scaleFactor, hTcxDec->syn_Overl, 0, no_col, workBuffer ); + cldfb_restore_memory( st->cldfbAna ); - cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna ); - cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/ + scaleFactor.hb_scale = scaleFactor.lb_scale; + move16(); - /* CLDFB synthesis of the combined signal */ - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) ) - { - return error; + /* CLDFB synthesis of the combined signal */ + IF( ( error = cldfb_save_memory( st->cldfbSyn ) ) != IVAS_ERR_OK ) + { + return error; + } + cldfbSynthesis_fx( st->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, hHQ_core->fer_samples_fx, 0, no_col, workBuffer ); + cldfb_restore_memory( st->cldfbSyn ); } - - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn ); - cldfb_restore_memory_ivas_fx( st->cldfbSyn ); - Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); - Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); } - - test(); - test(); - IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + ELSE +#endif { - lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); - /*Set to zero the remaining part*/ - set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); + /*TODO To be tested:control not entering the block*/ + test(); + test(); + IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + { + /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ + assert( 0 ); + Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH]; + Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; + Word32 syn_Overl_fx[320]; + Word32 fer_samples_fx[960]; + Copy_Scale_sig_16_32_DEPREC( hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); + Copy_Scale_sig_16_32_DEPREC( hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); + + + FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) + { + set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + realBuffer_fx[i] = realBufferTmp_fx[i]; + imagBuffer_fx[i] = imagBufferTmp_fx[i]; + } + + /* CLDFB analysis of the synthesis at internal sampling rate */ + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) ) + { + return error; + } + + cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna ); + cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/ + + /* CLDFB synthesis of the combined signal */ + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) ) + { + return error; + } + + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn ); + cldfb_restore_memory_ivas_fx( st->cldfbSyn ); + Copy_Scale_sig_32_16( syn_Overl_fx, hTcxDec->syn_Overl, 320, 15 ); + Copy_Scale_sig_32_16( fer_samples_fx, hHQ_core->fer_samples_fx, 960, 9 ); + } + + test(); + test(); + IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + { + lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); + /*Set to zero the remaining part*/ + set16_fx( hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); + } } } @@ -2394,17 +2533,37 @@ ivas_error core_switching_pre_dec_ivas_fx( { IF( NE_16( st->L_frame, st->last_L_frame ) ) { - IF( GT_16( st->L_frame, st->last_L_frame ) ) +#ifdef HARM_CORE_SW + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) ); - newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); + IF( GT_16( st->L_frame, st->last_L_frame ) ) + { + oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st->last_L_frame, getInvFrameLen( st->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); + newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + } + ELSE + { + oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + newLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st->L_frame, getInvFrameLen( st->last_L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); + } } ELSE +#endif { - oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) ); + IF( GT_16( st->L_frame, st->last_L_frame ) ) + { + oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) ); + newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + } + ELSE + { + oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) ); + } } lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); } @@ -2489,7 +2648,7 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) { /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ - set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); + set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); set16_fx( st->agc_mem_fx, 0, 2 ); } @@ -2500,9 +2659,9 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->mem_syn2_fx, 0, M ); } set16_fx( st->mem_syn1_fx, 0, M ); - if ( st->hBWE_TD != NULL ) + if ( hBWE_TD != NULL ) { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); } @@ -2511,11 +2670,11 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( EQ_32( st->sr_core, INT_FS_16k ) ) { - Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); + Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /* Q2.56 */ } ELSE { - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /* Q2.56 */ } st->tilt_code_fx = 0; @@ -2531,13 +2690,38 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_coder_type = GENERIC; move16(); - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ - st->lp_gainp_fx = 0; - move16(); - st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ - move16(); - st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ - move16(); +#ifdef HARM_CORE_SW + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); + st->lp_gainp_fx = 0; + move16(); + + IF( st->lp_ener_fx != 0 ) + { + exp = norm_l( st->lp_ener_fx ); /* In Q6 */ + tmp = extract_h( L_shl( st->lp_ener_fx, exp ) ); + exp = sub( exp, 30 - 6 ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + + st->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ + move16(); + } + } + ELSE +#endif + { + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + st->lp_gainp_fx = 0; + move16(); + st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ + move16(); + st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ + move16(); + } st->last_voice_factor_fx = 0; st->Last_GSC_noisy_speech_flag = 0; @@ -2545,9 +2729,20 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); /* reset CLDFB memories */ - cldfb_reset_memory_fx( st->cldfbAna ); - cldfb_reset_memory_fx( st->cldfbBPF ); - cldfb_reset_memory_fx( st->cldfbSyn ); +#ifdef HARM_CORE_SW + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + cldfb_reset_memory( st->cldfbAna ); + cldfb_reset_memory( st->cldfbBPF ); + cldfb_reset_memory( st->cldfbSyn ); + } + ELSE +#endif + { + cldfb_reset_memory_fx( st->cldfbAna ); + cldfb_reset_memory_fx( st->cldfbBPF ); + cldfb_reset_memory_fx( st->cldfbSyn ); + } /* reset TBE memories */ test(); @@ -2562,21 +2757,28 @@ ivas_error core_switching_pre_dec_ivas_fx( synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); } - IF( st->hBWE_TD != NULL ) + IF( hBWE_TD != NULL ) { - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); } test(); +#ifdef HARM_CORE_SWaa // !!!!! + IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#else IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) +#endif { hf_synth_reset_fx( st->hBWE_zero ); +#ifdef HARM_CORE_SW + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment +#endif set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } - IF( st->hBWE_FD != NULL ) + IF( hBWE_FD != NULL ) { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); } } @@ -2585,11 +2787,11 @@ ivas_error core_switching_pre_dec_ivas_fx( test(); IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) { - IF( st->hBWE_TD != NULL ) + IF( hBWE_TD != NULL ) { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); } st->tilt_code_fx = 0; @@ -2624,9 +2826,9 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } - IF( st->hBWE_FD != NULL ) + IF( hBWE_FD != NULL ) { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } test(); @@ -2637,17 +2839,23 @@ ivas_error core_switching_pre_dec_ivas_fx( /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ Word16 offset; offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); +#ifdef HARM_CORE_SW + Word32 old_synthFB_fx[L_FRAME_PLUS * 2]; +#else Word32 *old_synthFB_fx; - IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) + IF( ( old_synthFB_fx = (Word32 *) malloc( hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); } - Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 - Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); +#endif + Copy_Scale_sig_16_32_no_sat( hTcxDec->old_synthFB_fx, old_synthFB_fx, hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 + Copy32( old_synthFB_fx + hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); st->cldfbAna->Q_cldfb_state = Q10; move16(); +#ifndef HARM_CORE_SW IF( old_synthFB_fx ) free( old_synthFB_fx ); +#endif } } @@ -2657,22 +2865,22 @@ ivas_error core_switching_pre_dec_ivas_fx( test(); IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) { - set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); + set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); + set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - st->hHQ_core->last_max_pos_pulse = 0; + set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); + hHQ_core->last_max_pos_pulse = 0; move16(); - set16_fx( st->hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - st->hHQ_core->prev_frm_hfe2 = 0; - st->hHQ_core->prev_stab_hfe2 = 0; + set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); + hHQ_core->prev_frm_hfe2 = 0; + hHQ_core->prev_stab_hfe2 = 0; move16(); move16(); IF( GT_32( st->output_Fs, 16000 ) ) { - set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); + set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } IF( st->element_mode != EVS_MONO ) @@ -2680,46 +2888,46 @@ ivas_error core_switching_pre_dec_ivas_fx( /* Estimate mem_env_delta to reinit env_stab */ tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ - st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ + hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ move16(); test(); IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) { - set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( st->hHQ_core->old_out_LB_fx32, 0, L_FRAME16k ); - set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); + set16_fx( hHQ_core->old_out_fx, 0, output_frame ); + set32_fx( hHQ_core->old_out_LB_fx32, 0, L_FRAME16k ); + set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); } - st->hHQ_core->no_att_hangover = 0; + hHQ_core->no_att_hangover = 0; move16(); - st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/ + hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/ move32(); - set16_fx( st->hHQ_core->old_is_transient, 0, 3 ); - set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 ); - st->hHQ_core->prev_R = 0; + set16_fx( hHQ_core->old_is_transient, 0, 3 ); + set16_fx( hHQ_core->prev_noise_level_fx, 0, 2 ); + hHQ_core->prev_R = 0; move16(); - set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); - st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; - st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/ + set16_fx( hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); + hHQ_core->prev_hqswb_clas = HQ_NORMAL; + hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/ move16(); move16(); - set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS ); + set16_fx( hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS ); } ELSE { - set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( st->hHQ_core->old_out_LB_fx32, 0, L_FRAME16k ); + set16_fx( hHQ_core->old_out_fx, 0, output_frame ); + set32_fx( hHQ_core->old_out_LB_fx32, 0, L_FRAME16k ); } } /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ - IF( st->hHQ_core != NULL ) + IF( hHQ_core != NULL ) { - st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 ); + hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 ); move16(); - IF( st->hHQ_core->pastpre < 0 ) + IF( hHQ_core->pastpre < 0 ) { - reset_preecho_dec_fx( st->hHQ_core ); + reset_preecho_dec_fx( hHQ_core ); } } test(); @@ -2739,10 +2947,8 @@ ivas_error core_switching_pre_dec_ivas_fx( st->m_frame_type = ACTIVE_FRAME; } - move16(); - move16(); /*switch on CNA on active frames*/ - IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ + IF( st->element_mode == EVS_MONO ) /* for IVAS modes, st->flag_cna is set earlier */ { test(); test(); @@ -2778,6 +2984,25 @@ ivas_error core_switching_pre_dec_ivas_fx( /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ IF( NE_16( st->core, AMR_WB_CORE ) ) { +#ifdef HARM_CORE_SW + L_tmp = st->total_brate; + move32(); + test(); + if ( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) + { + L_tmp = ACELP_9k60; + move32(); + } + + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + configureFdCngDec_fx( st->hFdCngDec, st->bwidth, L_tmp, st->L_frame, st->last_L_frame, st->element_mode ); + } + ELSE + { + configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); + } +#else test(); IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) { @@ -2787,10 +3012,15 @@ ivas_error core_switching_pre_dec_ivas_fx( { configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); } +#endif } ELSE { +#ifdef HARM_CORE_SW + configureFdCngDec_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); +#else configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); +#endif if ( st->VAD ) { @@ -2808,27 +3038,57 @@ ivas_error core_switching_pre_dec_ivas_fx( lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); - - test(); - IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) +#ifdef HARM_CORE_SW + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); - - IF( EQ_16( st->L_frame, L_FRAME ) ) + lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); + test(); + IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); + IF( EQ_16( st->L_frame, L_FRAME ) ) { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); - move32(); + FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* q_olapBuffer */ + move16(); + } + } + ELSE + { + FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 /* Q14*/ ); /* q_olapBuffer */ + move16(); + } } } - ELSE + } + ELSE +#endif + { + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); + + test(); + IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); + + IF( EQ_16( st->L_frame, L_FRAME ) ) { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); - move32(); + FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); + move32(); + } + } + ELSE + { + FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); + move32(); + } } } } @@ -2837,12 +3097,15 @@ ivas_error core_switching_pre_dec_ivas_fx( return error; } + +#ifndef HARM_CORE_SW /*---------------------------------------------------------------------* * core_switching_hq_prepare_dec() * * Preprocessing in the first HQ frame after ACELP frame * Modify bit allocation for HQ core by removing ACELP subframe budget *---------------------------------------------------------------------*/ +#endif /*---------------------------------------------------------------------* * bandwidth_switching_detect() @@ -2850,7 +3113,11 @@ ivas_error core_switching_pre_dec_ivas_fx( * Classification for band-width switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW +void bandwidth_switching_detect_fx( +#else void bandwidth_switching_detect_ivas_fx( +#endif Decoder_State *st_fx /* i/o: encoder state structure */ ) { @@ -2966,7 +3233,7 @@ void bandwidth_switching_detect_ivas_fx( return; } - +#ifndef HARM_CORE_SW /*---------------------------------------------------------------------* * bw_switching_pre_proc() * @@ -3153,3 +3420,4 @@ void ivas_bw_switching_pre_proc_fx( return; } +#endif diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index a358cbe8a..e40f276f4 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -315,7 +315,11 @@ ivas_error evs_dec_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SWaa + IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ) != IVAS_ERR_OK ) +#else IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -355,7 +359,11 @@ ivas_error evs_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx, NULL, 0 ); +#else bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx ); +#endif /*---------------------------------------------------------------------* * WB TBE decoding diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index bf1f75333..81059c6c6 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -81,6 +81,9 @@ ivas_error ivas_core_dec_fx( Word16 core_switching_flag[CPE_CHANNELS]; Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q6 +#ifdef HARM_CORE_SW + Word16 old_syn_12k8_16k_fx_16[CPE_CHANNELS][L_FRAME16k]; +#endif Word32 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; Word16 unbits[CPE_CHANNELS]; @@ -439,7 +442,11 @@ ivas_error ivas_core_dec_fx( * Detect bandwidth switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + bandwidth_switching_detect_fx( st ); +#else bandwidth_switching_detect_ivas_fx( st ); +#endif /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching @@ -454,7 +461,11 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 +#ifdef HARM_CORE_SWaa + IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -478,7 +489,9 @@ ivas_error ivas_core_dec_fx( IF( st->core == ACELP_CORE ) { /* ACELP core decoder */ +#ifndef HARM_CORE_SW Word16 old_syn_12k8_16k_fx_16[L_FRAME16k]; +#endif Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx; IF( save_hb_synth_32_fx ) @@ -529,7 +542,11 @@ ivas_error ivas_core_dec_fx( st->Q_syn_factor = 0; move16(); +#ifdef HARM_CORE_SW + IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -567,6 +584,9 @@ ivas_error ivas_core_dec_fx( { Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) } +#else +#ifdef HARM_CORE_SW + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif @@ -937,7 +957,11 @@ ivas_error ivas_core_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], old_syn_fx ); +#else ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio ); +#endif IF( st->hHQ_core == NULL ) { -- GitLab From 5ef21d56fcad681a561cfcb6b875482894a8bd73 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 18:07:04 +0100 Subject: [PATCH 284/750] comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 95d94587a..9b8fdea3d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,7 @@ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ -#define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz outputs */ +#define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 400ca96d7ae7bd84eeec5ddc34eeefa821c18f90 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 18:13:22 +0100 Subject: [PATCH 285/750] clang-format --- lib_dec/amr_wb_dec_fx.c | 2 +- lib_dec/core_switching_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 8a6917374..d4b671e63 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -173,7 +173,7 @@ ivas_error amr_wb_dec_fx( /* Updates in case of EVS -> AMR-WB IO switching */ #ifdef HARM_CORE_SWaa - IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) ) #endif diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 695ddb64f..0d56a5154 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2506,7 +2506,7 @@ ivas_error core_switching_pre_dec_ivas_fx( cldfb_restore_memory_ivas_fx( st->cldfbSyn ); Copy_Scale_sig_32_16( syn_Overl_fx, hTcxDec->syn_Overl, 320, 15 ); Copy_Scale_sig_32_16( fer_samples_fx, hHQ_core->fer_samples_fx, 960, 9 ); - } + } test(); test(); -- GitLab From 38ab79b14f37b9da88f138749bfe763d503f7c35 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 18:43:51 +0100 Subject: [PATCH 286/750] HARM_CORE_SW, decoder step 2 (core_switching_pre_dec_fx) --- lib_com/options.h | 2 +- lib_com/prot_fx.h | 4 +-- lib_dec/amr_wb_dec_fx.c | 2 +- lib_dec/core_switching_dec_fx.c | 45 +++++++++++++++++++++++++-------- lib_dec/evs_dec_fx.c | 2 +- lib_dec/ivas_core_dec_fx.c | 9 ++++--- 6 files changed, 44 insertions(+), 20 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9518e3168..d841c2920 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,7 +117,7 @@ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ #define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ -#define HARM_CORE_SW +#define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 41d1ad5ae..2daf792a4 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7815,7 +7815,7 @@ void bw_switching_pre_proc_fx( ); ivas_error core_switching_pre_dec_fx( -#ifdef HARM_CORE_SWaa +#ifdef HARM_CORE_SW Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ @@ -10434,7 +10434,7 @@ void wtda_fx32( const Word16 L /* i : length */ ); -#ifndef HARM_CORE_SWaa +#ifndef HARM_CORE_SW ivas_error core_switching_pre_dec_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index d4b671e63..8f6229794 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -172,7 +172,7 @@ ivas_error amr_wb_dec_fx( } /* Updates in case of EVS -> AMR-WB IO switching */ -#ifdef HARM_CORE_SWaa +#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 0d56a5154..65d6e3ab2 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -345,7 +345,7 @@ void bw_switching_pre_proc_fx( return; } -#ifndef HARM_CORE_SWaa +#ifndef HARM_CORE_SW /*---------------------------------------------------------------------* * core_switching_pre_dec_fx() * @@ -2217,7 +2217,7 @@ static void smoothTransitionDtxToTcx_fx( * Preprocessing/preparation for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SWaa +#ifdef HARM_CORE_SW ivas_error core_switching_pre_dec_fx( #else ivas_error core_switching_pre_dec_ivas_fx( @@ -2228,7 +2228,7 @@ ivas_error core_switching_pre_dec_ivas_fx( const Word16 nchan_out, /* i : number of output channels */ const Word16 last_element_mode, /* i : last_element_mode */ const Word32 last_element_brate, /* i : last element bitrate */ -#ifdef HARM_CORE_SWaa +#ifdef HARM_CORE_SW const Word16 Q_old_synthFB, #else Word16 Q_old_synthFB, @@ -2324,11 +2324,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); test(); -#ifdef HARM_CORE_SWaa // !!!!! - IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { hf_synth_reset_fx( st->hBWE_zero ); #ifdef HARM_CORE_SW @@ -2337,6 +2333,16 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } +#ifdef HARM_CORE_SW // temp hack to keep EVS BE - see basop issue 2313 + IF( st->element_mode == EVS_MONO ) + { + IF( st->output_Fs == 16000 && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); + } + } + +#endif IF( hBWE_FD != NULL ) { set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); @@ -2571,6 +2577,10 @@ ivas_error core_switching_pre_dec_ivas_fx( ELSE { set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); +#ifdef HARM_CORE_SW + st->classifier_Q_mem_syn = 0; + move16(); +#endif } } @@ -2763,11 +2773,7 @@ ivas_error core_switching_pre_dec_ivas_fx( } test(); -#ifdef HARM_CORE_SWaa // !!!!! - IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { hf_synth_reset_fx( st->hBWE_zero ); #ifdef HARM_CORE_SW @@ -2776,6 +2782,16 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } +#ifdef HARM_CORE_SW // temp hack to keep EVS BE - see basop issue 2313 + IF( st->element_mode == EVS_MONO ) + { + IF( st->output_Fs == 16000 && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); + } + } + +#endif IF( hBWE_FD != NULL ) { set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); @@ -2915,8 +2931,15 @@ ivas_error core_switching_pre_dec_ivas_fx( } ELSE { +#ifdef HARM_CORE_SW + set16_fx( hHQ_core->old_out_fx, 0, output_frame ); + hHQ_core->Q_old_wtda_LB = 15; + hHQ_core->Q_old_wtda = 15; + move16(); +#else set16_fx( hHQ_core->old_out_fx, 0, output_frame ); set32_fx( hHQ_core->old_out_LB_fx32, 0, L_FRAME16k ); +#endif } } diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index e40f276f4..e5c8c47a6 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -315,7 +315,7 @@ ivas_error evs_dec_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SWaa +#ifdef HARM_CORE_SW IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ) != IVAS_ERR_OK ) #else IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 81059c6c6..fa8f193fb 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -461,7 +461,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 -#ifdef HARM_CORE_SWaa +#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) @@ -582,11 +582,12 @@ ivas_error ivas_core_dec_fx( #ifdef FIX_2290_COPY_OF_UNINIT_DATA IF( st->hBWE_FD != NULL ) { +#ifdef HARM_CORE_SW + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) +#else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) +#endif } -#else -#ifdef HARM_CORE_SW - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif -- GitLab From 89641aa6604d2f23f24be7a40bc1f24e6ff22803 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 18:57:24 +0100 Subject: [PATCH 287/750] clang-format --- lib_dec/core_switching_dec_fx.c | 12 ++++++++---- lib_dec/ivas_core_dec_fx.c | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 65d6e3ab2..2c1da3f12 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2933,8 +2933,9 @@ ivas_error core_switching_pre_dec_ivas_fx( { #ifdef HARM_CORE_SW set16_fx( hHQ_core->old_out_fx, 0, output_frame ); - hHQ_core->Q_old_wtda_LB = 15; - hHQ_core->Q_old_wtda = 15; + set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); + hHQ_core->Q_old_wtda_LB = Q15; + hHQ_core->Q_old_wtda = Q15; move16(); #else set16_fx( hHQ_core->old_out_fx, 0, output_frame ); @@ -2953,6 +2954,7 @@ ivas_error core_switching_pre_dec_ivas_fx( reset_preecho_dec_fx( hHQ_core ); } } + test(); IF( st->core_brate == FRAME_NO_DATA ) { @@ -3051,6 +3053,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); } } + test(); test(); IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) @@ -3069,6 +3072,7 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); + IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) @@ -3099,7 +3103,7 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( EQ_16( st->L_frame, L_FRAME ) ) { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); move32(); @@ -3107,7 +3111,7 @@ ivas_error core_switching_pre_dec_ivas_fx( } ELSE { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); move32(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index fa8f193fb..a10fc81ed 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -583,7 +583,7 @@ ivas_error ivas_core_dec_fx( IF( st->hBWE_FD != NULL ) { #ifdef HARM_CORE_SW - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif -- GitLab From bc1c38680c6ae71b264c8116541aa796df5a7e48 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 19:03:55 +0100 Subject: [PATCH 288/750] clang-format --- lib_dec/core_switching_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 2c1da3f12..c4a39fe0d 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -3072,7 +3072,7 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); - + IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) -- GitLab From 3b65ce59bf9e256326753af0031a9392e25a8ffd Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 13:11:52 -0500 Subject: [PATCH 289/750] possible fix for 2312, condition missing in GSC-dec --- lib_com/gs_gains_fx.c | 72 ++++++++++++++++++++++++------------------- lib_com/options.h | 2 +- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 87aa64ec8..55ced4ea0 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1193,45 +1193,55 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc *--------------------------------------------------------------------------------------*/ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); +#ifdef FIX_2312_CONDITION_MISSING_GSC_DEC_LR + IF( !( coder_type == INACTIVE && st_fx->tdm_LRTD_flag == 0 && EQ_16( st_fx->idchan, 1 ) ) || GT_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) + { +#endif + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 ); - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 ); - - /*----------------------------------------------------------------------* - * Interpolation of the last 4 Q bands to create bands 8-16 - * And scaling - *----------------------------------------------------------------------*/ + /*----------------------------------------------------------------------* + * Interpolation of the last 4 Q bands to create bands 8-16 + * And scaling + *----------------------------------------------------------------------*/ - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 ); + VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 ); - Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 ); - set16_fx( y_gainQ_fx + 12, 0, 4 ); + Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 ); + set16_fx( y_gainQ_fx + 12, 0, 4 ); - fft_rel_fx( y_gainQ_fx + 8, 4, 2 ); + fft_rel_fx( y_gainQ_fx + 8, 4, 2 ); - y_gainQ_fx[15] = y_gainQ_fx[11]; - move16(); - y_gainQ_fx[11] = 0; - move16(); - ifft_rel_fx( y_gainQ_fx + 8, 8, 3 ); - FOR( i = 8; i < 16; i++ ) - { - y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ + y_gainQ_fx[15] = y_gainQ_fx[11]; + move16(); + y_gainQ_fx[11] = 0; + move16(); + ifft_rel_fx( y_gainQ_fx + 8, 8, 3 ); + FOR( i = 8; i < 16; i++ ) + { + y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ + move16(); + } + /*----------------------------------------------------------------------* + * Copy the true Q values in the specific bands + *----------------------------------------------------------------------*/ + y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/ + move16(); + y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/ + move16(); + y_gainQ_fx[12] = y_gain_tmp3_fx[2]; /*Q12*/ move16(); + y_gainQ_fx[14] = y_gain_tmp3_fx[3]; /*Q12*/ + move16(); +#ifdef FIX_2312_CONDITION_MISSING_GSC_DEC_LR } - /*----------------------------------------------------------------------* - * Copy the true Q values in the specific bands - *----------------------------------------------------------------------*/ - y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/ - move16(); - y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/ - move16(); - y_gainQ_fx[12] = y_gain_tmp3_fx[2]; /*Q12*/ - move16(); - y_gainQ_fx[14] = y_gain_tmp3_fx[3]; /*Q12*/ - move16(); + ELSE + { + set16_fx( y_gainQ_fx + 3, 0, MBANDS_GN16k - 3 ); + } +#endif } ELSE { diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..ecb665620 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,7 @@ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ - +#define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ -- GitLab From 1c932cde13b34e31613a563bc51c17b2517f107f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jan 2026 19:17:44 +0100 Subject: [PATCH 290/750] remove unused parameter --- lib_com/prot_fx.h | 3 +-- lib_dec/core_switching_dec_fx.c | 7 +++---- lib_dec/evs_dec_fx.c | 2 +- lib_dec/ivas_core_dec_fx.c | 5 ++++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2daf792a4..079876573 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7806,8 +7806,7 @@ void bw_switching_pre_proc_fx( const Word32 last_element_brate, /* i : last element bitrate */ const Word16 nchan_out, /* i : number of output channels */ Word16 *old_syn_12k8_16k_fx16, - Word32 *old_syn_12k8_16k_fx32, - Word16 Q + Word32 *old_syn_12k8_16k_fx32 #else const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ Decoder_State *st_fx /* i/o: decoder state structure */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index c4a39fe0d..d96e97617 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -190,8 +190,7 @@ void bw_switching_pre_proc_fx( const Word32 last_element_brate, /* i : last element bitrate */ const Word16 nchan_out, /* i : number of output channels */ Word16 *old_syn_12k8_16k_fx16, - Word32 *old_syn_12k8_16k_fx32, - Word16 Q + Word32 *old_syn_12k8_16k_fx32 #else const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ Decoder_State *st_fx /* i/o: decoder state structure */ @@ -219,8 +218,8 @@ void bw_switching_pre_proc_fx( { /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; - Copy_Scale_sig_32_16( old_syn_12k8_16k_fx32, old_syn_12k8_16k_tmp_16fx, st_fx->L_frame, sub( -1, Q ) ); - st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st_fx->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 + Copy_Scale_sig_32_16( old_syn_12k8_16k_fx32, old_syn_12k8_16k_tmp_16fx, st_fx->L_frame, sub( -1, Q11 ) ); + st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st_fx->L_frame ), sub( Q11, 8 ) ) ); // Q24+(Q11-8) - 16 move16(); } diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index e5c8c47a6..0410dd62e 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -360,7 +360,7 @@ ivas_error evs_dec_fx( *---------------------------------------------------------------------*/ #ifdef HARM_CORE_SW - bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx, NULL, 0 ); + bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx, NULL ); #else bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx ); #endif diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index a10fc81ed..bd6e8fdb9 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -872,11 +872,14 @@ ivas_error ivas_core_dec_fx( move16(); } +#ifndef HARM_CORE_SW Word16 q_audio, old_syn_fx; old_syn_fx = Q11; move16(); q_audio = Q12; move16(); +#endif + test(); test(); test(); @@ -959,7 +962,7 @@ ivas_error ivas_core_dec_fx( *---------------------------------------------------------------------*/ #ifdef HARM_CORE_SW - bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], old_syn_fx ); + bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n] ); #else ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio ); #endif -- GitLab From 849c7c502a26d0bf5d9a775ba3eebc151759fb75 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 14:27:58 -0500 Subject: [PATCH 291/750] Harmonization GSC gain part 1 (should be BE --- lib_com/gs_gains_fx.c | 24 ++++++++++++++++++------ lib_com/options.h | 2 +- lib_com/prot_fx.h | 4 ++-- lib_dec/gs_dec_fx.c | 5 ++++- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 87aa64ec8..9a6338160 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -951,7 +951,7 @@ Word16 gsc_gainQ_ivas_fx( /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ - +#ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_fx( /* o : average frequency gain */ Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band */ @@ -1088,7 +1088,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai return mean_4g_fx; } - +#endif /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ @@ -1110,8 +1110,11 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ - +#ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ +#else +Word16 gsc_gaindec_fx( /* o : average frequency gain */ +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ const Word32 core_brate_fx, /* i : core used */ @@ -1269,9 +1272,18 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc } } - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - + #ifdef OPT_BE_2311_HARM_GSC_GAIN + IF( st_fx->element_mode == EVS_MONO ) + { + GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); + } + ELSE +#endif + { + /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ + GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); + } + return mean_4g_fx; } diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..fd0205267 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,7 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ - +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonisation */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index abb050c02..42e6073b1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1546,7 +1546,7 @@ Word16 gsc_gaindec_fx( const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : i signal bandwidth */ ); - +#ifndef OPT_BE_2311_HARM_GSC_GAIN /*! r: average frequency gain */ Word16 gsc_gaindec_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -1556,7 +1556,7 @@ Word16 gsc_gaindec_ivas_fx( const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : input signal bandwidth */ ); - +#endif Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q13 */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index c10306bc8..cfc9533d6 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -667,6 +667,7 @@ void gsc_dec_fx( i--; } +#ifndef OPT_BE_2311_HARM_GSC_GAIN IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ @@ -675,7 +676,9 @@ void gsc_dec_fx( { mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ } - +#else + mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ +#endif st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } -- GitLab From 4703bb6deca1e42fc22bc21741239fd8663089a0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 14:36:56 -0500 Subject: [PATCH 292/750] fix clang-format --- lib_com/gs_gains_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 9a6338160..8c47dfec0 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1111,9 +1111,9 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* _ (Word16) : average frequency gain */ /*==========================================================================*/ #ifndef OPT_BE_2311_HARM_GSC_GAIN -Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ +Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ #else -Word16 gsc_gaindec_fx( /* o : average frequency gain */ +Word16 gsc_gaindec_fx( /* o : average frequency gain */ #endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ @@ -1272,7 +1272,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai } } - #ifdef OPT_BE_2311_HARM_GSC_GAIN +#ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) { GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); @@ -1283,7 +1283,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); } - + return mean_4g_fx; } -- GitLab From 84d98c6961a329ee8a182ee0eec620d0de93038d Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Fri, 9 Jan 2026 21:28:02 +0100 Subject: [PATCH 293/750] fixed scaling direction of Eigenvectors --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index f6fa52c29..309ccb2ce 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3664,8 +3664,8 @@ static void eig2x2_fx( // Eigenvectors - q_diff = sub( q_e, *q_D ); - q_tmp1 = s_min( q_e, *q_D ); + q_diff = sub( *q_D, q_e ); + q_tmp1 = s_min( *q_D, q_e ); tmp1 = D_fx[0]; move32(); -- GitLab From 3f87f40f2de255896a68c356b4080a4d7e083d91 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 15:31:08 -0500 Subject: [PATCH 294/750] Firs part of nonBE 2311 harmonisation --- lib_com/gs_gains_fx.c | 52 ++++++++++++++++++++++++++++++++++++------- lib_com/options.h | 3 ++- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8c47dfec0..8c58fae95 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -388,6 +388,9 @@ void Ener_per_band_comp_ivas_fx( static void GSC_gain_adj( const Word16 coder_type, /* i : Coder type */ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + const Word16 Mbands_gn, /* i : Number of band */ +#endif const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ @@ -397,10 +400,23 @@ static void GSC_gain_adj( { /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; - +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + Word16 Fac_div; + Fac_div = 102; + move16(); +#endif +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + test(); + IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) +#else IF( coder_type != INACTIVE ) +#endif { +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + FOR( i = 0; i < Mbands_gn; i++ ) +#else FOR( i = 0; i < MBANDS_GN; i++ ) +#endif { old_y_gain[i] = y_gain_tmp[i]; move16(); @@ -412,7 +428,19 @@ static void GSC_gain_adj( { Gain_off = 0; move16(); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + test(); + IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ + { + Gain_off = 18432; + move16(); /* 9 -> Q11 */ + Fac_div = 205; /* Q15 -> Q16 to compensate for Gain_off being Q11 instead of Q12 */ + move16(); + } + ELSE IF( LE_32( core_brate, ACELP_7k20 ) ) +#else IF( LE_32( core_brate, ACELP_7k20 ) ) +#endif { Gain_off = 32767; move16(); /* 8 -> Q12 */ @@ -444,7 +472,11 @@ static void GSC_gain_adj( old_y_gain[i] = y_gain_tmp[i]; move16(); /*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, Fac_div /* 20/MBANDS_GN in Q15 */ ) ) ) ); +#else y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 102 /* 20/MBANDS_GN in Q15 */ ) ) ) ); +#endif move16(); } } @@ -452,7 +484,7 @@ static void GSC_gain_adj( return; } - +#ifndef OPT_NBE_2311_HARM_GSC_GAIN /*-------------------------------------------------------------------* * GSC_gain_adj_ivas_fx() * @@ -532,7 +564,7 @@ static void GSC_gain_adj_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * GSC_gain_DQ() @@ -930,7 +962,7 @@ Word16 gsc_gainQ_ivas_fx( return mean_4g_fx[0]; } - +#ifndef OPT_BE_2311_HARM_GSC_GAIN /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_fx() */ /*--------------------------------------------------------------------------*/ @@ -951,7 +983,6 @@ Word16 gsc_gainQ_ivas_fx( /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ -#ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_fx( /* o : average frequency gain */ Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band */ @@ -1271,7 +1302,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ } } } - +#ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) { @@ -1283,7 +1314,9 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); } - +#else + GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); +#endif return mean_4g_fx; } @@ -1515,8 +1548,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ } /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); +#else GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); - +#endif return mean_4g[0]; /*Q12*/ } diff --git a/lib_com/options.h b/lib_com/options.h index fd0205267..19f5f88f4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,8 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonisation */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization */ +#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: NBE part of the GSC gain harmonization */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From af82f7ccc96707dcd556415481a73488ff4fe78e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 15:53:40 -0500 Subject: [PATCH 295/750] fix clang --- lib_com/gs_gains_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8c58fae95..075002480 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -387,9 +387,9 @@ void Ener_per_band_comp_ivas_fx( *-------------------------------------------------------------------*/ static void GSC_gain_adj( - const Word16 coder_type, /* i : Coder type */ + const Word16 coder_type, /* i : Coder type */ #ifdef OPT_NBE_2311_HARM_GSC_GAIN - const Word16 Mbands_gn, /* i : Number of band */ + const Word16 Mbands_gn, /* i : Number of band */ #endif const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ @@ -410,13 +410,13 @@ static void GSC_gain_adj( IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) #else IF( coder_type != INACTIVE ) -#endif +#endif { #ifdef OPT_NBE_2311_HARM_GSC_GAIN FOR( i = 0; i < Mbands_gn; i++ ) #else FOR( i = 0; i < MBANDS_GN; i++ ) -#endif +#endif { old_y_gain[i] = y_gain_tmp[i]; move16(); @@ -430,10 +430,10 @@ static void GSC_gain_adj( move16(); #ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); - IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ + IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ { Gain_off = 18432; - move16(); /* 9 -> Q11 */ + move16(); /* 9 -> Q11 */ Fac_div = 205; /* Q15 -> Q16 to compensate for Gain_off being Q11 instead of Q12 */ move16(); } -- GitLab From ba71ff420aae03ad60c9c49a5c376f9bfa0434a5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 17:00:21 -0500 Subject: [PATCH 296/750] part 2 of NBE harmonisation --- lib_com/gs_gains_fx.c | 143 ++++++++++++++++++++++++++++++------------ lib_com/options.h | 2 +- lib_com/prot_fx.h | 16 +++++ lib_enc/gs_enc_fx.c | 6 ++ 4 files changed, 126 insertions(+), 41 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 075002480..c876a1d8e 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -564,7 +564,6 @@ static void GSC_gain_adj_ivas_fx( return; } -#endif /*-------------------------------------------------------------------* * GSC_gain_DQ() @@ -961,7 +960,7 @@ Word16 gsc_gainQ_ivas_fx( return mean_4g_fx[0]; } - +#endif #ifndef OPT_BE_2311_HARM_GSC_GAIN /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_fx() */ @@ -1326,8 +1325,21 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ * * Quantization of the energy per band *-------------------------------------------------------------------*/ - -Word16 gsc_gainQ_fx( /*Q12*/ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN +Word16 gsc_gainQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 y_gain4[], /* i : Energy per band Q12*/ + Word16 y_gainQ[], /* o : quantized energy per band Q12*/ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 L_frame, /* i : frame length */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word32 core_brate_inp /* i : true core bitrate */ + ) +#else + Word16 gsc_gainQ_fx( /*Q12*/ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q12 */ Word16 y_gainQ[], /* o : quantized energy per band Q12 */ @@ -1335,19 +1347,34 @@ Word16 gsc_gainQ_fx( /*Q12*/ const Word16 coder_type, /* i : coding type */ const Word16 bwidth /* i : input signal bandwidth */ ) +#endif { +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + Word16 y_gain_tmp[MBANDS_GN16k], y_gain_tmp2[MBANDS_GN16k]; +#else Word16 y_gain_tmp[MBANDS_GN], y_gain_tmp2[MBANDS_GN]; +#endif Word16 i, idx_g = 0; move16(); Word16 mean_4g[1] = { 0 }, tmp16, tmp1, tmp2; move16(); Word16 Mbands_gn = MBANDS_GN; +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + Word16 y_gain_tmp3[MBANDS_GN16k]; +#else Word16 y_gain_tmp3[MBANDS_GN]; +#endif Word16 cnt; Word32 L_tmp; mean_4g[0] = 0; - +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + if ( EQ_16( L_frame, L_FRAME16k ) ) + { + Mbands_gn = MBANDS_GN16k; + move16(); + } +#endif test(); test(); IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) ) @@ -1445,7 +1472,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ } tmp16 = round_fx( L_tmp ); - tmp1 = sub( tmp16, 4915 ); + tmp1 = sub( tmp16, 4915 ); /* 0.6 Q12 */ tmp2 = add( tmp16, 4915 ); L_tmp = 0; move32(); @@ -1501,49 +1528,85 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 ); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) + { +#endif + idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 ); - /* Update to quantized vector */ - Copy( y_gain_tmp2, y_gain_tmp, 8 ); + /* Update to quantized vector */ + Copy( y_gain_tmp2, y_gain_tmp, 8 ); - Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 ); - set16_fx( y_gain_tmp + 8, 0, 8 ); - fft_rel_fx( y_gain_tmp2 + 8, 4, 2 ); + Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 ); + set16_fx( y_gain_tmp + 8, 0, 8 ); + fft_rel_fx( y_gain_tmp2 + 8, 4, 2 ); - Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 ); - y_gain_tmp[15] = y_gain_tmp2[11]; - move16(); - ifft_rel_fx( y_gain_tmp + 8, 8, 3 ); + Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 ); + y_gain_tmp[15] = y_gain_tmp2[11]; + move16(); + ifft_rel_fx( y_gain_tmp + 8, 8, 3 ); - FOR( i = 8; i < 16; i++ ) - { - y_gain_tmp[i] = shl( mult_r( y_gain_tmp[i], 23101 ), 1 ); + FOR( i = 8; i < 16; i++ ) + { + y_gain_tmp[i] = shl( mult_r( y_gain_tmp[i], 23101 ), 1 ); + move16(); + } + + y_gain_tmp[8] = y_gain_tmp3[0]; move16(); + y_gain_tmp[10] = y_gain_tmp3[1]; + move16(); + y_gain_tmp[12] = y_gain_tmp3[2]; + move16(); + y_gain_tmp[14] = y_gain_tmp3[3]; + move16(); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN } - - y_gain_tmp[8] = y_gain_tmp3[0]; - move16(); - y_gain_tmp[10] = y_gain_tmp3[1]; - move16(); - y_gain_tmp[12] = y_gain_tmp3[2]; - move16(); - y_gain_tmp[14] = y_gain_tmp3[3]; - move16(); + ELSE + { + Copy( y_gain_tmp2, y_gain_tmp, 3 ); + set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 ); + } +#endif } ELSE { - idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + IF( EQ_16( L_frame, L_FRAME ) ) + { +#endif + idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); + } +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + ELSE + { + idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); + + idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16HR_fx + 4, y_gain_tmp + 4, YG_dicHR_2_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + + idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16HR_fx + 8, y_gain_tmp + 8, YG_dicHR_3_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + + idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16HR_16kHz_fx, y_gain_tmp + 12, YG_dicHR_4_16kHz_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + + idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 ); + push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 ); + } +#endif } } diff --git a/lib_com/options.h b/lib_com/options.h index 19f5f88f4..99f6e8a60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,7 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: NBE part of the GSC gain harmonization */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 42e6073b1..77577976a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1557,6 +1557,7 @@ Word16 gsc_gaindec_ivas_fx( const Word16 bwidth_fx /* i : input signal bandwidth */ ); #endif +#ifndef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q13 */ @@ -1580,6 +1581,21 @@ Word16 gsc_gainQ_ivas_fx( const Word32 core_brate_inp /* i : true core bitrate */ ); +#else +Word16 gsc_gainQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 y_gain4[], /* i : Energy per band Q12 */ + Word16 y_gainQ[], /* o : quantized energy per band Q12 */ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 L_frame, /* i : frame length */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word32 core_brate_inp /* i : true core bitrate */ +); +#endif + void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 0498c0c33..461606b8e 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -993,6 +993,7 @@ void gsc_enc_fx( { i--; } +#ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */ { @@ -1006,6 +1007,11 @@ void gsc_enc_fx( *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ } move16(); +#else + mean_gain = gsc_gainQ_fx( hBstr, 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_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ + move16(); +#endif /*--------------------------------------------------------------------------------------* * Frequency encoder -- GitLab From d91f9bca2192b795b56fb14c7aeb3262dbfb326f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 17:05:10 -0500 Subject: [PATCH 297/750] fix clang --- lib_com/gs_gains_fx.c | 28 ++++++++++++++-------------- lib_enc/gs_enc_fx.c | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index c876a1d8e..c447c6208 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1327,19 +1327,19 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ *-------------------------------------------------------------------*/ #ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 idchan, /* i : channel ID */ - const Word16 y_gain4[], /* i : Energy per band Q12*/ - Word16 y_gainQ[], /* o : quantized energy per band Q12*/ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 L_frame, /* i : frame length */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word32 core_brate_inp /* i : true core bitrate */ - ) + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 y_gain4[], /* i : Energy per band Q12*/ + Word16 y_gainQ[], /* o : quantized energy per band Q12*/ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 L_frame, /* i : frame length */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word32 core_brate_inp /* i : true core bitrate */ +) #else - Word16 gsc_gainQ_fx( /*Q12*/ +Word16 gsc_gainQ_fx( /*Q12*/ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q12 */ Word16 y_gainQ[], /* o : quantized energy per band Q12 */ @@ -1368,7 +1368,7 @@ Word16 gsc_gainQ_fx( Word32 L_tmp; mean_4g[0] = 0; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN +#ifdef OPT_NBE_2311_HARM_GSC_GAIN if ( EQ_16( L_frame, L_FRAME16k ) ) { Mbands_gn = MBANDS_GN16k; @@ -1614,7 +1614,7 @@ Word16 gsc_gainQ_fx( #ifdef OPT_NBE_2311_HARM_GSC_GAIN GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #else - GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); +GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #endif return mean_4g[0]; /*Q12*/ } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 461606b8e..dd35aae58 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1008,7 +1008,7 @@ void gsc_enc_fx( } move16(); #else - mean_gain = gsc_gainQ_fx( hBstr, 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 ); + mean_gain = gsc_gainQ_fx( hBstr, 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_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ move16(); #endif -- GitLab From 3923f6f414112462006e804556c02ad6b85682e5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 10 Jan 2026 13:21:39 +0100 Subject: [PATCH 298/750] HARM_CORE_SW, decoder step 3 (core_switching_pre_dec_fx) - move buffer old_syn_12k8_16k_fx[][] --- lib_com/prot_fx.h | 29 +++++++++++---------- lib_dec/core_switching_dec_fx.c | 46 ++++++++++++++++----------------- lib_dec/evs_dec_fx.c | 2 +- lib_dec/ivas_core_dec_fx.c | 15 +++++------ lib_dec/swb_tbe_dec_fx.c | 17 +++++++++--- 5 files changed, 60 insertions(+), 49 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 079876573..7cb2ef504 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7802,14 +7802,13 @@ void bandwidth_switching_detect_ivas_fx( #endif void bw_switching_pre_proc_fx( #ifdef HARM_CORE_SW - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word16 *old_syn_12k8_16k_fx16, - Word32 *old_syn_12k8_16k_fx32 + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ #else - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + Decoder_State *st_fx /* i/o: decoder state structure */ #endif ); @@ -7825,8 +7824,8 @@ ivas_error core_switching_pre_dec_fx( Word16 *Q_olapBufferSynth, Word16 *Q_olapBufferSynth2 #else - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 output_frame /* i : frame length Q0*/ #endif ); @@ -10385,11 +10384,15 @@ void ivas_swb_tbe_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ +#ifdef FIX_2290_COPY_OF_UNINIT_DATA + const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ +#else const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ +#endif + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ Word16 *Q_white_exc ); Word16 swb_bwe_dec_fx32( diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index d96e97617..98c38171d 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -186,11 +186,10 @@ static Word32 Calc_freq_ener_fx( void bw_switching_pre_proc_fx( #ifdef HARM_CORE_SW - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word16 *old_syn_12k8_16k_fx16, - Word32 *old_syn_12k8_16k_fx32 + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ #else const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ Decoder_State *st_fx /* i/o: decoder state structure */ @@ -218,7 +217,9 @@ void bw_switching_pre_proc_fx( { /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; - Copy_Scale_sig_32_16( old_syn_12k8_16k_fx32, old_syn_12k8_16k_tmp_16fx, st_fx->L_frame, sub( -1, Q11 ) ); + Word32 old_syn_12k8_16k_tmp_32fx[L_FRAME16k]; + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_32fx, st_fx->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) + Copy_Scale_sig_32_16( old_syn_12k8_16k_tmp_32fx, old_syn_12k8_16k_tmp_16fx, st_fx->L_frame, sub( -1, Q11 ) ); st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st_fx->L_frame ), sub( Q11, 8 ) ) ); // Q24+(Q11-8) - 16 move16(); } @@ -235,22 +236,14 @@ void bw_switching_pre_proc_fx( * Calculate tilt of the ACELP core synthesis *----------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW - st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_fx16, -1, st_fx->L_frame ), 3 ) ); /* Q11 */ -#else st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3 ) ); /* Q11 */ -#endif move16(); /*-------------------------------------------------------------------------------* * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis *-------------------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW - edct_16fx( old_syn_12k8_16k_fx16, syn_dct_fx, L_FRAME, 6, st_fx->element_mode ); -#else edct_16fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, 6, st_fx->element_mode ); -#endif L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME / 2; i++ ) @@ -341,6 +334,7 @@ void bw_switching_pre_proc_fx( st_fx->prev_fractive = 0; move16(); } + return; } @@ -2280,10 +2274,15 @@ ivas_error core_switching_pre_dec_ivas_fx( Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ - set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ +#ifndef HARM_CORE_SW + set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ +#endif } IF( hBPF != NULL ) { +#ifdef HARM_CORE_SW + set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ +#endif hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ hBPF->pst_mem_deemp_err_fx = 0; move16(); @@ -2512,15 +2511,15 @@ ivas_error core_switching_pre_dec_ivas_fx( Copy_Scale_sig_32_16( syn_Overl_fx, hTcxDec->syn_Overl, 320, 15 ); Copy_Scale_sig_32_16( fer_samples_fx, hHQ_core->fer_samples_fx, 960, 9 ); } + } - test(); - test(); - IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) - { - lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); - /*Set to zero the remaining part*/ - set16_fx( hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); - } + test(); + test(); + IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + { + lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); + /*Set to zero the remaining part*/ + set16_fx( hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); } } @@ -2934,6 +2933,7 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( hHQ_core->old_out_fx, 0, output_frame ); set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); hHQ_core->Q_old_wtda_LB = Q15; + move16(); hHQ_core->Q_old_wtda = Q15; move16(); #else diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 0410dd62e..6686099b8 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -360,7 +360,7 @@ ivas_error evs_dec_fx( *---------------------------------------------------------------------*/ #ifdef HARM_CORE_SW - bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx, NULL ); + bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx ); #else bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx ); #endif diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index bd6e8fdb9..cbf005b95 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -82,9 +82,10 @@ ivas_error ivas_core_dec_fx( Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q6 #ifdef HARM_CORE_SW - Word16 old_syn_12k8_16k_fx_16[CPE_CHANNELS][L_FRAME16k]; -#endif + Word16 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; +#else Word32 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; +#endif Word16 unbits[CPE_CHANNELS]; Word16 sid_bw[CPE_CHANNELS]; @@ -543,7 +544,7 @@ ivas_error ivas_core_dec_fx( move16(); #ifdef HARM_CORE_SW - IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) #endif @@ -579,17 +580,15 @@ ivas_error ivas_core_dec_fx( hSCE->q_save_hb_synth_fx = Q11; move16(); } +#ifndef HARM_CORE_SW #ifdef FIX_2290_COPY_OF_UNINIT_DATA IF( st->hBWE_FD != NULL ) { -#ifdef HARM_CORE_SW - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) -#else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) -#endif } #else Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) +#endif #endif } @@ -962,7 +961,7 @@ ivas_error ivas_core_dec_fx( *---------------------------------------------------------------------*/ #ifdef HARM_CORE_SW - bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx_16[n], old_syn_12k8_16k_fx[n] ); + bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n] ); #else ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio ); #endif diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index c61e4ddf3..f3f85d5cc 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -5473,11 +5473,15 @@ void ivas_swb_tbe_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ +#ifdef FIX_2290_COPY_OF_UNINIT_DATA + const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ +#else const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ +#endif + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ Word16 *Q_white_exc ) { Word16 i, j, cnt, n; @@ -5545,6 +5549,11 @@ void ivas_swb_tbe_dec_fx( hBWE_TD = st->hBWE_TD; +#ifdef FIX_2290_COPY_OF_UNINIT_DATA + Word32 old_syn_12k8_16k_fx[L_FRAME16k]; + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) +#endif + /* initializations */ GainFrame_fx = 0; move32(); -- GitLab From cd43a380df66453efddc115589636ee7d9b74629 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 09:00:20 +0100 Subject: [PATCH 299/750] clang-format --- lib_dec/core_switching_dec_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 98c38171d..b07c9ac6b 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -17,6 +17,7 @@ *---------------------------------------------------------------------*/ static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); + static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); #else @@ -191,8 +192,8 @@ void bw_switching_pre_proc_fx( const Word16 nchan_out, /* i : number of output channels */ const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ #else - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + Decoder_State *st_fx /* i/o: decoder state structure */ #endif ) { @@ -1303,7 +1304,7 @@ ivas_error core_switching_post_dec_fx( ivas_error core_switching_post_dec_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ -- GitLab From a310704f2f866876a815e8b58f14eda23bc0ed2b Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 10:02:29 +0100 Subject: [PATCH 300/750] HARM_CORE_SW, decoder step 4 (core_switching_post_dec) --- lib_dec/core_switching_dec_fx.c | 78 +++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 23 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index b07c9ac6b..2a1518500 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1348,10 +1348,22 @@ ivas_error core_switching_post_dec_ivas_fx( test(); IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { - if ( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) +#ifdef HARM_CORE_SW + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - return error; - } /*the output at Q0*/ + IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) + { + return error; + } /*the output at Q0*/ + } + ELSE +#endif + { + IF( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) + { + return error; + } /*the output at Q0*/ + } } /* set multiplication factor according to the sampling rate */ @@ -1360,14 +1372,14 @@ ivas_error core_switching_post_dec_ivas_fx( delta = 1; move16(); - IF( GE_16( output_frame, L_FRAME16k ) ) + if ( GE_16( output_frame, L_FRAME16k ) ) { delta = shr( Fs_kHz, 3 ); } /* set delay compensation between HQ synthesis and ACELP synthesis */ delay_comp = i_mult2( delta, HQ_DELAY_COMP ); /* Q0 */ - /*needed to add more condition in if*/ + test(); test(); test(); @@ -1384,11 +1396,13 @@ ivas_error core_switching_post_dec_ivas_fx( { st_fx->use_acelp_preq = 0; move16(); - /* rescaling to the min exp of the 2 */ - /* Qtmp=s_min(*Qsynth,st_fx->Q_old_postdec); - Scale_sig(synth, output_frame, sub(Qtmp,*Qsynth)); - Scale_sig(st_fx->delay_buf_out_fx, delay_comp, sub(Qtmp,st_fx->Q_old_postdec));*/ + +#ifdef HARM_CORE_SW + test(); + if ( EQ_16( st_fx->element_mode, EVS_MONO ) && st_fx->hBWE_FD != NULL ) +#else IF( st_fx->hBWE_FD != NULL ) +#endif { hBWE_FD->mem_deemph_old_syn_fx = 0; move16(); @@ -1417,27 +1431,34 @@ ivas_error core_switching_post_dec_ivas_fx( move16(); } } + /* delay HQ synthesis to synchronize with ACELP synthesis */ /* rescaling to the min exp of the 2 */ - Word16 NonZero = 1; - move16(); - FOR( i = 0; i < delay_comp; i++ ) +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) +#endif { - IF( st_fx->delay_buf_out_fx[i] != 0 ) + Word16 NonZero = 1; + move16(); + FOR( i = 0; i < delay_comp; i++ ) + { + IF( st_fx->delay_buf_out_fx[i] != 0 ) + { + NonZero = 0; + move16(); + break; + } + } + test(); + IF( hHQ_core->Q_old_postdec >= 0 || EQ_16( NonZero, 1 ) ) { - NonZero = 0; + Scale_sig( st_fx->delay_buf_out_fx, delay_comp, negate( hHQ_core->Q_old_postdec ) ); /* Q0 */ + hHQ_core->Q_old_postdec = 0; move16(); - break; } - } - test(); - IF( hHQ_core->Q_old_postdec >= 0 || EQ_16( NonZero, 1 ) ) - { - Scale_sig( st_fx->delay_buf_out_fx, delay_comp, negate( hHQ_core->Q_old_postdec ) ); /* Q0 */ - hHQ_core->Q_old_postdec = 0; move16(); + } - move16(); Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec ); Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qtmp */ *Qsynth = Qtmp; @@ -1602,7 +1623,6 @@ ivas_error core_switching_post_dec_ivas_fx( } ELSE IF( st_fx->element_mode != EVS_MONO ) { - /*needed to be filled with ivas specific code*/ /* Reset memories of CLDFBs */ IF( st_fx->cldfbAna != NULL ) { @@ -1650,6 +1670,7 @@ ivas_error core_switching_post_dec_ivas_fx( move16(); } } + IF( st_fx->hBWE_TD != NULL ) { hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); @@ -1768,6 +1789,17 @@ ivas_error core_switching_post_dec_ivas_fx( hHQ_core->oldHqVoicing = 0; move16(); } + +#ifdef HARM_CORE_SW + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); + hHQ_core->prev_frm_hfe2 = 0; + move16(); + hHQ_core->prev_stab_hfe2 = 0; + move16(); + } +#endif } } ELSE -- GitLab From a778abb99f49346458758292f92643e414456ef8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 12 Jan 2026 10:22:31 +0100 Subject: [PATCH 301/750] add guarded bits for memory shift --- lib_com/cldfb_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 1cfb30d57..83e1fa0bf 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -595,6 +595,9 @@ void cldfbAnalysis_ts_fx_var_q( IF( NE_16( h_cldfb->Q_cldfb_state, *q_cldfb ) ) { Word16 norm_st = L_norm_arr( timeBuffer_fx, offset ); +#ifdef FIX_2257_INCR_GUARD_BITS + norm_st = sub( norm_st, find_guarded_bits_fx( frameSize ) ); +#endif IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) ) { scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ); -- GitLab From 30d03cfeb32a60b5ae4495c6730ff5f20379ab13 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 10:29:47 +0100 Subject: [PATCH 302/750] HARM_CORE_SW, fix --- lib_dec/core_switching_dec_fx.c | 10 ++++++++-- lib_dec/evs_dec_fx.c | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 2a1518500..522f69588 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1457,7 +1457,6 @@ ivas_error core_switching_post_dec_ivas_fx( move16(); } move16(); - } Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec ); Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qtmp */ @@ -2339,7 +2338,7 @@ ivas_error core_switching_pre_dec_ivas_fx( test(); IF( hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) ) { - hBWE_TD->prev_hb_synth_fx_exp = 31; + hBWE_TD->prev_hb_synth_fx_exp = Q31; move16(); /* reset BWE memories */ set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); /* Q_exc */ @@ -2693,6 +2692,13 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); set16_fx( st->agc_mem_fx, 0, 2 ); } + +#ifdef HARM_CORE_SW + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + set16_fx( st->agc_mem_fx, 0, 2 ); + } +#endif st->mem_deemph_fx = 0; move16(); IF( !st->last_con_tcx ) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 6686099b8..0b59cccaa 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -350,7 +350,11 @@ ivas_error evs_dec_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + if ( ( error = core_switching_post_dec_ivas_fx( st_fx, synth_fx, NULL, NULL, 0, output_frame, core_switching_flag, 0, 1, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) +#else if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) +#endif { return error; } -- GitLab From 516d64b7d063741eef178149af8e1107a4908794 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 10:42:59 +0100 Subject: [PATCH 303/750] FIX_2315_AGC_MEMORY_RESET --- lib_com/options.h | 1 + lib_dec/core_switching_dec_fx.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..3b7720245 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,6 +133,7 @@ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ +#define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index d1040cb80..52a6d976f 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2491,8 +2491,14 @@ ivas_error core_switching_pre_dec_ivas_fx( /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); +#ifndef FIX_2315_AGC_MEMORY_RESET set16_fx( st->agc_mem_fx, 0, 2 ); +#endif } + +#ifdef FIX_2315_AGC_MEMORY_RESET + set16_fx( st->agc_mem_fx, 0, 2 ); +#endif st->mem_deemph_fx = 0; move16(); IF( !st->last_con_tcx ) -- GitLab From 13acea3976fbd4b6baeb66e36a31b6277fb78ebe Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 12 Jan 2026 11:59:51 +0100 Subject: [PATCH 304/750] fix variable type and wanring on windows --- lib_dec/ivas_jbm_dec_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 0bac13b87..8b1ba5062 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2462,7 +2462,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS]; Word16 nchan_in, nchan_out; #ifdef FIX_1486_INIT_OUTPUT_POINTERS - int16_t ch_idx; + Word16 ch_idx; #endif @@ -2791,7 +2791,11 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) { #ifndef DISABLE_LIMITER +#ifndef FIX_1486_INIT_OUTPUT_POINTERS Word16 ch_idx, exp = 11; +#else + Word16 exp = 11; +#endif move16(); FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { -- GitLab From e6d8e757c0594682a15a752656ce1e72277ef719 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 12 Jan 2026 12:01:56 +0100 Subject: [PATCH 305/750] revert accidental change to cI setup --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1de5e5538..3f84bc99f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF branch + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main # If you need to set some config variable only in a local branch, then add an overwrite here # One example is DISABLE_HRTF - this will be set on a branch which is about to be merged and will be removed in a subsequent second MR # this is more easily done directly here in the child repo -- GitLab From dd9359e4c3157f6d1766874679dbce4e2fa4cb6d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 12:11:51 +0100 Subject: [PATCH 306/750] port changes from FLP --- apps/decoder.c | 78 +++++++-------- apps/isar_post_rend.c | 24 ++--- apps/renderer.c | 26 ++--- lib_com/common_api_types.h | 11 ++- lib_dec/ivas_init_dec_fx.c | 4 +- lib_dec/ivas_stat_dec.h | 4 +- lib_dec/lib_dec.h | 17 ++-- lib_dec/lib_dec_fx.c | 141 ++++++++++++---------------- lib_isar/isar_prot.h | 4 +- lib_isar/isar_splitRendererPre.c | 11 ++- lib_isar/isar_splitRenderer_utils.c | 19 ++-- lib_isar/lib_isar_pre_rend.c | 33 +++---- lib_isar/lib_isar_pre_rend.h | 2 +- 13 files changed, 178 insertions(+), 196 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 494f76ccb..08cac8f21 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -124,7 +124,7 @@ typedef struct char *outputMdFilename; IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; - IVAS_RENDER_FRAMESIZE renderFramesize; + IVAS_RENDER_NUM_SUBFR render_num_subframes; AcousticEnvironmentSequence aeSequence; bool dpidEnabled; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; @@ -198,7 +198,7 @@ int main( Vector3PairFileReader *referenceVectorReader = NULL; RenderConfigReader *renderConfigReader = NULL; int16_t *pcmBuf = NULL; - IVAS_RENDER_FRAMESIZE asked_frame_size; + IVAS_RENDER_NUM_SUBFR asked_num_subframes; IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary; ObjectEditFileReader *objectEditFileReader = NULL; IVAS_ROOM_ACOUSTICS_CONFIG_DATA **pAE = NULL; @@ -415,11 +415,11 @@ int main( * Configure the decoder *------------------------------------------------------------------------------------------*/ - asked_frame_size = arg.renderFramesize; + asked_num_subframes = arg.render_num_subframes; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID; arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.render_num_subframes, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.roomSize, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain_fx, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { @@ -427,13 +427,13 @@ int main( goto cleanup; } - if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - if ( arg.renderFramesize != asked_frame_size ) + if ( arg.render_num_subframes != asked_num_subframes ) { fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" ); } @@ -442,7 +442,7 @@ int main( * Configure Split rendering *------------------------------------------------------------------------------------------*/ - asked_frame_size = arg.renderFramesize; + asked_num_subframes = arg.render_num_subframes; if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) @@ -451,14 +451,14 @@ int main( goto cleanup; } - if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } #ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR - if ( !arg.renderConfigEnabled && ( arg.renderFramesize != asked_frame_size ) ) + if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) { fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } @@ -574,24 +574,24 @@ int main( if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && + if ( asked_num_subframes != IVAS_RENDER_NUM_SUBFR_20MS && ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || renderConfig.split_rend_config.dof == 0 ) ) { - arg.renderFramesize = asked_frame_size; + arg.render_num_subframes = asked_num_subframes; } else { - arg.renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; + arg.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; } - if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_SetRenderNumSubfr( hIvasDec, arg.render_num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_SetRenderFramesize failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nIVAS_DEC_SetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - if ( arg.renderFramesize != asked_frame_size ) + if ( arg.render_num_subframes != asked_num_subframes ) { fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } @@ -616,7 +616,7 @@ int main( /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ - renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.render_num_subframes * 5; if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { @@ -938,7 +938,7 @@ static bool parseCmdlIVAS_dec( arg->non_diegetic_pan_enabled = false; arg->non_diegetic_pan_gain = 0.f; arg->tsmEnabled = false; - arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; + arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; arg->aeSequence.count = 0; arg->aeSequence.pID = NULL; arg->aeSequence.pValidity = NULL; @@ -1105,13 +1105,13 @@ static bool parseCmdlIVAS_dec( switch ( (int16_t) tmp ) { case 5: - arg->renderFramesize = IVAS_RENDER_FRAMESIZE_5MS; + arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_5MS; break; case 10: - arg->renderFramesize = IVAS_RENDER_FRAMESIZE_10MS; + arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_10MS; break; case 20: - arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; + arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; break; default: fprintf( stderr, "Error: Invalid render frame size %d \n\n", tmp ); @@ -2161,10 +2161,10 @@ static ivas_error decodeG192( } } - int16_t num_subframes; - if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) + IVAS_RENDER_NUM_SUBFR num_subframes; + if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: \n" ); goto cleanup; } @@ -2175,7 +2175,7 @@ static ivas_error decodeG192( if ( headRotReader == NULL ) { - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { Quaternions[i].w_fx = -12582912; Quaternions[i].x_fx = 0; @@ -2190,7 +2190,7 @@ static ivas_error decodeG192( } else { - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) { @@ -2200,7 +2200,7 @@ static ivas_error decodeG192( } } - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) { @@ -2218,7 +2218,7 @@ static ivas_error decodeG192( int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) { @@ -2226,7 +2226,7 @@ static ivas_error decodeG192( goto cleanup; } } - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK ) { @@ -2992,10 +2992,10 @@ static ivas_error decodeVoIP( } } - int16_t num_subframes; - if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) + IVAS_RENDER_NUM_SUBFR num_subframes; + if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: \n" ); goto cleanup; } @@ -3006,7 +3006,7 @@ static ivas_error decodeVoIP( if ( headRotReader == NULL ) { - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { Quaternions[i].w_fx = -12582912; Quaternions[i].x_fx = 0; @@ -3021,7 +3021,7 @@ static ivas_error decodeVoIP( } else { - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) { @@ -3031,7 +3031,7 @@ static ivas_error decodeVoIP( } } - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) { @@ -3049,7 +3049,7 @@ static ivas_error decodeVoIP( int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) @@ -3059,7 +3059,7 @@ static ivas_error decodeVoIP( goto cleanup; } } - for ( i = 0; i < num_subframes; i++ ) + for ( i = 0; i < (int16_t) num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK ) { @@ -3988,7 +3988,7 @@ static ivas_error restartDecoder( IVAS_AUDIO_CONFIG outputConfig = ( decMode == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO; - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled, + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->render_num_subframes, arg->customLsOutputEnabled, arg->hrtfReaderEnabled, arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->roomSize, arg->non_diegetic_pan_enabled, arg->non_diegetic_pan_gain_fx, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK ) { @@ -3996,7 +3996,7 @@ static ivas_error restartDecoder( goto cleanup; } - if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg->renderFramesize ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg->render_num_subframes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -4021,7 +4021,7 @@ static ivas_error restartDecoder( * This will be ignored if output format is not split rendering. */ if ( renderConfig != NULL ) { - renderConfig->split_rend_config.isar_frame_size_ms = (int16_t) arg->renderFramesize /* given in number of 5ms subframes */ * 5; + renderConfig->split_rend_config.isar_frame_size_ms = (int16_t) arg->render_num_subframes * 5; } if ( arg->renderConfigEnabled && renderConfig != NULL ) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 6ccf204ce..a7f695b11 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -114,7 +114,7 @@ typedef struct bool delayCompensationEnabled; bool quietModeEnabled; bool sceneDescriptionInput; - IVAS_RENDER_FRAMESIZE render_framesize; + IVAS_RENDER_NUM_SUBFR render_num_subframes; } CmdlnArgs; typedef enum @@ -342,11 +342,11 @@ static bool parseInConfig( static bool parseRenderFramesize( char *value, - IVAS_RENDER_FRAMESIZE *render_framesize ) + IVAS_RENDER_NUM_SUBFR *render_num_subframes ) { int32_t tmp; - *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_UNKNOWN; if ( !is_digits_only( value ) ) { return false; @@ -355,13 +355,13 @@ static bool parseRenderFramesize( switch ( (int16_t) tmp ) { case 5: - *render_framesize = IVAS_RENDER_FRAMESIZE_5MS; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_5MS; break; case 10: - *render_framesize = IVAS_RENDER_FRAMESIZE_10MS; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_10MS; break; case 20: - *render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; break; default: return false; @@ -476,7 +476,7 @@ static CmdlnArgs defaultArgs( args.quietModeEnabled = false; args.sceneDescriptionInput = false; - args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + args.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; return args; } @@ -559,7 +559,7 @@ static void parseOption( break; case CmdLnOptionId_framing: assert( numOptionValues == 1 ); - if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) + if ( !parseRenderFramesize( optionValues[0], &args->render_num_subframes ) ) { fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); exit( -1 ); @@ -951,7 +951,7 @@ int main( audioReader = NULL; /* Force owerwrite of command line provided rendersize to align with codec frame size */ - args.render_framesize = bitsBuffer.config.isar_frame_size_ms / 5; + args.render_num_subframes = bitsBuffer.config.isar_frame_size_ms / 5; } /*if split renderer is running in post renderer mode*/ else if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) @@ -1023,9 +1023,9 @@ int main( * Open ISAR handle *------------------------------------------------------------------------------------------*/ - const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); + const int16_t frameSize_smpls = (int16_t) ( ( args.render_num_subframes ) * args.sampleRate * 5 / ( 1000 ) ); args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_BINAURAL; - if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) + if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0, (int16_t) args.render_num_subframes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -1243,7 +1243,7 @@ int main( convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer_fx ); *inBuffer.pq_fact = 0; int16_t num_subframes, sf_idx; - num_subframes = (int16_t) args.render_framesize; + num_subframes = (int16_t) args.render_num_subframes; /* Read from head rotation trajectory file if specified */ if ( headRotReader != NULL ) diff --git a/apps/renderer.c b/apps/renderer.c index 70e68c757..5639f773e 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -195,7 +195,7 @@ typedef struct bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; int16_t syncMdDelay; - IVAS_RENDER_FRAMESIZE render_framesize; + IVAS_RENDER_NUM_SUBFR render_num_subframes; uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; AcousticEnvironmentSequence aeSequence; IVAS_ROOM_SIZE_T reverbRoomSize; @@ -992,12 +992,12 @@ int main( goto cleanup; } - const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); + const int16_t frameSize_smpls = (int16_t) ( ( args.render_num_subframes ) * args.sampleRate * BINAURAL_RENDERING_FRAME_SIZE_MS / ( 1000 ) ); Word32 nonDiegeticPanGain_fx = ( args.nonDiegeticPanGain == 1.0f ) ? ONE_IN_Q31 : ( args.nonDiegeticPanGain == -1.0f ) ? L_negate( ONE_IN_Q31 ) : (Word32) ( args.nonDiegeticPanGain * ( 1LL << Q31 ) ); - IF( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, nonDiegeticPanGain_fx, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) + IF( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, nonDiegeticPanGain_fx, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_num_subframes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -1225,7 +1225,7 @@ int main( /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ - renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_framesize /* given in number of 5ms subframes */ * 5; + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS; if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) { @@ -1653,7 +1653,7 @@ int main( { int16_t num_in_channels; num_in_channels = inBuffer.config.numChannels; - const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; + const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_num_subframes ) == 0; if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && renderConfigReader != NULL && args.aeSequence.count > 0 && args.aeSequence.pValidity[args.aeSequence.selected] != 0 ) @@ -1717,7 +1717,7 @@ int main( } int16_t num_subframes, sf_idx; - num_subframes = (int16_t) args.render_framesize; + num_subframes = (int16_t) args.render_num_subframes; if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame ) { @@ -2426,11 +2426,11 @@ static bool parseDiegeticPan( static bool parseRenderFramesize( char *value, - IVAS_RENDER_FRAMESIZE *render_framesize ) + IVAS_RENDER_NUM_SUBFR *render_num_subframes ) { int32_t tmp; - *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_UNKNOWN; if ( !is_digits_only( value ) ) { return false; @@ -2439,13 +2439,13 @@ static bool parseRenderFramesize( switch ( (int16_t) tmp ) { case 5: - *render_framesize = IVAS_RENDER_FRAMESIZE_5MS; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_5MS; break; case 10: - *render_framesize = IVAS_RENDER_FRAMESIZE_10MS; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_10MS; break; case 20: - *render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + *render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; break; default: return false; @@ -2812,7 +2812,7 @@ static CmdlnArgs defaultArgs( args.lfeCustomRoutingEnabled = false; clearString( args.inLfePanningMatrixFile ); - args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + args.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; args.syncMdDelay = 0; for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { @@ -2981,7 +2981,7 @@ static void parseOption( break; case CmdLnOptionId_framing: assert( numOptionValues == 1 ); - if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) + if ( !parseRenderFramesize( optionValues[0], &args->render_num_subframes ) ) { fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); exit( -1 ); diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 34bc08d43..887d87119 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -173,12 +173,12 @@ typedef enum typedef enum { - IVAS_RENDER_FRAMESIZE_UNKNOWN = 0, - IVAS_RENDER_FRAMESIZE_5MS = 1, - IVAS_RENDER_FRAMESIZE_10MS = 2, - IVAS_RENDER_FRAMESIZE_20MS = 4 + IVAS_RENDER_NUM_SUBFR_UNKNOWN = 0, + IVAS_RENDER_NUM_SUBFR_5MS = 1, + IVAS_RENDER_NUM_SUBFR_10MS = 2, + IVAS_RENDER_NUM_SUBFR_20MS = 4 -} IVAS_RENDER_FRAMESIZE; +} IVAS_RENDER_NUM_SUBFR; typedef enum { @@ -186,6 +186,7 @@ typedef enum IVAS_ROOM_SIZE_SMALL, IVAS_ROOM_SIZE_MEDIUM, IVAS_ROOM_SIZE_LARGE + } IVAS_ROOM_SIZE_T; typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 00cab0233..939f1d8c5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1557,7 +1557,7 @@ ivas_error ivas_init_decoder_front( IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - IF( NE_32( ( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_num_subframes ) ), IVAS_ERR_OK ) ) { return error; } @@ -1570,7 +1570,7 @@ ivas_error ivas_init_decoder_front( test(); IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - IF( NE_32( ( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_num_subframes ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 34c07d1f1..47a74c60b 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1073,8 +1073,8 @@ typedef struct decoder_config_structure Word16 Opt_aeid_on; /* indicates whether Acoustic environment option is used */ Word16 Opt_ObjEdit_on; /* indicates whether object editing option is used */ Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ - IVAS_RENDER_FRAMESIZE render_framesize; - Word16 Opt_delay_comp; /* flag indicating delay compensation active */ + IVAS_RENDER_NUM_SUBFR render_num_subframes; /* renderer number of subframes */ + Word16 Opt_delay_comp; /* flag indicating delay compensation active */ } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 58c33c92d..14f26b68a 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -112,7 +112,7 @@ ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const UWord32 sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : output configuration */ - const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ const bool enableHeadRotation, /* i : enable head rotation for binaural output */ @@ -352,14 +352,14 @@ ivas_error IVAS_DEC_EnableSplitRendering( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); -ivas_error IVAS_DEC_SetRenderFramesize( +ivas_error IVAS_DEC_SetRenderNumSubfr( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ + const IVAS_RENDER_NUM_SUBFR render_n_subfr /* i : rendering number of subframes */ ); -ivas_error IVAS_DEC_GetRenderFramesize( +ivas_error IVAS_DEC_GetRenderNumSubfr( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ + IVAS_RENDER_NUM_SUBFR *render_n_subfr /* o : rendering number of subframes */ ); ivas_error IVAS_DEC_GetRenderFramesizeSamples( @@ -372,14 +372,9 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( Word16 *update_frequency /* o : update frequency Q0 */ ); -ivas_error IVAS_DEC_GetNumOrientationSubframes( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - Word16 *num_subframes /* o : render framesize */ -); - ivas_error IVAS_DEC_GetRenderFramesizeMs( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord32 *render_framesize /* o : render framesize in samples Q0 */ + UWord32 *render_framesize_ms /* o : render framesize in ms Q0 */ ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c20a69451..0f25a9f44 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -116,7 +116,7 @@ static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas ); static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); -static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); +static Word16 get_render_frame_size_ms( IVAS_RENDER_NUM_SUBFR render_num_subframes ); static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig ); static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type ); static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); @@ -502,23 +502,23 @@ static ivas_error create_flush_buffer_fx( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Configure( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const UWord32 sampleRate, /* i : output sampling frequency */ - const IVAS_AUDIO_CONFIG outputConfig, /* i : output configuration */ - const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ - const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ - const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ - const bool enableHeadRotation, /* i : enable head rotation for binaural output */ - const bool enableExternalOrientation, /* i : enable external orientations */ - const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ - const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ - const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */ - const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ - const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ - const bool dpidEnabled, /* i : enable directivity pattern option */ - const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */ - const bool objEditEnabled, /* i : enable object editing */ - const bool delayCompensationEnabled /* i : enable delay compensation */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const UWord32 sampleRate, /* i : output sampling frequency */ + const IVAS_AUDIO_CONFIG outputConfig, /* i : output configuration */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ + const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ + const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ + const bool enableHeadRotation, /* i : enable head rotation for binaural output */ + const bool enableExternalOrientation, /* i : enable external orientations */ + const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ + const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ + const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */ + const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ + const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ + const bool dpidEnabled, /* i : enable directivity pattern option */ + const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */ + const bool objEditEnabled, /* i : enable object editing */ + const bool delayCompensationEnabled /* i : enable delay compensation */ ) { Decoder_Struct *st_ivas; @@ -622,18 +622,18 @@ ivas_error IVAS_DEC_Configure( move16(); move16(); - IF( EQ_16( renderFramesize, IVAS_RENDER_FRAMESIZE_UNKNOWN ) ) + IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_UNKNOWN ) ) { return IVAS_ERR_WRONG_PARAMS; } IF( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + hDecoderConfig->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; } ELSE { - hDecoderConfig->render_framesize = renderFramesize; + hDecoderConfig->render_num_subframes = render_num_subframes; } move16(); @@ -687,7 +687,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig->Opt_Headrotation = 1; move16(); - hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + hDecoderConfig->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; move32(); return IVAS_ERR_OK; @@ -700,18 +700,19 @@ ivas_error IVAS_DEC_EnableSplitRendering( * Get render framesize in ms *---------------------------------------------------------------------*/ +/*! r: render framesize in ms */ static Word16 get_render_frame_size_ms( - const IVAS_RENDER_FRAMESIZE render_framesize ) + IVAS_RENDER_NUM_SUBFR render_num_subframes ) { - IF( EQ_16( render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_5MS ) ) { - return ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + return ( 1000 / ( FRAMES_PER_SEC * IVAS_RENDER_NUM_SUBFR_5MS ) ); } - ELSE IF( EQ_16( render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) ) + ELSE IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_10MS ) ) { - return ( ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) << 1 ); + return ( ( 1000 / ( FRAMES_PER_SEC * IVAS_RENDER_NUM_SUBFR_10MS ) ) << 1 ); } - ELSE IF( EQ_16( render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) ) + ELSE IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) ) { return ( ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) << 2 ); } @@ -721,14 +722,14 @@ static Word16 get_render_frame_size_ms( /*---------------------------------------------------------------------* - * IVAS_DEC_SetRenderFramesize( ) + * IVAS_DEC_SetRenderNumSubfr( ) * - * Set render framesize + * Set number of rendering subrames *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_SetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ +ivas_error IVAS_DEC_SetRenderNumSubfr( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : renderer number of subframes */ ) { test(); @@ -738,18 +739,18 @@ ivas_error IVAS_DEC_SetRenderFramesize( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; + hIvasDec->st_ivas->hDecoderConfig->render_num_subframes = render_num_subframes; move16(); IF( hIvasDec->st_ivas->hExtOrientationData != NULL ) { - hIvasDec->st_ivas->hExtOrientationData->num_subframes = (Word16) render_framesize; + hIvasDec->st_ivas->hExtOrientationData->num_subframes = (Word16) render_num_subframes; move16(); } IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) { - hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (Word16) render_framesize; + hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (Word16) render_num_subframes; move16(); } @@ -758,24 +759,24 @@ ivas_error IVAS_DEC_SetRenderFramesize( /*---------------------------------------------------------------------* - * IVAS_DEC_GetGetRenderFramesize( ) + * IVAS_DEC_GetRenderNumSubfr( ) * - * Get render framesize + * Get number of rendering subframes *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ +ivas_error IVAS_DEC_GetRenderNumSubfr( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_RENDER_NUM_SUBFR *render_num_subframes /* o : rendering number of subframes */ ) { test(); test(); - IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_num_subframes == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = hIvasDec->st_ivas->hDecoderConfig->render_framesize; + *render_num_subframes = hIvasDec->st_ivas->hDecoderConfig->render_num_subframes; move16(); return IVAS_ERR_OK; @@ -796,15 +797,15 @@ static Word16 get_render_frame_size_samples( tmp = extract_l( Mpy_32_16_1( hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); - IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + IF( EQ_16( hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_5MS ) ) { /* correct value already in tmp */ } - ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) ) + ELSE IF( EQ_16( hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_10MS ) ) { tmp = shl( tmp, 1 ); } - ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) ) + ELSE IF( EQ_16( hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) ) { tmp = shl( tmp, 2 ); } @@ -860,7 +861,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeMs( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = get_render_frame_size_ms( hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + *render_framesize = get_render_frame_size_ms( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes ); move32(); return IVAS_ERR_OK; @@ -885,17 +886,17 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_5MS ) ) { *update_frequency = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; move16(); } - ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) ) + ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_10MS ) ) { *update_frequency = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES >> 1; move16(); } - ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) ) + ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) ) { *update_frequency = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES >> 2; move16(); @@ -904,30 +905,6 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_OK; } -/*---------------------------------------------------------------------* - * IVAS_DEC_GetGetNumOrientationSubframes( ) - * - * Get the number of subframes for head/external orientation per render frame - *---------------------------------------------------------------------*/ - -ivas_error IVAS_DEC_GetNumOrientationSubframes( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - Word16 *num_subframes /* o : render framesize */ -) -{ - test(); - test(); - IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || num_subframes == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - *num_subframes = (Word16) hIvasDec->st_ivas->hDecoderConfig->render_framesize; - move16(); - - return IVAS_ERR_OK; -} - /*---------------------------------------------------------------------* * IVAS_DEC_EnableVoIP( ) @@ -1158,12 +1135,12 @@ static Word16 isar_get_frame_size( test(); test(); - IF( NE_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) && + IF( NE_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) && ( EQ_32( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || EQ_32( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) { nSamplesPerChannel = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); - nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); + nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_num_subframes ); } ELSE { @@ -1638,7 +1615,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); #endif #else - IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); @@ -5011,7 +4988,7 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif #else - IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); @@ -5556,7 +5533,7 @@ static ivas_error printConfigInfo_dec( test(); IF( ( EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) { - fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); + fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_num_subframes ) ); } IF( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { @@ -6395,7 +6372,7 @@ static ivas_error ivas_dec_init_split_rend( move16(); } - error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag ); move16(); return error; @@ -6469,7 +6446,7 @@ static ivas_error feedSinglePIorientation( { IF( !st_ivas->hExtOrientationData ) { - IF( NE_32( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_num_subframes ), IVAS_ERR_OK ) ) { return error; } @@ -6477,7 +6454,7 @@ static ivas_error feedSinglePIorientation( IF( !st_ivas->hCombinedOrientationData ) { - IF( NE_32( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_num_subframes ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 10aaa6db5..80b736efe 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -58,7 +58,7 @@ ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ const Word32 output_Fs, /* i : output sampling rate */ - const IVAS_RENDER_FRAMESIZE ivas_frame_size /* i : IVAS frame size */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : rendering number of subframes */ ); void isar_splitBinPreRendClose( @@ -371,7 +371,7 @@ Word32 isar_get_split_rend_md_target_brate( ); ivas_error isar_framesize_to_ms( - const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ Word16 *ms /* o : frame size in ms */ ); diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 7255e7716..0288c5786 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2705,17 +2705,18 @@ void isar_init_split_rend_handles( *------------------------------------------------------------------------*/ ivas_error split_renderer_open_lc3plus( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const Word32 OutSampleRate, - const IVAS_RENDER_FRAMESIZE isar_frame_size ) + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const Word32 OutSampleRate, /* i : output sampling rate */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : rendering number of subframes */ +) { ivas_error error; Word16 i, delayBufferLength; LC3PLUS_CONFIG config; Word16 isar_frame_size_ms; - IF( ( error = isar_framesize_to_ms( isar_frame_size, &isar_frame_size_ms ) ) != IVAS_ERR_OK ) + IF( ( error = isar_framesize_to_ms( render_num_subframes, &isar_frame_size_ms ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 9aeda2289..2d9d14214 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -1278,20 +1278,27 @@ void isar_init_multi_bin_pose_data_fx_enc( return; } + +/*------------------------------------------------------------------------- + * Function isar_framesize_to_ms() + * + * + *------------------------------------------------------------------------*/ + ivas_error isar_framesize_to_ms( - const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ - Word16 *ms /* o : frame size in ms */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ + Word16 *ms /* o : frame size in ms */ ) { - switch ( frame_size ) + switch ( render_num_subframes ) { - case IVAS_RENDER_FRAMESIZE_5MS: + case IVAS_RENDER_NUM_SUBFR_5MS: *ms = 5; break; - case IVAS_RENDER_FRAMESIZE_10MS: + case IVAS_RENDER_NUM_SUBFR_10MS: *ms = 10; break; - case IVAS_RENDER_FRAMESIZE_20MS: + case IVAS_RENDER_NUM_SUBFR_20MS: *ms = 20; break; default: diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 61767c770..189f61c4d 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -51,13 +51,14 @@ *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_open( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const Word32 OutSampleRate, - const Word16 cldfb_in_flag, - const Word16 pcm_out_flag, - const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ - const Word16 mixed_td_cldfb_flag ) + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renerer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + const Word32 OutSampleRate, /* i : output sampling rate */ + const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ + const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ +) { ivas_error error, ch, num_ch; UWord8 isCldfbNeeded = 0; @@ -67,7 +68,7 @@ ivas_error ISAR_PRE_REND_open( &pSplitRendConfig->isar_frame_size_ms, &pSplitRendConfig->codec_frame_size_ms, cldfb_in_flag_local, - pcm_out_flag, (Word16) ivas_frame_size ) ) != IVAS_ERR_OK ) + pcm_out_flag, (Word16) render_num_subframes ) ) != IVAS_ERR_OK ) { return error; } @@ -150,7 +151,7 @@ ivas_error ISAR_PRE_REND_open( { IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) { - IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, ivas_frame_size ) ) != IVAS_ERR_OK ) + IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, render_num_subframes ) ) != IVAS_ERR_OK ) { return error; } @@ -276,13 +277,13 @@ void ISAR_PRE_REND_GetMultiBinPoseData( *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ - const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ - const Word32 SplitRendBitRate, /* i : Split renderer bitrate */ - ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ - const Word16 isar_frame_size_ms, /* i : ISAR framesize */ - Word16 codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const Word32 SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + const Word16 isar_frame_size_ms, /* i : ISAR framesize */ + Word16 codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */ Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ const Word16 max_bands, /* i : CLDFB bands */ diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index 0e1ca5672..e88336ee0 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -47,7 +47,7 @@ ivas_error ISAR_PRE_REND_open( const Word32 output_Fs, /* i : output sampling rate */ const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ - const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i : IVAS frame size */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ ); -- GitLab From 5b8d17cfe4ad2e6862d0b5202be3b5ebdd59eda2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 12:35:00 +0100 Subject: [PATCH 307/750] rename isar_framesize_to_ms() to isar_num_subfr_to_ms() --- lib_isar/isar_prot.h | 2 +- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/isar_splitRenderer_utils.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 80b736efe..fb7bfc11b 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -370,7 +370,7 @@ Word32 isar_get_split_rend_md_target_brate( const Word16 pcm_out_flag /* i : flag to indicate PCM output */ ); -ivas_error isar_framesize_to_ms( +ivas_error isar_num_subfr_to_ms( const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ Word16 *ms /* o : frame size in ms */ ); diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 0288c5786..3b04f7673 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2716,7 +2716,7 @@ ivas_error split_renderer_open_lc3plus( LC3PLUS_CONFIG config; Word16 isar_frame_size_ms; - IF( ( error = isar_framesize_to_ms( render_num_subframes, &isar_frame_size_ms ) ) != IVAS_ERR_OK ) + IF( ( error = isar_num_subfr_to_ms( render_num_subframes, &isar_frame_size_ms ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 2d9d14214..fc0ecf0d5 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -1280,12 +1280,12 @@ void isar_init_multi_bin_pose_data_fx_enc( /*------------------------------------------------------------------------- - * Function isar_framesize_to_ms() + * Function isar_num_subfr_to_ms() * * *------------------------------------------------------------------------*/ -ivas_error isar_framesize_to_ms( +ivas_error isar_num_subfr_to_ms( const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ Word16 *ms /* o : frame size in ms */ ) -- GitLab From c6ad9888377ed6d27e93eac437414c58a7e60ea4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 12:55:17 +0100 Subject: [PATCH 308/750] address reviewer's comments --- apps/renderer.c | 2 +- lib_dec/lib_dec.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 5639f773e..47acbe332 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1653,7 +1653,7 @@ int main( { int16_t num_in_channels; num_in_channels = inBuffer.config.numChannels; - const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_num_subframes ) == 0; + const bool isCurrentFrameMultipleOf20ms = frame % ( IVAS_RENDER_NUM_SUBFR_20MS / args.render_num_subframes ) == 0; if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && renderConfigReader != NULL && args.aeSequence.count > 0 && args.aeSequence.pValidity[args.aeSequence.selected] != 0 ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 14f26b68a..5bbfd604e 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -354,12 +354,12 @@ ivas_error IVAS_DEC_EnableSplitRendering( ivas_error IVAS_DEC_SetRenderNumSubfr( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_NUM_SUBFR render_n_subfr /* i : rendering number of subframes */ + const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : rendering number of subframes */ ); ivas_error IVAS_DEC_GetRenderNumSubfr( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_RENDER_NUM_SUBFR *render_n_subfr /* o : rendering number of subframes */ + IVAS_RENDER_NUM_SUBFR *render_num_subframes /* o : rendering number of subframes */ ); ivas_error IVAS_DEC_GetRenderFramesizeSamples( -- GitLab From fe38daf81e7c6fe4461e6e8aa4fb09c6ff14b4c8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 13:00:12 +0100 Subject: [PATCH 309/750] HARM_CORE_SW, decoder step 5 (core_switching_post_dec) --- lib_com/prot_fx.h | 2 ++ lib_dec/core_switching_dec_fx.c | 7 ++++++- lib_dec/evs_dec_fx.c | 2 +- lib_dec/ivas_core_dec_fx.c | 4 ++++ lib_dec/ivas_mct_dec_fx.c | 5 +++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 7cb2ef504..c4623fc1c 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7830,6 +7830,7 @@ ivas_error core_switching_pre_dec_fx( ); ivas_error core_switching_post_dec_fx( +#ifndef HARM_CORE_SW Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ const Word16 output_frame, /* i : frame length Q0*/ @@ -7839,6 +7840,7 @@ ivas_error core_switching_post_dec_fx( ); ivas_error core_switching_post_dec_ivas_fx( +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 522f69588..187cb1d18 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -911,7 +911,7 @@ ivas_error core_switching_pre_dec_fx( return error; } -#endif + /*---------------------------------------------------------------------* * core_switching_post_dec() @@ -1300,8 +1300,13 @@ ivas_error core_switching_post_dec_fx( return error; } +#endif +#ifdef HARM_CORE_SW +ivas_error core_switching_post_dec_fx( +#else ivas_error core_switching_post_dec_ivas_fx( +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 0b59cccaa..7042f2519 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -351,7 +351,7 @@ ivas_error evs_dec_fx( *---------------------------------------------------------------------*/ #ifdef HARM_CORE_SW - if ( ( error = core_switching_post_dec_ivas_fx( st_fx, synth_fx, NULL, NULL, 0, output_frame, core_switching_flag, 0, 1, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, NULL, NULL, 0, output_frame, core_switching_flag, 0, 1, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) #else if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index cbf005b95..d449921ba 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -930,7 +930,11 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx } +#ifdef HARM_CORE_SW + IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 5c5b0ac52..4f06158da 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -363,7 +363,12 @@ ivas_error ivas_mct_dec_fx( { dirac_stereo_flag = 0; } + +#ifdef HARM_CORE_SW + IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#endif { return error; } -- GitLab From 0239404206523add62117dccbd41c4196b46cd52 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 13:08:43 +0100 Subject: [PATCH 310/750] HARM_CORE_SW, decoder step 5 (acelp_core_switch_dec_bfi_fx) --- lib_com/prot_fx.h | 3 +- lib_dec/acelp_core_switch_dec_fx.c | 101 +++++++++++++++++++++-------- lib_dec/core_switching_dec_fx.c | 18 ++--- 3 files changed, 82 insertions(+), 40 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c4623fc1c..035885800 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7197,12 +7197,13 @@ ivas_error acelp_core_switch_dec_bfi_fx( const Word16 coder_type /* i : coder type */ ); +#ifndef HARM_CORE_SW ivas_error acelp_core_switch_dec_bfi_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 synth_out[], /* o : synthesis Q_syn */ const Word16 coder_type /* i : coder type */ ); - +#endif void pred_lt4( const Word16 excI[], /* in : excitation buffer Q_exc*/ Word16 excO[], /* out: excitation buffer Q_exc*/ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 049626e59..22d63d4b0 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -351,7 +351,7 @@ ivas_error acelp_core_switch_dec_fx( * * ACELP core decoder in the first ACELP->HQ switching frame in case of BAD frame *-------------------------------------------------------------------*/ - +#ifndef HARM_CORE_SW ivas_error acelp_core_switch_dec_bfi_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 synth_out[], /* o : synthesis Q_syn */ @@ -594,8 +594,13 @@ ivas_error acelp_core_switch_dec_bfi_fx( return error; } +#endif +#ifdef HARM_CORE_SW +ivas_error acelp_core_switch_dec_bfi_fx( +#else ivas_error acelp_core_switch_dec_bfi_ivas_fx( +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 synth_out[], /* o : synthesis Q_syn */ const Word16 coder_type /* i : coder type */ @@ -647,6 +652,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ + Q_exc = st_fx->Q_exc; move16(); st_fx->bpf_off = 1; @@ -757,11 +763,17 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( /*------------------------------------------------------------------* * Synthesis *-----------------------------------------------------------------*/ + Prev_Q_syn_r = st_fx->Q_syn; move16(); Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL ); - Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) ); // Q_syn +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) +#endif + { + Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) ); // Q_syn + } Copy( st_fx->mem_syn2_fx, tmp1, M ); syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn ); @@ -772,6 +784,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( /*------------------------------------------------------------------* * Perform fixed deemphasis through 1/(1 - g*z^-1) *-----------------------------------------------------------------*/ + tmp1[0] = st_fx->mem_deemph_fx; move16(); /*if in acelp_core_dec_fx deemph_fx is used*/ /*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ @@ -810,36 +823,70 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST ); hBPF->psf_att_fx = tmp7; move16(); + /*----------------------------------------------------------------* * Resamping to the output sampling frequency *----------------------------------------------------------------*/ - /* CLDFB analysis of the synthesis at internal sampling rate */ - Qtmp = sub( 11, st_fx->Q_syn ); - Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) ) - { - return error; - } - /*cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, - negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer);*/ - cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, shr( st_fx->L_frame, 1 ), st_fx->cldfbAna ); - cldfb_restore_memory_ivas_fx( st_fx->cldfbAna ); - /* CLDFB synthesis of the combined signal */ - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) ) +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { - return error; + CLDFB_SCALE_FACTOR scaleFactor; + Word32 workBuffer[128 * 3]; + + IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) ) + { + return error; + } + cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer ); + cldfb_restore_memory( st_fx->cldfbAna ); + + scaleFactor.hb_scale = scaleFactor.lb_scale; + move16(); + + /* CLDFB synthesis of the combined signal */ + IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) ) + { + return error; + } + cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, + negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer ); + + /* output to Q0 */ + Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); // Q0 + + cldfb_restore_memory( st_fx->cldfbSyn ); } - /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, - negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/ - Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ); - cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn ); - Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 ); + ELSE +#endif + { + /* CLDFB analysis of the synthesis at internal sampling rate */ + Qtmp = sub( 11, st_fx->Q_syn ); + Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) ) + { + return error; + } + /*cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, + negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer);*/ + cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, shr( st_fx->L_frame, 1 ), st_fx->cldfbAna ); + cldfb_restore_memory_ivas_fx( st_fx->cldfbAna ); + /* CLDFB synthesis of the combined signal */ + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) ) + { + return error; + } + /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, + negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/ + Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ); + cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn ); + Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 ); - // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); + // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); - cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn ); + cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn ); + } return error; } @@ -854,8 +901,8 @@ static void decod_gen_voic_core_switch_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 L_frame, /* i : length of the frame */ const Word16 sharpFlag, /* i : flag for formant sharpening */ - const Word16 *Aq, /* i : LP filter coefficient Q_12 */ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc */ + const Word16 *Aq, /* i : LP filter coefficient Q_12 */ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc */ const Word32 core_brate, /* i : switching frame bit-rate */ Word16 *Q_exc ) { @@ -873,7 +920,6 @@ static void decod_gen_voic_core_switch_fx( GSC_DEC_HANDLE hGSCDec; hGSCDec = st_fx->hGSCDec; - /*----------------------------------------------------------------------* * initializations *----------------------------------------------------------------------*/ @@ -902,6 +948,7 @@ static void decod_gen_voic_core_switch_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector. *--------------------------------------------------------------*/ + IF( st_fx->element_mode != EVS_MONO ) { pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -910,6 +957,7 @@ static void decod_gen_voic_core_switch_fx( { pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } + /*--------------------------------------------------------------* * LP filtering of the adaptive excitation *--------------------------------------------------------------*/ @@ -977,6 +1025,7 @@ static void decod_gen_voic_core_switch_fx( /*-----------------------------------------------------------------* * long term prediction on the 2nd sub frame *-----------------------------------------------------------------*/ + IF( st_fx->element_mode != EVS_MONO ) { pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 187cb1d18..3c64c6e16 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1354,21 +1354,13 @@ ivas_error core_switching_post_dec_ivas_fx( IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { #ifdef HARM_CORE_SW - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) - { - return error; - } /*the output at Q0*/ - } - ELSE + IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) +#else + IF( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) #endif { - IF( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) - { - return error; - } /*the output at Q0*/ - } + return error; + } /*the output at Q0*/ } /* set multiplication factor according to the sampling rate */ -- GitLab From 2598443ab36c1059fb7f169633fd32f81bf54540 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 13:13:33 +0100 Subject: [PATCH 311/750] address reviewer's comments --- apps/isar_post_rend.c | 4 ++-- apps/renderer.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index a7f695b11..5c5d4ccc2 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -340,7 +340,7 @@ static bool parseInConfig( } -static bool parseRenderFramesize( +static bool parseRenderNumSubfr( char *value, IVAS_RENDER_NUM_SUBFR *render_num_subframes ) { @@ -559,7 +559,7 @@ static void parseOption( break; case CmdLnOptionId_framing: assert( numOptionValues == 1 ); - if ( !parseRenderFramesize( optionValues[0], &args->render_num_subframes ) ) + if ( !parseRenderNumSubfr( optionValues[0], &args->render_num_subframes ) ) { fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); exit( -1 ); diff --git a/apps/renderer.c b/apps/renderer.c index 47acbe332..d803acb79 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2424,7 +2424,7 @@ static bool parseDiegeticPan( } -static bool parseRenderFramesize( +static bool parseRenderNumSubfr( char *value, IVAS_RENDER_NUM_SUBFR *render_num_subframes ) { @@ -2981,7 +2981,7 @@ static void parseOption( break; case CmdLnOptionId_framing: assert( numOptionValues == 1 ); - if ( !parseRenderFramesize( optionValues[0], &args->render_num_subframes ) ) + if ( !parseRenderNumSubfr( optionValues[0], &args->render_num_subframes ) ) { fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); exit( -1 ); -- GitLab From 46d3f18dd364806ecd750e6378532bea5ac32c51 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 14:03:27 +0100 Subject: [PATCH 312/750] HARM_CORE_SW, decoder step 6 (core_switching_post_enc) --- lib_dec/acelp_core_switch_dec_fx.c | 2 +- lib_enc/core_switching_enc_fx.c | 31 ++++++++++++++++++++++++++---- lib_enc/ivas_core_enc_fx.c | 4 ++++ lib_enc/prot_fx_enc.h | 4 ++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 22d63d4b0..5447f954c 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -829,7 +829,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( *----------------------------------------------------------------*/ #ifdef HARM_CORE_SW - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { CLDFB_SCALE_FACTOR scaleFactor; Word32 workBuffer[128 * 3]; diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 2d44ba36a..523672d4a 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -386,13 +386,14 @@ void core_switching_pre_enc_fx( * * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ + void core_switching_post_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 old_inp_12k8[], /* i : input signal @12.8 kHz Qinp */ const Word16 old_inp_16k[], /* i : input signal @16 kHz Qinp */ const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */ - Word16 Qshift, - Word16 Q_new, + const Word16 Qshift, + const Word16 Q_new, const Word16 Qsp, /* i/o : Q from acelp synthsis */ Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */ ) @@ -419,8 +420,14 @@ void core_switching_post_enc_fx( } ELSE { - *Qmus = Qsp; /* Write Qout */ - move16(); +#ifdef HARM_CORE_SW + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) +#endif + { + *Qmus = Qsp; /* Write Qout */ + move16(); + } + IF( hBWE_TD == NULL ) { return; @@ -483,6 +490,7 @@ void core_switching_post_enc_fx( { TBEreset_enc_fx( st_fx->hBWE_TD, st_fx->last_core, st_fx->bwidth ); } + test(); test(); test(); @@ -493,6 +501,18 @@ void core_switching_post_enc_fx( hBWE_TD->fb_tbe_demph_fx = 0; fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q ); } + +#ifdef HARM_CORE_SW + /* Fade towards init value for non HQ_CORE */ + test(); + IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->hHQ_core != NULL ) + { + st_fx->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st_fx->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st_fx->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/ + move32(); + st_fx->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st_fx->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st_fx->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ + move32(); + } +#endif } return; @@ -1016,9 +1036,11 @@ void core_switching_pre_enc_ivas_fx( st_fx->EnergyLT_fx_exp = 30; move16(); /* Set to a High Exponent so it is 1^-30 */ } + /*---------------------------------------------------------------------* * band-width switching from WB -> SWB/FB *---------------------------------------------------------------------*/ + IF( st_fx->element_mode > EVS_MONO ) { IF( st_fx->bwidth_sw_cnt == 0 ) @@ -1045,6 +1067,7 @@ void core_switching_pre_enc_ivas_fx( return; } + /*---------------------------------------------------------------------* * core_switching_post_enc() * diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index c19ec47db..6d5988bbe 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -648,7 +648,11 @@ ivas_error ivas_core_enc_fx( *---------------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC +#ifdef HARM_CORE_SWaaa + core_switching_post_enc_fx( st, NULL, NULL, NULL, 0, 0, 0, NULL ); +#else core_switching_post_enc_ivas_fx( st ); +#endif #else core_switching_post_enc_ivas_fx( st, old_inp_12k8_fx[n], old_inp_16k_fx[n], A_fx[n], Q_new[n] ); #endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index e16ae844b..dd0c2e441 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -118,8 +118,8 @@ void core_switching_post_enc_fx( const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/ const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/ const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */ - Word16 Qshift, - Word16 Q_new, + const Word16 Qshift, + const Word16 Q_new, const Word16 Qsp, /* i/o : Q from acelp synthsis */ Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */ ); -- GitLab From c2e5c89cba9816b2cdbd6f712aef0f1d43f96a72 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 14:14:40 +0100 Subject: [PATCH 313/750] clang-format --- lib_dec/acelp_core_switch_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 5447f954c..650f92ab1 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -859,7 +859,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( } ELSE #endif - { + { /* CLDFB analysis of the synthesis at internal sampling rate */ Qtmp = sub( 11, st_fx->Q_syn ); Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) -- GitLab From f2d37a5ea7aeb27bf63362f9e51fc6651564eb65 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 12 Jan 2026 14:34:54 +0100 Subject: [PATCH 314/750] alternative fix --- lib_com/cldfb_fx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 83e1fa0bf..c64447a34 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -596,8 +596,19 @@ void cldfbAnalysis_ts_fx_var_q( { Word16 norm_st = L_norm_arr( timeBuffer_fx, offset ); #ifdef FIX_2257_INCR_GUARD_BITS + Word16 q_min; + norm_st = sub( norm_st, find_guarded_bits_fx( frameSize ) ); -#endif + q_min = s_min( add( norm_st, h_cldfb->Q_cldfb_state ), *q_cldfb ); + + scale_sig32( timeBuffer_fx, offset, sub( q_min, h_cldfb->Q_cldfb_state ) ); + scale_sig32( &timeBuffer_fx[offset], frameSize, sub( q_min, *q_cldfb ) ); + + *q_cldfb = q_min; + move16(); + h_cldfb->Q_cldfb_state = q_min; + move16(); +#else IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) ) { scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ); @@ -613,6 +624,7 @@ void cldfbAnalysis_ts_fx_var_q( *q_cldfb = h_cldfb->Q_cldfb_state; move16(); } +#endif } /* only process needed cols */ -- GitLab From bcff8d7759544f4f9fce834cec96a3b8c921bdd7 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 12 Jan 2026 08:57:35 -0500 Subject: [PATCH 315/750] update define name to be more meaning full --- lib_com/options.h | 2 +- lib_enc/avq_cod_fx.c | 2 +- lib_enc/ext_sig_ana_fx.c | 2 +- lib_enc/ivas_core_enc_fx.c | 2 +- lib_enc/ivas_cpe_enc_fx.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 93dd7f849..36e8b4ca2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,7 +117,7 @@ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ #define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ -#define FIX_CLANG_18_ENC /* VA: Fix some encoder clang-18 warnings */ +#define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 3d88315c9..943e2d2a2 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -609,7 +609,7 @@ void AVQ_cod_lpc_fx( Word16 i, l, pos; Word32 I; Word32 x1[8]; -#ifdef FIX_CLANG_18_ENC +#ifdef FIX_2294_CLANG_18_WARNINGS_ENC UWord16 I16 = 0; #else UWord16 I16; diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 4a47f7aec..42c064ccc 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1132,7 +1132,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { Word16 Q; -#ifdef FIX_CLANG_18_ENC +#ifdef FIX_2294_CLANG_18_WARNINGS_ENC Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, L_subframe, 16 ); #else Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, N_MAX + L_MDCT_OVLP_MAX, 16 ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 055bbdcd9..528cd5f7c 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -116,7 +116,7 @@ ivas_error ivas_core_enc_fx( { set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET ); set16_fx( old_syn_12k8_16k_fx[i], 0, L_FRAME16k ); -#ifdef FIX_CLANG_18_ENC +#ifdef FIX_2294_CLANG_18_WARNINGS_ENC set16_fx( voice_factors_fx[i], 0, NB_SUBFR16k ); #endif } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index caa2a0c51..7792f57d3 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -336,7 +336,7 @@ ivas_error ivas_cpe_enc_fx( Word16 q_band_energies_LR; Word16 q_fr_bands[2], q_lf_E[2]; -#ifdef FIX_CLANG_18_ENC +#ifdef FIX_2294_CLANG_18_WARNINGS_ENC q_band_energies_LR = 0; q_lf_E[0] = 0; q_lf_E[1] = 0; -- GitLab From f9a640fd71f8dbd14877fc7526da96f25187cf37 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 15:22:20 +0100 Subject: [PATCH 316/750] fix get_render_frame_size_ms() --- lib_dec/lib_dec_fx.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0f25a9f44..c37ef54c6 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -704,20 +704,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( static Word16 get_render_frame_size_ms( IVAS_RENDER_NUM_SUBFR render_num_subframes ) { - IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_5MS ) ) - { - return ( 1000 / ( FRAMES_PER_SEC * IVAS_RENDER_NUM_SUBFR_5MS ) ); - } - ELSE IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_10MS ) ) - { - return ( ( 1000 / ( FRAMES_PER_SEC * IVAS_RENDER_NUM_SUBFR_10MS ) ) << 1 ); - } - ELSE IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) ) - { - return ( ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) << 2 ); - } - - return 0; + return (int16_t) ( render_num_subframes * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } -- GitLab From 0f159366c394324463e76ff1f4d5f812d4573f8a Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 16:51:55 +0100 Subject: [PATCH 317/750] HARM_CORE_SW, decoder step 7 (core_switching_pre_enc) --- lib_com/prot_fx.h | 3 +- lib_enc/amr_wb_enc_fx.c | 4 + lib_enc/core_switching_enc_fx.c | 126 +++++++++++++++++++++++++++++--- lib_enc/evs_enc_fx.c | 4 + lib_enc/ivas_core_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 12 ++- 6 files changed, 134 insertions(+), 17 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 035885800..b09bf6732 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10945,6 +10945,7 @@ ivas_error IGF_Reconfig_fx( const Word16 rf_mode /* i : flag to signal the RF mode */ ); +#ifndef HARM_CORE_SW void core_switching_post_enc_ivas_fx( Encoder_State *st /* i/o: encoder state structure */ #ifndef CLEANUP_ACELP_ENC @@ -10955,7 +10956,7 @@ void core_switching_post_enc_ivas_fx( Word16 Q_new #endif ); - +#endif void residu_ivas_fx( const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ const Word16 a_exp, diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 9b20100ba..5f7a13824 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -136,7 +136,11 @@ void amr_wb_enc_fx( /* Updates in case of HQ -> AMR-WB IO mode switching */ Q_new = 0; move16(); /* prevent compiler warning only*/ +#ifdef HARM_CORE_SW + core_switching_pre_enc_fx( st, NULL, 0, NULL, 0, 0, 0 ); +#else core_switching_pre_enc_fx( st, NULL, NULL, 0, 0 ); +#endif set16_fx( hf_gain_fx, 0, NB_SUBFR ); set16_fx( old_inp, 0, L_INP_12k8 ); diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 523672d4a..beee43d5f 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -19,9 +19,15 @@ *---------------------------------------------------------------------*/ void core_switching_pre_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ - const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ +#ifdef HARM_CORE_SW + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ +#endif + const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ +#ifdef HARM_CORE_SW + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ +#endif const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ) @@ -112,7 +118,7 @@ void core_switching_pre_enc_fx( test(); test(); test(); - IF( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) + if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) { /* very first frame is HQ_CORE */ st_fx->last_core = HQ_CORE; @@ -237,7 +243,16 @@ void core_switching_pre_enc_fx( } Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/ - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); + } + ELSE +#endif + { + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); + } /* Reset old ACELP buffers */ test(); @@ -251,6 +266,7 @@ void core_switching_pre_enc_fx( /* reset BWE memories */ hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); } IF( hBWE_FD != NULL ) { @@ -292,7 +308,7 @@ void core_switching_pre_enc_fx( { set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move16(); + move32(); } /* reset BWE memories */ @@ -301,6 +317,7 @@ void core_switching_pre_enc_fx( set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } } + test(); test(); test(); @@ -341,7 +358,27 @@ void core_switching_pre_enc_fx( } Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } - Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ + +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) + { + Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp + } + ELSE + { + Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8 + hBWE_FD->prev_Q_input_lp = q_old_inp_12k8; + move16(); + Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + } + ELSE +#endif + { + Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ + } } ELSE { @@ -356,12 +393,36 @@ void core_switching_pre_enc_fx( Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } - Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) + { + Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp + } + ELSE + { + Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k + hBWE_FD->prev_Q_input_lp = q_old_inp_16k; + move16(); + Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + } + ELSE +#endif + { + Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ + } } tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/ +#ifdef HARM_CORE_SW + hBWE_FD->Q_new_input_hp = 0; + move16(); +#else add( 0, 0 ); +#endif IF( NE_16( st_fx->last_extl, WB_BWE ) ) { @@ -417,6 +478,13 @@ void core_switching_post_enc_fx( hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); hBWE_FD->mem_deemph_old_syn_fx = 0; move16(); +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + hBWE_FD->q_mem_deemph_old_syn = 0; + move16(); + } +#endif } ELSE { @@ -461,23 +529,56 @@ void core_switching_post_enc_fx( test(); test(); test(); +#ifdef HARM_CORE_SW + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#endif IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) ) ) { set16_fx( hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + InitSWBencBufferStates_fx( st_fx->hBWE_TD, NULL ); + } + ELSE +#endif + { + set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); + } swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); - set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, 12 ); - set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 ); + set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + set16_fx( st_fx->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); + } + ELSE +#endif + { + set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 ); + } } +#ifdef HARM_CORE_SW + ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && + ( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) ) || + ( NE_16( st_fx->last_bwidth, st_fx->bwidth ) ) || ( NE_16( st_fx->last_codec_mode, MODE1 ) ) || ( NE_16( st_fx->rf_mode_last, st_fx->rf_mode ) ) ) ) +#else ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) || NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_mode, st_fx->rf_mode_last ) ) ) +#endif { set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); @@ -1066,7 +1167,7 @@ void core_switching_pre_enc_ivas_fx( return; } - +#ifndef HARM_CORE_SW /*---------------------------------------------------------------------* * core_switching_post_enc() @@ -1208,3 +1309,4 @@ void core_switching_post_enc_ivas_fx( return; } +#endif diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 416c2f4e9..34eda1c20 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -260,7 +260,11 @@ ivas_error evs_enc_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + core_switching_pre_enc_fx( st, old_inp_12k8, 0, old_inp_16k, 0, 0, 0 ); +#else core_switching_pre_enc_fx( st, old_inp_12k8, old_inp_16k, 0, 0 ); +#endif /*---------------------------------------------------------------------* * ACELP core encoding diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 6d5988bbe..a340fc4d0 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -648,7 +648,7 @@ ivas_error ivas_core_enc_fx( *---------------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC -#ifdef HARM_CORE_SWaaa +#ifdef HARM_CORE_SW core_switching_post_enc_fx( st, NULL, NULL, NULL, 0, 0, 0, NULL ); #else core_switching_post_enc_ivas_fx( st ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index dd0c2e441..ede39b497 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -125,9 +125,15 @@ void core_switching_post_enc_fx( ); void core_switching_pre_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old i signal @12.8kHz Qx*/ - const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ +#ifdef HARM_CORE_SW + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ +#endif + const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ +#ifdef HARM_CORE_SW + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ +#endif const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ); -- GitLab From 40f34aaa8c575db4d78de80c477b3974420be1bf Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 12 Jan 2026 17:40:53 +0100 Subject: [PATCH 318/750] alternative patch --- apps/renderer.c | 2 +- lib_com/cldfb_fx.c | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 0e499863c..35d686373 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1646,7 +1646,7 @@ int main( ObjectPositionBuffer mtdBuffer; outBuffer.pq_fact = &outBuffer.q_factor; -#ifdef FIX_2257_INCR_GUARD_BITS +#ifdef DISABLED__FIX_2257_INCR_GUARD_BITS Word16 gd_bits = find_guard_bits( frameSize_smpls ); #else Word16 subframe_len = (Word16) ( args.sampleRate / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index c64447a34..72a828102 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -596,19 +596,8 @@ void cldfbAnalysis_ts_fx_var_q( { Word16 norm_st = L_norm_arr( timeBuffer_fx, offset ); #ifdef FIX_2257_INCR_GUARD_BITS - Word16 q_min; - - norm_st = sub( norm_st, find_guarded_bits_fx( frameSize ) ); - q_min = s_min( add( norm_st, h_cldfb->Q_cldfb_state ), *q_cldfb ); - - scale_sig32( timeBuffer_fx, offset, sub( q_min, h_cldfb->Q_cldfb_state ) ); - scale_sig32( &timeBuffer_fx[offset], frameSize, sub( q_min, *q_cldfb ) ); - - *q_cldfb = q_min; - move16(); - h_cldfb->Q_cldfb_state = q_min; - move16(); -#else + norm_st = sub( norm_st, find_guarded_bits_fx( shr( h_cldfb->no_channels, 2 ) ) ); +#endif IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) ) { scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ); @@ -624,7 +613,6 @@ void cldfbAnalysis_ts_fx_var_q( *q_cldfb = h_cldfb->Q_cldfb_state; move16(); } -#endif } /* only process needed cols */ -- GitLab From 90d9274ec35e09522057d7b52108bccbee0a48e2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jan 2026 18:03:29 +0100 Subject: [PATCH 319/750] HARM_CORE_SW, decoder step 8 (core_switching_pre_enc) --- lib_com/ivas_prot_fx.h | 3 ++- lib_enc/core_switching_enc_fx.c | 41 +++++++++++++++++++++++++++++++-- lib_enc/ivas_core_enc_fx.c | 6 ++++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index fee62ca4c..b86e5281c 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2963,6 +2963,7 @@ void stereo_icBWE_preproc_fx( Word16 shb_speech_nonref[], /* o : SHB speech non-ref channel */ Word16 q_shb_speech_nonref /* i : Q SHB speech non-ref channel */ ); +#ifndef HARM_CORE_SW void core_switching_pre_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -2973,7 +2974,7 @@ void core_switching_pre_enc_ivas_fx( const Word16 active_cnt, /* i : active frame counter */ const Word16 last_element_mode /* i : last_element_mode */ ); - +#endif Word16 ivas_acelp_tcx20_switching_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *inp_fx, /* i : new input signal */ diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index beee43d5f..881c070b6 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -70,6 +70,7 @@ void core_switching_pre_enc_fx( set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } + test(); IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) { @@ -206,12 +207,17 @@ void core_switching_pre_enc_fx( /* Reset ACELP parameters */ IF( hLPDmem != NULL ) { - move16(); hLPDmem->syn[M] = 0; move16(); set16_fx( hLPDmem->mem_syn2, 0, M ); set16_fx( hLPDmem->mem_syn, 0, M ); set16_fx( hLPDmem->mem_syn1_fx, 0, M ); +#ifdef HARM_CORE_SW + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + hLPDmem->q_mem_syn = Q15; + } +#endif hLPDmem->mem_w0 = 0; move16(); hLPDmem->tilt_code = 0; @@ -273,6 +279,7 @@ void core_switching_pre_enc_fx( set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } } + test(); test(); test(); @@ -438,6 +445,35 @@ void core_switching_pre_enc_fx( move16(); /* Set to a High Exponent so it is 1^-30 */ } +#ifdef HARM_CORE_SW + /*---------------------------------------------------------------------* + * band-width switching from WB -> SWB/FB + *---------------------------------------------------------------------*/ + + IF( st_fx->element_mode > EVS_MONO ) + { + IF( st_fx->bwidth_sw_cnt == 0 ) + { + test(); + IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) + { + st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); + move16(); + } + } + ELSE + { + st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); + move16(); + IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) ) + { + st_fx->bwidth_sw_cnt = 0; + move16(); + } + } + } + +#endif return; } @@ -748,6 +784,7 @@ void core_switching_hq_prepare_enc_fx( } return; } +#ifndef HARM_CORE_SW void core_switching_pre_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -1167,7 +1204,7 @@ void core_switching_pre_enc_ivas_fx( return; } -#ifndef HARM_CORE_SW + /*---------------------------------------------------------------------* * core_switching_post_enc() diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index a340fc4d0..d95a9ce1c 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -306,7 +306,11 @@ ivas_error ivas_core_enc_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ +#ifdef HARM_CORE_SW + core_switching_pre_enc_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode ); +#else core_switching_pre_enc_ivas_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode ); +#endif /*---------------------------------------------------------------------* * ACELP core encoding @@ -637,7 +641,7 @@ ivas_error ivas_core_enc_fx( q_inp[0] = st->q_old_inp; q_inp[1] = st->q_inp; - Scale_sig( st->input_fx - input_frame, 2 * input_frame, sub( -1, st->q_inp ) ); + Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( -1, st->q_inp ) ); st->q_inp = -1; move16(); st->q_old_inp = -1; -- GitLab From 60f0209160ec76aac1bb08186afb1f7de65fe801 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 12 Jan 2026 20:20:29 +0100 Subject: [PATCH 320/750] remove previously disabled code --- apps/renderer.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 35d686373..70e68c757 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1646,12 +1646,8 @@ int main( ObjectPositionBuffer mtdBuffer; outBuffer.pq_fact = &outBuffer.q_factor; -#ifdef DISABLED__FIX_2257_INCR_GUARD_BITS - Word16 gd_bits = find_guard_bits( frameSize_smpls ); -#else Word16 subframe_len = (Word16) ( args.sampleRate / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); Word16 gd_bits = find_guard_bits( subframe_len ); -#endif Word16 prev_q_fact = Q11; while ( 1 ) { -- GitLab From 5dbbe90e2f8384b63cc4a800268a3c2bdd18971f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 12 Jan 2026 15:05:18 -0500 Subject: [PATCH 321/750] fix for 2334, removing duplicated and buggy function --- lib_com/options.h | 2 +- lib_enc/ivas_cpe_enc_fx.c | 4 ++++ lib_enc/ivas_ism_enc_fx.c | 5 ++++- lib_enc/ivas_sce_enc_fx.c | 5 ++++- lib_enc/prot_fx_enc.h | 3 ++- lib_enc/sig_clas_fx.c | 7 +++++-- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..995c12a81 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,6 @@ #define FIX_2290_COPY_OF_UNINIT_DATA /* VA: prevent the copy of un-initialized data */ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ #define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ - /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ @@ -133,6 +132,7 @@ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ +#define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334: remove a duplicated and wrong function, might affect some cases of VBR */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index a610d0dfc..c3c871844 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1096,7 +1096,11 @@ ivas_error ivas_cpe_enc_fx( IF( ( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->element_mode, IVAS_CPE_TD ) ) || n == 0 ) /* modify coder_type of primary channel */ { /* limit coder_type depending on the bitrate */ +#ifndef FIX_2334_HARM_CODER_MODIF coder_type_modif_ivas_fx( sts[n], relE_fx[n] ); +#else + coder_type_modif_fx( sts[n], relE_fx[n] ); +#endif } } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index ea509dd10..727a083f3 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -450,8 +450,11 @@ ivas_error ivas_ism_enc_fx( } /* modify the coder_type depending on the total_brate per channel */ +#ifndef FIX_2334_HARM_CODER_MODIF coder_type_modif_ivas_fx( st, relE_fx[sce_id][0] ); - +#else + coder_type_modif_fx( st, relE_fx[sce_id][0] ); +#endif /*----------------------------------------------------------------* * Encoder *----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 2457fef6e..c991d4cf9 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -343,8 +343,11 @@ ivas_error ivas_sce_enc_fx( move16(); /* modify the coder_type depending on the total_brate per channel */ +#ifndef FIX_2334_HARM_CODER_MODIF coder_type_modif_ivas_fx( st, relE_fx[0] ); - +#else + coder_type_modif_fx( st, relE_fx[0] ); +#endif /*----------------------------------------------------------------* * Encoder *----------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index e16ae844b..f734830b5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1194,11 +1194,12 @@ void coder_type_modif_fx( const Word16 relE /* i : frame relative E to the long term average */ ); +#ifndef FIX_2334_HARM_CODER_MODIF void coder_type_modif_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 relE /* i : frame relative E to the long term average */ ); - +#endif void speech_music_clas_init_fx( SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ); diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 990fad0db..a162a3de4 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -545,7 +545,7 @@ void select_TC_fx( * * Coder type modification *-------------------------------------------------------------------*/ - +#ifndef FIX_2334_HARM_CODER_MODIF void coder_type_modif_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 relE /* i : frame relative E to the long term average Q8*/ @@ -636,7 +636,7 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } - } + } // <<-- that bracket was wrongly placed hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); test(); @@ -687,6 +687,9 @@ void coder_type_modif_fx( return; } void coder_type_modif_ivas_fx( +#else +void coder_type_modif_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 relE /* i : frame relative E to the long term average */ ) -- GitLab From 4509b8640b96eeaf6ded80efb7a6b4df6316c5f7 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 12 Jan 2026 15:15:07 -0500 Subject: [PATCH 322/750] fix for 2334, removing duplicated and buggy function --- lib_enc/sig_clas_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index a162a3de4..209319738 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -636,7 +636,7 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } - } // <<-- that bracket was wrongly placed + } // <<-- that bracket was wrongly placed hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); test(); -- GitLab From 07d4a911a3bf56c2dbafa1875ce954e8d8c5819d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 12 Jan 2026 15:41:34 -0500 Subject: [PATCH 323/750] supplementary fixes --- lib_enc/vad_fx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 4335225ca..9604b6697 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -745,8 +745,11 @@ Word16 wb_vad_fx( st_fx->max_band = 19; move16(); } - +#ifdef FIX_2334_HARM_CODER_MODIF + IF( st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ +#else IF( 1 ) // st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ +#endif { last_7k2_coder_type = st_fx->hSC_VBR->last_7k2_coder_type; move16(); -- GitLab From 5f0e5d8ca422d33950ee38e19a51f8d75b880056 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 12 Jan 2026 15:57:40 -0500 Subject: [PATCH 324/750] supplementary fixes --- lib_enc/vad_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 9604b6697..619452c50 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -746,7 +746,7 @@ Word16 wb_vad_fx( move16(); } #ifdef FIX_2334_HARM_CODER_MODIF - IF( st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ + IF( st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ #else IF( 1 ) // st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ #endif -- GitLab From ebf629599f130842298b60a0edfc49739637fdd0 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 13 Jan 2026 08:22:55 +0100 Subject: [PATCH 325/750] Add FIX_1495_INCORRECT_FREAD_CALL to fix wrong order of size and number of elements in fread call --- lib_com/options.h | 1 + lib_util/hrtf_file_reader.c | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..b1be279e3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,6 +116,7 @@ #define FIX_2290_COPY_OF_UNINIT_DATA /* VA: prevent the copy of un-initialized data */ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ #define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ +#define FIX_1495_INCORRECT_FREAD_CALL /* Eri: Switched size and number of elements in fread call. */ /* #################### End BE switches ################################## */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index a21569f8d..c4f03fa1c 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -306,7 +306,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif fread( v_tmp16, sizeof( Word16 ), modelITD->elevDim3 - 2, f_hrtf ); for ( j = 0; j < modelITD->elevDim3 - 2; j++ ) { @@ -325,7 +329,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif fread( v_tmp16, sizeof( Word16 ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); for ( j = 0; j < ( modelITD->azimDim3 + 1 ) / 2 - 2; j++ ) { @@ -344,7 +352,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -392,7 +404,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -440,7 +456,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -485,9 +505,17 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif HrFiltSet_p->latency_s_Q_fx = Q31 - factor_Q; +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &HrFiltSet_p->latency_s_fx, sizeof( Word32 ), 1, f_hrtf ); +#else fread( &HrFiltSet_p->latency_s_fx, 1, sizeof( Word32 ), f_hrtf ); +#endif model = &( HrFiltSet_p->ModelParams ); /* Set ROM flag for correct deallocation */ @@ -536,7 +564,11 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif fread( v_tmp16, sizeof( Word16 ), model->elevDim3 - 2, f_hrtf ); for ( j = 0; j < model->elevDim3 - 2; j++ ) { @@ -578,7 +610,11 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif fread( v_tmp16, sizeof( Word16 ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); for ( j = 0; j < model->azimDim3_dyn[i] + 1; j++ ) { @@ -598,7 +634,11 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif model->AlphaL_e = Q15 - factor_Q; // model->AlphaL_dyn_e = 1; /* force to 6 to be corrected */ @@ -661,7 +701,11 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -731,7 +775,11 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -750,7 +798,11 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#ifdef FIX_1495_INCORRECT_FREAD_CALL + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); +#endif model->EL_e = Q31 - factor_Q; model->ER_e = model->EL_e; @@ -1024,7 +1076,11 @@ static ivas_error TDREND_MIX_LoadHRTF( /* try if it is old format for BE tests*/ fseek( f_hrtf, 0, SEEK_SET ); +#ifdef FIX_1495_INCORRECT_FREAD_CALL + if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 ) +#else if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) +#endif { header_check_result = IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -1096,7 +1152,11 @@ static ivas_error TDREND_MIX_LoadHRTF( if ( is_tdrend ) { +#ifdef FIX_1495_INCORRECT_FREAD_CALL + if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 ) +#else if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) +#endif { return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } -- GitLab From 58c8d89dc28878b8d3918092024602eef9267325 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 13 Jan 2026 08:51:40 +0100 Subject: [PATCH 326/750] correction in pre-processor instruction --- lib_com/ivas_cnst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 1f8eca447..8af9b0247 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -561,7 +561,7 @@ typedef enum #define STEREO_DFT_ITD_FS 32000 #define STEREO_DFT_ITD_MAX 160 /*samples @ 32000*/ #define STEREO_DFT_ITD_MAX_ANA 200 -#define STEREO_DFT_ITD_MIN s_max( STEREO_DFT_ITD_MAX - 256 + 1, 1 ) /*STEREO_DFT_ITD_MAX-pow(2,STEREO_DFT_ITD_NBITS-1)+1*/ +#define STEREO_DFT_ITD_MIN 1 /* == max( STEREO_DFT_ITD_MAX - pow(2,STEREO_DFT_ITD_NBITS-1) + 1, 1 )*/ #define STEREO_DFT_ITD_NBITS 9 /* 1 bit for sign, the rest for the absolute value*/ #define STEREO_DFT_ITD_MODE_NBITS 1 -- GitLab From ecda76b656df8f96e163add02d9252bb5ae8dab1 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 13 Jan 2026 09:01:27 +0100 Subject: [PATCH 327/750] Clang format --- lib_util/hrtf_file_reader.c | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index c4f03fa1c..de95f8a59 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -354,9 +354,9 @@ static ivas_error TDREND_LoadBSplineBinaryITD( #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -406,9 +406,9 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -458,9 +458,9 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -507,9 +507,9 @@ static ivas_error TDREND_LoadBSplineBinary( #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif HrFiltSet_p->latency_s_Q_fx = Q31 - factor_Q; #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &HrFiltSet_p->latency_s_fx, sizeof( Word32 ), 1, f_hrtf ); @@ -566,9 +566,9 @@ static ivas_error TDREND_LoadBSplineBinary( } #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif fread( v_tmp16, sizeof( Word16 ), model->elevDim3 - 2, f_hrtf ); for ( j = 0; j < model->elevDim3 - 2; j++ ) { @@ -612,9 +612,9 @@ static ivas_error TDREND_LoadBSplineBinary( } #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif fread( v_tmp16, sizeof( Word16 ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); for ( j = 0; j < model->azimDim3_dyn[i] + 1; j++ ) { @@ -636,9 +636,9 @@ static ivas_error TDREND_LoadBSplineBinary( } #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif model->AlphaL_e = Q15 - factor_Q; // model->AlphaL_dyn_e = 1; /* force to 6 to be corrected */ @@ -703,9 +703,9 @@ static ivas_error TDREND_LoadBSplineBinary( } #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -777,9 +777,9 @@ static ivas_error TDREND_LoadBSplineBinary( #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -800,9 +800,9 @@ static ivas_error TDREND_LoadBSplineBinary( } #ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else +#else fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif +#endif model->EL_e = Q31 - factor_Q; model->ER_e = model->EL_e; -- GitLab From c2f79309b71e55cac64837114f39ad9780c0c224 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 13 Jan 2026 09:45:52 +0100 Subject: [PATCH 328/750] clang-format --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 428be9c01..37bc17138 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1626,7 +1626,7 @@ void ivas_sba_dirac_stereo_dec_fx( } scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hStereoDft->q_dft ) ); - + FOR( i = 0; i < CPE_CHANNELS; ++i ) { scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hStereoDft->q_dft ) ); // Q11 @@ -1636,7 +1636,7 @@ void ivas_sba_dirac_stereo_dec_fx( IF( hCPE->hCoreCoder[0] != NULL ) { Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, output_frame, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, output_frame, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB } IF( hStereoDft != NULL ) -- GitLab From 13b5397c390d33d9a009c5c8b688ff8420ea268a Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 13 Jan 2026 10:25:42 +0100 Subject: [PATCH 329/750] update the fix --- lib_com/swb_tbe_com_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 751c7603b..956b57a97 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6173,8 +6173,6 @@ void create_random_vector_fx( } #else L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ -#endif - j = extract_l( L_shr( L_tmp, 23 ) ); #endif j = s_and( j, 0xff ); @@ -6189,9 +6187,9 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ k = extract_l( L_shr( L_tmp, 23 ) ); } - #else L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = extract_l( L_shr( L_tmp, 23 ) ); #endif k = s_and( k, 0xff ); @@ -6210,6 +6208,7 @@ void create_random_vector_fx( } #else L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + k = extract_l( L_shr( L_tmp, 23 ) ); #endif k = s_and( k, 0xff ); -- GitLab From 98fb5312364aeba590f1dddb56fddcbc6a6455fb Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 13 Jan 2026 10:27:23 +0100 Subject: [PATCH 330/750] clang format --- lib_com/swb_tbe_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 956b57a97..21d00ee5f 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6188,7 +6188,7 @@ void create_random_vector_fx( k = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ k = extract_l( L_shr( L_tmp, 23 ) ); #endif @@ -6207,7 +6207,7 @@ void create_random_vector_fx( k = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ k = extract_l( L_shr( L_tmp, 23 ) ); #endif -- GitLab From 4663ed8661bf10feb6a25eba4ab6207596777944 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 13 Jan 2026 14:40:48 +0100 Subject: [PATCH 331/750] fix to restore IVAS BE --- lib_dec/core_switching_dec_fx.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 3c64c6e16..08afdcabe 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1394,12 +1394,7 @@ ivas_error core_switching_post_dec_ivas_fx( st_fx->use_acelp_preq = 0; move16(); -#ifdef HARM_CORE_SW - test(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) && st_fx->hBWE_FD != NULL ) -#else IF( st_fx->hBWE_FD != NULL ) -#endif { hBWE_FD->mem_deemph_old_syn_fx = 0; move16(); -- GitLab From ab5fb1cf9630a0f84ad6c39e83a6d35289a527d1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 13 Jan 2026 15:16:48 +0100 Subject: [PATCH 332/750] address reviewer's comments --- apps/decoder.c | 10 ++++----- lib_dec/lib_dec_fx.c | 6 +++--- lib_isar/lib_isar_pre_rend.c | 17 +++++++-------- lib_isar/lib_isar_pre_rend.h | 40 ++++++++++++++++++------------------ lib_rend/lib_rend_fx.c | 2 +- 5 files changed, 38 insertions(+), 37 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 08cac8f21..cd811b7a3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -429,7 +429,7 @@ int main( if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } @@ -453,7 +453,7 @@ int main( if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } @@ -2164,7 +2164,7 @@ static ivas_error decodeG192( IVAS_RENDER_NUM_SUBFR num_subframes; if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: \n" ); + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } @@ -2995,7 +2995,7 @@ static ivas_error decodeVoIP( IVAS_RENDER_NUM_SUBFR num_subframes; if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: \n" ); + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } @@ -3998,7 +3998,7 @@ static ivas_error restartDecoder( if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg->render_num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c37ef54c6..f7d12e5d2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -116,7 +116,7 @@ static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas ); static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); -static Word16 get_render_frame_size_ms( IVAS_RENDER_NUM_SUBFR render_num_subframes ); +static Word16 get_render_frame_size_ms( const IVAS_RENDER_NUM_SUBFR render_num_subframes ); static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig ); static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type ); static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); @@ -702,7 +702,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( /*! r: render framesize in ms */ static Word16 get_render_frame_size_ms( - IVAS_RENDER_NUM_SUBFR render_num_subframes ) + const IVAS_RENDER_NUM_SUBFR render_num_subframes ) { return (int16_t) ( render_num_subframes * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } @@ -806,7 +806,7 @@ static Word16 get_render_frame_size_samples( /*---------------------------------------------------------------------* - * IVAS_DEC_GetGetRenderFramesizeSamples( ) + * IVAS_DEC_GetRenderFramesizeSamples( ) * * Get render framesize in samples *---------------------------------------------------------------------*/ diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 189f61c4d..dc62fec03 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -51,8 +51,8 @@ *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_open( - SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renerer handle */ - ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renderer config */ const Word32 OutSampleRate, /* i : output sampling rate */ const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ @@ -179,7 +179,7 @@ ivas_error ISAR_PRE_REND_open( *------------------------------------------------------------------------*/ void ISAR_PRE_REND_close( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */ IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ ) { @@ -259,7 +259,7 @@ void ISAR_PRE_REND_close( *-------------------------------------------------------------------------*/ void ISAR_PRE_REND_GetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renerer config */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */ ) @@ -277,13 +277,13 @@ void ISAR_PRE_REND_GetMultiBinPoseData( *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ const Word32 SplitRendBitRate, /* i : Split renderer bitrate */ ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ const Word16 isar_frame_size_ms, /* i : ISAR framesize */ Word16 codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ const Word16 max_bands, /* i : CLDFB bands */ @@ -292,16 +292,17 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time domain input */ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */ - Word16 Q_buff, + const Word16 Q_buff, Word16 *Q_out ) { ivas_error error; Word32 bit_len, target_md_bits, available_bits, tmp_32; Word16 q1 = 31, q2 = 31, q_final, Q_cldfb, tmp, tmp_e; Word16 i, j; - error = IVAS_ERR_OK; Word16 Q_buff_re, Q_buff_im; + error = IVAS_ERR_OK; + move16(); push_wmops( "ISAR_PRE_REND_MultiBinToSplitBinaural" ); Q_buff_re = Q_buff; diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index e88336ee0..e14f52805 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -42,8 +42,8 @@ *----------------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_open( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renderer config */ const Word32 output_Fs, /* i : output sampling rate */ const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ @@ -52,33 +52,33 @@ ivas_error ISAR_PRE_REND_open( ); void ISAR_PRE_REND_close( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */ IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ ); void ISAR_PRE_REND_GetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renerer config */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */ ); ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ - const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ - const Word32 SplitRendBitRate, /* i : Split renderer bitrate */ - ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ - const Word16 isar_frame_size_ms, /* i : ISAR framesize */ - Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */ - Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ - Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ - const Word16 max_bands, /* i : CLDFB bands */ - Word32 *pOutput_fx[], /* i : low time resolution pre-renderer flag */ - const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ - const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ - const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ - const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */ - Word16 Q_buff, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const Word32 SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + const Word16 isar_frame_size_ms, /* i : ISAR framesize */ + Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ + Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ + const Word16 max_bands, /* i : CLDFB bands */ + Word32 *pOutput_fx[], /* i : low time resolution pre-renderer flag */ + const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ + const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */ + const Word16 Q_buff, Word16 *Q_out ); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index eaed6ebf5..66d89d6f2 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11404,7 +11404,7 @@ static ivas_error printConfigInfo_rend( EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - fprintf( stdout, "Render framesize: %dms\n", i_mult( hIvasRend->num_subframes, 5 ) ); + fprintf( stdout, "Render framesize: %dms\n", i_mult( hIvasRend->num_subframes, BINAURAL_RENDERING_FRAME_SIZE_MS ) ); } return IVAS_ERR_OK; -- GitLab From ebfffe748460200da50bfa6606cda25f2b5df4d6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 13 Jan 2026 15:25:43 +0100 Subject: [PATCH 333/750] fix build --- lib_isar/lib_isar_pre_rend.c | 2 +- lib_isar/lib_isar_pre_rend.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index dc62fec03..05b98f6a4 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -292,7 +292,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time domain input */ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */ - const Word16 Q_buff, + Word16 Q_buff, Word16 *Q_out ) { ivas_error error; diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index e14f52805..f06877bbe 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -78,7 +78,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */ - const Word16 Q_buff, + Word16 Q_buff, Word16 *Q_out ); -- GitLab From 02d2fec411d57ec2c1fde38212f1f4d0b1595de0 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 13 Jan 2026 16:33:05 +0100 Subject: [PATCH 334/750] fixing ISAR command-line issues --- apps/decoder.c | 37 ++- apps/isar_post_rend.c | 357 +++++++++++++---------- apps/renderer.c | 91 +++--- lib_dec/lib_dec_fx.c | 6 + lib_isar/lib_isar_post_rend.h | 1 - lib_rend/ivas_output_init_fx.c | 4 +- lib_util/cmdl_tools.c | 26 ++ lib_util/cmdl_tools.h | 2 + lib_util/cmdln_parser.c | 369 +++++++++++++++++------- lib_util/cmdln_parser.h | 16 +- lib_util/split_render_file_read_write.c | 6 +- readme.txt | 25 +- 12 files changed, 602 insertions(+), 338 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 494f76ccb..4e1bfc1a6 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -417,7 +417,6 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID; - arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.roomSize, arg.non_diegetic_pan_enabled, @@ -2021,6 +2020,7 @@ static ivas_error decodeG192( bool needNewFrame; int16_t nSamplesRendered, nSamplesRendered_loop, nSamplesToRender; IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 } }; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; SplitFileReadWrite *splitRendWriter = NULL; @@ -2169,10 +2169,8 @@ static ivas_error decodeG192( } /* Head-tracking input simulation */ - if ( arg.enableHeadRotation ) + if ( arg.enableHeadRotation || isSplitRend ) { - IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -2212,7 +2210,6 @@ static ivas_error decodeG192( if ( arg.enableExternalOrientation ) { - IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -2559,16 +2556,28 @@ static ivas_error decodeG192( } /* Head-tracking input simulation */ - if ( arg.enableHeadRotation ) + if ( arg.enableHeadRotation || isSplitRend ) { - IVAS_QUATERNION Quaternion; - if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos[0] ) ) != IVAS_ERR_OK ) + if ( headRotReader == NULL ) { - fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); - goto cleanup; + Quaternions[0].w = -3.0f; + Quaternions[0].x = 0.0f; + Quaternions[0].y = 0.0f; + Quaternions[0].z = 0.0f; + Pos[0].x = 0.0f; + Pos[0].y = 0.0f; + Pos[0].z = 0.0f; + } + else + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[0], &Pos[0] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } } - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[0], Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2800,6 +2809,7 @@ static ivas_error decodeVoIP( IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 } }; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; int16_t nOutSamples = 0; @@ -3000,10 +3010,8 @@ static ivas_error decodeVoIP( } /* Head-tracking input simulation */ - if ( arg.enableHeadRotation ) + if ( arg.enableHeadRotation || isSplitRend ) { - IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -3043,7 +3051,6 @@ static ivas_error decodeVoIP( if ( arg.enableExternalOrientation ) { - IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 6ccf204ce..e6e45683b 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -106,14 +106,12 @@ typedef struct int32_t sampleRate; InputConfig inConfig; OutputConfig outConfig; - char inMetadataFilePaths[RENDERER_MAX_ISAR_MD_INPUTS][POST_REND_MAX_CLI_ARG_LENGTH]; - int16_t numInMetadataFiles; + char inMetadataFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; char headRotationFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; char splitRendBFIFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; ISAR_POST_REND_COMPLEXITY_LEVEL complexityLevel; bool delayCompensationEnabled; bool quietModeEnabled; - bool sceneDescriptionInput; IVAS_RENDER_FRAMESIZE render_framesize; } CmdlnArgs; @@ -124,7 +122,6 @@ typedef enum CmdLnOptionId_outputFile, CmdLnOptionId_sampleRate, CmdLnOptionId_trajFile, - CmdLnOptionId_orientationTracking, CmdLnOptionId_complexityLevel, CmdLnOptionId_noDelayCmp, CmdLnOptionId_quietModeEnabled, @@ -133,6 +130,7 @@ typedef enum CmdLnOptionId_SplitRendBFIFile, CmdLnOptionId_framing, CmdLnOptionId_srParamsFile, + CmdLnOptionId_help, } CmdLnOptionId; static const CmdLnParser_Option cliOptions[] = { @@ -140,80 +138,99 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputFile, .match = "input_file", .matchShort = "i", - .description = "Path to the input file (WAV, raw PCM or scene description file)", + .placeholder = "", + .description = "Path to the input file (WAV or raw PCM file with BINAURAL_SPLIT_PCM input format\nor ISAR bitstream file with BINAURAL_SPLIT_CODED input format)", + .isMandatory = true, }, { .id = CmdLnOptionId_inputFormat, .match = "input_format", .matchShort = "if", - .description = "Audio format of input file (e.g. BINAURAL_SPLIT_PCM, use -l for a list)", - }, - { - .id = CmdLnOptionId_inputMetadata, - .match = "input_metadata", - .matchShort = "im", - .description = "Space-separated list of path to metadata files for BINAURAL_SPLIT_PCM input mode", + .placeholder = "", + .description = "Audio format of input file (e.g. BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, ... Use -l for a list)", + .isMandatory = true, }, { .id = CmdLnOptionId_outputFile, .match = "output_file", .matchShort = "o", + .placeholder = "", .description = "Path to the output file", + .isMandatory = true, + }, + { + .id = CmdLnOptionId_inputMetadata, + .match = "input_metadata", + .matchShort = "im", + .placeholder = "", + .description = "Path to the input metadata file for BINAURAL_SPLIT_PCM input format", }, { .id = CmdLnOptionId_sampleRate, .match = "sample_rate", .matchShort = "fs", - .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs", + .placeholder = "", + .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM input files", }, { .id = CmdLnOptionId_trajFile, .match = "trajectory_file", .matchShort = "T", + .placeholder = "", .description = "Head rotation trajectory file for simulation of head tracking", }, { .id = CmdLnOptionId_SplitRendBFIFile, .match = "post_rend_bfi_file", .matchShort = "prbfi", - .description = "Split rendering option: bfi file", + .placeholder = "", + .description = "Split rendering BFI (Bad Frame Indicator) file", }, { .id = CmdLnOptionId_noDelayCmp, .match = "no_delay_compensation", .matchShort = "no_delay_cmp", - .description = "[flag] Turn off delay compensation", + .description = "Turn off delay compensation", }, { .id = CmdLnOptionId_complexityLevel, .match = "complexity_level", .matchShort = "level", - .description = "Complexity level, level = (1, 2, 3), will be defined after characterisation.", + .placeholder = "", + .description = "Complexity level (1, 2, 3) - will be defined after characterisation", }, { .id = CmdLnOptionId_quietModeEnabled, .match = "quiet", .matchShort = "q", - .description = "[flag] Limit printouts to terminal", + .description = "Quiet mode - limit printouts to terminal", }, { .id = CmdLnOptionId_listFormats, .match = "list", .matchShort = "l", - .description = "List supported audio formats", + .description = "List supported audio formats of input file", }, { .id = CmdLnOptionId_framing, .match = "framing", .matchShort = "fr", - .description = "Set Render audio framing.", + .placeholder = "", + .description = "Set audio rendering frame size in ms (5, 10, 20)", }, { .id = CmdLnOptionId_srParamsFile, .match = "sr_params", .matchShort = "s", + .placeholder = "", .description = "Path to the split rendering init params file", }, + { + .id = CmdLnOptionId_help, + .match = "help", + .matchShort = "h", + .description = "Show this help message and exit", + }, }; @@ -293,26 +310,12 @@ static const CmdLnParser_Option *findOptionById( static bool parseInConfig( const char *inFormatStr, - InputConfig *inConfig, - bool *sceneDescriptionInput ) + InputConfig *inConfig ) { - char charBuf[FILENAME_MAX]; /* Initialize input config struct */ inConfig->numBinBuses = 0; - /* First check if input is being set to scene description file - this is not covered by parseAudioConfig(). */ - strncpy( charBuf, inFormatStr, sizeof( charBuf ) - 1 ); - charBuf[sizeof( charBuf ) - 1] = '\0'; - to_upper( charBuf ); - if ( strcmp( charBuf, "META" ) == 0 ) - { - *sceneDescriptionInput = true; - /* Parsing the file will be done later. At this point the actual file path - * may not be known as command line parameters are still being parsed. */ - return true; - } - /* Check for single-format inputs. The given string should map to a member of AUDIO_CONFIG enum. */ bool srRtp = false; IVAS_AUDIO_CONFIG audioConfig = parseAudioConfig( inFormatStr, &srRtp ); @@ -331,7 +334,7 @@ static bool parseInConfig( /* Default case covers formats that are defined in the AUDIO_CONFIG enum, * but cannot be used at input, e.g. BINAURAL */ const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats ); - fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); + fprintf( stderr, "Error: Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); return false; } } @@ -405,50 +408,6 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( } -static bool checkRequiredArgs( - CmdlnArgs args ) -{ - const CmdLnParser_Option *tmpOption; - - /* Check required arguments */ - bool missingRequiredArg = false; - if ( isEmptyString( args.inputFilePath ) ) - { - tmpOption = findOptionById( CmdLnOptionId_inputFile ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - - const bool singleInputSpecified = ( args.inConfig.numBinBuses != 0 ); - - if ( !args.sceneDescriptionInput && !singleInputSpecified ) - { - /* Neither scene description input nor single-type input was specified on command line */ - tmpOption = findOptionById( CmdLnOptionId_inputFormat ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - if ( isEmptyString( args.outputFilePath ) ) - { - tmpOption = findOptionById( CmdLnOptionId_outputFile ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - if ( args.sampleRate == 0 ) - { - tmpOption = findOptionById( CmdLnOptionId_sampleRate ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - if ( missingRequiredArg ) - { - CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions ); - } - - return !missingRequiredArg; -} - - static CmdlnArgs defaultArgs( const char *executableName ) { @@ -461,20 +420,21 @@ static CmdlnArgs defaultArgs( args.sampleRate = 0; - args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; + args.inConfig.numBinBuses = 0; + args.inConfig.binBuses[0].srRtp = false; + args.inConfig.binBuses[0].audioConfig = IVAS_AUDIO_CONFIG_INVALID; + args.inConfig.binBuses[0].inputChannelIndex = 0; + args.inConfig.binBuses[0].gain_dB = 0; - for ( int32_t i = 0; i < RENDERER_MAX_ISAR_MD_INPUTS; ++i ) - { - clearString( args.inMetadataFilePaths[i] ); - } - args.numInMetadataFiles = 0; + args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; + clearString( args.inMetadataFilePath ); clearString( args.headRotationFilePath ); clearString( args.splitRendBFIFilePath ); + args.complexityLevel = ISAR_POST_REND_COMPLEXITY_LEVEL_THREE; args.delayCompensationEnabled = true; args.quietModeEnabled = false; - args.sceneDescriptionInput = false; args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; @@ -482,7 +442,7 @@ static CmdlnArgs defaultArgs( } -static void parseOption( +static int16_t parseOption( const int32_t optionId, char **optionValues, const int16_t numOptionValues, @@ -493,88 +453,177 @@ static void parseOption( switch ( optionId ) { case CmdLnOptionId_listFormats: - assert( numOptionValues == 0 ); printSupportedAudioConfigs(); exit( 0 ); case CmdLnOptionId_inputFile: - assert( numOptionValues == 1 ); + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: No input file has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a single input file, but %d have been provided!\n", numOptionValues ); + return -1; + } strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_inputFormat: - assert( numOptionValues == 1 ); - if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) ) + if ( numOptionValues == 0 ) { - exit( -1 ); /* Error printout handled by failing function */ + fprintf( stderr, "Error: No input file format has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a single input file format, but %d have been provided!\n", numOptionValues ); + return -1; + } + + if ( !parseInConfig( optionValues[0], &args->inConfig ) ) + { + /* Error printout handled by failing function */ + return -1; } break; case CmdLnOptionId_inputMetadata: - assert( numOptionValues <= RENDERER_MAX_ISAR_MD_INPUTS ); - for ( int16_t i = 0; i < numOptionValues; ++i ) + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: No input metadata file for BINAURAL_SPLIT_PCM mode has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) { - strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + fprintf( stderr, "Error: The program expects a single input metadata file, but %d have been provided!\n", numOptionValues ); + return -1; } - args->numInMetadataFiles = numOptionValues; + strncpy( args->inMetadataFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_outputFile: - assert( numOptionValues == 1 ); + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: No output file has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a single output file, but %d have been provided!\n", numOptionValues ); + return -1; + } strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_sampleRate: - assert( numOptionValues == 1 ); args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 ); if ( args->sampleRate == 0 ) { - fprintf( stderr, "Invalid sampling rate specified\n" ); - exit( -1 ); + fprintf( stderr, "Error: Invalid sampling rate specified\n" ); + return -1; } break; case CmdLnOptionId_trajFile: - assert( numOptionValues == 1 ); + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: No head rotation trajectory file has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a single head rotation trajectory file, but %d have been provided!\n", numOptionValues ); + return -1; + } strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_SplitRendBFIFile: - assert( numOptionValues == 1 ); + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: No BFI file has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a single BFI file, but %d have been provided!\n", numOptionValues ); + return -1; + } strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_complexityLevel: - assert( numOptionValues == 1 ); + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: No complexity level has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a single complexity level, but %d have been provided!\n", numOptionValues ); + return -1; + } args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) { - fprintf( stdout, "Invalid complexity level specified.\n" ); - exit( -1 ); + fprintf( stderr, "Error: Invalid complexity level specified.\n" ); + return -1; } else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) { - fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); + fprintf( stderr, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); } break; case CmdLnOptionId_noDelayCmp: - assert( numOptionValues == 0 ); + if ( numOptionValues != 0 ) + { + fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match ); + return -1; + } args->delayCompensationEnabled = false; break; case CmdLnOptionId_quietModeEnabled: - assert( numOptionValues == 0 ); + if ( numOptionValues != 0 ) + { + fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match ); + return -1; + } args->quietModeEnabled = true; break; case CmdLnOptionId_framing: - assert( numOptionValues == 1 ); + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: Incorrect audio rendering frame size!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a rendering frame size, but %d have been provided!\n", numOptionValues ); + return -1; + } if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) { - fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); - exit( -1 ); + fprintf( stderr, "Error: Unknown or invalid option for audio rendring frame size: %s\n", optionValues[0] ); + return -1; } break; case CmdLnOptionId_srParamsFile: - assert( numOptionValues == 1 ); + if ( numOptionValues == 0 ) + { + fprintf( stderr, "Error: No path to the parameter initialization file has been provided!\n" ); + return -1; + } + else if ( numOptionValues > 1 ) + { + fprintf( stderr, "Error: The program expects a single parameter initialization file, but %d have been provided!\n", numOptionValues ); + return -1; + } strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; + case CmdLnOptionId_help: + CmdLnParser_printUsage( args->executableName, cliOptions, numCliOptions ); + exit( 0 ); default: - assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); + fprintf( stderr, "Error: Incorrect or invalid command-line usage!\n" ); + return -1; break; } - return; + return 0; } @@ -589,11 +638,6 @@ static CmdlnArgs parseCmdlnArgs( exit( -1 ); /* Error printout handled by failing function */ } - if ( !checkRequiredArgs( args ) ) - { - exit( -1 ); /* Error printout handled by failing function */ - } - return args; } @@ -602,13 +646,12 @@ static void printSupportedAudioConfigs( void ) { uint16_t i; const char *supportedFormats[] = { - "BINAURAL (output only)", "BINAURAL_SPLIT_PCM", "BINAURAL_SPLIT_CODED", "RTPDUMP", }; - fprintf( stdout, "Supported audio formats:\n" ); + fprintf( stdout, "Supported audio formats:\n\n" ); for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ ) { fprintf( stdout, "%s\n", supportedFormats[i] ); @@ -876,7 +919,6 @@ int main( convert_backslash( args.inputFilePath ); convert_backslash( args.outputFilePath ); - convert_backslash( args.headRotationFilePath ); convert_backslash( args.srParamsFilePath ); /*------------------------------------------------------------------------------------------* @@ -885,6 +927,7 @@ int main( if ( !isEmptyString( args.headRotationFilePath ) ) { + convert_backslash( args.headRotationFilePath ); if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError opening file: %s\n", args.headRotationFilePath ); @@ -899,7 +942,11 @@ int main( if ( !isEmptyString( args.splitRendBFIFilePath ) ) { convert_backslash( args.splitRendBFIFilePath ); - SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); + if ( SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError opening file: %s\n", args.splitRendBFIFilePath ); + goto cleanup; + } } int32_t inFileSampleRate = 0; @@ -908,7 +955,7 @@ int main( if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { error = split_rend_reader_open( &hSplitRendFileReadWrite, - args.inMetadataFilePaths[0], + args.inMetadataFilePath, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, @@ -917,13 +964,21 @@ int main( &bitsBuffer.config.lc3plusHighRes ); if ( error != IVAS_ERR_OK ) { - fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.inMetadataFilePaths[0] ); + if ( isEmptyString( args.inMetadataFilePath ) ) + { + const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_inputMetadata ); + fprintf( stderr, "\nError: Split rendering metadata file not specified, use option -%s/--%s.\n", listOption->matchShort, listOption->match ); + } + else + { + fprintf( stderr, "\nError: Could not open split rendering metadata file %s!\n", args.inMetadataFilePath ); + } goto cleanup; } if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError opening file: %s\n", audioFilePath ); + fprintf( stderr, "\nError: Could not open input file: %s!\n", audioFilePath ); goto cleanup; } } @@ -939,13 +994,13 @@ int main( &bitsBuffer.config.lc3plusHighRes ); if ( error != IVAS_ERR_OK ) { - fprintf( stderr, "\nCould not open split rend params file %s\n", args.srParamsFilePath ); + fprintf( stderr, "\nError: Could not open split rendering init params file %s!\n", args.srParamsFilePath ); goto cleanup; } if ( ( error = IVAS_RTP_READER_Init( &srRTP, args.inputFilePath, NULL, false, NULL ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error ); + fprintf( stderr, "\nError in IVAS_RTP_READER_Init(), error code: %d!\n", error ); goto cleanup; } audioReader = NULL; @@ -966,7 +1021,7 @@ int main( &bitsBuffer.config.lc3plusHighRes ); if ( error != IVAS_ERR_OK ) { - fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.inputFilePath ); + fprintf( stderr, "\nError reading input file %s, error code: %d!\n", args.inputFilePath, error ); goto cleanup; } audioReader = NULL; @@ -992,14 +1047,14 @@ int main( /* else if sampling rate given on command line, compare with wav file */ else if ( inFileSampleRate != args.sampleRate ) { - fprintf( stderr, "\nSampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); + fprintf( stderr, "\nError: Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s!\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); goto cleanup; } break; case IVAS_ERR_SAMPLING_RATE_UNKNOWN: /* Returned when input is raw PCM */ if ( args.sampleRate == 0 ) { - fprintf( stderr, "\nSampling rate must be specified on command line when using raw PCM input\n" ); + fprintf( stderr, "\nError: Sampling rate must be specified on command line in case of raw PCM input!\n" ); goto cleanup; } break; @@ -1014,7 +1069,7 @@ int main( error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN ) { - fprintf( stderr, "\nAudioFileReader_getNumChannels failed: %s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "\nError: AudioFileReader_getNumChannels() failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } } @@ -1242,34 +1297,44 @@ int main( /* Convert from int to float and from interleaved to packed */ convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer_fx ); *inBuffer.pq_fact = 0; - int16_t num_subframes, sf_idx; + int16_t num_subframes; num_subframes = (int16_t) args.render_framesize; /* Read from head rotation trajectory file if specified */ + IVAS_QUATERNION headRot[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; if ( headRotReader != NULL ) { - for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + for ( i = 0; i < num_subframes; i++ ) { - IVAS_QUATERNION headRot; - IVAS_VECTOR3 Pos; - - IF( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK ) + if( ( error = HeadRotationFileReading( headRotReader, &headRot[i], &Pos[i] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); goto cleanup; } - - if ( ( error = ISAR_POST_REND_SetHeadRotation( hIsarPostRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError setting Head Rotation: %s\n", ivas_error_to_string( error ) ); - goto cleanup; - } } } else { - fprintf( stderr, "\nHead Rotation should be enabled in post renderer\n" ); - goto cleanup; + for ( i = 0; i < num_subframes; i++ ) + { + headRot[i].w = -3.0f; + headRot[i].x = 0.0f; + headRot[i].y = 0.0f; + headRot[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; + } + } + + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = ISAR_POST_REND_SetHeadRotation( hIsarPostRend, headRot[i], Pos[i], DEFAULT_AXIS, i ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError setting Head Rotation: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } } /* Read from split renderer bfi file if specified */ diff --git a/apps/renderer.c b/apps/renderer.c index c494ee0f1..51fda9b11 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -242,48 +242,60 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputFile, .match = "input_file", .matchShort = "i", + .placeholder = "", .description = "Path to the input file (WAV, raw PCM or scene description file)", + .isMandatory = true, }, { .id = CmdLnOptionId_inputFormat, .match = "input_format", .matchShort = "if", + .placeholder = "", .description = "Audio format of input file (e.g. 5_1 or HOA3 or META,\nuse -l for a list)", + .isMandatory = true, }, { .id = CmdLnOptionId_inputMetadata, .match = "input_metadata", .matchShort = "im", + .placeholder = " [...]", .description = "Space-separated list of path to metadata files for ISM/MASA/OMASA/\nOSBA/BINAURAL_SPLIT_PCM inputs. \nFor OMASA, ISM files must be specified first.", }, { .id = CmdLnOptionId_outputFile, .match = "output_file", .matchShort = "o", + .placeholder = "", .description = "Path to the output file", + .isMandatory = true, }, { .id = CmdLnOptionId_outputFormat, .match = "output_format", .matchShort = "of", + .placeholder = "", .description = "Output format to render.\nAlternatively, can be a custom loudspeaker layout file", + .isMandatory = true, }, { .id = CmdLnOptionId_sampleRate, .match = "sample_rate", .matchShort = "fs", + .placeholder = "", .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw\nPCM inputs", }, { .id = CmdLnOptionId_trajFile, .match = "trajectory_file", .matchShort = "T", + .placeholder = "", .description = "Head rotation trajectory file for simulation of head tracking\n(only for binaural outputs)", }, { .id = CmdLnOptionId_outputMetadata, .match = "output_metadata", .matchShort = "om", + .placeholder = "", .description = "coded metadata file for BINAURAL_SPLIT_PCM output mode", }, #ifndef FIX_1494_SET_SPLITBFI_UNUSED @@ -291,6 +303,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_SplitRendBFIFile, .match = "post_rend_bfi_file", .matchShort = "prbfi", + .placeholder = "", .description = "Split rendering option: bfi file", }, #endif @@ -298,42 +311,49 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", .matchShort = "rf", + .placeholder = "", .description = "Reference rotation trajectory file for simulation of head tracking\n(only for binaural outputs)", }, { .id = CmdLnOptionId_customHrtfFile, .match = "custom_hrtf", .matchShort = "hrtf", + .placeholder = "", .description = "Custom HRTF file for binaural rendering\n(only for binaural outputs)", }, { .id = CmdLnOptionId_renderConfigFile, .match = "render_config_parameters", .matchShort = "render_config", + .placeholder = "", .description = "Binaural renderer configuration parameters in file\n(only for binaural outputs)", }, { .id = CmdLnOptionId_nonDiegeticPan, .match = "non_diegetic_panning", .matchShort = "non_diegetic_pan", + .placeholder = "", .description = "Panning mono non diegetic sound to stereo -90<= pan <= 90\nleft or l or 90->left, right or r or -90->right,\ncenter or c or 0 ->middle", }, { .id = CmdLnOptionId_orientationTracking, .match = "tracking_type", .matchShort = "otr", + .placeholder = "", .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec`\nor `ref_vec_lev` (only for binaural outputs)", }, { .id = CmdlnOptionId_lfePosition, .match = "lfe_position", .matchShort = "lp", + .placeholder = ",,", .description = "Output LFE position. Comma-delimited triplet of [gain, azimuth,\nelevation] where gain is linear (like --gain, -g) and azimuth,\nelevation are in degrees. If specified, overrides the default\nbehavior which attempts to map input to output LFE channel(s)", }, { .id = CmdlnOptionId_lfeMatrix, .match = "lfe_matrix", .matchShort = "lm", + .placeholder = "", .description = "LFE panning matrix. File (CSV table) containing a matrix of\ndimensions [ num_input_lfe x num_output_channels ] with elements\nspecifying linear routing gain (like --gain, -g). If specified,\noverrides the output LFE position option and the default\nbehavior which attempts to map input to output LFE channel(s)", }, { @@ -346,6 +366,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_complexityLevel, .match = "complexity_level", .matchShort = "level", + .placeholder = "", .description = "Complexity level, level = (1, 2, 3), will be defined after\ncharacterisation.", }, { @@ -358,6 +379,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputGain, .match = "gain", .matchShort = "g", + .placeholder = "", .description = "Input gain (linear, not in dB) to be applied to input audio file", }, { @@ -370,43 +392,50 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_referenceVectorFile, .match = "reference_vector_file", .matchShort = "rvf", + .placeholder = "", .description = "Reference vector trajectory file for simulation of head tracking\n(only for binaural outputs)", }, { .id = CmdLnOptionId_exteriorOrientationFile, .match = "exterior_orientation_file", .matchShort = "exof", + .placeholder = "", .description = "External orientation trajectory file for simulation of external\norientations", }, { .id = CmdLnOptionId_framing, .match = "framing", .matchShort = "fr", - .description = "Set Render audio framing.", + .placeholder = "", + .description = "Set render audio framing in ms", }, { .id = CmdLnOptionId_syncMdDelay, .match = "sync_md_delay", .matchShort = "smd", + .placeholder = "", .description = "Metadata Synchronization Delay in ms, Default is 0. Quantized by\n5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes)", }, { .id = CmdLnOptionId_directivityPatternId, .match = "ism_directivity_pattern_id", .matchShort = "dpid", + .placeholder = " [...]", .description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated\nlist of up to 4 numbers (unsigned integers) can be specified for\nBINAURAL and BINAURAL_ROOM_REVERB output.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for\nISMs 1,2,3 and 4 respectively. \nThis option needs to be accompanied by a render_config file,\notherwise a default directivity pattern is used.", }, { .id = CmdLnOptionId_acousticEnvironmentId, .match = "acoustic_environment_id", .matchShort = "aeid", + .placeholder = "", .description = "Acoustic environment ID (number > 0) alternatively, it can be a text file where each line contains \"ID duration\" for BINAURAL_ROOM_REVERB output configuration.", }, { .id = CmdLnOptionId_roomSize, .match = "room_size", .matchShort = "rsz", - .description = "Selects default reverb based on a room size (S - small | M - medium | L - large)", + .placeholder = "", + .description = "Selects default reverb based on a room size (S - small |\nM - medium | L - large)", } }; @@ -1559,7 +1588,7 @@ int main( if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, outFile, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nCould not open split rend metadata file %s\n", outFile ); + fprintf( stderr, "\nError: Could not open split rend metadata file %s!\n", outFile ); goto cleanup; } } @@ -2716,53 +2745,6 @@ static bool parseReverbRoomSize( return true; } - -static bool checkRequiredArgs( - CmdlnArgs args ) -{ - const CmdLnParser_Option *tmpOption; - - /* Check required arguments */ - bool missingRequiredArg = false; - if ( isEmptyString( args.inputFilePath ) ) - { - tmpOption = findOptionById( CmdLnOptionId_inputFile ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - - const bool singleInputSpecified = args.inConfig.numAudioObjects != 0 || - args.inConfig.numAmbisonicsBuses != 0 || - args.inConfig.numMultiChannelBuses != 0 || - args.inConfig.numMasaBuses != 0; - - if ( !args.sceneDescriptionInput && !singleInputSpecified ) - { - /* Neither scene description input nor single-type input was specified on command line */ - tmpOption = findOptionById( CmdLnOptionId_inputFormat ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - if ( isEmptyString( args.outputFilePath ) ) - { - tmpOption = findOptionById( CmdLnOptionId_outputFile ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_INVALID ) - { - tmpOption = findOptionById( CmdLnOptionId_outputFormat ); - fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); - missingRequiredArg = true; - } - if ( missingRequiredArg ) - { - CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions ); - } - - return !missingRequiredArg; -} - static CmdlnArgs defaultArgs( const char *executableName ) { @@ -2844,7 +2826,7 @@ static CmdlnArgs defaultArgs( return args; } -static void parseOption( +static int16_t parseOption( const int32_t optionId, char **optionValues, const int16_t numOptionValues, @@ -3036,7 +3018,7 @@ static void parseOption( break; } - return; + return 0; } static CmdlnArgs parseCmdlnArgs( @@ -3050,11 +3032,6 @@ static CmdlnArgs parseCmdlnArgs( exit( -1 ); /* Error printout handled by failing function */ } - if ( !checkRequiredArgs( args ) ) - { - exit( -1 ); /* Error printout handled by failing function */ - } - if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { args.Opt_Headrotation = 1; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c20a69451..0787634b1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -622,6 +622,12 @@ ivas_error IVAS_DEC_Configure( move16(); move16(); + IF ( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hDecoderConfig->Opt_Headrotation = 1; + move16(); + } + IF( EQ_16( renderFramesize, IVAS_RENDER_FRAMESIZE_UNKNOWN ) ) { return IVAS_ERR_WRONG_PARAMS; diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index ba22fba6a..5e5b62082 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -41,7 +41,6 @@ * ISAR post-renderer constants *---------------------------------------------------------------------*/ -#define RENDERER_MAX_ISAR_MD_INPUTS 1 #define RENDERER_MAX_BIN_INPUTS 1 /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 95a225aba..0377c6984 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -615,11 +615,11 @@ ivas_error get_channel_config( } ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { - strcpy( (char *) str, "BINAURAL_SPLIT_CODED" ); + strcpy( (char *) str, "Binaural: split-rendering mode using encoded data" ); } ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - strcpy( (char *) str, "Binaural_Split_PCM" ); + strcpy( (char *) str, "Binaural: split-rendering mode using PCM data" ); } ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index 945bda07d..db848c124 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -226,3 +226,29 @@ bool isEmptyString( { return str[0] == '\0'; } + + + +/*---------------------------------------------------------------------* + * strLength() + * + * Get the length of a string up to a maximum length. + * + * Equivalent to strnlen, which is not part of the C standard and only provided by POSIX. + * + *---------------------------------------------------------------------*/ + +int32_t strLength( + const char *str, + int32_t maxlen ) +{ + int32_t len; + + len = 0; + while ( len < maxlen && str[len] != '\0' ) + { + len++; + } + + return len; +} diff --git a/lib_util/cmdl_tools.h b/lib_util/cmdl_tools.h index 327acb93d..b331dea03 100644 --- a/lib_util/cmdl_tools.h +++ b/lib_util/cmdl_tools.h @@ -50,4 +50,6 @@ void clearString( char *str ); bool isEmptyString( const char *str ); +int32_t strLength( const char *str, int32_t maxlen ); + #endif /* CMDL_TOOLS_H */ diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c index 1b9eb7a92..561643864 100644 --- a/lib_util/cmdln_parser.c +++ b/lib_util/cmdln_parser.c @@ -36,19 +36,30 @@ #include #include #include +#include +#include -#define MAX_SUPPORTED_OPTS ( 1024 ) -#define MAX_OPTION_LENGTH ( 1024 ) +#define MAX_SUPPORTED_OPTS ( 1024 ) +#define MAX_OPTION_MATCH_LENGTH ( 30 ) +#define MAX_OPTION_LENGTH ( MAX_OPTION_MATCH_LENGTH + 2 ) typedef CmdLnParser_Option OptionProps; typedef struct { OptionProps props; - int8_t hasBeenParsed; + bool hasBeenParsed; } Option; -static int16_t validateNoDuplicateIds( +/* Error enum for internal use */ +typedef enum +{ + CMDLN_PARSER_ERR_OK = 0, + CMDLN_PARSER_ERR_FAILED_PARSING = -1, + CMDLN_PARSER_ERR_MISCONFIGURED = -2, +} CmdLnParserError; + +static CmdLnParserError validateNoDuplicateIds( const OptionProps *props, int32_t numOpts ) { @@ -59,121 +70,136 @@ static int16_t validateNoDuplicateIds( if ( props[i].id == props[j].id ) { fprintf( stderr, "[dev] Duplicate ID == %d between options %s and %s\n", props[i].id, props[i].match, props[j].match ); - return -1; + return CMDLN_PARSER_ERR_MISCONFIGURED; } } } - return 0; + return CMDLN_PARSER_ERR_OK; } -static int16_t validateOptionProps( +static CmdLnParserError validateOptionProps( OptionProps props ) { /* Check required properties */ if ( props.match == NULL ) { - /* TODO(sgi): Don't print out usage after this - props.match is used there */ - fprintf( stderr, "[dev] Option with ID == %d - missing required property \"match\"\n", props.id ); - return -1; + fprintf( stderr, "[dev] Option with ID %d - missing required property \"match\"\n", props.id ); + return CMDLN_PARSER_ERR_MISCONFIGURED; } if ( props.id == 0 ) { fprintf( stderr, "[dev] Invalid ID for option %s. ID == %d is reserved.\n", props.match, props.id ); - return -1; + return CMDLN_PARSER_ERR_MISCONFIGURED; } - return 0; + /* Check match string length */ + if ( strLength( props.match, MAX_OPTION_MATCH_LENGTH + 1 ) > MAX_OPTION_MATCH_LENGTH ) + { + fprintf( stderr, "[dev] Option with ID %d - match string exceeds limit of %d characters.\n", props.id, MAX_OPTION_MATCH_LENGTH ); + return CMDLN_PARSER_ERR_MISCONFIGURED; + } + if ( props.matchShort != NULL && strLength( props.matchShort, MAX_OPTION_MATCH_LENGTH + 1 ) > MAX_OPTION_MATCH_LENGTH ) + { + fprintf( stderr, "[dev] Option with ID %d - matchShort string exceeds limit of %d characters.\n", props.id, MAX_OPTION_MATCH_LENGTH ); + return CMDLN_PARSER_ERR_MISCONFIGURED; + } + + return CMDLN_PARSER_ERR_OK; } /* Validate given OptionProps and use them to initialize array of Options */ -static int16_t initOpts( +static CmdLnParserError initOpts( const OptionProps *options, const int32_t numOpts, Option *opts ) { + CmdLnParserError error; + + if ( numOpts > MAX_SUPPORTED_OPTS ) + { + fprintf( stderr, "[dev] Number of defined options (%d) exceeds limit (%d).\n", numOpts, MAX_SUPPORTED_OPTS ); + return CMDLN_PARSER_ERR_MISCONFIGURED; + } + + /* Check for duplicate IDs */ + if ( ( error = validateNoDuplicateIds( options, numOpts ) ) != 0 ) + { + return error; + } + for ( int32_t i = 0; i < numOpts; ++i ) { - if ( validateOptionProps( options[i] ) != 0 ) + if ( ( error = validateOptionProps( options[i] ) ) != CMDLN_PARSER_ERR_OK ) { - return -1; + return error; } Option tmp = { - .hasBeenParsed = 0 + .hasBeenParsed = false }; tmp.props = options[i]; /* Cannot assign in aggregate initializer above - causes Visual Studio warning */ opts[i] = tmp; } - /* Check for duplicate IDs */ - if ( validateNoDuplicateIds( options, numOpts ) != 0 ) - { - return -1; - } - - return 0; -} - -static int8_t stringLooksLikeOption( - const char *str ) -{ - if ( ( str[0] == '-' ) && is_number( str ) == false ) - { - return 1; - } - return 0; } -static const char *stringToOptionName( +static bool stringLooksLikeOption( const char *str ) { - while ( ( *str == '-' ) && ( ( str[1] != '0' ) || ( str[1] != '1' ) ) ) + if ( ( str[0] == '-' ) && !is_number( str ) ) { - ++str; + return true; } - return str; + return false; } -static int8_t optionMatchesString( +static bool optionMatchesString( Option opt, const char *str ) { if ( !stringLooksLikeOption( str ) ) { - return 0; + return false; } - const char *optionName = stringToOptionName( str ); + if ( strLength( str, MAX_OPTION_LENGTH + 1 ) > MAX_OPTION_LENGTH ) + { + /* String longer than longest possible option - not a match */ + return false; + } - char optionName_to_upper[FILENAME_MAX]; - strncpy( optionName_to_upper, optionName, sizeof( optionName_to_upper ) - 1 ); - optionName_to_upper[sizeof( optionName_to_upper ) - 1] = '\0'; - to_upper( optionName_to_upper ); + char str_to_upper[MAX_OPTION_LENGTH + 1]; + snprintf( str_to_upper, sizeof( str_to_upper ), "%s", str ); + to_upper( str_to_upper ); - char match_to_upper[FILENAME_MAX]; - strncpy( match_to_upper, opt.props.match, sizeof( match_to_upper ) - 1 ); - optionName_to_upper[sizeof( match_to_upper ) - 1] = '\0'; + char match_to_upper[MAX_OPTION_LENGTH + 1]; + snprintf( match_to_upper, sizeof( match_to_upper ), "--%s", opt.props.match ); to_upper( match_to_upper ); + if ( strcmp( str_to_upper, match_to_upper ) == 0 ) + { + return true; + } - char matchShort_to_upper[FILENAME_MAX]; - strncpy( matchShort_to_upper, opt.props.matchShort, sizeof( matchShort_to_upper ) - 1 ); - optionName_to_upper[sizeof( matchShort_to_upper ) - 1] = '\0'; - to_upper( matchShort_to_upper ); - - if ( strncmp( optionName_to_upper, match_to_upper, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName_to_upper, matchShort_to_upper, MAX_OPTION_LENGTH ) == 0 ) + if ( opt.props.matchShort != NULL ) { - return 1; + snprintf( match_to_upper, sizeof( match_to_upper ), "-%s", opt.props.matchShort ); + to_upper( match_to_upper ); + + if ( strcmp( str_to_upper, match_to_upper ) == 0 ) + { + return true; + } } - return 0; + return false; } -static int16_t parseOpts( +static CmdLnParserError parseOpts( int32_t argc, char **argv, Option *opts, @@ -202,8 +228,14 @@ static int16_t parseOpts( /* Check if already parsed */ if ( optToMatch->hasBeenParsed ) { - fprintf( stderr, "Duplicate option: %s (%s)\n", optToMatch->props.match, optToMatch->props.matchShort ); - return -1; + fprintf( stderr, "Duplicate option provided: --%s", optToMatch->props.match ); + if ( optToMatch->props.matchShort != NULL ) + { + fprintf( stderr, "/-%s", optToMatch->props.matchShort ); + } + fprintf( stderr, "\n" ); + + return CMDLN_PARSER_ERR_FAILED_PARSING; } break; @@ -216,8 +248,8 @@ static int16_t parseOpts( /* Invalid option */ if ( stringLooksLikeOption( argv[argIdx] ) ) { - fprintf( stderr, "Unknown option `%s`\n", stringToOptionName( argv[argIdx] ) ); - return -1; + fprintf( stderr, "Unknown option `%s`\n", argv[argIdx] ); + return CMDLN_PARSER_ERR_FAILED_PARSING; } /* Otherwise, value following current option. @@ -229,7 +261,7 @@ static int16_t parseOpts( else { fprintf( stderr, "Unexpected token `%s`\n", argv[argIdx] ); - return -1; + return CMDLN_PARSER_ERR_FAILED_PARSING; } } @@ -238,8 +270,11 @@ static int16_t parseOpts( { if ( currOpt != NULL ) { - parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ); - currOpt->hasBeenParsed = 1; + if ( parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ) != 0 ) + { + return CMDLN_PARSER_ERR_FAILED_PARSING; + } + currOpt->hasBeenParsed = true; } currOpt = nextOpt; @@ -253,11 +288,37 @@ static int16_t parseOpts( /* Parse last option */ if ( currOpt != NULL ) { - parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ); - currOpt->hasBeenParsed = 1; + if ( parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ) != 0 ) + { + return CMDLN_PARSER_ERR_FAILED_PARSING; + } + currOpt->hasBeenParsed = true; } - return 0; + /* Check mandatory options */ + bool missingMandatory = false; + for ( int32_t optIdx = 0; optIdx < numOpts; ++optIdx ) + { + Option opt = opts[optIdx]; + + if ( opt.props.isMandatory && !opt.hasBeenParsed ) + { + fprintf( stderr, "Missing mandatory parameter: --%s", opt.props.match ); + if ( opt.props.matchShort != NULL ) + { + fprintf( stderr, "/-%s", opt.props.matchShort ); + } + fprintf( stderr, "\n" ); + + missingMandatory = true; + } + } + if ( missingMandatory ) + { + return CMDLN_PARSER_ERR_FAILED_PARSING; + } + + return CMDLN_PARSER_ERR_OK; } static const char *getBasename( @@ -281,19 +342,22 @@ static const char *getBasename( return path; } -static int32_t totalOptionNameLength( +static int32_t totalNumOptChars( const OptionProps opt ) { - return (int32_t) ( strlen( opt.match ) + strlen( opt.matchShort ) ); -} + int32_t len = (int32_t) strlen( opt.match ); -static void printWhitespace( - const int32_t n ) -{ - for ( int32_t i = 0; i < n; ++i ) + if ( opt.matchShort != NULL ) + { + len += (int32_t) strlen( opt.matchShort ); + } + + if ( opt.placeholder != NULL ) { - fprintf( stderr, " " ); + len += (int32_t) strlen( opt.placeholder ); } + + return len; } static void printOptDescriptionAligned( @@ -317,7 +381,7 @@ static void printOptDescriptionAligned( fprintf( stderr, "%c", *descPtr ); if ( *descPtr == '\n' ) { - printWhitespace( descriptionColumnIdx ); + fprintf( stderr, "%*s", descriptionColumnIdx, "" ); } ++descPtr; } @@ -325,41 +389,114 @@ static void printOptDescriptionAligned( return; } +static void printOptions( + const OptionProps *optionProps, + const int32_t numOptions, + const bool mandatory, + const int32_t maxNumOptChars ) +{ + const int32_t descriptionColumnIdx = maxNumOptChars + 11 /* Additional chars we will print in the options column */; + int32_t numOptChars; + + for ( int32_t i = 0; i < numOptions; ++i ) + { + OptionProps opt = optionProps[i]; + + if ( opt.isMandatory != mandatory ) + { + continue; + } + + numOptChars = totalNumOptChars( optionProps[i] ); + + fprintf( stderr, " --%s", opt.match ); + numOptChars += 4; + + if ( opt.matchShort != NULL ) + { + fprintf( stderr, ", -%s", opt.matchShort ); + numOptChars += 3; + } + + if ( opt.placeholder != NULL ) + { + fprintf( stderr, " %s", opt.placeholder ); + numOptChars += 1; + } + + if ( opt.description != NULL ) + { + /* Done printing options column, fill with whitespace until description column */ + fprintf( stderr, "%*s", descriptionColumnIdx - numOptChars, ": " ); + printOptDescriptionAligned( opt.description, descriptionColumnIdx ); + } + else + { + fprintf( stderr, "\n" ); + } + } +} + static void printUsage( const char *argv0, const OptionProps *optionProps, const int32_t numOptions ) { - fprintf( stderr, "\n" ); - fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) ); - fprintf( stderr, "\n" ); - fprintf( stderr, "Valid options:\n" ); - - /* Find option with longest name, used for pretty formatting */ - int32_t maxOptNameLength = 0; + int32_t numOptChars; + int32_t maxNumOptChars = 0; + bool hasMandatoryOptions = false; for ( int32_t i = 0; i < numOptions; ++i ) { - const int32_t optNameLength = totalOptionNameLength( optionProps[i] ); - if ( maxOptNameLength < optNameLength ) + /* Find option with most characters when printed, used for pretty formatting */ + numOptChars = totalNumOptChars( optionProps[i] ); + if ( maxNumOptChars < numOptChars ) { - maxOptNameLength = optNameLength; + maxNumOptChars = numOptChars; + } + + /* Check if mandatory parameters should be printed separately */ + if ( optionProps[i].isMandatory ) + { + hasMandatoryOptions = true; } } - const int32_t preDescriptionWhitespace = 8; - const int32_t leftColumnAdditionalChars = 7; + fprintf( stderr, "\n" ); + fprintf( stderr, "Usage: %s [options]", getBasename( argv0 ) ); for ( int32_t i = 0; i < numOptions; ++i ) { OptionProps opt = optionProps[i]; - const int32_t optNameLength = totalOptionNameLength( optionProps[i] ); - /* TODO(sgi): make matchShort optional */ - fprintf( stderr, " --%s, -%s", opt.match, opt.matchShort ); + if ( opt.isMandatory ) + { + if ( opt.matchShort != NULL ) + { + fprintf( stderr, " -%s", opt.matchShort ); + } + else + { + fprintf( stderr, " --%s", opt.match ); + } + + if ( opt.placeholder != NULL ) + { + fprintf( stderr, " %s", opt.placeholder ); + } + } + } - printWhitespace( maxOptNameLength - optNameLength + preDescriptionWhitespace ); - printOptDescriptionAligned( opt.description, maxOptNameLength + preDescriptionWhitespace + leftColumnAdditionalChars ); + fprintf( stderr, "\n\n" ); + + if ( hasMandatoryOptions ) + { + fprintf( stderr, "Mandatory parameters:\n---------------------\n" ); + printOptions( optionProps, numOptions, true, maxNumOptChars ); + fprintf( stderr, "\n" ); } + fprintf( stderr, "Options:\n--------\n" ); + printOptions( optionProps, numOptions, false, maxNumOptChars ); + return; } @@ -371,34 +508,64 @@ int16_t CmdLnParser_parseArgs( void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ) { - assert( numOptions <= MAX_SUPPORTED_OPTS ); + CmdLnParserError error; /* Prepare option array */ Option opts[MAX_SUPPORTED_OPTS]; - if ( initOpts( optionProps, numOptions, opts ) != 0 ) + if ( ( error = initOpts( optionProps, numOptions, opts ) ) != CMDLN_PARSER_ERR_OK ) { goto fail; } /* Iterate over argv and parse */ - if ( parseOpts( argc, argv, opts, numOptions, pOutputStruct, parseOption ) != 0 ) + if ( ( error = parseOpts( argc, argv, opts, numOptions, pOutputStruct, parseOption ) ) != CMDLN_PARSER_ERR_OK ) { goto fail; } - return 0; - fail: - printUsage( argv[0], optionProps, numOptions ); - return -1; + switch ( error ) + { + case CMDLN_PARSER_ERR_OK: + break; + case CMDLN_PARSER_ERR_MISCONFIGURED: + fprintf( stderr, "CmdLnParser is misconfigured.\n" ); + break; + case CMDLN_PARSER_ERR_FAILED_PARSING: + printUsage( argv[0], optionProps, numOptions ); + break; + } + + return error; } -void CmdLnParser_printUsage( +int16_t CmdLnParser_printUsage( char *executableName, const CmdLnParser_Option *options, const int32_t numOptions ) { + CmdLnParserError error; + + /* Re-use initOpts for validation only */ + Option opts[MAX_SUPPORTED_OPTS]; + if ( ( error = initOpts( options, numOptions, opts ) ) != CMDLN_PARSER_ERR_OK ) + { + goto fail; + } + printUsage( executableName, options, numOptions ); - return; +fail: + switch ( error ) + { + case CMDLN_PARSER_ERR_OK: + break; + case CMDLN_PARSER_ERR_MISCONFIGURED: + fprintf( stderr, "CmdLnParser is misconfigured.\n" ); + break; + case CMDLN_PARSER_ERR_FAILED_PARSING: + break; + } + + return error; } diff --git a/lib_util/cmdln_parser.h b/lib_util/cmdln_parser.h index 2627d5566..c6848f79b 100644 --- a/lib_util/cmdln_parser.h +++ b/lib_util/cmdln_parser.h @@ -38,17 +38,21 @@ typedef struct { - int32_t id; - const char *match; - const char *matchShort; - const char *description; + int32_t id; /* Unique ID for the option */ + const char *match; /* String to match, e.g. "input" here will match "--input" on CLI */ + + /* Struct members below are optional and can be omitted in option definition. If omitted, C will implicitly set them to 0. */ + const char *matchShort; /* Short version of the string to match, e.g. "i" here will match "-i" on CLI */ + const char *placeholder; /* If not NULL, this will follow the match string in the usage printout, e.g. "" here will print "--input " on CLI */ + const char *description; /* Description of the option for the usage printout. May contain '\n' for line breaks. */ + bool isMandatory; /* Parsing will fail if an option with `isMandatory == true` is not given */ } CmdLnParser_Option; /* Function for parsing option values into an output struct, to be implemented by the user */ -typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct ); +typedef int16_t ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct ); int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ); -void CmdLnParser_printUsage( char *executableName, const CmdLnParser_Option *options, const int32_t numOptions ); +int16_t CmdLnParser_printUsage( char *executableName, const CmdLnParser_Option *options, const int32_t numOptions ); #endif /* CMDLN_PARSER_H */ diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 75fd30d88..637560e72 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -76,13 +76,13 @@ ivas_error split_rend_reader_open( if ( ( hSplitRendFileReadWrite = (SplitFileReadWrite *) malloc( sizeof( SplitFileReadWrite ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering writer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering reader\n" ) ); } hSplitRendFileReadWrite->file = fopen( filename, "rb" ); if ( hSplitRendFileReadWrite->file == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nCould not open split rend metadata file %s\n", filename ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nCould not open file %s\n", filename ) ); } header_len = strlen( header ); @@ -98,7 +98,7 @@ ivas_error split_rend_reader_open( if ( strncmp( header_read, header, header_len ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nError split rend bitstream main header mismatch\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nSplit rendering bitstream main header mismatch\n" ) ); } fread( &hSplitRendFileReadWrite->delay_ns, sizeof( uint32_t ), 1, hSplitRendFileReadWrite->file ); diff --git a/readme.txt b/readme.txt index f2c21eab2..6a602f135 100644 --- a/readme.txt +++ b/readme.txt @@ -385,16 +385,27 @@ Options: The usage of the "ISAR_post_rend" program is as follows: -------------------------------------------------------- -Usage: ISAR_post_rend [options] +Usage: ISAR_post_rend [options] -i -if -o + +Mandatory parameters: +--------------------- +-i File : Path to the input file (WAV or raw PCM file with BINAURAL_SPLIT_PCM input format or ISAR bitstream file with BINAURAL_SPLIT_CODED input format) +-if Format : Audio format of input file (e.g. BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, ... Use -l for a list) +-o File : Path to the output file Options: -------- --i File : Input File (input file is bitstream if format is BINAURAL_SPLIT_CODED, or PCM/WAV file if format is BINAURAL_SPLIT_PCM) --if Format : Input Format of input (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM) --im File : Coded metadata File for BINAURAL_SPLIT_PCM input format --o File : Output Audio File in BINAURAL format --fs : Input sampling rate in kHz (48) --prbfi File : BFI File +-im File : Path to the input metadata file for BINAURAL_SPLIT_PCM input format +-fs : Input sampling rate in kHz (16, 32, 48) - required only with raw PCM input files +-T File : Head rotation trajectory file for simulation of head tracking +-prbfi File : Split rendering BFI (Bad Frame Indicator) file +-no_delay_cmp : Turn off delay compensation +-level level : Complexity level (1, 2, 3) - will be defined after characterisation +-q : Quiet mode - limit printouts to terminal +-l : List supported audio formats of input file +-fr L : Render frame size in ms L=(5, 10, 20), default is 20 +-s File : Path to the split rendering init params file +-h : Show this help message and exit The usage of the "ambi_converter" program is as follows: -- GitLab From 79f0caccbef7f9b05abc409806bc895441179f87 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 13 Jan 2026 16:36:26 +0100 Subject: [PATCH 335/750] clang format --- apps/isar_post_rend.c | 2 +- lib_dec/lib_dec_fx.c | 2 +- lib_isar/lib_isar_post_rend.h | 2 +- lib_util/cmdl_tools.c | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index e6e45683b..759ababa9 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -1307,7 +1307,7 @@ int main( { for ( i = 0; i < num_subframes; i++ ) { - if( ( error = HeadRotationFileReading( headRotReader, &headRot[i], &Pos[i] ) ) != IVAS_ERR_OK ) + if ( ( error = HeadRotationFileReading( headRotReader, &headRot[i], &Pos[i] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); goto cleanup; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0787634b1..fcebfad5a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -622,7 +622,7 @@ ivas_error IVAS_DEC_Configure( move16(); move16(); - IF ( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { hDecoderConfig->Opt_Headrotation = 1; move16(); diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index 5e5b62082..7dc2a0fe2 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -41,7 +41,7 @@ * ISAR post-renderer constants *---------------------------------------------------------------------*/ -#define RENDERER_MAX_BIN_INPUTS 1 +#define RENDERER_MAX_BIN_INPUTS 1 /*---------------------------------------------------------------------* * ISAR post-renderer structures diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index db848c124..00e13b14d 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -228,7 +228,6 @@ bool isEmptyString( } - /*---------------------------------------------------------------------* * strLength() * -- GitLab From 86e58077827dcbf8a8ebc457d9df064ffc88d951 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 13 Jan 2026 13:50:10 -0500 Subject: [PATCH 336/750] fixes to make EVS BE --- lib_enc/sig_clas_fx.c | 19 ++++++++++++++++++- lib_enc/vad_fx.c | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 209319738..d62b35a3e 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -777,7 +777,9 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } - +#ifdef FIX_2334_HARM_CODER_MODIF + IF( NE_16( st->element_mode, EVS_MONO ) ) + { hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); test(); @@ -787,6 +789,21 @@ void coder_type_modif_fx( move16(); } } +#endif + } +#ifdef FIX_2334_HARM_CODER_MODIF + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + hSC_VBR->last_7k2_coder_type = st->coder_type; + move16(); + test(); + if ( st->localVAD == 0 && EQ_16( st->coder_type, UNVOICED ) ) + { + hSC_VBR->last_7k2_coder_type = GENERIC; + move16(); + } + } +#endif IF( st->element_mode == 0 ) { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 619452c50..dc2144f1e 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -746,7 +746,7 @@ Word16 wb_vad_fx( move16(); } #ifdef FIX_2334_HARM_CODER_MODIF - IF( st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ + IF( st_fx->Opt_SC_VBR || ( !st_fx->Opt_SC_VBR && st_fx->element_mode == EVS_MONO ) ) /* this keep 26.444 BE */ #else IF( 1 ) // st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ #endif -- GitLab From adaca3cdc36ce21302d2761bd74769a6730abadd Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 13 Jan 2026 13:53:07 -0500 Subject: [PATCH 337/750] fixes clang format --- lib_enc/sig_clas_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index d62b35a3e..d97cd8bc4 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -780,15 +780,15 @@ void coder_type_modif_fx( #ifdef FIX_2334_HARM_CODER_MODIF IF( NE_16( st->element_mode, EVS_MONO ) ) { - hSC_VBR->last_7k2_coder_type = st->coder_type; - move16(); - test(); - if ( st->localVAD == 0 && EQ_16( st->coder_type, UNVOICED ) ) - { - hSC_VBR->last_7k2_coder_type = GENERIC; + hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); + test(); + if ( st->localVAD == 0 && EQ_16( st->coder_type, UNVOICED ) ) + { + hSC_VBR->last_7k2_coder_type = GENERIC; + move16(); + } } - } #endif } #ifdef FIX_2334_HARM_CODER_MODIF -- GitLab From 032e1cfce9ba499615dfdf5b82b1ae1a0d9a3acb Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 09:41:39 +0100 Subject: [PATCH 338/750] fix FIX_2302_LSF_CDBK_THRESHOLD --- lib_com/options.h | 1 + lib_enc/lsf_enc_fx.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..302890e14 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,6 +145,7 @@ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ +#define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 4fc0777c7..bd9ae96d4 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -1585,10 +1585,12 @@ void lsf_end_enc_ivas_fx( #else abs_threshold = SFNETLOWLIMIT_NB / 2; #endif - move32(); } ELSE { +#ifdef FIX_2302_LSF_CDBK_THRESHOLD + abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); +#else abs_threshold = SFNETLOWLIMIT_WB / 2; move32(); #ifdef HARM_LSF_ENC @@ -1596,6 +1598,7 @@ void lsf_end_enc_ivas_fx( { abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); } +#endif #endif } @@ -2638,12 +2641,12 @@ static Word32 vq_lvq_lsf_enc( diff[j] = shl_sat( diff[j], 4 ); move16(); } - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */ FOR( j = 1; j < M; j++ ) { - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */ } - e[i] = L_tmp; /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ + e[i] = L_tmp; /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */ move32(); } @@ -2757,10 +2760,10 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( diff[j] = shl_sat( diff[j], 4 ); move16(); } - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */ FOR( j = 1; j < M; j++ ) { - L_tmp = L_mac_sat( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ + L_tmp = L_mac_sat( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */ } e[i] = L_tmp; move32(); -- GitLab From 8fc1f4eadff7717cd17bc091d64805427ae014b8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 10:12:56 +0100 Subject: [PATCH 339/750] formatting --- lib_com/gs_gains_fx.c | 36 +++++++++++++++++++++++++++--------- lib_com/gs_preech_fx.c | 2 +- lib_com/options.h | 5 +++-- lib_com/prot_fx.h | 2 ++ lib_dec/gs_dec_fx.c | 3 +++ lib_enc/gs_enc_fx.c | 12 ++++++++---- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index c447c6208..f77c8442a 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -405,6 +405,7 @@ static void GSC_gain_adj( Fac_div = 102; move16(); #endif + #ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) @@ -428,6 +429,7 @@ static void GSC_gain_adj( { Gain_off = 0; move16(); + #ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ @@ -1140,17 +1142,19 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ + #ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ #else -Word16 gsc_gaindec_fx( /* o : average frequency gain */ +/*! r: average frequency gain */ +Word16 gsc_gaindec_fx( #endif - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ + const Word32 core_brate_fx, /* i : core used */ + Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth_fx /* i : input signal bandwidth */ ) { Word16 idx_g_fx, i; @@ -1158,6 +1162,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ Word16 Mbands_gn = MBANDS_GN; move16(); Word16 y_gain_tmp3_fx[MBANDS_GN]; + if ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { Mbands_gn = MBANDS_GN16k; @@ -1224,6 +1229,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ /*--------------------------------------------------------------------------------------* * UQ of the first 8 bands and half of the last 8 bands *--------------------------------------------------------------------------------------*/ + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); @@ -1254,9 +1260,11 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ move16(); } + /*----------------------------------------------------------------------* * Copy the true Q values in the specific bands *----------------------------------------------------------------------*/ + y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/ move16(); y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/ @@ -1301,6 +1309,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ } } } + #ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) @@ -1316,6 +1325,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ #else GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); #endif + return mean_4g_fx; } @@ -1325,6 +1335,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ * * Quantization of the energy per band *-------------------------------------------------------------------*/ + #ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -1375,11 +1386,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); } #endif + test(); test(); IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) ) { - /*ftmp1 = mean(y_gain4, 10)-0.6f;*/ L_tmp = L_deposit_l( 0 ); FOR( cnt = 0; cnt < 10; cnt++ ) @@ -1463,7 +1474,6 @@ Word16 gsc_gainQ_fx( /*Q12*/ ELSE { /*ftmp1 = mean(y_gain4, 16);*/ - L_tmp = 0; move32(); FOR( cnt = 0; cnt < 16; cnt++ ) @@ -1528,7 +1538,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + #ifdef OPT_NBE_2311_HARM_GSC_GAIN + test(); + test(); + test(); IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) { #endif @@ -1581,10 +1595,13 @@ Word16 gsc_gainQ_fx( /*Q12*/ #endif idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); } @@ -1616,6 +1633,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ #else GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #endif + return mean_4g[0]; /*Q12*/ } diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 28092088e..5a35108ec 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -76,6 +76,7 @@ void pre_echo_att_fx( #ifdef FIX_1904_HARM_GSC_ENC 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 */ { @@ -203,7 +204,6 @@ void pre_echo_att_fx( return; } - #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*/ diff --git a/lib_com/options.h b/lib_com/options.h index 99f6e8a60..0e255c412 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,8 +148,9 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ -#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: NBE part of the GSC gain harmonization */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ +#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ + /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 77577976a..c84835452 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1546,6 +1546,7 @@ Word16 gsc_gaindec_fx( const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : i signal bandwidth */ ); + #ifndef OPT_BE_2311_HARM_GSC_GAIN /*! r: average frequency gain */ Word16 gsc_gaindec_ivas_fx( @@ -5077,6 +5078,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 */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index cfc9533d6..05b111fbe 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -679,6 +679,7 @@ void gsc_dec_fx( #else mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ #endif + st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } @@ -863,6 +864,7 @@ 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, @@ -874,6 +876,7 @@ void gsc_dec_fx( 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 dd35aae58..79b419633 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -105,6 +105,7 @@ void encod_audio_fx( 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 ); @@ -371,6 +372,7 @@ void encod_audio_fx( #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 ); #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 ); @@ -418,6 +420,7 @@ void encod_audio_fx( interp_code_5over2_fx( exc, bwe_exc, L_FRAME ); } } + /*--------------------------------------------------------------------------------------* * Synthesis *--------------------------------------------------------------------------------------*/ @@ -840,7 +843,7 @@ void encod_audio_ivas_fx( #endif /*================================================================================*/ -/* FUNCTION : void gsc_enc_fx () */ +/* FUNCTION : void gsc_enc_fx() */ /*--------------------------------------------------------------------------------*/ /* PURPOSE : Generic audio signal encoder */ /*--------------------------------------------------------------------------------*/ @@ -856,7 +859,7 @@ void encod_audio_ivas_fx( /* _ None */ /*--------------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* Encoder_State *st_fx:Encoder State Structure */ +/* Encoder_State *st_fx:Encoder State Structure */ /* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Q_exc */ /*--------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ @@ -864,8 +867,8 @@ void encod_audio_ivas_fx( /*================================================================================*/ void gsc_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/ + Encoder_State *st_fx, /* i/o: State structure */ + Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ const Word16 Diff_len, const Word16 bits_used, @@ -993,6 +996,7 @@ void gsc_enc_fx( { i--; } + #ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */ -- GitLab From 584d51b1ad2c668f91969b05f0646acd2b310b4c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 11:29:51 +0100 Subject: [PATCH 340/750] HARM_DTX, HARM_PREPROC --- lib_com/options.h | 2 + lib_enc/amr_wb_enc_fx.c | 4 + lib_enc/dtx_fx.c | 53 +++++-- lib_enc/init_enc_fx.c | 4 + lib_enc/ivas_core_pre_proc_front_fx.c | 209 +++++++++---------------- lib_enc/ivas_front_vad_fx.c | 4 + lib_enc/ivas_stereo_switching_enc_fx.c | 4 + lib_enc/pre_proc_fx.c | 13 +- lib_enc/prot_fx_enc.h | 5 +- 9 files changed, 147 insertions(+), 151 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..64addadef 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,8 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define HARM_DTX /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define HARM_PREPROC /* #################### End BE switches ################################## */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 9b20100ba..e5da3ed7f 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -332,7 +332,11 @@ void amr_wb_enc_fx( move16(); } +#ifdef HARM_DTX + dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new ); +#else dtx_fx( st, vad_flag_dtx, inp, Q_new ); +#endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 483304cde..12c7fdbc6 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -43,7 +43,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /*==================================================================================*/ -/* FUNCTION : dtx_ivas_fx() */ +/* FUNCTION : dtx_fx() */ /*----------------------------------------------------------------------------------*/ /* PURPOSE : Discontinuous transmission operation */ /*----------------------------------------------------------------------------------*/ @@ -58,25 +58,28 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ /* _ (Encoder_State_Fx) st_fx : encoder state structure */ /*----------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ /*==================================================================================*/ + +#ifdef HARM_DTX +void dtx_fx( +#else void dtx_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ + const Word16 Q_speech /* i : Q factor for speech */ ) { Word16 alpha, i, j, Q_speech2; Word32 L_tmp; DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word32 total_brate_ref; @@ -100,7 +103,7 @@ void dtx_ivas_fx( test(); test(); test(); - + test(); last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); @@ -114,6 +117,7 @@ void dtx_ivas_fx( st_fx->cng_type = FD_CNG; move16(); + test(); test(); test(); @@ -123,6 +127,7 @@ void dtx_ivas_fx( move16(); } } + test(); test(); test(); @@ -142,12 +147,14 @@ void dtx_ivas_fx( { st_fx->total_brate = st_fx->last_total_brate_cng; move32(); + test(); if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) { st_fx->Opt_SC_VBR = 0; move16(); } + st_fx->rf_mode = st_fx->last_rf_mode_cng; move16(); st_fx->bwidth = st_fx->last_bwidth_cng; @@ -155,13 +162,14 @@ void dtx_ivas_fx( st_fx->codec_mode = st_fx->last_codec_mode_cng; move16(); } + test(); test(); IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag ) - { st_fx->total_brate = st_fx->last_total_brate; move32(); + test(); if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) { @@ -179,10 +187,12 @@ void dtx_ivas_fx( st_fx->Opt_RF_ON = 1; move16(); } + st_fx->rf_mode = st_fx->Opt_RF_ON; move16(); st_fx->bwidth = st_fx->last_bwidth; move32(); + IF( st_fx->element_mode > EVS_MONO ) { st_fx->codec_mode = MODE1; @@ -213,6 +223,7 @@ void dtx_ivas_fx( ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 ); } + test(); test(); test(); @@ -272,12 +283,14 @@ void dtx_ivas_fx( st_fx->core_brate = SID_2k40; move32(); } + test(); test(); IF( ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) ) { st_fx->cng_type = FD_CNG; move16(); + test(); test(); test(); @@ -320,6 +333,7 @@ void dtx_ivas_fx( move16(); } } + /* reset the bitstream (IVAS format signalling was already written) */ test(); IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) @@ -337,7 +351,7 @@ void dtx_ivas_fx( /*------------------------------------------------------------------------* * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame) *------------------------------------------------------------------------*/ - /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */ + test(); test(); IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) ) @@ -428,6 +442,7 @@ void dtx_ivas_fx( move16(); } } + st_fx->last_total_brate_cng = -1; move16(); } @@ -436,6 +451,7 @@ void dtx_ivas_fx( st_fx->cng_type = LP_CNG; move16(); } + st_fx->active_cnt = add( st_fx->active_cnt, 1 ); move16(); st_fx->active_cnt = s_min( st_fx->active_cnt, 200 ); @@ -445,6 +461,7 @@ void dtx_ivas_fx( /*------------------------------------------------------------------------* * Update speech and background noise long-term energy *------------------------------------------------------------------------*/ + IF( hDtxEnc != NULL ) { hDtxEnc->frame_ener_fx = L_deposit_l( 0 ); @@ -467,7 +484,6 @@ void dtx_ivas_fx( } /* Active speech (voiced) */ - IF( EQ_16( st_fx->clas, VOICED_CLAS ) ) { alpha = ALPHA_ENER_SLOW_FX; /*Q15 */ @@ -524,7 +540,6 @@ void dtx_ivas_fx( test(); IF( st_fx->Opt_DTX_ON && ( EQ_32( st_fx->core_brate, SID_2k40 ) || ( st_fx->core_brate == FRAME_NO_DATA ) ) ) { - st_fx->bwidth = st_fx->last_bwidth; move16(); test(); @@ -561,7 +576,6 @@ void dtx_ivas_fx( IF( EQ_16( st_fx->codec_mode, MODE2 ) ) { Word16 n, bits_frame_nominal; - UWord16 lsb; Word16 tmpbandwidthMin; @@ -575,17 +589,20 @@ void dtx_ivas_fx( BREAK; } } - IF( EQ_16( n, FRAME_SIZE_NB ) ) + if ( n == FRAME_SIZE_NB ) { assert( !"Bitrate not supported: not part of EVS" ); } + tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min; move16(); + if ( EQ_16( st_fx->rf_mode, 1 ) ) { tmpbandwidthMin = WB; move16(); } + st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin ); move16(); } @@ -594,6 +611,7 @@ void dtx_ivas_fx( return; } +#ifndef HARM_DTX /*==================================================================================*/ /* FUNCTION : dtx_fx() */ /*----------------------------------------------------------------------------------*/ @@ -1052,6 +1070,7 @@ void dtx_fx( return; } +#endif /*---------------------------------------------------------------------* * update_SID_cnt() @@ -1201,6 +1220,12 @@ static void update_SID_cnt_fx( } +/*-------------------------------------------------------------------* + * dtx_hangover_control() + * + * + *-------------------------------------------------------------------*/ + void dtx_hangover_control_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 lsp_new_fx[M] /* i : current frame LSPs Q15*/ @@ -1480,6 +1505,7 @@ void dtx_hangover_control_fx( return; } + /*-------------------------------------------------------------------* * td_cng_enc_init_fx() * @@ -1491,6 +1517,7 @@ void td_cng_enc_init_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) +#ifndef HARM_DTX { hTdCngEnc->cng_seed = RANDOM_INITSEED; @@ -1580,8 +1607,8 @@ void td_cng_enc_init_ivas_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) +#endif { - hTdCngEnc->cng_seed = RANDOM_INITSEED; move16(); hTdCngEnc->cng_ener_seed = RANDOM_INITSEED; @@ -1672,6 +1699,7 @@ void td_cng_enc_init_ivas_fx( return; } + /*-------------------------------------------------------------------* * dtx_enc_init_fx() * @@ -1734,5 +1762,6 @@ void dtx_enc_init_fx( move16(); } } + return; } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 7c29b4e06..018efdedb 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -686,6 +686,9 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } +#ifdef HARM_DTX + td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); +#else IF( st->element_mode == EVS_MONO ) { td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); @@ -694,6 +697,7 @@ ivas_error init_encoder_fx( { td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); } +#endif } ELSE { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 38c5abd23..a80638b41 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -50,15 +50,13 @@ #define SCE_SMC_THR 16000 -static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] ); - /*-------------------------------------------------------------------* - * pre_proc_front_ivas() - * - * Front Pre-processing for IVAS - * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) + * Local function prototypes *--------------------------------------------------------------------*/ -static Word16 get_zero_flag( Word32 arr[], Word16 len ) + +static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] ); + +static Word16 get_zero_flag( const Word32 arr[], const Word16 len ) { FOR( Word16 j = 0; j < len; j++ ) { @@ -70,6 +68,14 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len ) return 0; } + +/*-------------------------------------------------------------------* + * pre_proc_front_ivas() + * + * Front Pre-processing for IVAS + * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) + *--------------------------------------------------------------------*/ + ivas_error pre_proc_front_ivas_fx( SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ @@ -131,15 +137,6 @@ ivas_error pre_proc_front_ivas_fx( ) { Encoder_State *st; - IF( hSCE != NULL ) - { - st = hSCE->hCoreCoder[n]; - } - ELSE - { - st = hCPE->hCoreCoder[n]; - } - Word16 q_tmpN_LR[CPE_CHANNELS]; Word16 q_tmpE_LR[CPE_CHANNELS]; Word16 q_tmpN; @@ -165,22 +162,23 @@ ivas_error pre_proc_front_ivas_fx( Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */ Word16 LR_localVAD; ivas_error error; - - push_wmops( "pre_proc_front" ); - Word16 *signal_in_fx; Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ CLDFB_SCALE_FACTOR cldfbScale; +#ifdef HARM_PREPROC + Word16 temp1F_icatdmResampBuf_fx[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */ + Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ +#else Word16 *temp1F_icatdmResampBuf_fx; Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ +#endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; Word16 snr_sum_he_fx; /* HE SAD parameters */ Word16 new_inp_out_size; Word16 Q_new_inp; Word16 mem_decim_size; - Word16 dummy_fx; Word16 ncharX_fx; Word16 ncharX_LR_fx; /* noise character for sp/mus classifier */ @@ -218,55 +216,21 @@ ivas_error pre_proc_front_ivas_fx( Word32 *in_buff_temp; Word16 in_q_temp; #endif - +#ifndef HARM_PREPROC mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); set16_fx( fft_buff_fx, 0, 512 ); - - Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); - Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) - Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); - Q_min = s_max( -2, Q_min ); - Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min - st->q_inp = Q_min; - move16(); - st->q_old_inp = Q_min; - move16(); - -#ifdef DEBUG_MODE_INFO - IF( hSCE != NULL ) - { - in_buff_temp = hSCE->hCoreCoder[n]->input32_fx; - in_q_temp = hSCE->hCoreCoder[n]->q_inp32; - } - ELSE - { - in_buff_temp = hCPE->hCoreCoder[n]->input32_fx; - in_q_temp = hCPE->hCoreCoder[n]->q_inp32; - } -#endif - - -#ifdef DEBUG_MODE_INFO - if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && ch_idx > 0 ) ) - { - /* for TD stereo only write out first channel. The existence of a second channel can vary, this is just easier to handle */ - int16_t tmpF[L_FRAME48k]; - for ( int16_t isample = 0; isample < input_frame; isample++ ) - { - tmpF[isample] = (int16_t) ( (float) in_buff_temp[isample - NS2SA( st->input_Fs, ACELP_LOOK_NS )] / ( (float) ( 1 << in_q_temp ) ) ); - } - dbgwrite( &tmpF, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); - } #endif - + Word16 Q_min; + Word16 input_frame_full; +#ifndef HARM_PREPROC FOR( Word16 k = 0; k < CLDFB_NO_COL_MAX; k++ ) { set32_fx( realBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( imagBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); } +#endif Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; - Word16 Q_inp_const = -1; move16(); Word16 headroom = 0, preemp_len = 0, inp_max = 0; @@ -276,6 +240,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 *preemp_start_idx = NULL; Word32 sig_out[960], max_32; + push_wmops( "pre_proc_front" ); /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -283,8 +248,8 @@ ivas_error pre_proc_front_ivas_fx( error = IVAS_ERR_OK; move32(); - cldfbScale.lb_scale = 31; - cldfbScale.hb_scale = 31; + cldfbScale.lb_scale = Q31; + cldfbScale.hb_scale = Q31; move16(); move16(); @@ -297,12 +262,6 @@ ivas_error pre_proc_front_ivas_fx( LR_localVAD = 0; move16(); - IF( st->cldfbAnaEnc != NULL ) - { - scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */ - st->cldfbAnaEnc->Q_cldfb_state = Q11; - move16(); - } IF( hSCE != NULL ) { @@ -413,6 +372,16 @@ ivas_error pre_proc_front_ivas_fx( move16(); } + Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); + input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) + Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); + Q_min = s_max( -2, Q_min ); + Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min + st->q_inp = Q_min; + move16(); + st->q_old_inp = Q_min; + move16(); + L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */ move16(); @@ -448,6 +417,13 @@ ivas_error pre_proc_front_ivas_fx( last_core_orig = st->last_core; /* Q0 */ move16(); + IF( st->cldfbAnaEnc != NULL ) + { + scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */ + st->cldfbAnaEnc->Q_cldfb_state = Q11; + move16(); + } + /*--------------------------------------------------------------* * energy analysis *---------------------------------------------------------------*/ @@ -490,6 +466,7 @@ ivas_error pre_proc_front_ivas_fx( * Change the sampling frequency to 12.8 kHz * (if not available from downsampled DMX) *----------------------------------------------------------------*/ + Scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */ test(); @@ -501,7 +478,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) @@ -765,16 +742,6 @@ ivas_error pre_proc_front_ivas_fx( st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, fr_bands_fx_q, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float move16(); -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); - } -#endif test(); IF( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_flag, 1 ) ) @@ -869,18 +836,6 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); - } -#endif - - /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates @@ -907,6 +862,7 @@ ivas_error pre_proc_front_ivas_fx( /*----------------------------------------------------------------* * FD-CNG Noise Estimator *----------------------------------------------------------------*/ + IF( st->hFdCngEnc != NULL ) { resetFdCngEnc_fx( st ); @@ -958,6 +914,7 @@ ivas_error pre_proc_front_ivas_fx( /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ + test(); test(); if ( hCPE != NULL && NE_16( element_mode, IVAS_CPE_DFT ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) @@ -976,7 +933,11 @@ ivas_error pre_proc_front_ivas_fx( move16(); } +#ifdef HARM_DTX + dtx_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); +#else dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); +#endif test(); test(); @@ -990,6 +951,7 @@ ivas_error pre_proc_front_ivas_fx( /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ + test(); test(); test(); @@ -1006,7 +968,9 @@ ivas_error pre_proc_front_ivas_fx( { total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal ); /* Q0 */ } + configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate ); + IF( hCPE != NULL ) { st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 ); /* Q0 */ @@ -1063,6 +1027,7 @@ ivas_error pre_proc_front_ivas_fx( /*----------------------------------------------------------------* * LP analysis *----------------------------------------------------------------*/ + Word16 stab_fac_fx; Word16 Q_r[2]; set16_fx( Q_r, 0, 2 ); @@ -1111,6 +1076,7 @@ ivas_error pre_proc_front_ivas_fx( * Comparison of the LP coefficents to determine if it is possible * to reuse the primary channel LP coefficients in the secondary channel *----------------------------------------------------------------*/ + Word32 speech_buff[L_FRAME + M]; Copy_Scale_sig_16_32_DEPREC( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 ); /* Q_new + 12 */ hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison_fx( hCPE->hStereoTD, hCPE->hStereoClassif, st, &speech_buff[0], tdm_A_PCh_fx, A_fx, M, tdm_lsp_new_PCh_fx, lsp_new_fx, L_FRAME, L_sub( element_brate, imult3216( FRAMES_PER_SEC, nb_bits_metadata ) ), add( *Q_new, 12 ) ); /* Q0 */ @@ -1212,6 +1178,7 @@ ivas_error pre_proc_front_ivas_fx( /*------------------------------------------------------------------* * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ + Word16 scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) ); scale = s_min( scale, add( q_tmpE, L_norm_arr( tmpE_fx, NB_BANDS ) ) ); scale = sub( scale, 1 ); // guard bits @@ -1281,6 +1248,7 @@ ivas_error pre_proc_front_ivas_fx( /*------------------------------------------------------------------* * Update parameters used in the VAD and DTX *-----------------------------------------------------------------*/ + vad_param_updt_fx( st, old_pitch1, corr_shift_fx, corr_shift_fx, A_fx, NULL, 1 ); test(); @@ -1288,6 +1256,7 @@ ivas_error pre_proc_front_ivas_fx( { vad_param_updt_fx( st, old_pitch1, corr_shiftL_fx, corr_shiftR_fx, A_fx, &hCPE->hFrontVad[0], CPE_CHANNELS ); } + /*-----------------------------------------------------------------* * Find spectral tilt * UC and VC frame selection @@ -1306,20 +1275,6 @@ ivas_error pre_proc_front_ivas_fx( &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->coder_type, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type.enf", -1, -1, -1 ) ); - dbgread( &st->coder_type_raw, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type_raw.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->coder_type, sizeof( int16_t ), 1, 1, "res/force_coder_type.enf" ); - dbgwrite( &st->coder_type_raw, sizeof( int16_t ), 1, 1, "res/force_coder_type_raw.enf" ); - } -#endif - - /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ @@ -1348,6 +1303,7 @@ ivas_error pre_proc_front_ivas_fx( /*-----------------------------------------------------------------* * Collect stereo classifier features *-----------------------------------------------------------------*/ + IF( hStereoClassif != NULL ) { Word16 max_e_Etot; @@ -1362,6 +1318,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); move16(); move16(); + stereo_classifier_features_ivas_fx( hStereoClassif, st->idchan, element_mode, localVAD_HE_SAD, lsf_new_fx, epsP_fx, st->pitch, st->voicing_fx, *cor_map_sum_fx, non_staX_fx, sp_div_fx, st->clas, sub( 31, *epsP_fx_q ), ( 31 - Q8 ) /* exp of cor_map_sum */, ( 31 - Q20 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); @@ -1378,17 +1335,6 @@ ivas_error pre_proc_front_ivas_fx( smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */ -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); - } -#endif - #ifdef DEBUGGING if ( st->idchan == 0 ) { @@ -1436,6 +1382,7 @@ ivas_error pre_proc_front_ivas_fx( st->GSC_IVAS_mode = 0; move16(); + test(); IF( EQ_16( st->idchan, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) { @@ -1492,6 +1439,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); st->hTcxEnc->spectrum_e[1] = 16; move16(); + IF( flag_16k_smc ) { Word16 Q_old_inp_16k = -1; @@ -1525,15 +1473,14 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_old_inp_12k8 = *Q_new; move16(); + /* Compute core-coder buffers at internal sampling rate */ - error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, - A_fx, Aw_fx, - epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); + error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } + *epsP_fx_q = add( Q_r[0], 1 ); move16(); @@ -1594,23 +1541,6 @@ ivas_error pre_proc_front_ivas_fx( ivas_smc_mode_selection_fx( st, element_brate, smc_dec, *relE_fx, extract_h( Etot_fx ), attack_flag, inp_12k8_fx, *Q_new, S_map_fx, flag_spitch ); } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); - dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); - dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); - dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); - } -#endif - /*----------------------------------------------------------------* * Final VAD correction (when HE-SAD is used instead of the normal VAD, * rewrite the VAD flag by VAD flag with DTX hangover for further processing) @@ -1626,26 +1556,30 @@ ivas_error pre_proc_front_ivas_fx( /*-----------------------------------------------------------------* * Update old input signal buffer *-----------------------------------------------------------------*/ + shift = getScaleFactor16( &old_inp_12k8_fx[L_FRAME], L_INP_MEM ); Copy_Scale_sig( &old_inp_12k8_fx[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM, shift ); /* Q_new + shift */ st->exp_old_inp_12k8 = sub( Q15, add( *Q_new, shift ) ); move16(); - *Q_new = sub( *Q_new, Q_inp_const ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1 move16(); +#ifndef HARM_PREPROC free( mem_decim_dummy_fx ); free( temp1F_icatdmResampBuf_fx ); +#endif pop_wmops(); return error; } + /*-------------------------------------------------------------------* * calculate_energy_buffer() * * calculate DFT-based energies *--------------------------------------------------------------------*/ + static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/ @@ -1715,5 +1649,6 @@ static void calculate_energy_buffer_ivas_fx( enerBuffer_dft_e[i] = 0; move16(); } + return; } diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index f58f48e97..642e5c5f8 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -599,7 +599,11 @@ ivas_error front_vad_spar_fx( corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ +#ifdef HARM_DTX + dtx_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); +#else dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); +#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */ diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 107fb9681..2c8d21593 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -385,7 +385,11 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } +#ifdef HARM_DTX + td_cng_enc_init_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); +#else td_cng_enc_init_ivas_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); +#endif } /* allocate TCA data structure */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 3b5892975..eba46d645 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -325,17 +325,23 @@ void pre_proc_fx( *----------------------------------------------------------------*/ resetFdCngEnc_fx( st ); + perform_noise_estimation_enc_fx( st->band_energies, st->band_energies_exp, enerBuffer, enerBuffer_exp, st->hFdCngEnc ); /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ +#ifdef HARM_DTX + dtx_fx( st, -1, -1, vad_flag_dtx, inp_12k8, *Q_new ); +#else dtx_fx( st, vad_flag_dtx, inp_12k8, *Q_new ); +#endif /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ + test(); IF( ( NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) ) { @@ -349,6 +355,7 @@ void pre_proc_fx( } configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, L_tmp ); } + test(); IF( st->hFdCngEnc != NULL && st->Opt_DTX_ON ) { @@ -493,6 +500,7 @@ void pre_proc_fx( /*------------------------------------------------------------------* * Update parameters used in the VAD and DTX *-----------------------------------------------------------------*/ + vad_param_updt_fx( st, old_pitch1, corr_shift, corr_shift, A, NULL, 1 ); /*-----------------------------------------------------------------* @@ -506,9 +514,10 @@ void pre_proc_fx( st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); - /*----------------------------------------------------------------* + /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ + test(); test(); IF( !st->Opt_RF_ON ) @@ -562,6 +571,7 @@ void pre_proc_fx( hSC_VBR->Local_VAD = st->localVAD; move16(); } + /*----------------------------------------------------------------* * Speech/music classification * AC frame selection @@ -769,6 +779,7 @@ void pre_proc_fx( /*---------------------------------------------------------------------* * Decision matrix (selection of technologies) *---------------------------------------------------------------------*/ + IF( EQ_16( st->codec_mode, MODE1 ) ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 06630ab57..727c60c73 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -138,6 +138,7 @@ Word16 correlation_shift_fx( ); void dtx_fx( +#ifndef HARM_DTX Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad, /* i : vad flag Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ @@ -145,6 +146,7 @@ void dtx_fx( ); void dtx_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ @@ -1175,12 +1177,13 @@ void td_cng_enc_init_fx( const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); +#ifndef HARM_DTX void td_cng_enc_init_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); - +#endif void dtx_enc_init_fx( Encoder_State *st, /* i : Encoder state handle */ const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/ -- GitLab From 30fa8df764446e101539e555fa82479aad21b05a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 11:43:17 +0100 Subject: [PATCH 341/750] step 2 (dtx_hangover_addition_fx) --- lib_enc/amr_wb_enc_fx.c | 4 ++++ lib_enc/ivas_core_pre_proc_front_fx.c | 9 +++++++-- lib_enc/ivas_front_vad_fx.c | 5 +++++ lib_enc/pre_proc_fx.c | 4 ++++ lib_enc/prot_fx_enc.h | 2 ++ lib_enc/vad_fx.c | 19 +++++++++++++++++-- 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index e5da3ed7f..bd708c2c0 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -310,7 +310,11 @@ void amr_wb_enc_fx( } /* apply DTX hangover for CNG analysis */ +#ifdef HARM_PREPROC + vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL, NULL ); +#else vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL ); +#endif /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index a80638b41..8fbe9512b 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -479,7 +479,7 @@ ivas_error pre_proc_front_ivas_fx( Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ - Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ + Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -563,6 +563,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); st->mem_preemph_DFT_fx_q_inp = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/ move16(); + test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -757,7 +758,11 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { +#ifdef HARM_PREPROC + *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ +#else *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ +#endif move16(); } ELSE @@ -1475,7 +1480,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Compute core-coder buffers at internal sampling rate */ - error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); + error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 642e5c5f8..f16881b2f 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -286,7 +286,12 @@ ivas_error front_vad_fx( sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */ move16(); } + +#ifdef HARM_PREPROC + vad_flag_dtx[n] = dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ +#else vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ +#endif move16(); if ( EQ_16( n_chan, 1 ) ) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index eba46d645..930f784d6 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -282,7 +282,11 @@ void pre_proc_fx( } /* apply DTX hangover for CNG analysis */ +#ifdef HARM_PREPROC + vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst, NULL ); +#else vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst ); +#endif /*----------------------------------------------------------------* * NB/WB/SWB/FB bandwidth detector diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 727c60c73..3042d2ee6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -156,6 +156,7 @@ void dtx_ivas_fx( ); Word16 dtx_hangover_addition_fx( +#ifndef HARM_PREPROC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -166,6 +167,7 @@ Word16 dtx_hangover_addition_fx( ); Word16 ivas_dtx_hangover_addition_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 4335225ca..5278a7b07 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -229,6 +229,7 @@ static void sign_thr_snr_acc_fx( *-----------------------------------------------------------------*/ Word16 dtx_hangover_addition_fx( +#ifndef HARM_PREPROC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -425,6 +426,7 @@ Word16 dtx_hangover_addition_fx( return flag_dtx; } Word16 ivas_dtx_hangover_addition_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -548,6 +550,18 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); /* float fix FIX_HO_TERMINATE */ /* Music hangover when music detected */ +#ifdef HARM_DTX + IF( st_fx->element_mode == EVS_MONO ) + { + if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ + { + hVAD->hangover_cnt_music = 0; + move16(); + } + } + ELSE +#endif + { test(); test(); test(); @@ -556,6 +570,7 @@ Word16 ivas_dtx_hangover_addition_fx( hVAD->hangover_cnt_music = 0; move16(); } +} /* inside Music HO period */ test(); @@ -609,9 +624,7 @@ Word16 ivas_dtx_hangover_addition_fx( } } - test(); - IF( flag_dtx != 0 && st_fx->localVAD == 0 ) { *vad_hover_flag_ptr = 1; @@ -625,6 +638,8 @@ Word16 ivas_dtx_hangover_addition_fx( return flag_dtx; } + + /*-----------------------------------------------------------------* * wb_vad() * -- GitLab From 5c654a7bdb8507f3afe04f1ed8ef43a3f52a3a4c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 11:51:02 +0100 Subject: [PATCH 342/750] clang-format --- lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/vad_fx.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8fbe9512b..bb4ad3c84 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -171,7 +171,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ #else Word16 *temp1F_icatdmResampBuf_fx; - Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ + Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ #endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 5278a7b07..11bc79ee0 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -562,15 +562,15 @@ Word16 ivas_dtx_hangover_addition_fx( ELSE #endif { - test(); - test(); - test(); - if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ - { - hVAD->hangover_cnt_music = 0; - move16(); + test(); + test(); + test(); + if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ + { + hVAD->hangover_cnt_music = 0; + move16(); + } } -} /* inside Music HO period */ test(); -- GitLab From e02584652cf818e088e4b3ad1b35e616e428bf39 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 12:45:42 +0100 Subject: [PATCH 343/750] step 3 (StableHighPitchDetect_fx) --- lib_com/options.h | 3 +- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/dtx_fx.c | 6 +-- lib_enc/init_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 10 ++-- lib_enc/ivas_front_vad_fx.c | 7 ++- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_enc/pitch_ol2_fx.c | 70 +++++++++++++++++++------- lib_enc/pre_proc_fx.c | 7 ++- lib_enc/prot_fx_enc.h | 9 +++- lib_enc/vad_fx.c | 5 +- 11 files changed, 88 insertions(+), 35 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 64addadef..8907db790 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,8 +124,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ -#define HARM_DTX /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ -#define HARM_PREPROC +#define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index bd708c2c0..195b36dc4 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -336,7 +336,7 @@ void amr_wb_enc_fx( move16(); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new ); #else dtx_fx( st, vad_flag_dtx, inp, Q_new ); diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 12c7fdbc6..c9b2f5d0a 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -63,7 +63,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ None */ /*==================================================================================*/ -#ifdef HARM_DTX +#ifdef HARM_PREPROC void dtx_fx( #else void dtx_ivas_fx( @@ -611,7 +611,7 @@ void dtx_ivas_fx( return; } -#ifndef HARM_DTX +#ifndef HARM_PREPROC /*==================================================================================*/ /* FUNCTION : dtx_fx() */ /*----------------------------------------------------------------------------------*/ @@ -1517,7 +1517,7 @@ void td_cng_enc_init_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) -#ifndef HARM_DTX +#ifndef HARM_PREPROC { hTdCngEnc->cng_seed = RANDOM_INITSEED; diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 018efdedb..07ae94937 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -686,7 +686,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); #else IF( st->element_mode == EVS_MONO ) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index bb4ad3c84..c6d9d1d0b 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -773,7 +773,6 @@ ivas_error pre_proc_front_ivas_fx( *vad_flag_dtx = *vad_flag_dtx || st->vad_flag; /* Q0 */ move16(); - /* Determine hangover flag status based on LR localVAD and downmix localVAD */ test(); test(); @@ -830,7 +829,6 @@ ivas_error pre_proc_front_ivas_fx( set_bw_fx( element_mode, element_brate, st, MODE1 ); } - /* set the BW of the TD secondary channel in LRTD mode same as BW of the primary channel (only at higher bitrates) */ test(); test(); @@ -938,7 +936,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC dtx_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); #else dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); @@ -1134,6 +1132,7 @@ ivas_error pre_proc_front_ivas_fx( pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp ); + /* Updates for adaptive lag window memory */ st->old_pitch_la = st->pitch[2]; /* Q0 */ move16(); @@ -1147,8 +1146,13 @@ ivas_error pre_proc_front_ivas_fx( move16(); Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); /* Q7 */ + /* Detection of very short stable pitch period */ +#ifdef HARM_PREPROC + StableHighPitchDetect_fx( element_mode, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); +#else StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); +#endif /* 1/4 pitch precision improvement */ IF( LE_32( element_brate, IVAS_32k ) ) diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index f16881b2f..f6e9978ef 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -604,7 +604,7 @@ ivas_error front_vad_spar_fx( corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ -#ifdef HARM_DTX +#ifdef HARM_PREPROC dtx_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); #else dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); @@ -692,7 +692,12 @@ ivas_error front_vad_spar_fx( st->old_pitch_la = st->pitch[2]; /* Q0 */ move16(); +#ifdef HARM_PREPROC + StableHighPitchDetect_fx( IVAS_SCE /* needs to be other than EVS_MONO */, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); +#else StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); +#endif + IF( st->hSpMusClas != NULL ) { Word16 dummy_int; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 2c8d21593..8507bc58c 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -385,7 +385,7 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC td_cng_enc_init_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); #else td_cng_enc_init_ivas_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index f50677cf0..af01e8dbf 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -26,6 +26,7 @@ * The pitch is searched in the interval pitch period (MODE1 bit-rates) */ +#ifdef HARM_PREPROC + StableHighPitchDetect_fx( EVS_MONO, &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, + &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); +#else StableHighPitchDetect_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); +#endif /* 1/4 pitch precision improvement */ IF( LE_32( st->total_brate, ACELP_24k40 ) ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 3042d2ee6..eddda1a67 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -138,7 +138,7 @@ Word16 correlation_shift_fx( ); void dtx_fx( -#ifndef HARM_DTX +#ifndef HARM_PREPROC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad, /* i : vad flag Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ @@ -575,6 +575,9 @@ void speech_music_classif_fx( ); void StableHighPitchDetect_fx( +#ifdef HARM_PREPROC + const Word16 element_mode, /* i : element mode */ +#endif Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ Word16 pitch[], /* i/o: OL pitch buffer */ const Word16 voicing[], /* i : OL pitch gains */ @@ -588,6 +591,7 @@ void StableHighPitchDetect_fx( Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency */ Word16 Q_new, Word16 EspecdB[] ); +#ifndef HARM_PREPROC void StableHighPitchDetect_ivas_fx( Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */ @@ -604,6 +608,7 @@ void StableHighPitchDetect_ivas_fx( Word16 Q_new, Word16 EspecdB[] /* Q7 */ ); +#endif void swb_bwe_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -1179,7 +1184,7 @@ void td_cng_enc_init_fx( const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); -#ifndef HARM_DTX +#ifndef HARM_PREPROC void td_cng_enc_init_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 11bc79ee0..8a37d87ba 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -550,7 +550,10 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); /* float fix FIX_HO_TERMINATE */ /* Music hangover when music detected */ -#ifdef HARM_DTX +#ifdef HARM_PREPROC + test(); + test(); + test(); IF( st_fx->element_mode == EVS_MONO ) { if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ -- GitLab From 8e5ecba6e7e0778d7b1555668d6bf3e3201d3b31 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 14 Jan 2026 07:40:41 -0500 Subject: [PATCH 344/750] remove unneeded comment --- lib_enc/sig_clas_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index d97cd8bc4..29d4f3bd3 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -636,7 +636,7 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } - } // <<-- that bracket was wrongly placed + } hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); test(); -- GitLab From 6c7cb79d8e07a5e79851bd11760477212e214aa1 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 14 Jan 2026 07:48:20 -0500 Subject: [PATCH 345/750] fix clang-format --- lib_enc/sig_clas_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 29d4f3bd3..b4d41c405 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -636,7 +636,7 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } - } + } hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); test(); -- GitLab From 84c43f03b94816f87c9b16ec74bbb90bf2acf31f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 15:13:28 +0100 Subject: [PATCH 346/750] HARM_CORECODER_UPDT --- lib_com/options.h | 1 + lib_com/prot_fx.h | 21 +++- lib_dec/amr_wb_dec_fx.c | 4 + lib_dec/evs_dec_fx.c | 10 ++ lib_dec/ivas_core_dec_fx.c | 4 + lib_dec/ivas_mct_dec_fx.c | 4 + lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 + lib_dec/updt_dec_fx.c | 145 +++++++++++++++++++------ lib_enc/amr_wb_enc_fx.c | 4 + lib_enc/evs_enc_fx.c | 4 + lib_enc/ivas_core_enc_fx.c | 4 + lib_enc/ivas_mct_enc_fx.c | 6 +- lib_enc/long_enr_fx.c | 20 +++- lib_enc/prot_fx_enc.h | 2 + lib_enc/updt_enc_fx.c | 4 +- 15 files changed, 193 insertions(+), 44 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..891f5b8fc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 588617196..dcbd9d4b1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5380,6 +5380,7 @@ Word32 sign_l( const Word32 x /* i : input value of x */ ); +#ifndef HARM_CORECODER_UPDT void ivas_updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ @@ -5387,7 +5388,7 @@ void ivas_updt_dec_common_fx( const Word32 *synth, /* i : decoded synthesis */ const Word16 Qpostd /* i : Synthesis Q value */ ); - +#endif /* Random generator with Gaussian distribution with mean 0 and std 1 */ Word32 rand_gauss( Word16 *seed ); @@ -7850,17 +7851,24 @@ void updt_IO_switch_dec_fx( Decoder_State *st_fx /* o : Decoder static variables structure */ ); +#ifndef HARM_CORECODER_UPDT void updt_bw_switching_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost ); - + const Word16 Qpost /* i : Synthesis Q value */ +); +#endif void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ +#ifdef HARM_CORECODER_UPDT + const Word16 *synth16, /* i : decoded synthesis Qpostd */ + const Word32 *synth, /* i : decoded synthesis Qpostd */ +#else + const Word16 *synth, /* i : decoded synthesis */ +#endif + const Word16 Qpostd /* i : Synthesis Q value */ ); void update_decoder_LPD_cng( @@ -10522,11 +10530,12 @@ void core_encode_update_ivas_fx( Encoder_State *st /* i/o: Encoder state structure */ ); +#ifndef HARM_CORECODER_UPDT void updt_enc_common_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 Q_new /* i : CUrrent frame scaling */ ); - +#endif /* o : Q(2x - 31 - gb) */ Word32 sum2_f_32_fx( const Word32 *vec, /* i : input vector, Qx */ diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index d7dcf5b03..632992d96 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -993,7 +993,11 @@ ivas_error amr_wb_dec_fx( st_fx->last_flag_cna = flag_cna; move16(); +#ifdef HARM_CORECODER_UPDT + updt_dec_common_fx( st_fx, -1, -1, NULL, NULL, 0 ); +#else updt_dec_common_fx( st_fx, -1, -1, NULL, 0 ); +#endif /*----------------------------------------------------------------* * Overlap of ACELP synthesis with old MDCT memory diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index a358cbe8a..2831c57ab 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -1374,7 +1374,12 @@ ivas_error evs_dec_fx( st_fx->bfi = 1; move16(); } + +#ifdef HARM_CORECODER_UPDT + updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, NULL, Qpostd ); +#else updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, Qpostd ); +#endif } ELSE { @@ -1383,7 +1388,12 @@ ivas_error evs_dec_fx( st_fx->bfi = 0; move16(); } + +#ifdef HARM_CORECODER_UPDT + updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, NULL, Qpostd ); +#else updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, Qpostd ); +#endif } pop_wmops(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index bf1f75333..655fc7ff0 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1492,7 +1492,11 @@ ivas_error ivas_core_dec_fx( save_synthesis_hq_fec_fx( st, NULL, output_fx_loc, output_frame, 0, hCPE ); /* Updates */ +#ifdef HARM_CORECODER_UPDT + updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, NULL, output_32_fx[n], Q11 ); +#else ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_32_fx[n], Q11 ); +#endif Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( exp_max ) ); // Q0 diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 5c5b0ac52..7c1cae860 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -380,7 +380,11 @@ ivas_error ivas_mct_dec_fx( save_synthesis_hq_fec_fx( sts[n], NULL, output_fx_, output_frame, 0, hCPE ); /* CoreCoder common updates */ +#ifdef HARM_CORECODER_UPDT + updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, NULL, output_fx[( cpe_id * CPE_CHANNELS ) + n], Q11 ); +#else ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[( cpe_id * CPE_CHANNELS ) + n], 11 ); +#endif } /* n_channels loop */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 37bc17138..7ed00053c 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1508,7 +1508,11 @@ void ivas_sba_dirac_stereo_dec_fx( stereo_dft_dec_core_switching_fx( hCPE, output[0] /*hSCE->save_output*/, hSCE->save_synth_fx, hSCE->save_hb_synth_fx, DFT, output_frame, 0, dtx_flag, &q, &q_dft[0] ); /* do updates here after skipping this in SCE decoder (needs to be done after core switching) */ +#ifdef HARM_CORECODER_UPDT + updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, NULL, hSCE->save_synth_fx, q ); +#else ivas_updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, hSCE->save_synth_fx, q ); +#endif q_synth = sub( getScaleFactor32( tmp_synth, hSCE->hCoreCoder[0]->L_frame ), 10 ); scale_sig32( tmp_synth, hSCE->hCoreCoder[0]->L_frame, q_synth ); /*hSCE->q_save_synth_fx + q_synth*/ diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 240f9545c..7f42e6b69 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -14,17 +14,18 @@ * * Common updates (all frame types) *-------------------------------------------------------------------*/ + void updt_dec_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 *old_exc_fx, /* i : buffer of excitation Q_exc */ + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 *old_exc_fx, /* i : buffer of excitation Q_exc */ const Word16 *pitch_buf_fx, /* i : fixed point pitch values for each subframe Q6*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - const Word16 *Aq, /* i : A(z) quantized for all subframes Q12 */ - const Word16 *lsf_new_fx, /* i : current frame LSF vector Qlog2(2.56)*/ - const Word16 *lsp_new_fx, /* i : current frame LSP vector Q15*/ - const Word16 voice_factors[], /* i : voicing factors Q15*/ - const Word16 *old_bwe_exc_fx, /* i : buffer of excitation Q_syn*/ - const Word16 *gain_buf /* i : fixed point pitch gain for each subframe Q14*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + const Word16 *Aq, /* i : A(z) quantized for all subframes Q12 */ + const Word16 *lsf_new_fx, /* i : current frame LSF vector Qlog2(2.56)*/ + const Word16 *lsp_new_fx, /* i : current frame LSP vector Q15*/ + const Word16 voice_factors[], /* i : voicing factors Q15*/ + const Word16 *old_bwe_exc_fx, /* i : buffer of excitation Q_syn*/ + const Word16 *gain_buf /* i : fixed point pitch gain for each subframe Q14*/ ) { Word16 i, len; @@ -56,6 +57,7 @@ void updt_dec_fx( st_fx->last_coder_type = UNVOICED; move16(); } + IF( st_fx->hGSCDec != NULL ) { test(); @@ -68,13 +70,13 @@ void updt_dec_fx( } /* this ensures that st_fx->last_coder_type is never set to INACTIVE in case of AVQ inactive because the FEC does not distinguish between GSC inactive and AVQ inactive */ - test(); if ( GT_32( st_fx->total_brate, ACELP_24k40 ) && EQ_16( st_fx->coder_type, INACTIVE ) ) { st_fx->last_coder_type = GENERIC; move16(); } + test(); test(); test(); @@ -91,7 +93,6 @@ void updt_dec_fx( IF( !st_fx->Opt_AMR_WB ) { /* update voicing factor of TBE to help FEC */ - st_fx->last_voice_factor_fx = voice_factors[NB_SUBFR16k - 1]; move16(); if ( EQ_16( st_fx->L_frame, L_FRAME ) ) @@ -100,6 +101,7 @@ void updt_dec_fx( move16(); } } + test(); test(); IF( st_fx->hGSCDec != NULL && NE_16( st_fx->coder_type, AUDIO ) && NE_16( st_fx->coder_type, INACTIVE ) ) @@ -159,7 +161,6 @@ void updt_dec_fx( move16(); } - /* FEC - update adaptive LSF mean vector */ Copy( st_fx->lsfoldbfi0_fx, st_fx->lsfoldbfi1_fx, M ); Copy( lsf_new_fx, st_fx->lsfoldbfi0_fx, M ); @@ -198,13 +199,15 @@ void updt_dec_fx( return; } + /*-------------------------------------------------------------------* * updt_IO_switch() * * Common updates for AMR-WB IO mode and EVS primary switching *-------------------------------------------------------------------*/ + void updt_IO_switch_dec_fx( - const Word16 output_frame, /* i : output frame length */ + const Word16 output_frame, /* i : output frame length */ Decoder_State *st_fx /* o : Decoder static variables structure */ ) { @@ -393,15 +396,32 @@ void updt_IO_switch_dec_fx( * Updates for BW switching *-------------------------------------------------------------------*/ +#ifdef HARM_CORECODER_UPDT +static void updt_bw_switching_fx( +#else void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost ) +#endif + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ +#ifdef HARM_CORECODER_UPDT + const Word32 *synth32, /* i : synthesis signal32 Qpost */ +#endif + const Word16 Qpost /* i : Synthesis Q value */ +) { test(); IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { - st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11 +#ifdef HARM_CORECODER_UPDT + IF( st_fx->element_mode != EVS_MONO ) + { + st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth32, Qpost, L_FRAME32k ); + } + ELSE +#endif + { + st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11 + } } st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q @@ -433,17 +453,20 @@ void updt_bw_switching_fx( move16(); } } + st_fx->prev_bws_cnt = st_fx->bws_cnt; move16(); + return; } + /*-------------------------------------------------------------------* * updt_dec_common() * * Common updates for MODE1 and MODE2 *-------------------------------------------------------------------*/ - +#ifndef HARM_CORECODER_UPDT void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ @@ -790,8 +813,9 @@ static void ivas_updt_bw_switching_fx( move16(); return; } +#endif -static Word32 sum_32_32_fx( const Word32 *x, Word16 length ) // Qx +static Word32 sum_32_32_fx( const Word32 *x, const Word16 length ) // Qx { Word64 sum = 0; Word16 i; @@ -802,19 +826,28 @@ static Word32 sum_32_32_fx( const Word32 *x, Word16 length ) // Qx return W_round64_L( sum ); } +#ifdef HARM_CORECODER_UPDT +void updt_dec_common_fx( +#else void ivas_updt_dec_common_fx( +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis Qpostd */ - const Word16 Qpostd /* i : Synthesis Q value */ +#ifdef HARM_CORECODER_UPDT + const Word16 *synth16, /* i : decoded synthesis Qpostd */ + const Word32 *synth, /* i : decoded synthesis Qpostd */ +#else + const Word32 *synth, /* i : decoded synthesis Qpostd */ +#endif + const Word16 Qpostd /* i : Synthesis Q value */ ) { Word16 i; Word32 L_tmp; - TCX_DEC_HANDLE hTcxDec; + hTcxDec = st_fx->hTcxDec; st_fx->last_codec_mode = st_fx->codec_mode; @@ -845,11 +878,12 @@ void ivas_updt_dec_common_fx( move16(); } - IF( st_fx->hTcxDec != NULL ) + IF( hTcxDec != NULL ) { hTcxDec->tcxConceal_recalc_exc = 0; move16(); } + test(); test(); test(); @@ -860,8 +894,7 @@ void ivas_updt_dec_common_fx( test(); test(); test(); - - if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL ) + if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && hTcxDec != NULL ) { hTcxDec->tcxConceal_recalc_exc = 1; move16(); @@ -869,6 +902,7 @@ void ivas_updt_dec_common_fx( st_fx->last_good = st_fx->clas_dec; move16(); } + IF( st_fx->use_partial_copy ) { st_fx->prev_rf_frame_type = st_fx->rf_frame_type; @@ -879,9 +913,14 @@ void ivas_updt_dec_common_fx( st_fx->prev_rf_frame_type = INACTIVE; move16(); } + test(); test(); +#ifdef HARM_CORECODER_UPDT + if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) ) +#else if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( st_fx->bfi != 0 || st_fx->use_partial_copy != 0 ) ) +#endif { st_fx->rf_flag_last = st_fx->rf_flag; move16(); @@ -898,6 +937,24 @@ void ivas_updt_dec_common_fx( st_fx->last_active_brate = st_fx->total_brate; } +#ifdef HARM_CORECODER_UPDT + IF( st_fx->element_mode == EVS_MONO ) + { + st_fx->last_core = st_fx->core; + move16(); + } + ELSE + { + test(); + if ( !st_fx->bfi || st_fx->element_mode == EVS_MONO ) + { + st_fx->last_core = st_fx->core; + move16(); + } + st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ + move16(); + } +#else move16(); move16(); if ( !st_fx->bfi || st_fx->element_mode == EVS_MONO ) @@ -905,6 +962,8 @@ void ivas_updt_dec_common_fx( st_fx->last_core = st_fx->core; } st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ +#endif + if ( st_fx->hHQ_core != NULL ) { st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx; @@ -919,14 +978,13 @@ void ivas_updt_dec_common_fx( move16(); st_fx->last_active_brate = st_fx->total_brate; } - /* INFO: moved from update_decoder_LPD_cng() */ + if ( NE_16( st_fx->m_frame_type, ACTIVE_FRAME ) ) { move16(); st_fx->last_is_cng = 1; } - if ( !st_fx->bfi ) { st_fx->last_core = st_fx->core; @@ -942,8 +1000,13 @@ void ivas_updt_dec_common_fx( test(); IF( EQ_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->core, AMR_WB_CORE ) ) { +#ifdef HARM_CORECODER_UPDT + Copy_Scale_sig( synth16 + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); +#else Copy_Scale_sig_32_16( synth + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); +#endif } + test(); test(); test(); @@ -987,6 +1050,7 @@ void ivas_updt_dec_common_fx( Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); } } + IF( EQ_16( st_fx->codec_mode, MODE2 ) ) { test(); @@ -1035,7 +1099,6 @@ void ivas_updt_dec_common_fx( test(); IF( ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) && EQ_16( st_fx->first_CNG, 1 ) && st_fx->hTdCngDec != NULL ) { - if ( GE_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) { st_fx->hTdCngDec->act_cnt = 0; @@ -1045,12 +1108,17 @@ void ivas_updt_dec_common_fx( st_fx->hTdCngDec->act_cnt = add( st_fx->hTdCngDec->act_cnt, 1 ); test(); - if ( ( EQ_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) && ( st_fx->hTdCngDec->ho_hist_size > 0 ) ) { st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 ); } +#ifdef HARM_CORECODER_UPDT + if ( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + st_fx->hTdCngDec->act_cnt2 = add( st_fx->hTdCngDec->act_cnt2, 1 ); + } +#endif if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) { st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; @@ -1101,7 +1169,11 @@ void ivas_updt_dec_common_fx( } ELSE IF( EQ_16( st_fx->codec_mode, MODE1 ) && ( ( GT_32( st_fx->core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, EVS_MONO ) ) ) ) { +#ifdef HARM_CORECODER_UPDT + updt_bw_switching_fx( st_fx, synth16, synth, Qpostd ); +#else ivas_updt_bw_switching_fx( st_fx, synth, Qpostd ); +#endif } ELSE { @@ -1125,10 +1197,19 @@ void ivas_updt_dec_common_fx( test(); test(); test(); - IF( st_fx->hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) ) + IF( hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) ) { /* update the parameters used in waveform adjustment */ - concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); +#ifdef HARM_CORECODER_UPDT + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + concealment_update2_x( (const Word16 *) synth16, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); + } + ELSE +#endif + { + concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); + } } st_fx->last_total_brate_ber = st_fx->total_brate; @@ -1140,8 +1221,10 @@ void ivas_updt_dec_common_fx( move32(); move32(); } + st_fx->last_low_rate_mode = st_fx->low_rate_mode; move16(); + if ( LT_16( st_fx->ini_frame, MAX_FRAME_COUNTER ) ) { st_fx->ini_frame = add( st_fx->ini_frame, 1 ); diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 9b20100ba..b5e2a6042 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -579,7 +579,11 @@ void amr_wb_enc_fx( updt_enc_fx( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf ); /* update main codec parameters */ +#ifdef HARM_CORECODER_UPDT + updt_enc_common_fx( st, Q_new ); +#else updt_enc_common_fx( st, Etot, Q_new ); +#endif #ifdef DEBUG_MODE_INFO dbgwrite( &st->codec_mode, sizeof( short ), 1, input_frame, "res/codec" ); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 34336ef79..46d357b17 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -541,7 +541,11 @@ ivas_error evs_enc_fx( signalling_enc_rf_fx( st ); #endif +#ifdef HARM_CORECODER_UPDT + updt_enc_common_fx( st, Q_new ); +#else updt_enc_common_fx( st, Etot, Q_new ); +#endif if ( EQ_16( st->mdct_sw, MODE1 ) ) { diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 4c9b00d46..acc9df330 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -847,7 +847,11 @@ ivas_error ivas_core_enc_fx( IF( !MCT_flag ) /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */ { +#ifdef HARM_CORECODER_UPDT + updt_enc_common_fx( st, Q_new[n] ); +#else updt_enc_common_ivas_fx( st, Q_new[n] ); +#endif } IF( st->hBWE_FD != NULL ) diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 88e88a865..534450f79 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -482,9 +482,13 @@ ivas_error ivas_mct_enc_fx( Copy32( hCPE->hCoreCoder[n]->input32_fx, hCPE->hCoreCoder[n]->old_input_signal32_fx, input_frame ); hCPE->hCoreCoder[n]->q_old_inp32 = hCPE->hCoreCoder[n]->q_inp32; move16(); - /* common encoder updates */ + /* common encoder updates */ +#ifdef HARM_CORECODER_UPDT + updt_enc_common_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); +#else updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); +#endif } } diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 0228b6cbe..45660c619 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -145,9 +145,11 @@ void ivas_long_enr_fx( move32(); } +#ifndef HARM_CORECODER_UPDT /*-----------------------------------------------------------------* * Initialize parameters for energy tracking and signal dynamics *-----------------------------------------------------------------*/ +#endif return; } @@ -168,7 +170,9 @@ void long_enr_fx( * and total active speech energy *-----------------------------------------------------------------*/ +#ifndef HARM_CORECODER_UPDT { +#endif IF( LT_16( st_fx->ini_frame, 4 ) ) { st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ @@ -210,10 +214,16 @@ void long_enr_fx( } } } - } - /*-----------------------------------------------------------------* - * Initialize parameters for energy tracking and signal dynamics - *-----------------------------------------------------------------*/ - return; +#ifdef HARM_CORECODER_UPDT + /* Update */ + st_fx->hNoiseEst->Etot_last_fx = Etot; +#else } +/*-----------------------------------------------------------------* + * Initialize parameters for energy tracking and signal dynamics + *-----------------------------------------------------------------*/ +#endif + + return; + } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 06630ab57..00acce41a 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -812,7 +812,9 @@ void sc_vbr_enc_init_fx( void updt_enc_common_fx( Encoder_State *st, /* i/o: encoder state structure */ +#ifndef HARM_CORECODER_UPDT const Word16 Etot, /* i : total energy */ +#endif const Word16 Q_new /* i : CUrrent frame scaling */ ); diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 2eb3e1a17..b9bf810e1 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -297,6 +297,7 @@ void updt_IO_switch_enc_fx( return; } + /*-------------------------------------------------------------------* * updt_enc_common_fx() * @@ -304,6 +305,7 @@ void updt_IO_switch_enc_fx( *-------------------------------------------------------------------*/ void updt_enc_common_fx( +#ifndef HARM_CORECODER_UPDT Encoder_State *st, /* i/o: encoder state structure */ const Word16 Etot, /* i : total energy */ const Word16 Q_new /* i : CUrrent frame scaling */ @@ -526,8 +528,8 @@ void updt_enc_common_fx( return; } - void updt_enc_common_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 Q_new /* i : CUrrent frame scaling */ ) -- GitLab From cf722b50460be034a5bc403fb49e24321678ea82 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 15:17:20 +0100 Subject: [PATCH 347/750] addition --- lib_enc/lsf_enc_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index bd9ae96d4..946330614 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -1580,10 +1580,14 @@ void lsf_end_enc_ivas_fx( IF( st->bwidth == NB ) { +#ifdef FIX_2302_LSF_CDBK_THRESHOLD + abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); +#else #ifdef HARM_LSF_ENC abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); #else abs_threshold = SFNETLOWLIMIT_NB / 2; +#endif #endif } ELSE -- GitLab From 03049121de35c2fc9769441d9da96bee0292973a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 14 Jan 2026 10:50:28 -0500 Subject: [PATCH 348/750] fixed missplaced braket that prevent compiling when 2311 switches are disabled --- lib_com/gs_gains_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 6e18a5f43..186cf3e98 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1599,8 +1599,8 @@ Word16 gsc_gainQ_fx( /*Q12*/ { #ifdef OPT_NBE_2311_HARM_GSC_GAIN IF( EQ_16( L_frame, L_FRAME ) ) - { #endif + { idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); @@ -1639,7 +1639,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ #ifdef OPT_NBE_2311_HARM_GSC_GAIN GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #else -GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); + GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #endif return mean_4g[0]; /*Q12*/ -- GitLab From 1a2a27f94c05b577b711c44c8aed6426fdab0752 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 17:14:10 +0100 Subject: [PATCH 349/750] fix init --- lib_com/prot_fx.h | 2 +- lib_enc/core_enc_updt_fx.c | 30 +++++++++++++++++++++++------- lib_enc/updt_enc_fx.c | 4 ++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index dcbd9d4b1..10f6ed23f 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10526,11 +10526,11 @@ void swb_pre_proc_ivas_fx( CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ); +#ifndef HARM_CORECODER_UPDT void core_encode_update_ivas_fx( Encoder_State *st /* i/o: Encoder state structure */ ); -#ifndef HARM_CORECODER_UPDT void updt_enc_common_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 Q_new /* i : CUrrent frame scaling */ diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c index 94a2ef746..9ec6eda6f 100644 --- a/lib_enc/core_enc_updt_fx.c +++ b/lib_enc/core_enc_updt_fx.c @@ -3,7 +3,6 @@ ====================================================================================*/ #include -//#include "prot_fx.h" #include "options.h" #include "cnst.h" /* Common constants */ #include "basop_util.h" @@ -12,6 +11,7 @@ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ +#ifndef HARM_CORECODER_UPDT void core_encode_update_fx( Encoder_State *st ) { Word16 n; @@ -61,11 +61,14 @@ void core_encode_update_fx( Encoder_State *st ) Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); } } +#endif + /*-------------------------------------------------------------------* * core_encode_update_cng_fx() * * Common updates in case of CNG *-------------------------------------------------------------------*/ + void core_encode_update_cng_fx( Encoder_State *st, Word16 *timeDomainBuffer, @@ -150,7 +153,6 @@ void core_encode_update_cng_fx( p_A += ( M + 1 ); } - tmp = sub( st->wspeech_enc[-1], shl( hLPDmem->mem_w0, shift ) ); E_UTIL_deemph2( negate( shift ), wsyn, st->preemph_fac, st->L_frame, &tmp ); hLPDmem->mem_w0 = sub_sat( st->wspeech_enc[st->L_frame - 1], tmp ); @@ -200,7 +202,11 @@ void core_encode_update_cng_fx( * Common updates of buffers *-------------------------------------------------------------------*/ +#ifdef HARM_CORECODER_UPDT +void core_encode_update_fx( +#else void core_encode_update_ivas_fx( +#endif Encoder_State *st /* i/o: Encoder state structure */ ) { @@ -226,11 +232,20 @@ void core_encode_update_ivas_fx( test(); IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) ) { - Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); - Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) - Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e) - st->hTcxEnc->exp_buf_speech_ltp = max_e; - move16(); +#ifdef HARM_CORECODER_UPDT + IF( st->element_mode == EVS_MONO ) + { + Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame ); + } + ELSE +#endif + { + Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); + Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) + Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e) + st->hTcxEnc->exp_buf_speech_ltp = max_e; + move16(); + } } } @@ -265,5 +280,6 @@ void core_encode_update_ivas_fx( set16_fx( st->mem_MA_fx, 0, M ); Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // 2.56 scaling } + return; } diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index b9bf810e1..138312847 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -707,7 +707,11 @@ void updt_enc_common_ivas_fx( } /* Update Core */ +#ifdef HARM_CORECODER_UPDT + core_encode_update_fx( st ); +#else core_encode_update_ivas_fx( st ); +#endif /*---------------------------------------------------------------------* * RF mode updates -- GitLab From fdc2daff2bd212e2ecd8621372466f41c7d26fa5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 14 Jan 2026 17:17:24 +0100 Subject: [PATCH 350/750] remove the unused function E_ACELP_conv_ivas_fx() --- lib_enc/acelp_enc_util_fx.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 26ca2a020..cd93c7f13 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -6,7 +6,6 @@ #include #include #include "options.h" -//#include "prot_fx.h" #include "basop_util.h" #include "cnst.h" #include "prot_fx.h" /* Function prototypes */ @@ -176,30 +175,6 @@ void E_ACELP_conv( } } -void E_ACELP_conv_ivas_fx( - const Word16 xn2[], /* i Qnew - 1*/ - const Word16 h2[], /* i Q12*/ - Word16 cn2[] /* o Qnew*/ -) -{ - Word16 i, k; - Word32 L_tmp; - - FOR( k = 0; k < L_SUBFR; k++ ) - { - /*cn2[k] = xn2[k]; */ - Word64 L_tmp_64; - L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* Qnew -1 + 12 */ - FOR( i = 0; i < k; i++ ) - { - /*cn2[k]-=cn2[i]*h2[k-i];*/ - L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*Qnew + 11*/ - } - L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */ - cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/ - move16(); - } -} void E_ACELP_build_code( Word16 nb_pulse, /* i Q0*/ const Word16 codvec[], /* i Q0*/ -- GitLab From ad92c9b318dbc9ea124eada32875b8e1796653cc Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 17:36:20 +0100 Subject: [PATCH 351/750] fix dtx_fx() --- lib_enc/dtx_fx.c | 25 +++++++++++++++++++++++++ lib_enc/prot_fx_enc.h | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index c9b2f5d0a..b80944b5f 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -82,6 +82,19 @@ void dtx_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word32 total_brate_ref; +#ifdef HARM_PREPROC + Word16 flag_lp_noise; + + IF( st_fx->element_mode == EVS_MONO ) + { + flag_lp_noise = LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); + } + ELSE + { + flag_lp_noise = LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); + } + move16(); +#endif total_brate_ref = st_fx->total_brate; move32(); @@ -98,7 +111,11 @@ void dtx_ivas_fx( test(); test(); test(); +#ifdef HARM_PREPROC + last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || flag_lp_noise || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); +#else last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); +#endif test(); test(); @@ -106,7 +123,11 @@ void dtx_ivas_fx( test(); last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || +#ifdef HARM_PREPROC + flag_lp_noise; +#else LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); +#endif } /* Initialization */ @@ -221,7 +242,11 @@ void dtx_ivas_fx( test(); br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || +#ifdef HARM_PREPROC + flag_lp_noise; +#else LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 ); +#endif } test(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index eddda1a67..9802f4f75 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -152,7 +152,7 @@ void dtx_ivas_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ + const Word16 Q_speech /* i : Q factor for speech */ ); Word16 dtx_hangover_addition_fx( -- GitLab From ff92cefe6df29156becdb6e43b1be099410929d0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 18:39:31 +0100 Subject: [PATCH 352/750] comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 302890e14..934347a54 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,7 +145,7 @@ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ -#define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ +#define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 5b7c2a8f80d52b61967d5b8d12e50b3298aa3f4f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:10:50 +0100 Subject: [PATCH 353/750] fix EVS BE --- lib_enc/pitch_ol2_fx.c | 14 +++++++++++++- lib_enc/vad_fx.c | 7 +++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index af01e8dbf..b866091bc 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -489,7 +489,19 @@ void StableHighPitchDetect_ivas_fx( /* pitch_freq_point = (short)(L_FFT/(mult_fact*T_op[1])+0.5f);*/ Top = pitch[1]; move16(); - pitch_freq_point = idiv1616( L_FFT, Top ); /* Q0*/ +#ifdef HARM_PREPROC + IF( element_mode == EVS_MONO ) + { + exp = norm_s( Top ); + tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ + L_tmp = L_mult0( tmp, L_FFT ); + pitch_freq_point = extract_h( L_add( L_shl( L_tmp, sub( exp, 13 ) ), 32768 ) ); /* Q0*/ + } + ELSE +#endif + { + pitch_freq_point = idiv1616( L_FFT, Top ); /* Q0*/ + } sum_energy = L_deposit_l( 0 ); FOR( i = 1; i < 2 * pitch_freq_point; i++ ) { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 8a37d87ba..2e03bc59e 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -439,6 +439,7 @@ Word16 ivas_dtx_hangover_addition_fx( Word16 hangover_short_dtx; /* Q0 */ Word16 flag_dtx; /* Q0 */ Word16 tmp; /* Q0 */ + if ( hNoiseEst == NULL ) { hNoiseEst = st_fx->hNoiseEst; @@ -451,7 +452,6 @@ Word16 ivas_dtx_hangover_addition_fx( hVAD = st_fx->hVAD; } - flag_dtx = 0; move16(); @@ -486,7 +486,6 @@ Word16 ivas_dtx_hangover_addition_fx( } /* Only allow short HO if not sufficient active frames in clean speech*/ - tmp = 3; move16(); /* default for EVS*/ if ( EQ_16( st_fx->core, AMR_WB_CORE ) ) @@ -505,7 +504,7 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); } - /* limit dtx hangover addition up to "tmp" frames in clean cond */ + /* limit dtx hangover addition up to "tmp" frames in clean cond */ IF( tmp != 0 ) { test(); @@ -519,13 +518,13 @@ Word16 ivas_dtx_hangover_addition_fx( } } - /* hangover adjustment from combined FFT+CLDFBVAD */ IF( NE_16( st_fx->core, AMR_WB_CORE ) ) { hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /*Q0*/ hangover_short_dtx = s_max( hangover_short_dtx, 0 ); } + IF( vad_flag != 0 ) /* Speech present */ { flag_dtx = 1; -- GitLab From 2a65dca10653a72092aa440590c804dc64c730a4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:33:26 +0100 Subject: [PATCH 354/750] cleaning --- lib_enc/pitch_ol2_fx.c | 58 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index b866091bc..9a1a00ff0 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -519,7 +519,6 @@ void StableHighPitchDetect_ivas_fx( diff = L_mac0( L_negate( sum_energy ), EspecdB[pitch_freq_point], tmp ); /*sum_energy /= (2*pitch_freq_point-1);*/ - exp = norm_s( tmp ); tmp1 = div_s( shl( 1, sub( 14, exp ) ), tmp ); /*Q(29-exp)*/ L_tmp = Mult_32_16( sum_energy, tmp1 ); @@ -559,6 +558,7 @@ void StableHighPitchDetect_ivas_fx( { diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); } + test(); test(); IF( LT_32( *diff_sm, -1280 /*-10.0f Q7*/ ) && LT_32( *energy_sm, 4928 /*38.5f Q7*/ ) && LT_16( diff16, -26214 /*-.8f Q15*/ ) ) @@ -566,6 +566,7 @@ void StableHighPitchDetect_ivas_fx( *predecision_flag = 1; move16(); } + test(); test(); if ( GT_32( *diff_sm, 1280 /*10.0f Q7*/ ) && GT_32( *energy_sm, 10624 /*83.0f Q7*/ ) && GT_16( diff16, 16384 /*.5 Q15*/ ) ) @@ -595,6 +596,7 @@ void StableHighPitchDetect_ivas_fx( L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); *LF_EnergyRatio_sm = round_fx( L_tmp ); move16(); + test(); if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) { @@ -649,43 +651,37 @@ void StableHighPitchDetect_ivas_fx( move16(); /* final short pitch detection */ +#ifdef HARM_PREPROC + *flag_spitch = 0; + move16(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && + ( ( EQ_16( element_mode, EVS_MONO ) && GT_16( *voicing0_sm, 16384 ) && GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) || + ( NE_16( element_mode, EVS_MONO ) && GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) && GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) ) +#else test(); test(); test(); *flag_spitch = 0; move16(); - -#ifdef HARM_PREPROC - IF( element_mode == EVS_MONO ) - { - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 16384 ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } - } - ELSE + IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && + ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) #endif { - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } + *flag_spitch = 1; + move16(); + pitch[0] = Tp; + move16(); + pitch[1] = Tp; + move16(); + pitch[2] = Tp; + move16(); } return; -- GitLab From a95a07684f16abbaaf104a3405a94b6ab4352ff2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:40:30 +0100 Subject: [PATCH 355/750] clang-format --- lib_enc/pitch_ol2_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 9a1a00ff0..5b49c85b4 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -493,7 +493,7 @@ void StableHighPitchDetect_ivas_fx( IF( element_mode == EVS_MONO ) { exp = norm_s( Top ); - tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ + tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ L_tmp = L_mult0( tmp, L_FFT ); pitch_freq_point = extract_h( L_add( L_shl( L_tmp, sub( exp, 13 ) ), 32768 ) ); /* Q0*/ } -- GitLab From 7df0a90501e3be0d0477317b94999a98581cf4a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:58:33 +0100 Subject: [PATCH 356/750] fix build --- lib_enc/dtx_fx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index b80944b5f..b9ec0c872 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -85,15 +85,17 @@ void dtx_ivas_fx( #ifdef HARM_PREPROC Word16 flag_lp_noise; - IF( st_fx->element_mode == EVS_MONO ) - { - flag_lp_noise = LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); - } - ELSE + flag_lp_noise = 0; + move16(); + test(); + test(); + test(); + IF( ( st_fx->element_mode == EVS_MONO && LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) || + ( st_fx->element_mode != EVS_MONO && LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) ) ) { - flag_lp_noise = LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); + flag_lp_noise = 1; + move16(); } - move16(); #endif total_brate_ref = st_fx->total_brate; -- GitLab From 6ccdb87cff5710cc2fee0a618bf2f1d92a23a3f8 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 15 Jan 2026 10:53:20 +0100 Subject: [PATCH 357/750] clang format --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 056250818..c44dfc324 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -628,7 +628,7 @@ ivas_error IVAS_DEC_Configure( move16(); } - IF( EQ_16(render_num_subframes, IVAS_RENDER_NUM_SUBFR_UNKNOWN) ) + IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_UNKNOWN ) ) { return IVAS_ERR_WRONG_PARAMS; } -- GitLab From 067f70906e93555969842dfa22828a5a0e66f190 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 15 Jan 2026 10:50:31 +0100 Subject: [PATCH 358/750] change Makefile to assure use of clang-18 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c9ae4493d..1fa184306 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ endif endif ifndef VERBOSE -QUIET_CC = @echo ' ' Compiling $<; +QUIET_CC = @echo ' ' Compiling $< with $(CC); QUIET_LINK= @echo ' ' Linking $@; QUIET_AR = @echo ' ' Archiving $@; QUIET = @ @@ -75,7 +75,7 @@ CFLAGS += -Wunused-but-set-variable LDLIBS += -lm # Clang sanitizer compiler options -CCCLANG = clang +CCCLANG = clang-18 ifeq "$(CLANG)" "0" CC = $(CCCLANG) endif -- GitLab From 464a060cd5511a03e583d1a62660365ec60fa409 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 15 Jan 2026 10:50:49 +0100 Subject: [PATCH 359/750] initialize currentPanGains_fx --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 03286b669..8365436c2 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6987,7 +6987,7 @@ static ivas_error renderIsmToSba( Word8 position_changed; Word16 ambiOrderOut; Word16 numOutChannels; - pan_vector_fx currentPanGains_fx; + pan_vector_fx currentPanGains_fx = { 0 }; //Solve Clang-18 warnings ivas_error error; error = IVAS_ERR_OK; move32(); -- GitLab From baccb330f029510f009410410acf5498be76f26c Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 15 Jan 2026 10:58:51 +0100 Subject: [PATCH 360/750] fix incorrect inintialization --- apps/decoder.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index d2f26d6dd..a6b05dccc 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2020,7 +2020,7 @@ static ivas_error decodeG192( bool needNewFrame; int16_t nSamplesRendered, nSamplesRendered_loop, nSamplesToRender; IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; - IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 } }; + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 } }; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; SplitFileReadWrite *splitRendWriter = NULL; @@ -2560,13 +2560,15 @@ static ivas_error decodeG192( { if ( headRotReader == NULL ) { - Quaternions[0].w = -3.0f; - Quaternions[0].x = 0.0f; - Quaternions[0].y = 0.0f; - Quaternions[0].z = 0.0f; - Pos[0].x = 0.0f; - Pos[0].y = 0.0f; - Pos[0].z = 0.0f; + Quaternions[i].w_fx = -12582912; + Quaternions[i].x_fx = 0; + Quaternions[i].y_fx = 0; + Quaternions[i].z_fx = 0; + Quaternions[i].q_fact = 22; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; + Pos[i].q_fact = 25; } else { @@ -2809,7 +2811,7 @@ static ivas_error decodeVoIP( IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; - IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 }, { -3, 0, 0, 0 } }; + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 } }; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; int16_t nOutSamples = 0; -- GitLab From 11c9f236ad878e12e24b123801cac71b6f6fda6d Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 15 Jan 2026 11:07:32 +0100 Subject: [PATCH 361/750] fix incorrect inintialization --- apps/isar_post_rend.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 196930428..52abe4fe7 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -1318,13 +1318,14 @@ int main( { for ( i = 0; i < num_subframes; i++ ) { - headRot[i].w = -3.0f; - headRot[i].x = 0.0f; - headRot[i].y = 0.0f; - headRot[i].z = 0.0f; - Pos[i].x = 0.0f; - Pos[i].y = 0.0f; - Pos[i].z = 0.0f; + headRot[i].w_fx = -12582912; + headRot[i].x_fx = 0; + headRot[i].y_fx = 0; + headRot[i].z_fx = 0; + headRot[i].q_fact = 22; + Pos[i].x_fx = 0; + Pos[i].y_fx = 0; + Pos[i].z_fx = 0; } } -- GitLab From 2b3263450636a40998f621f8ed35fa040c2eeae7 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 15 Jan 2026 14:37:29 +0200 Subject: [PATCH 362/750] Fix float issue 1501 by adding a skip if number of two dir bands is zero. This matches the float code. --- lib_com/options.h | 1 + lib_enc/ivas_masa_enc_fx.c | 46 ++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..43b070174 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index cb3b6e563..4d321702f 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1800,33 +1800,41 @@ void ivas_masa_combine_directions_fx( } } - /* Estimate the importance of having two directions instead of one */ - /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */ - FOR( i = 0; i < numCodingBands; i++ ) +#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA + IF( GT_16( hMasa->config.numTwoDirBands, 0 ) ) { - importance_fx[i] = 0; - move32(); - FOR( j = 0; j < numSf; j++ ) +#endif + /* Estimate the importance of having two directions instead of one */ + /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */ + FOR( i = 0; i < numCodingBands; i++ ) { - tempImportance_fx = L_shr( L_add( hMeta->directional_meta[0].energy_ratio_fx[j][i], hMeta->directional_meta[1].energy_ratio_fx[j][i] ), Q30 - Q13 ); // Q13 - tempImportance_fx = L_sub( tempImportance_fx, L_shr( sumVecLen_fx[j][i], sub( sub( Q31, exp_sumVecLen ), Q13 ) ) ); // Q13 - importance_fx[i] = L_add( importance_fx[i], tempImportance_fx ); // Q13 + importance_fx[i] = 0; move32(); - } + FOR( j = 0; j < numSf; j++ ) + { + tempImportance_fx = L_shr( L_add( hMeta->directional_meta[0].energy_ratio_fx[j][i], hMeta->directional_meta[1].energy_ratio_fx[j][i] ), Q30 - Q13 ); // Q13 + tempImportance_fx = L_sub( tempImportance_fx, L_shr( sumVecLen_fx[j][i], sub( sub( Q31, exp_sumVecLen ), Q13 ) ) ); // Q13 + importance_fx[i] = L_add( importance_fx[i], tempImportance_fx ); // Q13 + move32(); + } - IF( NE_16( numSf, 1 ) ) - { - importance_fx[i] = L_shr( importance_fx[i], 2 ); // Q13 + IF( NE_16( numSf, 1 ) ) + { + importance_fx[i] = L_shr( importance_fx[i], 2 ); // Q13 + move32(); + } + importance_fx[i] = Mpy_32_32( importance_fx[i], hMasa->data.importanceWeight_fx[i] ); //(Q13, Q30) -> Q12 move32(); } - importance_fx[i] = Mpy_32_32( importance_fx[i], hMasa->data.importanceWeight_fx[i] ); //(Q13, Q30) -> Q12 - move32(); + exp_importance = Q31 - Q12; + move16(); + + /* Determine bands where to use two directions */ + find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands ); +#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA } - exp_importance = Q31 - Q12; - move16(); - /* Determine bands where to use two directions */ - find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands ); +#endif FOR( i = 0; i < numCodingBands; i++ ) { -- GitLab From f9b8d5b20029e0693229dd6b70e7f5b8770c7303 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:42:59 +0100 Subject: [PATCH 363/750] [cleanup] accept FIX_1466_EXTREND --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 28 ---------------------------- 2 files changed, 29 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..c9d9fde5a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ -#define FIX_1466_EXTREND /* FhG: float issue 1466: enable rendering of mono/stereo to other formats in the external renderer */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ #define FIX_2249_MEMORY_LEAK_IN_SBA /* OR : issue 2249 : Memory leak in SBA to BINAURAL_ROOM_REVERB with memory instrumentation */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 03286b669..9ac2314fd 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1398,7 +1398,6 @@ static bool isIoConfigPairSupported( const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig ) { -#ifdef FIX_1466_EXTREND /* input config cannot be binaural */ test(); test(); @@ -1413,15 +1412,6 @@ static bool isIoConfigPairSupported( { return false; } -#else - /* Rendering mono or stereo to binaural is not supported */ - test(); - test(); - IF( ( EQ_32( inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) && EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) - { - return false; - } -#endif /* If not returned so far, config pair is supported */ return true; @@ -2586,23 +2576,18 @@ static ivas_error updateMcPanGainsForAmbiOut( { Word16 ch_in, ch_out, lfeIdx, i; Word16 numNonLfeInChannels, outAmbiOrder; -#ifdef FIX_1466_EXTREND AUDIO_CONFIG inConfig; -#endif const Word32 *spkAzi_fx, *spkEle_fx; /* Q22 */ ivas_error error; -#ifdef FIX_1466_EXTREND inConfig = inputMc->base.inConfig; move32(); -#endif IF( NE_32( ( error = getAmbisonicsOrder_fx( outConfig, &outAmbiOrder ) ), IVAS_ERR_OK ) ) { return error; } -#ifdef FIX_1466_EXTREND test(); IF( EQ_32( inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) { @@ -2630,9 +2615,6 @@ static ivas_error updateMcPanGainsForAmbiOut( return IVAS_ERR_OK; } ELSE IF( NE_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) -#else - IF( NE_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) -#endif { IF( NE_32( ( error = getNumNonLfeChannelsInSpeakerLayout( inputMc->base.inConfig, &numNonLfeInChannels ) ), IVAS_ERR_OK ) ) { @@ -2743,7 +2725,6 @@ static ivas_error updateMcPanGainsForAmbiOut( return IVAS_ERR_OK; } -#ifdef FIX_1466_EXTREND static ivas_error updateMcPanGainsForBinauralOut( input_mc *inputMc ) @@ -2775,7 +2756,6 @@ static ivas_error updateMcPanGainsForBinauralOut( return IVAS_ERR_OK; } -#endif static ivas_error updateMcPanGains( input_mc *inputMc, const AUDIO_CONFIG outConfig ) @@ -2797,7 +2777,6 @@ static ivas_error updateMcPanGains( error = updateMcPanGainsForAmbiOut( inputMc, outConfig ); BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: -#ifdef FIX_1466_EXTREND test(); IF( EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) { @@ -2806,7 +2785,6 @@ static ivas_error updateMcPanGains( } /* not mono or stereo */ -#endif SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: @@ -2864,14 +2842,12 @@ static ivas_error initMcBinauralRendering( Word32 outSampleRate; Word8 useTDRend; Word16 i; -#ifdef FIX_1466_EXTREND test(); IF( EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) { return IVAS_ERR_OK; } -#endif /* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation) or planar MC layouts with headrotation, CREND for the rest */ @@ -7390,7 +7366,6 @@ static ivas_error renderActiveInputsIsm( } return IVAS_ERR_OK; } -#ifdef FIX_1466_EXTREND static void renderMonoStereoToBinaural( const input_mc *mcInput, @@ -7412,7 +7387,6 @@ static void renderMonoStereoToBinaural( return; } -#endif static ivas_error renderLfeToBinaural_fx( const input_mc *mcInput, @@ -8167,7 +8141,6 @@ static ivas_error renderInputMc( renderMcToSba( mcInput, outAudio ); BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: -#ifdef FIX_1466_EXTREND test(); IF( EQ_32( mcInput->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( mcInput->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) { @@ -8176,7 +8149,6 @@ static ivas_error renderInputMc( } /* not mono or stereo */ -#endif SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: -- GitLab From 1f4de7d92737ece6f448f3c3ae641b3656779ac7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:43:59 +0100 Subject: [PATCH 364/750] [cleanup] accept FIX_1435_MOVE_STEREO_PANNING --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 39 ------------------------------ lib_dec/ivas_output_config_fx.c | 33 -------------------------- lib_dec/jbm_pcmdsp_apa_fx.c | 4 ---- lib_dec/lib_dec_fx.c | 42 --------------------------------- 5 files changed, 119 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c9d9fde5a..b68261fc0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ #define FIX_2249_MEMORY_LEAK_IN_SBA /* OR : issue 2249 : Memory leak in SBA to BINAURAL_ROOM_REVERB with memory instrumentation */ #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 */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index fce0f97f3..996c637af 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1844,16 +1844,6 @@ ivas_error ivas_dec_render_fx( } ELSE IF( EQ_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { -#ifndef FIX_1435_MOVE_STEREO_PANNING - Word16 slot_size, tmp, e; - - slot_size = st_ivas->hTcBuffer->n_samples_granularity; - move16(); - - /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e ); - tmp = shr( tmp, sub( 15, e ) ); -#endif ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); } ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) @@ -1863,12 +1853,10 @@ ivas_error ivas_dec_render_fx( { ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } -#ifdef FIX_1435_MOVE_STEREO_PANNING ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); } -#endif ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { #ifdef FIX_1454_FIX_STEREO_TO_FOA_JBM @@ -3232,7 +3220,6 @@ Word16 ivas_dec_get_num_tc_channels_fx( test(); test(); test(); -#ifdef FIX_1435_MOVE_STEREO_PANNING test(); IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { @@ -3240,9 +3227,6 @@ Word16 ivas_dec_get_num_tc_channels_fx( move16(); } ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) -#else - IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) -#endif { num_tc = 1; move16(); @@ -3383,13 +3367,6 @@ Word16 ivas_dec_get_num_tc_channels_fx( } } } -#ifndef FIX_1435_MOVE_STEREO_PANNING - ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) - { - num_tc = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; - move16(); - } -#endif return num_tc; } @@ -3920,9 +3897,7 @@ TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx( buffer_mode = TC_BUFFER_MODE_BUFFER; move16(); BREAK; -#ifdef FIX_1435_MOVE_STEREO_PANNING case RENDERER_NON_DIEGETIC_DOWNMIX: -#endif case RENDERER_TD_PANNING: case RENDERER_BINAURAL_OBJECTS_TD: case RENDERER_BINAURAL_FASTCONV: @@ -3941,20 +3916,6 @@ TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx( buffer_mode = TC_BUFFER_MODE_RENDERER; move16(); BREAK; -#ifndef FIX_1435_MOVE_STEREO_PANNING - case RENDERER_NON_DIEGETIC_DOWNMIX: - IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) - { - buffer_mode = TC_BUFFER_MODE_BUFFER; - move16(); - } - ELSE - { - buffer_mode = TC_BUFFER_MODE_RENDERER; - move16(); - } - break; -#endif case RENDERER_MC_PARAMMC: IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 2d825d64a..932f07606 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -283,22 +283,14 @@ void ivas_renderer_select( * Non-binaural rendering configurations *-----------------------------------------------------------------*/ -#ifdef FIX_1435_MOVE_STEREO_PANNING ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) -#else - ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) -#endif { test(); test(); test(); test(); test(); -#ifdef FIX_1435_MOVE_STEREO_PANNING IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) -#endif { *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; move16(); @@ -308,38 +300,13 @@ void ivas_renderer_select( *renderer_type = RENDERER_MC; move16(); } -#ifdef FIX_1435_MOVE_STEREO_PANNING ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) { *renderer_type = RENDERER_SBA_LINEAR_ENC; move16(); } -#endif } -#ifndef FIX_1435_MOVE_STEREO_PANNING - ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - *renderer_type = RENDERER_SBA_LINEAR_ENC; - move16(); - } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - *renderer_type = RENDERER_MC; - move16(); - } - } -#endif ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { test(); diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 63cbe2e1e..8adcb9a3e 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -690,11 +690,7 @@ UWord8 apa_exec_fx( ) { UWord16 i; -#ifdef FIX_1435_MOVE_STEREO_PANNING Word16 frm_in[APA_BUF_PER_CHANNEL]; /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate */ -#else - Word16 frm_in[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */ -#endif UWord16 l_frm_out; Word16 l_rem; Word32 dl_scaled, dl_copied, l_frm_out_target; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f7d12e5d2..b6ea7970e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1637,18 +1637,7 @@ static ivas_error ivas_dec_setup_all( IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { -#ifdef FIX_1435_MOVE_STEREO_PANNING *nTransportChannels = 1; -#else - IF( EQ_16( (Word16) hIvasDec->st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) - { - *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; - } - ELSE - { - *nTransportChannels = 1; - } -#endif move16(); } ELSE @@ -3852,11 +3841,7 @@ static ivas_error apa_exec_evs_wrapper( { Word16 ch; UWord16 apa_buff_len; -#ifdef FIX_1435_MOVE_STEREO_PANNING Word16 tmp_apaExecBuffer[APA_BUF_PER_CHANNEL]; -#else - Word16 tmp_apaExecBuffer[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ -#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; test(); @@ -5645,14 +5630,8 @@ static ivas_error evs_dec_main_fx( Decoder_Struct *st_ivas ) { DEC_CORE_HANDLE *hCoreCoder; -#ifndef FIX_1435_MOVE_STEREO_PANNING - Word16 mixer_left_fx, mixer_right_fx; - Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; - Word16 ch, i, nOutSamples; -#else Word32 *p_output_fx[1]; Word16 i, nOutSamples; -#endif Word16 output_16[L_FRAME48k]; ivas_error error; @@ -5666,18 +5645,7 @@ static ivas_error evs_dec_main_fx( mdct_switching_dec_fx( hCoreCoder[0] ); -#ifdef FIX_1435_MOVE_STEREO_PANNING p_output_fx[0] = st_ivas->p_output_fx[0]; -#else - FOR( ch = 0; ch < MAX_TRANSPORT_CHANNELS; ch++ ) - { - p_output_fx[ch] = st_ivas->p_output_fx[ch]; // Q0 - IF( p_output_fx[ch] != NULL ) - { - set_zero_fx( p_output_fx[ch], L_FRAME48k ); - } - } -#endif /* run the main EVS decoding routine */ IF( EQ_16( hCoreCoder[0]->codec_mode, MODE1 ) ) @@ -5729,16 +5697,6 @@ static ivas_error evs_dec_main_fx( st_ivas->BER_detect = hCoreCoder[0]->BER_detect; move16(); -#ifndef FIX_1435_MOVE_STEREO_PANNING - IF( EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) - { - mixer_left_fx = add( shr( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, Q1 ), ONE_IN_Q14 ); // Q14 - mixer_right_fx = sub( MAX16B, mixer_left_fx ); - - v_multc_fx_16( p_output_fx[0], mixer_right_fx, p_output_fx[1], nOutSamples ); /* Q11 */ - v_multc_fx_16( p_output_fx[0], mixer_left_fx, p_output_fx[0], nOutSamples ); /* Q11 */ - } -#endif /*if ( st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO )*/ { -- GitLab From 14e7c538c5684a8aeda10c26ccd9ad537fbe9525 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:45:00 +0100 Subject: [PATCH 365/750] [cleanup] accept FIX_2249_MEMORY_LEAK_IN_SBA --- apps/decoder.c | 63 ------ apps/renderer.c | 8 - lib_com/options.h | 1 - lib_dec/ivas_init_dec_fx.c | 29 --- lib_dec/lib_dec_fx.c | 12 -- lib_rend/ivas_crend_fx.c | 3 - lib_rend/ivas_hrtf_fx.c | 245 ---------------------- lib_rend/ivas_objectRenderer_mix_fx.c | 25 --- lib_rend/ivas_prot_rend_fx.h | 38 ---- lib_rend/ivas_reverb_fx.c | 4 - lib_rend/ivas_stat_rend.h | 13 -- lib_rend/lib_rend_fx.c | 23 --- lib_util/hrtf_file_reader.c | 280 -------------------------- lib_util/hrtf_file_reader.h | 14 -- 14 files changed, 758 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index cd811b7a3..0b8a1d018 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -142,11 +142,6 @@ typedef struct hrtfFileReader *hrtfReader; char *hrtfFileName; -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD; - - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics; -#endif IVAS_BIN_RENDERER_TYPE binaural_renderer; IVAS_BIN_RENDERER_TYPE binaural_renderer_old; @@ -209,10 +204,6 @@ int main( reset_mem( USE_BYTES ); #endif -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */ - hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */ -#endif splitRendBits.bits_buf = splitRendBitsBuf; @@ -741,21 +732,6 @@ cleanup: free( arg.aeSequence.pValidity ); } -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - if ( arg.hrtfReaderEnabled ) - { - destroy_td_hrtf( hHrtfBinary.hHrtfTD ); - destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics ); - } -#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD - // TODO: - /* This free differs from float version. - This is needed as HRTF statistics from ROM are currently converted from Word16 values to scaled Word32 values. */ - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; - IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); - destroy_hrtf_statistics( hHrtfStatistics ); -#endif -#endif IVAS_DEC_Close( &hIvasDec ); CustomLsReader_close( &hLsCustomReader ); hrtfFileReader_close( &hrtfReader ); @@ -3769,12 +3745,6 @@ static ivas_error load_hrtf_from_file( /*------------------------------------------------------------------------------------------* * Release HRTF binary data *------------------------------------------------------------------------------------------*/ -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && binaural_renderer_sec != IVAS_BIN_RENDERER_TYPE_TDREND && hHrtfBinary->hHrtfTD != NULL ) - { - destroy_td_hrtf( hHrtfBinary->hHrtfTD ); - } -#endif if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK ) { return error; @@ -3797,22 +3767,14 @@ static ivas_error load_hrtf_from_file( if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_sec == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD = NULL; if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nIVAS_DEC_GetHrtfTDrendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -3821,11 +3783,7 @@ static ivas_error load_hrtf_from_file( } else { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA destroy_td_hrtf( hHrtfTD ); -#else - destroy_td_hrtf( hHrtfBinary->hHrtfTD ); -#endif } } } @@ -3898,32 +3856,17 @@ static ivas_error load_hrtf_from_file( } } } -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - } -#endif -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) -#else - if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) -#endif { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -3932,17 +3875,11 @@ static ivas_error load_hrtf_from_file( } else { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA destroy_hrtf_statistics( hHrtfStatistics ); -#else - destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); -#endif } } } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA } -#endif return IVAS_ERR_OK; } diff --git a/apps/renderer.c b/apps/renderer.c index 356e8c0af..8da507bbe 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1107,11 +1107,7 @@ int main( fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" ); goto cleanup; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) -#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -2203,10 +2199,6 @@ cleanup: RotationFileReader_close( &externalOrientationFileReader ); RotationFileReader_close( &referenceRotReader ); Vector3PairFileReader_close( &referenceVectorReader ); -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - destroy_td_hrtf( hHrtfTD ); - destroy_hrtf_statistics( hHrtfStatistics ); -#endif IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); RenderConfigReader_close( &renderConfigReader ); diff --git a/lib_com/options.h b/lib_com/options.h index b68261fc0..3716a126c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2249_MEMORY_LEAK_IN_SBA /* OR : issue 2249 : Memory leak in SBA to BINAURAL_ROOM_REVERB with memory instrumentation */ #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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 939f1d8c5..a5e28c136 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1799,18 +1799,11 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { /* Init HRTF statistics */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /* Allocate HRTF and init statistics */ IF( NE_32( ( error = ivas_reverb_HRTF_statistics_open_fx( &( st_ivas->hHrtfStatistics ), output_Fs ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif /* Get default reverb values based on format, if custom values were not given */ IF( EQ_16( st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0 ) ) @@ -3549,30 +3542,12 @@ void ivas_destroy_dec_fx( ivas_combined_orientation_close_fx( &st_ivas->hCombinedOrientationData ); /* Time Domain binaural renderer handle */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); -#else - IF( st_ivas->hBinRendererTd != NULL ) - { - ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); - } - - IF( st_ivas->hHrtfTD != NULL ) - { - BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); - - ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); - } -#endif /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close_fx( &st_ivas->hHrtfCrend ); -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - /* Fastconv HRTF memories */ - ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv ); -#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); @@ -3581,11 +3556,7 @@ void ivas_destroy_dec_fx( ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); /* HRTF statistics */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_statistics_binary_close_fx( &st_ivas->hHrtfStatistics ); -#else - ivas_HRTF_statistics_close_fx( &st_ivas->hHrtfStatistics ); -#endif /* Config. Renderer */ ivas_render_config_close_fx( &( st_ivas->hRenderConfig ) ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index b6ea7970e..fb526e127 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2483,11 +2483,7 @@ ivas_error IVAS_DEC_HRTF_binary_open( test(); IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfTD == NULL ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA IF( ( error = ivas_HRTF_td_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) -#else - IF( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2569,11 +2565,7 @@ ivas_error IVAS_DEC_HRTF_binary_close( test(); IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); -#else - ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); -#endif } test(); @@ -2586,10 +2578,6 @@ ivas_error IVAS_DEC_HRTF_binary_close( test(); IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_FASTCONV ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) ) { -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - /* Fastconv HRTF memories */ - ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv ); -#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 4d8117561..2a4e26937 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1814,9 +1814,6 @@ void ivas_rend_closeCldfbRend( ivas_binRenderer_close_fx( &pCldfbRend->hCldfbRend ); -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_binaural_hrtf_close_fx( &pCldfbRend->hHrtfFastConv ); -#endif ivas_HRTF_fastconv_binary_close_fx( &pCldfbRend->hHrtfFastConv ); return; diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 118c94e32..8bce30d53 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -37,9 +37,6 @@ #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA -#include "ivas_rom_binaural_crend_head.h" -#endif /*-----------------------------------------------------------------------* * ivas_HRTF_td_binary_open() @@ -47,13 +44,8 @@ * Allocate HRTF binary handle for TD renderer *-----------------------------------------------------------------------*/ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_error ivas_HRTF_td_binary_open_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD ) -#else -ivas_error ivas_HRTF_binary_open_fx( - TDREND_HRFILT_FiltSet_t **hHrtfTD ) -#endif { /* Allocate HR filter set for headphones configuration */ *hHrtfTD = (TDREND_HRFILT_FiltSet_t *) malloc( sizeof( TDREND_HRFILT_FiltSet_t ) ); @@ -72,13 +64,8 @@ ivas_error ivas_HRTF_binary_open_fx( * * Close HRTF binary handle for TD renderer *-------------------------------------------------------------------*/ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_td_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD ) -#else -void ivas_HRTF_binary_close_fx( - TDREND_HRFILT_FiltSet_t **hHrtfTD ) -#endif { test(); IF( hHrtfTD == NULL || *hHrtfTD == NULL ) @@ -86,7 +73,6 @@ void ivas_HRTF_binary_close_fx( return; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA Word16 i; IF( ( *hHrtfTD )->ModelParams.modelROM ) { @@ -156,7 +142,6 @@ void ivas_HRTF_binary_close_fx( free( ( *hHrtfTD )->ModelEval.hrfModL_fx ); free( ( *hHrtfTD )->ModelEval.hrfModR_fx ); } -#endif free( *hHrtfTD ); *hHrtfTD = NULL; @@ -195,17 +180,10 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( * * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_error ivas_HRTF_binary_open_buffers_int16( Word16 **buffer, /* o : buffer to allocate */ const UWord32 mem_size /* i : size of buffer */ ) -#else -ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( - Word16 **buffer, /* o : buffer to allocate */ - const UWord32 mem_size /* i : size of buffer */ -) -#endif { *buffer = (Word16 *) malloc( mem_size ); @@ -217,7 +195,6 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( return IVAS_ERR_OK; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open_buffers_uint16() * @@ -298,7 +275,6 @@ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( return IVAS_ERR_OK; } -#endif /*-------------------------------------------------------------------* * ivas_HRTF_CRend_binary_close() * @@ -393,10 +369,8 @@ void ivas_HRTF_fastconv_binary_close_fx( return; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( hHrtfFastConv ); -#endif free( *hHrtfFastConv ); *hHrtfFastConv = NULL; @@ -462,9 +436,7 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA set_c( (Word8 *) ( *hHrtfStatistics ), 0, (Word32) sizeof( HRTFS_STATISTICS ) ); -#endif return IVAS_ERR_OK; } @@ -473,22 +445,15 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( * * Destroy the HRTF statistics set. *---------------------------------------------------------------------*/ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_statistics_binary_close_fx( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) -#else -void ivas_HRTF_statistics_close_fx( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ -) -#endif { test(); IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) { return; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA test(); IF( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { @@ -505,7 +470,6 @@ void ivas_HRTF_statistics_close_fx( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } -#endif free( *hHrtfStatistics ); *hHrtfStatistics = NULL; @@ -513,212 +477,3 @@ void ivas_HRTF_statistics_close_fx( return; } -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA -/*-----------------------------------------------------------------------* - * ivas_HRTF_statistics_init() - * - * Allocates HRTF statistics handle and initializes from ROM - *-----------------------------------------------------------------------*/ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA -ivas_error ivas_HRTF_statistics_init_from_rom_fx( - HRTFS_STATISTICS_HANDLE *hHrtfStatistics, - const Word32 sampleRate ) -#else -ivas_error ivas_HRTF_statistics_init_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, - const Word32 sampleRate ) -#endif -{ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA - - test(); - IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) - { - /* Tables already loaded from file */ - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - SWITCH( sampleRate ) - { - case 48000: - ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_coherence_48kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; - ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; - ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; - BREAK; - case 32000: - ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_coherence_32kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; - ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; - ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; - BREAK; - case 16000: - ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); - IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_coherence_16kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q26 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; - ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; - ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; - BREAK; - default: - ( *hHrtfStatistics )->average_energy_l = NULL; - ( *hHrtfStatistics )->average_energy_r = NULL; - ( *hHrtfStatistics )->inter_aural_coherence = NULL; - BREAK; - } - ( *hHrtfStatistics )->fromROM = TRUE; -#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD - ( *hHrtfStatistics )->fromROM = FALSE; // TODO: temporary hack until HRTF statistics ROM tables are converted from Word16 to Word32 -#endif - -#else - HRTFS_STATISTICS *HrtfStatistics; - - test(); - IF( hHrtfStatistics != NULL && *hHrtfStatistics != NULL ) - { - /* Tables already loaded from file */ - return IVAS_ERR_OK; - } - - /* Initialise tables from ROM */ - IF( ( HrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); - } - - HrtfStatistics->average_energy_l = NULL; - HrtfStatistics->average_energy_r = NULL; - HrtfStatistics->inter_aural_coherence = NULL; - - SWITCH( sampleRate ) - { - case 48000: - HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( HrtfStatistics->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( HrtfStatistics->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( HrtfStatistics->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_48kHz_fx, HrtfStatistics->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_48kHz_fx, HrtfStatistics->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_coherence_48kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; - HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; - HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; - BREAK; - case 32000: - HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( HrtfStatistics->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( HrtfStatistics->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - IF( HrtfStatistics->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_32kHz_fx, HrtfStatistics->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_32kHz_fx, HrtfStatistics->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_coherence_32kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; - HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; - HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; - BREAK; - case 16000: - HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); - IF( HrtfStatistics->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); - IF( HrtfStatistics->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); - IF( HrtfStatistics->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - Copy_Scale_sig_16_32_r( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q26 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; - HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; - HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; - BREAK; - } - HrtfStatistics->fromROM = TRUE; -#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD - HrtfStatistics->fromROM = FALSE; // TODO: temporary hack until HRTF statistics ROM tables are converted from Word16 to Word32 -#endif - - *hHrtfStatistics = HrtfStatistics; -#endif - - return IVAS_ERR_OK; -} -#endif diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index 35cf31546..ac2067c00 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -151,31 +151,6 @@ void TDREND_MIX_Dealloc_fx( { BSplineModelEvalDealloc_fx( &hBinRendererTd->HrFiltSet_p->ModelParams, &hBinRendererTd->HrFiltSet_p->ModelEval ); } -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - ELSE - { - IF( hBinRendererTd->HrFiltSet_p->Elev_p_fx != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->Elev_p_fx ); - hBinRendererTd->HrFiltSet_p->Elev_p_fx = NULL; - } - IF( hBinRendererTd->HrFiltSet_p->Azim_p_fx != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->Azim_p_fx ); - hBinRendererTd->HrFiltSet_p->Azim_p_fx = NULL; - } - IF( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p_fx != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p_fx ); - hBinRendererTd->HrFiltSet_p->LeftFiltSet_p_fx = NULL; - } - IF( hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx ); - hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx = NULL; - } - } -#endif IF( hBinRendererTd->HrFiltSet_p->ModelParams.modelROM ) { IF( hBinRendererTd->HrFiltSet_p->ModelParams.UseItdModel ) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index f6416f109..039b251ca 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -578,7 +578,6 @@ void ivas_masa_ext_dirac_render_fx( /*----------------------------------------------------------------------------------* * HRTF *----------------------------------------------------------------------------------*/ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_error ivas_HRTF_td_binary_open_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); @@ -586,15 +585,6 @@ ivas_error ivas_HRTF_td_binary_open_fx( void ivas_HRTF_td_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); -#else -ivas_error ivas_HRTF_binary_open_fx( - TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ -); - -void ivas_HRTF_binary_close_fx( - TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ -); -#endif ivas_error ivas_HRTF_fastconv_binary_open_fx( HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ @@ -616,7 +606,6 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_error ivas_HRTF_binary_open_buffers_uint16( uint16_t **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ @@ -641,38 +630,13 @@ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( const int32_t ***buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ); -#else -ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( - Word16 **buffer, /* o : buffer to allocate */ - const uint32_t mem_size /* i : size of buffer */ -); -#endif void ivas_HRTF_CRend_binary_close_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA -ivas_error ivas_HRTF_statistics_init_from_rom_fx( - HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ - const Word32 sampleRate /* i : Sample rate */ -); -#else -ivas_error ivas_HRTF_statistics_init_fx( - HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ - const Word32 sampleRate /* i : Sample rate */ -); -#endif -#endif -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_statistics_binary_close_fx( HRTFS_STATISTICS **hHrtfStatistics ); /* i/o: HRTF statistics structure */ -#else -void ivas_HRTF_statistics_close_fx( - HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ -); -#endif ivas_error ivas_HRTF_statistics_binary_open_fx( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ @@ -1002,12 +966,10 @@ void ivas_binaural_reverb_processSubframe_fx( Word32 outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_error ivas_reverb_HRTF_statistics_open_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* o : HRTF statistics handle */ const Word32 output_Fs /* i : output sampling rate */ ); -#endif ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 5d1e287a0..773f59276 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -34,9 +34,7 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA #include "ivas_rom_binaural_crend_head.h" -#endif #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include @@ -133,7 +131,6 @@ typedef struct ivas_reverb_params_t static ivas_error calc_jot_t60_coeffs_fx( Word16 *pH_dB_fx, Word16 pH_dB_exp, const UWord16 nrFrequencies, Word16 *pFrequencies_fx, Word16 *pCoeffA_fx, Word16 *pCoeffB_fx, const Word16 fNyquist_fx ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /*------------------------------------------------------------------------- * ivas_reverb_HRTF_statistics_open() @@ -246,7 +243,6 @@ ivas_error ivas_reverb_HRTF_statistics_open_fx( return IVAS_ERR_OK; } -#endif /*------------------------------------------------------------------------- * wrap_rad_fx() * diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ba5ee6f4e..8b7580a4f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1163,20 +1163,7 @@ typedef struct typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct { Word32 SampleRate; /* Sample rate of the HR filter */ -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - Word16 NumPos; - Word16 NumElev; - Word32 Dist_fx; - Word32 *ItdSet_p_fx; -#endif Word16 FiltLength; -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - Word16 *Azim_p_fx; - Word16 *Elev_p_fx; - Word16 *ItdSetNominal_p_fx; - Word16 *LeftFiltSet_p_fx; - Word16 *RightFiltSet_p_fx; -#endif ModelParams_t ModelParams; ModelEval_t ModelEval; ModelParamsITD_t ModelParamsITD; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 9ac2314fd..23c4ef0c4 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -3874,17 +3874,10 @@ ivas_error IVAS_REND_Open( IF( asHrtfBinary ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA IF( NE_32( ( error = ivas_HRTF_td_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) ) ), IVAS_ERR_OK ) ) { return error; @@ -3905,7 +3898,6 @@ ivas_error IVAS_REND_Open( IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( hIvasRend->hHrtfs.hHrtfStatistics == NULL ) { /* Allocate and init HRTF statistics */ @@ -3914,9 +3906,6 @@ ivas_error IVAS_REND_Open( return error; } } -#else - IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -9944,25 +9933,13 @@ void IVAS_REND_Close( ivas_external_orientation_close_fx( &hIvasRend->hExternalOrientationData ); ivas_combined_orientation_close_fx( &hIvasRend->hCombinedOrientationData ); -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - /* Fastconv HRTF memories */ - ivas_binaural_hrtf_close_fx( &hIvasRend->hHrtfs.hHrtfFastConv ); -#endif /* Parametric binauralizer HRTF filters */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_td_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ); -#else - ivas_HRTF_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ); -#endif ivas_HRTF_CRend_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) ); ivas_HRTF_fastconv_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); ivas_HRTF_parambin_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfParambin ) ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_statistics_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); -#else - ivas_HRTF_statistics_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); -#endif free( hIvasRend ); *phIvasRend = NULL; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index a21569f8d..02e99ae84 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -296,11 +296,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( &modelITD->elevDim3, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) ); -#else - modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) ); -#endif v_tmp16 = (Word16 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word16 ) ); if ( modelITD->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -315,11 +311,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); fread( &modelITD->azimDim3, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); -#else - modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ -#endif v_tmp16 = (Word16 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word16 ) ); if ( modelITD->azimKSeq_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -334,11 +326,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &modelITD->W_dyn_fx, tmp * sizeof( Word32 ) ); -#else - modelITD->W_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); -#endif if ( modelITD->W_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -360,21 +348,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); /* azimuth */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#else - modelITD->azimBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#endif if ( modelITD->azimBsLen_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( modelITD->azimBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#else - modelITD->azimBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#endif if ( modelITD->azimBsStart_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -382,11 +362,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->azimBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( Word32 ) ); -#else - modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); -#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( modelITD->azimBsShape_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -403,21 +379,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &modelITD->azimSegSamples, sizeof( Word16 ), 1, f_hrtf ); /* elevation */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#else - modelITD->elevBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#endif if ( modelITD->elevBsLen_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( modelITD->elevBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#else - modelITD->elevBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#endif if ( modelITD->elevBsStart_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -425,11 +393,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->elevBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) ); -#else - modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); -#endif if ( modelITD->elevBsShape_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -525,11 +489,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->K, sizeof( Word16 ), 1, f_hrtf ); fread( &model->elevDim3, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); -#else - model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); -#endif v_tmp16 = (Word16 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word16 ) ); if ( model->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) @@ -543,21 +503,9 @@ static ivas_error TDREND_LoadBSplineBinary( model->elevKSeq_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q ); } free( v_tmp16 ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( Word16 ) ); -#else - model->azimDim3_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); -#endif -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( Word16 ) ); -#else - model->azim_start_idx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); -#endif -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimKSeq_fx, model->elevDim3 * sizeof( float * ) ); -#else - model->azimKSeq_fx = (Word32 **) malloc( model->elevDim3 * sizeof( Word32 * ) ); -#endif if ( model->azimDim3_dyn == NULL || model->azim_start_idx_dyn == NULL || model->azimKSeq_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -567,11 +515,7 @@ static ivas_error TDREND_LoadBSplineBinary( { fread( &model->azimDim3_dyn[i], sizeof( Word16 ), 1, f_hrtf ); fread( &model->azim_start_idx_dyn[i], sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); -#else - model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); -#endif v_tmp16 = (Word16 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word16 ) ); if ( model->azimKSeq_fx[i] == NULL || v_tmp16 == NULL ) @@ -587,11 +531,7 @@ static ivas_error TDREND_LoadBSplineBinary( free( v_tmp16 ); } fread( &model->AlphaN, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) ); -#else - model->AlphaL_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); -#endif v_tmp16 = (Word16 *) malloc( model->AlphaN * model->K * sizeof( Word16 ) ); if ( model->AlphaL_dyn_fx == NULL || v_tmp16 == NULL ) @@ -609,11 +549,7 @@ static ivas_error TDREND_LoadBSplineBinary( { model->AlphaL_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) ); -#else - model->AlphaR_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); -#endif if ( model->AlphaR_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -629,21 +565,9 @@ static ivas_error TDREND_LoadBSplineBinary( /* azimuth */ fread( &model->num_unique_azim_splines, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32_ptr_const( &model->azimBsShape_fx, model->num_unique_azim_splines * sizeof( float * ) ); -#else - model->azimBsShape_fx = (const Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); -#endif -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimBsShape_dyn_fx, model->num_unique_azim_splines * sizeof( float * ) ); -#else - model->azimBsShape_dyn_fx = (Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); -#endif -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( Word16 ) ); -#else - model->azimSegSamples_dyn = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) ); -#endif if ( model->azimBsShape_fx == NULL || model->azimBsShape_dyn_fx == NULL || model->azimSegSamples_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -652,11 +576,7 @@ static ivas_error TDREND_LoadBSplineBinary( for ( i = 0; i < model->num_unique_azim_splines; i++ ) { fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->azimBsShape_dyn_fx[i], tmp * sizeof( Word32 ) ); -#else - model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) ); -#endif if ( model->azimBsShape_dyn_fx[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -676,21 +596,13 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->azimSegSamples_dyn[i], sizeof( Word16 ), 1, f_hrtf ); free( v_tmp16 ); } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( Word16 ) ); -#else - model->azimShapeIdx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); -#endif if ( model->azimShapeIdx_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( model->azimShapeIdx_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &model->azimShapeSampFactor_dyn, model->elevDim3 * sizeof( Word16 ) ); -#else - model->azimShapeSampFactor_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); -#endif if ( model->azimShapeSampFactor_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -698,21 +610,13 @@ static ivas_error TDREND_LoadBSplineBinary( fread( model->azimShapeSampFactor_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); /* elevation */ -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#else - model->elevBsLen_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#endif if ( model->elevBsLen_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( model->elevBsLen_dyn, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#else - model->elevBsStart_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); -#endif if ( model->elevBsStart_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -721,11 +625,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) ); -#else - model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); -#endif if ( model->elevBsShape_dyn_fx == NULL || v_tmp16 == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -741,11 +641,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->elevSegSamples, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->EL_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); -#else - model->EL_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); -#endif if ( model->EL_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -757,11 +653,7 @@ static ivas_error TDREND_LoadBSplineBinary( fread( (Word32 *) model->EL_dyn_fx, sizeof( Word32 ), model->AlphaN * HRTF_MODEL_N_SECTIONS, f_hrtf ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &model->ER_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); -#else - model->ER_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); -#endif if ( model->ER_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -791,13 +683,8 @@ static ivas_error TDREND_LoadBSplineBinary( HRTF_model_precalc( model ); HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModL_fx, model->K * sizeof( Word32 ) ); ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModR_fx, model->K * sizeof( Word32 ) ); -#else - HrFiltSet_p->ModelEval.hrfModL_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); - HrFiltSet_p->ModelEval.hrfModR_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); -#endif if ( HrFiltSet_p->ModelEval.hrfModL_fx == NULL || HrFiltSet_p->ModelEval.hrfModR_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -910,15 +797,9 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_l_dyn, lr_iac_len * sizeof( Word32 ) ); ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_r_dyn, lr_iac_len * sizeof( Word32 ) ); ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->inter_aural_coherence_dyn, lr_iac_len * sizeof( Word32 ) ); -#else - hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); -#endif if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -954,7 +835,6 @@ static ivas_error load_reverb_from_binary( return IVAS_ERR_OK; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /*---------------------------------------------------------------------* * load_HrtfStatistics_from_binary() * @@ -966,19 +846,6 @@ ivas_error load_HrtfStatistics_from_binary( const Word32 sampleRate, /* i : sample rate */ const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) -#else -/*---------------------------------------------------------------------* - * load_reverb_binary() - * - * Load HRTF binary data into the HRTF handle for TD and Crend renderers - *---------------------------------------------------------------------*/ - -ivas_error load_reverb_binary( - IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ - const Word32 sampleRate, /* i : sample rate */ - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ -) -#endif { if ( hrtfReader == NULL || hrtfReader->file == NULL || hHrtfStatistics == NULL ) { @@ -1154,63 +1021,7 @@ void destroy_td_hrtf( ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_td_binary_close_fx( hHrtf ); -#else - Word16 i; - if ( ( hHrtf == NULL ) || ( *hHrtf == NULL ) ) - { - return; - } - - if ( !( *hHrtf )->ModelParams.modelROM ) - { - if ( ( *hHrtf )->ModelParams.UseItdModel ) - { - free( ( *hHrtf )->ModelParamsITD.elevKSeq_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.azimKSeq_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.W_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.azimBsShape_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.elevBsShape_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.azimBsLen_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.azimBsStart_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.elevBsLen_dyn_fx ); - free( ( *hHrtf )->ModelParamsITD.elevBsStart_dyn_fx ); - } - free( ( *hHrtf )->ModelParams.elevKSeq_dyn_fx ); - free( ( *hHrtf )->ModelParams.azim_start_idx_dyn ); - free( ( *hHrtf )->ModelParams.azimDim3_dyn ); - free( ( *hHrtf )->ModelParams.AlphaL_dyn_fx ); - free( ( *hHrtf )->ModelParams.AlphaR_dyn_fx ); - free( ( *hHrtf )->ModelParams.azimSegSamples_dyn ); - - free( ( *hHrtf )->ModelParams.azimShapeIdx_dyn ); - free( ( *hHrtf )->ModelParams.azimShapeSampFactor_dyn ); - free( ( *hHrtf )->ModelParams.elevBsLen_dyn ); - free( ( *hHrtf )->ModelParams.elevBsStart_dyn ); - free( ( *hHrtf )->ModelParams.elevBsShape_dyn_fx ); - - for ( i = 0; i < ( *hHrtf )->ModelParams.num_unique_azim_splines; i++ ) - { - free( ( *hHrtf )->ModelParams.azimBsShape_dyn_fx[i] ); - } - free( ( *hHrtf )->ModelParams.azimBsShape_dyn_fx ); - - free( (void *) ( *hHrtf )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ - for ( i = 0; i < ( *hHrtf )->ModelParams.elevDim3; i++ ) - { - free( ( *hHrtf )->ModelParams.azimKSeq_fx[i] ); - } - free( ( *hHrtf )->ModelParams.azimKSeq_fx ); - - free( ( *hHrtf )->ModelParams.EL_dyn_fx ); - free( ( *hHrtf )->ModelParams.ER_dyn_fx ); - - free( ( *hHrtf )->ModelEval.hrfModL_fx ); - free( ( *hHrtf )->ModelEval.hrfModR_fx ); - } - ivas_HRTF_binary_close_fx( hHrtf ); -#endif return; @@ -1283,11 +1094,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1314,11 +1121,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( UWord16 ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1361,11 +1164,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1392,11 +1191,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1431,11 +1226,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1459,11 +1250,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2149,51 +1936,7 @@ void destroy_crend_hrtf( IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */ ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_CRend_binary_close_fx( hHrtfCrend ); -#else - UWord16 i, j; - - test(); - if ( *hHrtfCrend != NULL && hHrtfCrend != NULL ) - { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHrtfCrend )->pIndex_frequency_max[i][j] != NULL ) - { - free( ( *hHrtfCrend )->pIndex_frequency_max_dyn_fx[i][j] ); - } - if ( ( *hHrtfCrend )->pOut_to_bin_re_fx[i][j] != NULL ) - { - free( ( *hHrtfCrend )->pOut_to_bin_re_dyn_fx[i][j] ); - } - if ( ( *hHrtfCrend )->pOut_to_bin_im_fx[i][j] != NULL ) - { - free( ( *hHrtfCrend )->pOut_to_bin_im_dyn_fx[i][j] ); - } - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHrtfCrend )->pIndex_frequency_max_diffuse[j] != NULL ) - { - free( ( *hHrtfCrend )->pIndex_frequency_max_diffuse_dyn_fx[j] ); - } - if ( ( *hHrtfCrend )->pOut_to_bin_diffuse_re_fx[j] != NULL ) - { - free( ( *hHrtfCrend )->pOut_to_bin_diffuse_re_dyn_fx[j] ); - } - if ( ( *hHrtfCrend )->pOut_to_bin_diffuse_im_fx[j] != NULL ) - { - free( ( *hHrtfCrend )->pOut_to_bin_diffuse_im_dyn_fx[j] ); - } - } - free( *hHrtfCrend ); - *hHrtfCrend = NULL; - } -#endif return; } @@ -2209,10 +1952,6 @@ void destroy_fastconv_hrtf( IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv /* i/o: FastConv HRTF handle */ ) { -#ifndef FIX_2249_MEMORY_LEAK_IN_SBA - /* Fastconv HRTF memories */ - ivas_binaural_hrtf_close_fx( hHrtfFastConv ); -#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( hHrtfFastConv ); @@ -2245,26 +1984,7 @@ void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_statistics_binary_close_fx( hHrtfStatistics ); -#else - if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) - { - if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_l_dyn ); - } - if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_r_dyn ); - } - if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) - { - free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); - } - } - ivas_HRTF_statistics_close_fx( hHrtfStatistics ); -#endif return; } diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index ea539a24e..c503caa73 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -105,7 +105,6 @@ ivas_error load_TDrend_HRTF_binary( const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /*---------------------------------------------------------------------* * load_HrtfStatistics_from_binary() * @@ -117,19 +116,6 @@ ivas_error load_HrtfStatistics_from_binary( const Word32 sampleRate, /* i : sample rate */ const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); -#else -/*---------------------------------------------------------------------* - * load_reverb_binary() - * - * Load reverb binary data into the HRTF handle - *---------------------------------------------------------------------*/ - -ivas_error load_reverb_binary( - IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ - const Word32 sampleRate, /* i : sample rate */ - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ -); -#endif /*---------------------------------------------------------------------* * load_Crend_HRTF_from_binary() -- GitLab From 27d220cdf8d8bb6d226667f8a256c5c30343f095 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:45:43 +0100 Subject: [PATCH 366/750] [cleanup] accept FIX_2252_SCALING_SAVE_HB_SYNTH --- lib_com/options.h | 1 - lib_dec/acelp_core_dec_fx.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3716a126c..613dd3c31 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#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 FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ #define FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC /* FhG: fix a USAN OOB error */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 580e3610a..c5d367699 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2337,17 +2337,9 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->element_mode, EVS_MONO ) ) { -#ifdef FIX_2252_SCALING_SAVE_HB_SYNTH IF( save_hb_synth_fx16 != NULL ) -#else - IF( save_hb_synth_fx16 ) -#endif { -#ifdef FIX_2252_SCALING_SAVE_HB_SYNTH Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0 -#else - Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0 -#endif } Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 } -- GitLab From 540070c0689e10411049d287609dc88a8cdc822f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:50:52 +0100 Subject: [PATCH 367/750] [cleanup] accept FIX_2248_EVS_ASSERT --- lib_com/options.h | 1 - lib_enc/enc_acelpx_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 613dd3c31..8f5b84f8c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2248_EVS_ASSERT /* VA: Include _sat in an EVS related part of the code */ #define FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ #define FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC /* FhG: fix a USAN OOB error */ #define FIX_2284_ADD_ASSERT_LOG /* FhG: add asserts to Log2_norm_lc() and log10_fx() */ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 089c3bbb4..c03553898 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -293,11 +293,7 @@ static void E_ACELP_1pulse_searchx_fx( ps0 = *ps; /* Qdn */ move16(); alp0 = L_deposit_h( *alp ); /* Q22 */ -#ifndef FIX_2248_EVS_ASSERT - alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#else alp0 = L_mac_sat( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#endif /* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */ move16(); move16(); -- GitLab From 8f72a46735c929a587e0dfcbb709a0bbb5da9fef Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:51:39 +0100 Subject: [PATCH 368/750] [cleanup] accept FIX_2254_IMPROV_COMPLEXITY_BE --- lib_com/options.h | 1 - lib_com/pred_lt4_fx.c | 5 ----- lib_dec/ivas_sns_dec_fx.c | 8 -------- lib_enc/ivas_omasa_enc_fx.c | 4 ---- lib_enc/swb_tbe_enc_fx.c | 8 -------- 5 files changed, 26 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8f5b84f8c..67870b9e1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ #define FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC /* FhG: fix a USAN OOB error */ #define FIX_2284_ADD_ASSERT_LOG /* FhG: add asserts to Log2_norm_lc() and log10_fx() */ #define FIX_2286_GCC_WARNING_Idx2Freq_Tbl /* FhG: Fix compiler warning for OOB access of Idx2Freq_Tbl[] */ diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index 591eab841..b04456870 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -58,13 +58,8 @@ void pred_lt4_ivas_fx( FOR( i = 0; i < nb_coef; i++ ) { /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/ -#ifdef FIX_2254_IMPROV_COMPLEXITY_BE s64 = W_mac_32_16( s64, ( *c1 ), *x1-- ); /* Q_exc + Q32 */ s64 = W_mac_32_16( s64, ( *c2 ), *x2++ ); /* Q_exc + Q32 */ -#else - 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 */ -#endif c1 += up_sample; c2 += up_sample; } diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 2f0217b48..b86234ec9 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -81,11 +81,7 @@ static void sns_1st_dec_fx( FOR( i = 0; i < M / 2; i++ ) { -#ifdef FIX_2254_IMPROV_COMPLEXITY_BE snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); // Q16 -#else - snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); // Q16 -#endif move32(); } @@ -93,11 +89,7 @@ static void sns_1st_dec_fx( FOR( i = M / 2; i < M; i++ ) { -#ifdef FIX_2254_IMPROV_COMPLEXITY_BE snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); /*Q16*/ -#else - snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); /*Q16*/ -#endif move32(); } diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 49418c8fc..0e1caa1f7 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1542,11 +1542,7 @@ static void ivas_omasa_dmx_fx( g1 = interpolator[k]; move16(); g2 = sub( MAX_WORD16, g1 ); /*q15*/ -#ifdef FIX_2254_IMPROV_COMPLEXITY_BE data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_mac( L_mult( g1, gains[j] ), g2, prev_gains[i][j] ) /*q31*/, data_in[i][k] ) ); /*Qx*/ -#else - data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_add( L_mult( g1, gains[j] ), L_mult( g2, prev_gains[i][j] ) ) /*q31*/, data_in[i][k] ) ); /*Qx*/ -#endif move32(); } } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 6df7696bf..ebe37fae5 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -3986,11 +3986,7 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { // GainShape[i] = ( 1 - feedback ) * GainShape[i] + feedback * GainShape_Interp[i]; -#ifdef FIX_2254_IMPROV_COMPLEXITY_BE GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), feedback, GainShape_Interp_fx[i] ) ); -#else - GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) ); -#endif move16(); } } @@ -4104,11 +4100,7 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { // GainShape[i] = ( 1 - feedback ) * GainShape[i * NUM_SHB_SUBGAINS] + feedback * GainShape_Interp[i]; -#ifdef FIX_2254_IMPROV_COMPLEXITY_BE GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), feedback, GainShape_Interp_fx[i] ) ); // Q15 -#else - GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) ); // Q15 -#endif move16(); } -- GitLab From 2de182ee33cd668672a5aa462ece0f8859b74cd6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:52:21 +0100 Subject: [PATCH 369/750] [cleanup] accept FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC --- lib_com/options.h | 1 - lib_com/tcx_ltp_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 67870b9e1..f086a3b4e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC /* FhG: fix a USAN OOB error */ #define FIX_2284_ADD_ASSERT_LOG /* FhG: add asserts to Log2_norm_lc() and log10_fx() */ #define FIX_2286_GCC_WARNING_Idx2Freq_Tbl /* FhG: Fix compiler warning for OOB access of Idx2Freq_Tbl[] */ #define FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER /* FhG: fix CLANG18 MSAN error in decoder init */ diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c index 1ecc8b766..29febbbfc 100644 --- a/lib_com/tcx_ltp_fx.c +++ b/lib_com/tcx_ltp_fx.c @@ -401,7 +401,6 @@ void predict_signal( x0--; } -#ifdef FIX_2275_OOB_INDEXING_IN_PREDICT_SIGNAL_FUNC IF( EQ_16( frac_max, 6 ) ) { win = &inter6_2tcx2[frac][0]; /* Q15 */ @@ -410,11 +409,6 @@ void predict_signal( { win = &inter4_2tcx2[frac][0]; /* Q15 */ } -#else - win = &inter4_2tcx2[frac][0]; /* Q15 */ - if ( EQ_16( frac_max, 6 ) ) - win = &inter6_2tcx2[frac][0]; /* Q15 */ -#endif FOR( j = 0; j < L_subfr; j++ ) { -- GitLab From 689bf65b5097ef9835f68492b2cd63bec7b9ad9f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:54:14 +0100 Subject: [PATCH 370/750] [cleanup] accept FIX_2284_ADD_ASSERT_LOG --- lib_com/log2.c | 11 ----------- lib_com/options.h | 1 - 2 files changed, 12 deletions(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 55ea6aa40..ce6b821ea 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -72,9 +72,7 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val i = mac_r( L_x, -32 * 2 - 1, 16384 ); /* Extract b25-b31 minus 32 */ -#ifdef FIX_2284_ADD_ASSERT_LOG assert( ( i >= 0 ) && ( i < (Word16) ( sizeof( L_table_Log2_norm_lc ) / sizeof( L_table_Log2_norm_lc[0] ) ) ) && ( i < (Word16) ( sizeof( table_diff_Log2_norm_lc ) / sizeof( table_diff_Log2_norm_lc[0] ) ) ) ); -#endif y = mac_r( L_table_Log2_norm_lc[i], table_diff_Log2_norm_lc[i], a ); /* table[i] << 16 - diff*a*2 */ @@ -84,9 +82,7 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/ { Word16 n1, frac, p1, p2, q1; -#ifdef FIX_2284_ADD_ASSERT_LOG Word16 idx; -#endif Word32 Ltemp1, Ltemp2; Word32 L_tmp; @@ -101,7 +97,6 @@ Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/ Ltemp2 = L_mult( extract_h( Ltemp1 ), 0x40 ); frac = extract_l( Ltemp2 ); -#ifdef FIX_2284_ADD_ASSERT_LOG idx = sub( extract_h( Ltemp2 ), 0x20 ); assert( idx >= 0 && idx < (Word16) ( sizeof( log2_tab ) / sizeof( log2_tab[0] ) ) ); p1 = log2_tab[idx]; @@ -112,12 +107,6 @@ Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/ p2 = log2_tab[idx]; move16(); -#else - p1 = log2_tab[sub( extract_h( Ltemp2 ), 0x20 )]; - move16(); - p2 = log2_tab[sub( extract_h( Ltemp2 ), 0x1F )]; - move16(); -#endif Ltemp2 = L_mult( n1, 0x200 ); n1 = extract_l( Ltemp2 ); diff --git a/lib_com/options.h b/lib_com/options.h index f086a3b4e..cc2ce6c21 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2284_ADD_ASSERT_LOG /* FhG: add asserts to Log2_norm_lc() and log10_fx() */ #define FIX_2286_GCC_WARNING_Idx2Freq_Tbl /* FhG: Fix compiler warning for OOB access of Idx2Freq_Tbl[] */ #define FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER /* FhG: fix CLANG18 MSAN error in decoder init */ #define FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE /* FhG: initialize last_element_brate to avoid CLANG18 MSAN complaint */ -- GitLab From 46bddf8f55c982a37b065f730aa5f49ec8760078 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:54:56 +0100 Subject: [PATCH 371/750] [cleanup] accept FIX_2286_GCC_WARNING_Idx2Freq_Tbl --- lib_com/cnst.h | 4 ---- lib_com/options.h | 1 - 2 files changed, 5 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 43c20a27a..051b6024f 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -2734,11 +2734,7 @@ extern const Word16 Idx2Freq_Tbl[]; /* 'x' is converted to Q6, 'Freq_Tbl'/1000 in Q9 */ /* only works for 'fs' = [8000,12800,16000,25600,32000,48000] (unpredictable otherwise) */ /* 15625 is 1000000.0f/Q6 but we use the calculated value to avoid float point code */ -#ifdef FIX_2286_GCC_WARNING_Idx2Freq_Tbl #define NS2SA_FX2(fs,x) (chk_fs(fs) mult(Idx2Freq_Tbl[L_and(L_shr(fs,8),7)-2], (Word16)((x)/15625))) -#else -#define NS2SA_FX2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625))) -#endif #define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */ #define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */ diff --git a/lib_com/options.h b/lib_com/options.h index cc2ce6c21..c5a2db085 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2286_GCC_WARNING_Idx2Freq_Tbl /* FhG: Fix compiler warning for OOB access of Idx2Freq_Tbl[] */ #define FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER /* FhG: fix CLANG18 MSAN error in decoder init */ #define FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE /* FhG: initialize last_element_brate to avoid CLANG18 MSAN complaint */ #define FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE /* FhG: initialize st->element_brate per default */ -- GitLab From 6f4a8d4b26064363b95f8320df241703b24cd438 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:55:45 +0100 Subject: [PATCH 372/750] [cleanup] accept FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER --- lib_com/options.h | 1 - lib_dec/lib_dec_fx.c | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c5a2db085..ecc9df81f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER /* FhG: fix CLANG18 MSAN error in decoder init */ #define FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE /* FhG: initialize last_element_brate to avoid CLANG18 MSAN complaint */ #define FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE /* FhG: initialize st->element_brate per default */ #define FIX_1464_UBSAN_RC_CONTEXT_MAP /* FhG: BE UBSAN fix for float issue 1464 in the TCX range coder */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index fb526e127..17a8d966e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -232,7 +232,6 @@ ivas_error IVAS_DEC_Open( move16(); /* set high-level parameters */ -#ifdef FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER st_ivas->codec_mode = 0; /* unknown before first frame */ st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID; @@ -244,15 +243,8 @@ ivas_error IVAS_DEC_Open( move16(); move16(); -#endif IF( EQ_16( mode, IVAS_DEC_MODE_EVS ) ) { -#ifndef FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER - st_ivas->codec_mode = 0; /* unknown before first frame */ - st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; - st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID; - st_ivas->writeFECoffset = 0; -#endif st_ivas->element_mode_init = EVS_MONO; st_ivas->ivas_format = MONO_FORMAT; hIvasDec->hasDecodedFirstGoodFrame = true; /* Functionality to suppress output for initial lost frames is disabled in EVS operation */ @@ -264,13 +256,6 @@ ivas_error IVAS_DEC_Open( } ELSE IF( EQ_16( mode, IVAS_DEC_MODE_IVAS ) ) { -#ifndef FIX_CLANG18_MSAN_IN_DEC_INIT_BY_MOVING_COMMON_INITS_TOGETHER - st_ivas->codec_mode = 0; /* unknown before first frame */ - st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; - st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID; - st_ivas->writeFECoffset = 0; - st_ivas->sba_analysis_order = 0; -#endif st_ivas->element_mode_init = -1; st_ivas->ivas_format = UNDEFINED_FORMAT; st_ivas->renderer_type = RENDERER_DISABLE; -- GitLab From 81a099e0e071ce767f0a6f4a4a34b2a6e11c5742 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:57:37 +0100 Subject: [PATCH 373/750] [cleanup] accept FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE --- lib_com/options.h | 1 - lib_dec/ivas_sce_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ecc9df81f..c4626b507 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE /* FhG: initialize last_element_brate to avoid CLANG18 MSAN complaint */ #define FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE /* FhG: initialize st->element_brate per default */ #define FIX_1464_UBSAN_RC_CONTEXT_MAP /* FhG: BE UBSAN fix for float issue 1464 in the TCX range coder */ #define FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH /* FhG: fix OOB index USAN error in TCX LTP pitch search */ diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index ab237934a..a015cdb38 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -385,10 +385,8 @@ ivas_error create_sce_dec( move16(); hSCE->element_brate = element_brate; /*Q0*/ move32(); -#ifdef FIX_1481_CLANG18_MSAN_INIT_LAST_ELEM_BRATE hSCE->last_element_brate = hSCE->element_brate; move32(); -#endif set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); -- GitLab From c9ae52080e732e63785d8523ab10fcbc8757f0b7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:58:23 +0100 Subject: [PATCH 374/750] [cleanup] accept FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE --- lib_com/options.h | 1 - lib_dec/ivas_sce_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c4626b507..0077f975f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE /* FhG: initialize st->element_brate per default */ #define FIX_1464_UBSAN_RC_CONTEXT_MAP /* FhG: BE UBSAN fix for float issue 1464 in the TCX range coder */ #define FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH /* FhG: fix OOB index USAN error in TCX LTP pitch search */ #define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index a015cdb38..8d5f7d0c3 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -404,10 +404,8 @@ ivas_error create_sce_dec( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ move32(); -#ifdef FIX_1484_CLANG18_MSAN_INIT_ST_ELEM_BRATE st->element_brate = -1; move32(); -#endif st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move16(); st->is_ism_format = 0; -- GitLab From 5bf157cfb49661031d5c005ca2101b0e9488a590 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 13:59:10 +0100 Subject: [PATCH 375/750] [cleanup] accept FIX_1464_UBSAN_RC_CONTEXT_MAP --- lib_com/options.h | 1 - lib_dec/ACcontextMapping_dec_fx.c | 6 ------ lib_enc/ACcontextMapping_enc_fx.c | 10 ---------- 3 files changed, 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0077f975f..f77ab09bd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_1464_UBSAN_RC_CONTEXT_MAP /* FhG: BE UBSAN fix for float issue 1464 in the TCX range coder */ #define FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH /* FhG: fix OOB index USAN error in TCX LTP pitch search */ #define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index e88d96aa6..9b6ac8434 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -702,15 +702,9 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( c = add( 12, esc_nb ); } -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP s = shl( s_and( s, 0x0F ), 4 ); /*Shift old 4 bits*/ s = add( s, c ); /*replace last 4 bits*/ t = s_and( s, 0xFF ); -#else - s = (UWord16) L_shl( s, 4 ); /*Shift old 4 bits*/ - s = (UWord16) L_add( s, c ); /*replace last 4 bits*/ - t = (UWord16) L_and( s, 0xFF ); -#endif } /* Decode signs */ diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 2d2ad83b1..b637047a2 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1099,13 +1099,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( } /*Shift old 4 bits, replace last 4 bits*/ -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP s = add( shl( s_and( s, 0x0F ), 4 ), cp ); t = s_and( s, 0xFF ); -#else - s = (UWord16) ( L_add( L_shl( s, 4 ), cp ) ); - t = (UWord16) L_and( s, 0xFF ); -#endif } /*end of the 2-tuples loop*/ } @@ -1569,13 +1564,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( cp = add( 12, esc_nb ); /* Q0 */ } /*shift old bits and replace last 4 bits*/ -#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP s = add( shl( s_and( s, 0x0F ), 4 ), cp ); t = s_and( s, 0xFF ); -#else - s = (UWord16) L_add( L_shl( s, 4 ), cp ); - t = s_and( s, 0xFF ); -#endif } /*end of the 2-tuples loop*/ tot_bits2 = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ -- GitLab From 5b14975886e3cce29aec96776e48c9abf59fb250 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:00:13 +0100 Subject: [PATCH 376/750] [cleanup] accept FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH --- lib_com/options.h | 1 - lib_enc/tcx_ltp_enc_fx.c | 53 ---------------------------------------- 2 files changed, 54 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f77ab09bd..4326d22bc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH /* FhG: fix OOB index USAN error in TCX LTP pitch search */ #define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index bd43b84f1..7650516cb 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -89,9 +89,7 @@ static void tcx_ltp_pitch_search( Word16 pitres ) { Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH Word16 cor_idx_ini, cor_idx; -#endif Word32 cor_max, cor[256], *pt_cor, temp; Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; @@ -206,11 +204,7 @@ static void tcx_ltp_pitch_search( * the interpolated normalized correlation. *-----------------------------------------------------------------*/ -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx_ini = sub( L_INTERPOL1, t0_min ); -#else - pt_cor = cor + sub( L_INTERPOL1, t0_min ); -#endif t0 = t1; move16(); @@ -226,34 +220,20 @@ static void tcx_ltp_pitch_search( IF( EQ_16( t0, t0_min ) ) /* Limit case */ { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx = add( cor_idx_ini, t0 ); -#endif fraction = 0; move16(); -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); -#else - cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); -#endif } ELSE /* Process negative fractions */ { t0 = sub( t0, 1 ); -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx = add( cor_idx_ini, t0 ); cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); -#else - cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); -#endif FOR( i = fraction + step; i < pitres; i += step ) { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH temp = interpolate_corr( &cor[cor_idx], i, pitres ); -#else - temp = interpolate_corr( &pt_cor[t0], i, pitres ); -#endif IF( GT_32( temp, cor_max ) ) { @@ -264,16 +244,10 @@ static void tcx_ltp_pitch_search( } } -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx = add( cor_idx_ini, t1 ); -#endif FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH temp = interpolate_corr( &cor[cor_idx], i, pitres ); -#else - temp = interpolate_corr( &pt_cor[t1], i, pitres ); -#endif IF( GT_32( temp, cor_max ) ) { @@ -321,9 +295,7 @@ static void tcx_ltp_pitch_search_ivas_fx( Word16 *border_case ) { Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH Word16 cor_idx_ini, cor_idx; -#endif Word32 cor_max, cor[256], *pt_cor, temp; Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; @@ -449,12 +421,7 @@ static void tcx_ltp_pitch_search_ivas_fx( * search the fractions around t0 and choose the one which maximizes * the interpolated normalized correlation. *-----------------------------------------------------------------*/ -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx_ini = sub( L_INTERPOL1, t0_min ); -#else - - pt_cor = cor + sub( L_INTERPOL1, t0_min ); -#endif t0 = t1; move16(); @@ -470,34 +437,20 @@ static void tcx_ltp_pitch_search_ivas_fx( IF( EQ_16( t0, t0_min ) ) /* Limit case */ { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx = add( cor_idx_ini, t0 ); -#endif fraction = 0; move16(); -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); -#else - cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); -#endif } ELSE /* Process negative fractions */ { t0 = sub( t0, 1 ); -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx = add( cor_idx_ini, t0 ); cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); -#else - cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); -#endif FOR( i = fraction + step; i < pitres; i += step ) { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH temp = interpolate_corr( &cor[cor_idx], i, pitres ); -#else - temp = interpolate_corr( &pt_cor[t0], i, pitres ); -#endif IF( GT_32( temp, cor_max ) ) { @@ -508,16 +461,10 @@ static void tcx_ltp_pitch_search_ivas_fx( } } -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH cor_idx = add( cor_idx_ini, t1 ); -#endif FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { -#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH temp = interpolate_corr( &cor[cor_idx], i, pitres ); -#else - temp = interpolate_corr( &pt_cor[t1], i, pitres ); -#endif IF( GT_32( temp, cor_max ) ) { -- GitLab From 24056b7e43b1214a1dbd246d4a5867c503274f94 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 15 Jan 2026 14:00:55 +0100 Subject: [PATCH 377/750] Revert "change Makefile to assure use of clang-18" This reverts commit 067f70906e93555969842dfa22828a5a0e66f190. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1fa184306..c9ae4493d 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ endif endif ifndef VERBOSE -QUIET_CC = @echo ' ' Compiling $< with $(CC); +QUIET_CC = @echo ' ' Compiling $<; QUIET_LINK= @echo ' ' Linking $@; QUIET_AR = @echo ' ' Archiving $@; QUIET = @ @@ -75,7 +75,7 @@ CFLAGS += -Wunused-but-set-variable LDLIBS += -lm # Clang sanitizer compiler options -CCCLANG = clang-18 +CCCLANG = clang ifeq "$(CLANG)" "0" CC = $(CCCLANG) endif -- GitLab From 07780a7343dbb9185c5811b8f4fb390496b75a83 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:01:27 +0100 Subject: [PATCH 378/750] [cleanup] accept FIX_2274_OOB_INDEXING_IN_CORRMATRIX --- lib_com/options.h | 1 - lib_enc/enc_acelp_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4326d22bc..c4aaa8ffa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 626d89aaa..0f4e77253 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -997,14 +997,10 @@ void E_ACELP_corrmatrix_fx( p3 = &rrixiy[2][pos]; /* Q9 */ p2 = &rrixiy[1][pos]; p1 = &rrixiy[0][pos]; -#ifdef FIX_2274_OOB_INDEXING_IN_CORRMATRIX p0 = &rrixiy[3][pos]; /* decrement pointer instead of indexing the array to avoid CLANG Usan complaint */ /* for last loop iteration, this points to rrixiy[3][-1], but is not actually accessed in later loop (k = 15 then, so inner loop will not run) */ p0 -= 16; -#else - p0 = &rrixiy[3][pos - 16]; -#endif cor = L_deposit_h( 0 ); ptr_h1 = h; /*Q12*/ -- GitLab From 3bbcd7f3729dfe16f5ac97611a55604bd5e823d2 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:02:13 +0100 Subject: [PATCH 379/750] [cleanup] accept FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH --- lib_com/options.h | 1 - lib_enc/enc_gain_fx.c | 41 ----------------------------------------- 2 files changed, 42 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c4aaa8ffa..e518e304c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1474_USAN_TRANS_INV /* Eri: Float issue 1474: Fix USAN out-of-bounds warning. No OOB occurs, but the pointer is set to point to uninitialized memory. */ diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c index ed954ebed..5a8a08596 100644 --- a/lib_enc/enc_gain_fx.c +++ b/lib_enc/enc_gain_fx.c @@ -254,11 +254,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ { Word16 corr_v[32 + 2 * L_INTERPOL1 + 1]; Word16 cor_max, max, temp; -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH Word16 corr_idx; -#else - Word16 *corr; -#endif Word16 i, fraction, frac1, frac2, step; Word16 t0, t_min, t_max; @@ -274,48 +270,29 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ move16(); move16(); -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH corr_idx = negate( t_min ); -#else - /* allocate memory to normalized correlation vector */ - corr = &corr_v[negate( t_min )]; /* corr[t_min..t_max] */ -#endif /* Compute normalized correlation between target and filtered excitation */ E_GAIN_norm_corr_fx( exc, xn, h, t_min, t_max, corr_v, L_subfr ); /* find integer pitch */ -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH max = corr_v[add( t0_min, corr_idx )]; /*(Q15+(Q_new+shift-1)+scale)*/ -#else - max = corr[t0_min]; /*(Q15+(Q_new+shift-1)+scale)*/ -#endif move16(); t0 = t0_min; /*Q0*/ move16(); FOR( i = t0_min + 1; i <= t0_max; i++ ) { -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH Word16 corr_tmp; corr_tmp = corr_v[add( corr_idx, i )]; -#endif BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH if ( GE_16( corr_tmp, max ) ) -#else - if ( GE_16( corr[i], max ) ) -#endif { t0 = i; move16(); } -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH max = s_max( max, corr_tmp ); -#else - max = s_max( max, corr[i] ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -380,26 +357,16 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ } assert( frac1 <= 0 && frac2 >= 0 && frac2 > frac1 ); -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH corr_idx = add( corr_idx, t0 ); -#endif IF( EQ_16( pit_res_max, 6 ) ) { -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ -#else - cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ -#endif fraction = frac1; /*Q0*/ move16(); FOR( i = ( frac1 + step ); i <= frac2; i += step ) { -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH temp = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/ -#else - temp = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ -#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/ @@ -411,21 +378,13 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ } ELSE { -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH cor_max = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ -#else - cor_max = E_GAIN_norm_corr_interpolate_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ -#endif fraction = frac1; /*Q0*/ move16(); FOR( i = ( frac1 + step ); i <= frac2; i += step ) { -#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH temp = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/ -#else - temp = E_GAIN_norm_corr_interpolate_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/ -#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/ -- GitLab From 8752c7dcb1f33381f13fe0512f0f165477ac87bb Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:02:57 +0100 Subject: [PATCH 380/750] [cleanup] accept FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE --- lib_com/options.h | 1 - lib_dec/ivas_mct_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e518e304c..71f25b2cd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,7 +85,6 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1474_USAN_TRANS_INV /* Eri: Float issue 1474: Fix USAN out-of-bounds warning. No OOB occurs, but the pointer is set to point to uninitialized memory. */ #define FIX_2268_OOB_INDEXING_IN_IFFT /* VA: Fix for issue 2268, to silence clang18 */ diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 5c5b0ac52..c8a712c49 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -699,11 +699,7 @@ ivas_error mct_dec_reconfigure_fx( move16(); /* MDCT stereo initialization */ -#ifdef FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL ) -#else - IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL ) -#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); } -- GitLab From 7cca9b9390c682d419924b32d0aff4cfc060cb4d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:05:32 +0100 Subject: [PATCH 381/750] [cleanup] accept FIX_1474_USAN_TRANS_INV --- lib_com/options.h | 1 - lib_com/trans_direct_fx.c | 15 --------------- lib_com/trans_inv_fx.c | 16 ---------------- 3 files changed, 32 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 71f25b2cd..88a3104cf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1474_USAN_TRANS_INV /* Eri: Float issue 1474: Fix USAN out-of-bounds warning. No OOB occurs, but the pointer is set to point to uninitialized memory. */ #define FIX_2268_OOB_INDEXING_IN_IFFT /* VA: Fix for issue 2268, to silence clang18 */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c index 7598bd422..fe526d372 100644 --- a/lib_com/trans_direct_fx.c +++ b/lib_com/trans_direct_fx.c @@ -76,20 +76,13 @@ void direct_transform_fx( move32(); } -#ifndef FIX_1474_USAN_TRANS_INV - iseg_fx = &in32_r16_fx[-segment_length4]; /*Q*/ -#endif oseg_fx = out32_fx; /*Q*/ wh_fx = &win_fx[segment_length4]; /*Q15*/ wl_fx = wh_fx - 1; /*Q15*/ shift = extract_l( L_mult0( 3, segment_length4 ) ); /*Q0*/ -#ifdef FIX_1474_USAN_TRANS_INV sh_fx = &in32_r16_fx[segment_length2]; /*Q*/ -#else - sh_fx = &iseg_fx[shift]; /*Q*/ -#endif sl_fx2 = sh_fx - 1; /*Q*/ @@ -100,11 +93,7 @@ void direct_transform_fx( move32(); } -#ifdef FIX_1474_USAN_TRANS_INV sl_fx2 = &in32_r16_fx[( segment_length4 - 1 )]; /*Q*/ -#else - sl_fx2 = &iseg_fx[( segment_length2 - 1 )]; /*Q*/ -#endif FOR( i = segment_length4; i < segment_length2; i++ ) { @@ -117,11 +106,7 @@ void direct_transform_fx( edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[0] ); Qmin = s_min( Qs[0], Qmin ); -#ifdef FIX_1474_USAN_TRANS_INV iseg_fx = &in32_r16_fx[segment_length4]; -#else - iseg_fx += segment_length2; -#endif oseg_fx += segment_length2; FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ ) diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 9a0774215..50e272bd7 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -1032,11 +1032,7 @@ void Inverse_Transform( } } -#ifdef FIX_1474_USAN_TRANS_INV out_segment = out_alias; -#else - out_segment = out_alias - segment_length_div4; -#endif in_segment = in_mdct_modif; /*Q*/ tmp = *Q; @@ -1055,11 +1051,7 @@ void Inverse_Transform( FOR( ta = segment_length_div4; ta < segment_length_div2; ta++ ) { -#ifdef FIX_1474_USAN_TRANS_INV *out_segment++ = L_shr( alias[ta], tmp ); /*q_out*/ -#else - out_segment[ta] = L_shr( alias[ta], tmp ); /*q_out*/ -#endif move32(); } /* This previous loop fills the output buffer from [0..seg_len_div4-1] */ @@ -1067,20 +1059,12 @@ void Inverse_Transform( win2 = &win[segment_length_div2]; /*Q15*/ FOR( ta = segment_length_div2; ta < segment_length; ta++ ) { -#ifdef FIX_1474_USAN_TRANS_INV *out_segment++ = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/ -#else - out_segment[ta] = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/ -#endif move32(); } /* This previous loop fills the output buffer from [seg_len_div4..seg_len-seg_len_div4-1] */ -#ifdef FIX_1474_USAN_TRANS_INV out_segment = &out_alias[segment_length_div4]; /*q_out*/ -#else - out_segment += segment_length_div2; /*q_out*/ -#endif in_segment += segment_length_div2; /*Q*/ FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ ) -- GitLab From a9bb438dea36bc55dc0f522c070352cea5b91cc2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 15 Jan 2026 14:05:40 +0100 Subject: [PATCH 382/750] [fix] use a temp var instead of an enum to read/write consistent sizes in the split rendering bitstream header --- lib_util/split_render_file_read_write.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 75fd30d88..06c5eb14f 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -71,6 +71,7 @@ ivas_error split_rend_reader_open( { SplitFileReadWrite *hSplitRendFileReadWrite; size_t header_len, h; + int32_t tmp; char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH"; char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN]; @@ -104,16 +105,19 @@ ivas_error split_rend_reader_open( fread( &hSplitRendFileReadWrite->delay_ns, sizeof( uint32_t ), 1, hSplitRendFileReadWrite->file ); /* read codec signalling */ - if ( fread( codec, sizeof( *codec ), 1, hSplitRendFileReadWrite->file ) != 1 ) + if ( fread( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + *codec = (ISAR_SPLIT_REND_CODEC) tmp; /* read pose correction signalling */ - if ( fread( poseCorrection, sizeof( *poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 ) + if ( fread( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + *poseCorrection = (ISAR_SPLIT_REND_POSE_CORRECTION_MODE) tmp; + /* read transport codec frame size signalling */ if ( fread( codec_frame_size_ms, sizeof( *codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { @@ -161,6 +165,7 @@ ivas_error split_rend_writer_open( { SplitFileReadWrite *hSplitRendFileReadWrite; size_t header_len, h; + int32_t tmp; char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH"; if ( filename == NULL ) @@ -193,13 +198,15 @@ ivas_error split_rend_writer_open( fwrite( &hSplitRendFileReadWrite->delay_ns, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ); /* Write codec signalling */ - if ( fwrite( &codec, sizeof( codec ), 1, hSplitRendFileReadWrite->file ) != 1 ) + tmp = (int32_t) codec; + if ( fwrite( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } /* Write pose correction signalling */ - if ( fwrite( &poseCorrection, sizeof( poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 ) + tmp = (int32_t) poseCorrection; + if ( fwrite( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } -- GitLab From 646e82851d9accb1433159b75e2f2eef8bb2d7fc Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:06:12 +0100 Subject: [PATCH 383/750] [cleanup] accept FIX_2268_OOB_INDEXING_IN_IFFT --- lib_com/ifft_rel_fx.c | 2 -- lib_com/options.h | 1 - 2 files changed, 3 deletions(-) diff --git a/lib_com/ifft_rel_fx.c b/lib_com/ifft_rel_fx.c index d11e07baa..e47f07128 100644 --- a/lib_com/ifft_rel_fx.c +++ b/lib_com/ifft_rel_fx.c @@ -139,12 +139,10 @@ void ifft_rel_fx( /*Can be acheived with a shr */ step = idiv1616( N_MAX_SAS, n2 ); move16(); -#ifdef FIX_2268_OOB_INDEXING_IN_IFFT IF( LT_16( n8, 2 ) ) { continue; } -#endif s = sincos_t_fx + step; /*Q15 */ c = s + 64; /*Q15 */ s3 = sincos_t_fx + i_mult2( step, 3 ); /*Q15 */ diff --git a/lib_com/options.h b/lib_com/options.h index 88a3104cf..821b0e73f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2268_OOB_INDEXING_IN_IFFT /* VA: Fix for issue 2268, to silence clang18 */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ #define FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR /* Eri: When no PVQ bands are selected in peaq_vq_enc, the number of bands is not initialized. */ -- GitLab From 6b37c8bbb6c1f90cbaecfda360d548cafa52265d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:07:28 +0100 Subject: [PATCH 384/750] [cleanup] accept FIX_2271_OOB_INDEXING_IN_PIT_OL2 --- lib_com/options.h | 1 - lib_enc/pitch_ol2_fx.c | 23 ----------------------- 2 files changed, 24 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 821b0e73f..01ed83ee3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ #define FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR /* Eri: When no PVQ bands are selected in peaq_vq_enc, the number of bands is not initialized. */ #define FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE /* Eri: Initializes a variables in HQ decoder. It is not used, but is passed uninitialized to a function which is caught by clang-18 */ diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index f50677cf0..49566e31d 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -50,9 +50,7 @@ void pitch_ol2_fx( Word32 R1, R2; Word16 R0, exp_R0, exp_R1, exp_R2, j; Word16 pit_max; -#ifdef FIX_2271_OOB_INDEXING_IN_PIT_OL2 Word16 base_idx; -#endif /* initialization */ pit_max = PIT_MAX; move16(); @@ -106,14 +104,9 @@ void pitch_ol2_fx( * search the fractions around t0 and choose the one which maximizes * the interpolated normalized correlation. *----------------------------------------------------------------*/ -#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 - pt_cor_fx = cor_fx + sub( L_INTERPOL1, t0_min ); -#endif t0s = t1s; move16(); -#ifdef FIX_2271_OOB_INDEXING_IN_PIT_OL2 base_idx = sub( L_INTERPOL1, t0_min ); -#endif step = 1; move16(); /* 1/4 subsample resolution */ @@ -123,18 +116,10 @@ void pitch_ol2_fx( IF( NE_16( t0s, t0_min ) ) /* Process negative fractions */ { t0s = sub( t0s, 1 ); -#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 - cor_max_fx = Interpol_4( &pt_cor_fx[t0s], fraction ); -#else cor_max_fx = Interpol_4( &cor_fx[t0s + base_idx], fraction ); -#endif FOR( i = fraction + step; i <= 3; i += step ) { -#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 - temp_fx = Interpol_4( &pt_cor_fx[t0s], i ); -#else temp_fx = Interpol_4( &cor_fx[t0s + base_idx], i ); -#endif if ( GT_16( temp_fx, cor_max_fx ) ) { fraction = i; @@ -147,20 +132,12 @@ void pitch_ol2_fx( { fraction = 0; move16(); -#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 - cor_max_fx = Interpol_4( &pt_cor_fx[t0s], fraction ); -#else cor_max_fx = Interpol_4( &cor_fx[t0s + base_idx], fraction ); -#endif move16(); } FOR( i = 0; i <= 3; i += step ) /* Process positive fractions */ { -#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2 - temp_fx = Interpol_4( &pt_cor_fx[t1s], i ); -#else temp_fx = Interpol_4( &cor_fx[t1s + base_idx], i ); -#endif IF( GT_16( temp_fx, cor_max_fx ) ) { cor_max_fx = temp_fx; -- GitLab From f9b319b69186ff70976e1c86964c3d15e05b1213 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:08:16 +0100 Subject: [PATCH 385/750] [cleanup] accept FIX_2273_OOB_INDEXING_IN_PIT_FR4 --- lib_com/options.h | 1 - lib_enc/pit_enc_fx.c | 49 -------------------------------------------- 2 files changed, 50 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 01ed83ee3..46a2c7f6a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ #define FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR /* Eri: When no PVQ bands are selected in peaq_vq_enc, the number of bands is not initialized. */ #define FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE /* Eri: Initializes a variables in HQ decoder. It is not used, but is passed uninitialized to a function which is caught by clang-18 */ #define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 5c9a5bdcd..1fff57905 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -762,9 +762,7 @@ Word16 pitch_fr4_fx( Word16 corr_v[15 + 2 * L_INTERPOL1 + 1]; /* Total length = t0_max-t0_min+1+2*L_inter */ Word16 pit_min; Word16 cor_max; -#ifdef FIX_2273_OOB_INDEXING_IN_PIT_FR4 Word16 corr_off; -#endif /* initialization */ IF( limit_flag == 0 ) @@ -809,25 +807,11 @@ Word16 pitch_fr4_fx( t_min = sub( t0_min, L_INTERPOL1 ); t_max = add( t0_max, L_INTERPOL1 ); -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - corr = &corr_v[-t_min]; -#else corr = corr_v; corr_off = -t_min; move16(); -#endif /* corr[t_min..t_max] */ -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - if ( element_mode > EVS_MONO ) - { - norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr, Q_new ); - } - else - { - norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); - } -#else if ( element_mode > EVS_MONO ) { norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr, Q_new ); @@ -836,37 +820,24 @@ Word16 pitch_fr4_fx( { norm_corr_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr ); } -#endif /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - max_val = corr[t0_min]; -#else max_val = corr[t0_min + corr_off]; -#endif move16(); t0 = t0_min; move16(); FOR( i = t0_min + 1; i <= t0_max; i++ ) { -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - if ( GE_16( corr[i], max_val ) ) -#else if ( GE_16( corr[i + corr_off], max_val ) ) -#endif { t0 = i; move16(); } -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - max_val = s_max( corr[i], max_val ); -#else max_val = s_max( corr[i + corr_off], max_val ); -#endif } IF( EQ_16( t0_fr1, pit_min ) ) @@ -880,11 +851,7 @@ Word16 pitch_fr4_fx( { i = sub( i, 2 ); } -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - IF( GT_16( corr[i], corr[i + 2] ) ) -#else IF( GT_16( corr[i + corr_off], corr[i + 2 + corr_off] ) ) -#endif { t0 = i; move16(); @@ -935,27 +902,15 @@ Word16 pitch_fr4_fx( { fraction = 0; move16(); -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - cor_max = Interpol_4( &corr[t0], fraction ); -#else cor_max = Interpol_4( &corr[t0 + corr_off], fraction ); -#endif } ELSE { t0 = sub( t0, 1 ); -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - cor_max = Interpol_4( &corr[t0], fraction ); -#else cor_max = Interpol_4( &corr[t0 + corr_off], fraction ); -#endif FOR( i = fraction + step; i <= 3; i = ( i + step ) ) { -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - temp = Interpol_4( &corr[t0], i ); -#else temp = Interpol_4( &corr[t0 + corr_off], i ); -#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; @@ -968,11 +923,7 @@ Word16 pitch_fr4_fx( FOR( i = 0; i <= 3; i = ( i + step ) ) { -#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 - temp = Interpol_4( &corr[t1], i ); -#else temp = Interpol_4( &corr[t1 + corr_off], i ); -#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; -- GitLab From 1ccc046862a540348935105524df97140ccaf5bd Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:11:45 +0100 Subject: [PATCH 386/750] [cleanup] accept FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR --- lib_com/hvq_pvq_bitalloc_fx.c | 6 ------ lib_com/options.h | 1 - 2 files changed, 7 deletions(-) diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c index 2e01a7361..905749d47 100644 --- a/lib_com/hvq_pvq_bitalloc_fx.c +++ b/lib_com/hvq_pvq_bitalloc_fx.c @@ -40,10 +40,8 @@ Word16 hvq_pvq_bitalloc_fx( UWord16 lsb; Word16 num_sfm; -#ifdef FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR *n_sel_bands = 0; move16(); -#endif IF( EQ_16( bwidth_fx, FB ) ) { @@ -112,10 +110,6 @@ Word16 hvq_pvq_bitalloc_fx( return 0; } -#ifndef FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR - *n_sel_bands = 0; - move16(); -#endif envSum = 0; move16(); E_max = L_deposit_l( 0 ); diff --git a/lib_com/options.h b/lib_com/options.h index 46a2c7f6a..5f9eb153f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1483_PEAQ_VQ_ENC_MSAN_ERROR /* Eri: When no PVQ bands are selected in peaq_vq_enc, the number of bands is not initialized. */ #define FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE /* Eri: Initializes a variables in HQ decoder. It is not used, but is passed uninitialized to a function which is caught by clang-18 */ #define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ -- GitLab From 5a9a09c624495085b14ae7283f609109b9671e77 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:12:31 +0100 Subject: [PATCH 387/750] [cleanup] accept FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE --- lib_com/options.h | 1 - lib_dec/hq_hr_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5f9eb153f..b4d508d02 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE /* Eri: Initializes a variables in HQ decoder. It is not used, but is passed uninitialized to a function which is caught by clang-18 */ #define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 975b643a4..858306b17 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -166,10 +166,8 @@ void ivas_hq_hr_dec_fx( Word16 csw_flag1, csw_flag2; HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; -#ifdef FIX_1480_CLANG18_MSAN_UNINIT_VARIABLE hq_generic_offset = 0; move16(); -#endif move16(); move16(); -- GitLab From eee5d2831540bd715f7686656b5321aa98ba2a78 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:13:50 +0100 Subject: [PATCH 388/750] [cleanup] accept FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR --- apps/decoder.c | 2 -- lib_com/options.h | 1 - lib_dec/lib_dec_fx.c | 26 -------------------------- 3 files changed, 29 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0b8a1d018..4500e080c 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -448,12 +448,10 @@ int main( goto cleanup; } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) { fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } -#endif } /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index b4d508d02..b35900ea4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 17a8d966e..32e4d690a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1582,22 +1582,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); #endif -#else - IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) - { -#ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); -#endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); - } -#endif ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, pcmBuf_out ); } @@ -4928,22 +4915,9 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif -#else - IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) - { -#ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); -#endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); - } -#endif ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } -- GitLab From e4c68d8ac3f368e3044323781a423a606ab1a6c0 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:15:51 +0100 Subject: [PATCH 389/750] Revert "[cleanup] accept FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR" This reverts commit eee5d2831540bd715f7686656b5321aa98ba2a78. --- apps/decoder.c | 2 ++ lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 4500e080c..0b8a1d018 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -448,10 +448,12 @@ int main( goto cleanup; } +#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) { fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } +#endif } /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index b35900ea4..b4d508d02 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ +#define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 32e4d690a..17a8d966e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1582,9 +1582,22 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } +#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); #endif +#else + IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); +#endif + } + ELSE + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); + } +#endif ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, pcmBuf_out ); } @@ -4915,9 +4928,22 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } +#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif +#else + IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); +#endif + } + ELSE + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + } +#endif ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } -- GitLab From caf3c608c26ab403f628ab12f98b2438b363fe86 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:16:48 +0100 Subject: [PATCH 390/750] [cleanup] accept FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX --- lib_com/options.h | 1 - lib_dec/ivas_ism_dtx_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b4d508d02..53288573c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +89,6 @@ #define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ #define FIX_2290_COPY_OF_UNINIT_DATA /* VA: prevent the copy of un-initialized data */ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index ebd6a0360..f69fe17ea 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -126,12 +126,10 @@ void ivas_ism_dtx_dec_fx( move16(); } } -#ifdef FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX ELSE { set16_fx( nb_bits_metadata, 0, st_ivas->nchan_transport ); } -#endif IF( !st_ivas->bfi ) { -- GitLab From 77670b498b745a8acd7cb9d0c15e196afe8268c1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:17:40 +0100 Subject: [PATCH 391/750] [cleanup] accept FIX_2290_COPY_OF_UNINIT_DATA --- lib_com/options.h | 1 - lib_dec/ivas_core_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 53288573c..308416b98 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,7 +90,6 @@ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ -#define FIX_2290_COPY_OF_UNINIT_DATA /* VA: prevent the copy of un-initialized data */ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ #define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ #define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index bf1f75333..d839e3808 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -562,14 +562,10 @@ ivas_error ivas_core_dec_fx( hSCE->q_save_hb_synth_fx = Q11; move16(); } -#ifdef FIX_2290_COPY_OF_UNINIT_DATA IF( st->hBWE_FD != NULL ) { Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) } -#else - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) -#endif } Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0 -- GitLab From 83e968f491b6b7f9717724a1fc6f19bae8b44e4f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:18:18 +0100 Subject: [PATCH 392/750] [cleanup] accept CLEANUP_ACELP_ENC --- lib_com/est_tilt_fx.c | 110 --- lib_com/options.h | 1 - lib_com/prot_fx.h | 65 -- lib_com/swb_tbe_com_fx.c | 122 ---- lib_dec/acelp_core_switch_dec_fx.c | 4 - lib_dec/dec_ace_fx.c | 4 - lib_dec/dec_amr_wb_fx.c | 8 - lib_dec/dec_gen_voic_fx.c | 19 - lib_dec/dec_pit_exc_fx.c | 12 - lib_dec/dec_tran_fx.c | 17 - lib_dec/dec_uv_fx.c | 15 - lib_dec/gain_dec_fx.c | 124 ---- lib_dec/gaus_dec_fx.c | 11 - lib_dec/inov_dec_fx.c | 186 ----- lib_dec/ivas_td_low_rate_dec_fx.c | 17 - lib_enc/acelp_core_enc_fx.c | 59 -- lib_enc/acelp_core_switch_enc_fx.c | 476 ------------- lib_enc/cod_ace_fx.c | 4 - lib_enc/core_switching_enc_fx.c | 27 - lib_enc/enc_amr_wb_fx.c | 5 - lib_enc/enc_gen_voic_fx.c | 401 ----------- lib_enc/enc_higher_acelp_fx.c | 361 ---------- lib_enc/enc_pit_exc_fx.c | 38 - lib_enc/enc_tran_fx.c | 409 ----------- lib_enc/enc_uv_fx.c | 248 ------- lib_enc/inov_enc_fx.c | 305 -------- lib_enc/ivas_core_enc_fx.c | 4 - lib_enc/ivas_td_low_rate_enc_fx.c | 12 - lib_enc/prot_fx_enc.h | 170 ----- lib_enc/transition_enc_fx.c | 1071 ---------------------------- 30 files changed, 4305 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 9d92d5d77..95e527da0 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -33,93 +33,9 @@ /* RETURN ARGUMENTS : */ /* _ (Word16) tolt_code : tilt of the code Q15 */ /*=======================================================================*/ -#ifndef CLEANUP_ACELP_ENC -Word16 est_tilt_fx( /* o : tilt of the code Q15 */ - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -) -{ - Word16 i, tmp, exp, ener1, exp1, ener2, exp2; - Word32 L_tmp; - Word16 tilt_code; - - ener1 = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp1 ) ); - exp1 = sub( exp1, add( Q_exc, Q_exc ) ); - L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */ - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); - ener1 = mult( ener1, tmp ); - exp1 = sub( sub( exp1, exp ), 10 ); /* 10 -> gain_pit Q14 to Q9 */ - - ener2 = extract_h( Dot_product12( code, code, L_SUBFR, &exp2 ) ); - - exp = norm_l( gain_code ); - tmp = extract_h( L_shl( gain_code, exp ) ); - tmp = mult( tmp, tmp ); /* energy of innovative code excitation */ - ener2 = mult( ener2, tmp ); - exp2 = sub( exp2, add( exp, exp ) ); - - i = sub( exp1, exp2 ); - BASOP_SATURATE_WARNING_OFF_EVS - ener1 = shr_sat( ener1, sub( 1, s_min( i, 0 ) ) ); - ener2 = shr_sat( ener2, add( s_max( 0, i ), 1 ) ); - BASOP_SATURATE_WARNING_ON_EVS - tmp = sub( ener1, ener2 ); - ener1 = add( add( ener1, ener2 ), 1 ); - - /* find voice factor (1=voiced, -1=unvoiced) */ - exp = div_s( abs_s( tmp ), ener1 ); - if ( tmp < 0 ) - { - exp = negate( exp ); - } - *voice_fac = exp; - move16(); - - /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */ - - /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */ - tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */ - - return tilt_code; -} - -/*======================================================================*/ -/* FUNCTION : est_tilt_ivas_fx() */ -/*-----------------------------------------------------------------------*/ -/* PURPOSE : Estimate spectral tilt based on the relative E of adaptive */ -/* and innovative excitations */ -/* */ -/*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16 *) exc : adaptive excitation vector Q0 */ -/* _ (Word16) gain_pit : adaptive gain Q14 */ -/* _ (Word16 *) code : algebraic exctitation vector Q12 */ -/* _ (Word32) gain_code : algebraic code gain Q16 */ -/* _ (Word16) Q_exc : Scaling factor of excitation Q0 */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16 *) voice_fac : voicing factor Q15 */ -/*-----------------------------------------------------------------------*/ -/* INPUT OUTPUT ARGUMENTS */ -/*-----------------------------------------------------------------------*/ - -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ (Word16) tolt_code : tilt of the code Q15 */ -/*=======================================================================*/ -#endif /* o : tilt of the code Q15 */ -#ifdef CLEANUP_ACELP_ENC Word16 est_tilt_fx( -#else -Word16 est_tilt_ivas_fx( -#endif const Word16 *exc, /* i : adaptive excitation vector Qx */ const Word16 gain_pit, /* i : adaptive gain Q14 */ const Word16 *code, /* i : algebraic excitation vector Q9 */ @@ -127,10 +43,6 @@ Word16 est_tilt_ivas_fx( Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ const Word16 L_subfr /* i : Sub frame length */ -#ifndef CLEANUP_ACELP_ENC - , - const Word16 flag_tilt /* i : flag for special tilt */ -#endif ) { Word16 i, tmp, exp, ener1, exp1, ener2, exp2; @@ -170,29 +82,7 @@ Word16 est_tilt_ivas_fx( *voice_fac = exp; move16(); -#ifdef CLEANUP_ACELP_ENC tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */ -#else - IF( flag_tilt == 0 ) - { - /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */ - - /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */ - tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */ - } - ELSE IF( EQ_16( flag_tilt, 1 ) ) - { - /*Between 0.25 (=unvoiced) and 0.5 (=voiced)*/ - // tilt_code = (float)(0.25f + (*voice_fac + 1.0f) * 0.125f); - tilt_code = mac_r( 12288L /*0.375.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4096 /*0.125.Q15*/ ); /*Q15 */ - } - ELSE - { - /*Between 0.28 (=unvoiced) and 0.56 (=voiced)*/ - // tilt_code = (float)(0.28f + (*voice_fac + 1.0f) * 0.14f); - tilt_code = mac_r( 13763L /*0.42.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4588 /*0.14.Q15*/ ); /*Q15 */ - } -#endif return tilt_code; } diff --git a/lib_com/options.h b/lib_com/options.h index 308416b98..5b47e7fc8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,7 +90,6 @@ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ -#define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ #define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ #define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 588617196..7c23158ed 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2895,19 +2895,7 @@ Word16 tbe_celp_exc_offset( const Word16 L_frame /* i : frame lenght */ ); -#ifdef CLEANUP_ACELP_ENC void tbe_celp_exc_fx( -#else -void tbe_celp_exc( - const Word16 L_frame_fx, /* i : Frame lenght */ - const Word16 i_subfr_fx, /* i : sub frame */ - const Word16 T0_fx, /* i : Integer pitch */ - const Word16 T0_frac_fx, /* i : Fractional part of the pitch */ - Word16 *error_fx, /* i/o: Error */ - Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */ -); -void tbe_celp_exc_ivas( -#endif const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 L_frame_fx, /* i : Frame lenght */ @@ -4830,30 +4818,10 @@ Word16 est_tilt_fx( const Word16 *code, /* i : algebraic exctitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ -#ifdef CLEANUP_ACELP_ENC const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ const Word16 L_subfr /* i : Sub frame length */ -#else - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#endif ); -#ifndef CLEANUP_ACELP_ENC -/* o : tilt of the code Q15 */ -Word16 est_tilt_ivas_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ -#ifndef CLEANUP_ACELP_ENC - , - const Word16 flag_tilt /* i : flag for special tilt */ -#endif -); -#endif /* o : tilt of the code */ Word16 Est_tilt2( const Word16 *exc, /* i : adaptive excitation vector Qx */ @@ -6846,18 +6814,7 @@ void gain_dec_lbr_fx( ); void lp_gain_updt_fx( -#ifdef CLEANUP_ACELP_ENC const Word16 element_mode, /* i : element mode */ -#else - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ -); -void lp_gain_updt_ivas_fx( -#endif const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ @@ -7116,21 +7073,6 @@ void inov_decode_fx( const Word16 L_subfr /* i : subframe length Q0 */ ); -#ifndef CLEANUP_ACELP_ENC -void inov_decode_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ -); -#endif void dec_acelp_4t64_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 nbbits, /* i : number of bits per codebook */ @@ -10897,13 +10839,6 @@ ivas_error IGF_Reconfig_fx( void core_switching_post_enc_ivas_fx( Encoder_State *st /* i/o: encoder state structure */ -#ifndef CLEANUP_ACELP_ENC - , - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ - Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new -#endif ); void residu_ivas_fx( diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 0ad2588f2..4d005d6b7 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -160,92 +160,8 @@ Word16 tbe_celp_exc_offset( * * Compute tbe bwe celp excitation *-------------------------------------------------------------------*/ -#ifndef CLEANUP_ACELP_ENC -void tbe_celp_exc( - const Word16 L_frame_fx, /* i : Frame lenght */ - const Word16 i_subfr_fx, /* i : sub frame */ - const Word16 T0_fx, /* i : Integer pitch Q0 */ - const Word16 T0_frac_fx, /* i : Fractional part of the pitch Q1 */ - Word16 *error_fx, /* i/o: Error Q5 */ - Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */ -) -{ - Word16 offset_fx, tmp_fx, i; - IF( EQ_16( L_frame_fx, L_FRAME ) ) - { - /*offset = T0 * HIBND_ACB_L_FAC + (int) ((float) T0_frac * 0.25f * HIBND_ACB_L_FAC + 2 * HIBND_ACB_L_FAC + 0.5f) - 2 * HIBND_ACB_L_FAC; - for (i=0; i 0 ) - { - tmp_fx = shr( *error_fx, 5 ); /*Q0*/ - } - ELSE - { - tmp_fx = negate( shr( abs_s( *error_fx ), 5 ) ); /*Q0*/ - } - - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) - { - bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC - offset_fx + tmp_fx]; // Qx - move16(); - } - tmp_fx = extract_l( L_mult( T0_frac_fx, 1 ) ); /*Q3; 0.25 in Q2*/ - tmp_fx = add( shl( T0_fx, 3 ), tmp_fx ); /*Q3*/ - tmp_fx = extract_l( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/ - tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/ - *error_fx = add( *error_fx, tmp_fx ); /*Q5*/ - move16(); - } - ELSE - { - /* offset = T0*2.5 + (int) ((float) T0_frac * 0.25f*2.5 + 2*2.5 + 0.5f) - 2*2.5; - case above*/ - /* offset = T0*2 + (int) ((float) T0_frac * 0.25f*2 + 2*2 + 0.5f) - 2*2; - case here*/ - - /*(int) ((float) T0_frac * 0.25f*2 + 2*2 + 0.5f)*/ - offset_fx = tbe_celp_exc_offset( T0_fx, T0_frac_fx, L_frame_fx ); - IF( *error_fx > 0 ) - { - tmp_fx = shr( *error_fx, 5 ); /*Q0*/ - } - ELSE - { - tmp_fx = negate( shr( abs_s( *error_fx ), 5 ) ); /*Q0*/ - } - - FOR( i = 0; i < L_SUBFR * 2; i++ ) - { - bwe_exc_fx[i + i_subfr_fx * 2] = bwe_exc_fx[i + i_subfr_fx * 2 - offset_fx + tmp_fx]; // Qx - move16(); - } - /* error += (float) offset - (float) T0 * 2 - 0.5f * (float) T0_frac;*/ - tmp_fx = extract_l( L_mult( T0_frac_fx, 2 ) ); /*Q3; 0.5 in Q2*/ - tmp_fx = add( shl( T0_fx, 4 ), tmp_fx ); /* now tmp_fx = "T0_fx*2+ 0.5f*T0_frac_fx" in Q3*/ - tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/ - tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/ - *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/ - move16(); - } -} - -/*-------------------------------------------------------------------* - * swb_tbe_celp_exc_ivas() - * - * Compute tbe bwe celp excitation - *-------------------------------------------------------------------*/ -#endif - -#ifdef CLEANUP_ACELP_ENC void tbe_celp_exc_fx( -#else -void tbe_celp_exc_ivas( -#endif const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 L_frame_fx, /* i : Frame lenght */ @@ -359,14 +275,12 @@ void tbe_celp_exc_ivas( /* _ None */ /*---------------------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC static const Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, -26319, -17530, -6393, 6393, 17530, 26319, 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ static const Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739, -19519, -27683, -32137, -32137, -27683, -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ -#endif void flip_and_downmix_generic_fx( Word16 input[], /* i : input spectrum Qx*/ @@ -390,24 +304,11 @@ void flip_and_downmix_generic_fx( /*Word16 s_tmp[L_FRAME32k];*/ /*Word16 factor;*/ Word16 period; -#ifndef CLEANUP_ACELP_ENC - Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, - -26319, -17530, -6393, 6393, 17530, 26319, - 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ - Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739, - -19519, -27683, -32137, -32137, -27683, - -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ - Word16 *local_negsin_table, *local_cos_table; -#endif Word32 L_tmp; /* 1850 Hz downmix */ period = 17; move16(); -#ifndef CLEANUP_ACELP_ENC - local_negsin_table = local_negsin_table17; - local_cos_table = local_cos_table17; -#endif FOR( i = 0; i < length; i = i + 2 ) { @@ -489,13 +390,8 @@ void flip_and_downmix_generic_fx( { WHILE( ( j < period ) && ( i < length ) ) { -#ifdef CLEANUP_ACELP_ENC L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ -#else - L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */ - L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */ -#endif output[i] = round_fx( L_tmp ); /*Qx */ move16(); i++; @@ -538,24 +434,11 @@ void flip_and_downmix_generic_fx32( /*Word16 s_tmp[L_FRAME32k];*/ /*Word16 factor;*/ Word16 period; -#ifndef CLEANUP_ACELP_ENC - Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, - -26319, -17530, -6393, 6393, 17530, 26319, - 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ - Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739, - -19519, -27683, -32137, -32137, -27683, - -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ - Word16 *local_negsin_table, *local_cos_table; -#endif Word32 L_tmp; /* 1850 Hz downmix */ period = 17; move16(); -#ifndef CLEANUP_ACELP_ENC - local_negsin_table = local_negsin_table17; - local_cos_table = local_cos_table17; -#endif FOR( i = 0; i < length; i = i + 2 ) { @@ -627,13 +510,8 @@ void flip_and_downmix_generic_fx32( WHILE( ( j < period ) && ( i < length ) ) { test(); -#ifdef CLEANUP_ACELP_ENC L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ -#else - L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */ - L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */ -#endif output[i] = L_tmp; /*Qx */ move32(); i++; diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 049626e59..707957d0f 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -936,11 +936,7 @@ static void decod_gen_voic_core_switch_fx( gain_dec_mless_fx( st_fx, L_frame, GENERIC, 0, -1, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code ); } -#ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc, L_SUBFR ); /*Q15*/ -#else - st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc ); /*Q15*/ -#endif move16(); /*----------------------------------------------------------------------* diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 9c1cd74ac..ac137b37c 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -353,11 +353,7 @@ void decoder_acelp_fx( IF( st->igf != 0 ) { -#ifdef CLEANUP_ACELP_ENC tbe_celp_exc_fx( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); -#else - tbe_celp_exc( st->L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); -#endif } pitch_buffer[idx] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); // Q6 diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 2a977033d..af6c706f7 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -99,17 +99,9 @@ void decod_amr_wb_fx( gain_dec_amr_wb_fx( st_fx, st_fx->core_brate, &gain_pit_fx, &L_gain_code_fx, hAmrwb_IO->past_qua_en_fx, &gain_inov_fx, code_fx, &L_norm_gain_code_fx ); /* update LP filtered gains for the case of frame erasures */ -#ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( EVS_MONO, i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); -#else - lp_gain_updt_fx( i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); -#endif -#ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); -#else - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); -#endif move16(); Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_SUBFR, 0, diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 0288e3d85..e1a3917df 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -174,11 +174,7 @@ ivas_error decod_gen_voic_fx( pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } -#ifdef CLEANUP_ACELP_ENC tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); -#else - tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); -#endif /*--------------------------------------------------------------* * LP filtering of the adaptive excitation @@ -222,11 +218,7 @@ ivas_error decod_gen_voic_fx( gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } -#ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15 -#else - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); // Q15 -#endif move16(); /*-----------------------------------------------------------------* @@ -240,18 +232,7 @@ ivas_error decod_gen_voic_fx( } /* update LP filtered gains for the case of frame erasures */ -#ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); -#else - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); - } - ELSE - { - lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); - } -#endif /*----------------------------------------------------------------------* * Find the total excitation diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 41fcb64c7..83818d1c9 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -202,11 +202,7 @@ void dec_pit_exc_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); -#ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); -#else - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); -#endif move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ @@ -220,11 +216,7 @@ void dec_pit_exc_fx( gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); -#ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); -#else - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); -#endif move16(); } ELSE @@ -426,11 +418,7 @@ void dec_pit_exc_fx( move16(); pt_gain++; -#ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame ); -#else - lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame ); -#endif } } diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 43a948bba..110c6e97f 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -168,27 +168,10 @@ void decod_tran_fx( } /* update LP filtered gains for the case of frame erasures */ -#ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st_fx->element_mode, i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); move16(); -#else - IF( st_fx->element_mode == EVS_MONO ) - { - lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); - - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); - move16(); - } - ELSE - { - lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); - - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); - move16(); - } -#endif /*----------------------------------------------------------------------* * Find the total excitation diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index 9ced61d68..83e5666b4 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -116,26 +116,11 @@ void decod_unvoiced_fx( gain_dec_gacelp_uv_fx( index, code_fx, code2_fx, Es_pred_fx, L_SUBFR, &gain_pit_fx, &gain_code_fx, &gain_code2_fx, &( st_fx->past_gpit ), &norm_gain_code_fx, &gain_inov_fx ); -#ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); -#else - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); -#endif move16(); /* update LP filtered gains for the case of frame erasures */ -#ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); -#else - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); - } - ELSE - { - lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); - } -#endif /*-------------------------------------------------------* * - Find the total excitation. * diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index c145610f8..8f75cdaa8 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -989,125 +989,9 @@ void gain_dec_lbr_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*=======================================================================*/ -#ifndef CLEANUP_ACELP_ENC -void lp_gain_updt_fx( - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ -) -{ - Word16 tmp; - - tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ - IF( EQ_16( L_frame, L_FRAME ) ) - { - IF( EQ_16( i_subfr, 0 ) ) - { - *lp_gainp = mult( 3277, gain_pit ); - move16(); /*0.1 in Q15 = 3277 , (15+14)-15 -> Q14*/ - *lp_gainc = mult_r( 3277, tmp ); - move16(); /* (15+3)-15 -> Q3*/ - } - ELSE IF( EQ_16( i_subfr, L_SUBFR ) ) - { - *lp_gainp = add( *lp_gainp, mult( 6554, gain_pit ) ); - move16(); /*Q14 (0.2 in Q15 = 6554)*/ - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 6554, tmp ); - move16(); /*Q3*/ - } - ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) ) - { - *lp_gainp = add( *lp_gainp, mult( 9830, gain_pit ) ); - move16(); /*Q14 (0.3 in Q15 = 9830)*/ - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 9830, tmp ); - move16(); /*Q3*/ - } - ELSE /* i_subfr == 3*L_SUBFR */ - { - *lp_gainp = add( *lp_gainp, mult( 13107, gain_pit ) ); - move16(); /*Q14 (0.4 in Q15 = 13107)*/ - *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 13107, tmp ); - move16(); /*Q3*/ - } - } - ELSE - { - IF( i_subfr == 0 ) - { - *lp_gainp = mult( 2185, gain_pit ); - move16(); /*(1.0/15.0) in Q15 = 2185 , (15+14)-15 -> Q14*/ - *lp_gainc = mult_r( 2185, tmp ); - move16(); /* (15+3)-15 -> Q3*/ - } - ELSE IF( EQ_16( i_subfr, L_SUBFR ) ) - { - *lp_gainp = add( *lp_gainp, mult( 4369, gain_pit ) ); - move16(); /*Q14 (2.0/15.0 in Q15 = 4369)*/ - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 4369, tmp ); - move16(); /*Q3*/ - } - ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) ) - { - *lp_gainp = add( *lp_gainp, mult( 6554, gain_pit ) ); - move16(); /*Q14 (3.0/15.0 in Q15 = 6554)*/ - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 6554, tmp ); - move16(); /*Q3*/ - } - ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) ) - { - *lp_gainp = add( *lp_gainp, mult( 8738, gain_pit ) ); - move16(); /*Q14 (4.0/15.0 in Q15 = 8738)*/ - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 8738, tmp ); - move16(); /*Q3*/ - } - ELSE /* i_subfr == 4*L_SUBFR */ - { - *lp_gainp = add( *lp_gainp, mult( 10923, gain_pit ) ); - move16(); /*Q14 (5.0/15.0 in Q15 = 10923)*/ - *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 10923, tmp ); - move16(); /*Q3*/ - } - } - return; -} - -/*====================================================================== */ -/* FUNCTION : lp_gain_updt_ivas_fx() */ -/*-----------------------------------------------------------------------*/ -/* PURPOSE : Update of LP pitch and code gains (FEC) */ -/* */ -/*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) i_subfr : subframe number Q0 */ -/* _ (Word16) gain_pit : Decoded gain pitch Q14 */ -/* _ (Word32) norm_gain_code : Normalised gain code Q16 */ -/* _ (Word16) L_frame : length of the frame Q0 */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16 *) T0 : close loop integer pitch */ -/* _ (Word16 *) T0_frac : close loop fractional part of the pitch */ -/* _ (Word16 ) pitch : pitch value Q6 */ -/*-----------------------------------------------------------------------*/ -/* INPUT OUTPUT ARGUMENTS */ -/* _ (Word16 *) lp_gainp : LP-filtered pitch gain(FEC) Q14 */ -/* _ (Word16 *) lp_gainc : LP-filtered code gain (FEC) Q3 */ -/*-----------------------------------------------------------------------*/ - -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*=======================================================================*/ -#endif -#ifdef CLEANUP_ACELP_ENC void lp_gain_updt_fx( const Word16 element_mode, /* i : element mode */ -#else -void lp_gain_updt_ivas_fx( -#endif const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ @@ -1121,12 +1005,8 @@ void lp_gain_updt_ivas_fx( tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ /* To handle extremely low values */ test(); -#ifdef CLEANUP_ACELP_ENC test(); if ( element_mode != EVS_MONO && norm_gain_code != 0 && tmp == 0 ) -#else - if ( norm_gain_code != 0 && tmp == 0 ) -#endif { tmp = 1; move16(); @@ -1204,12 +1084,8 @@ void lp_gain_updt_ivas_fx( /* To handle extremely low values */ test(); -#ifdef CLEANUP_ACELP_ENC test(); if ( element_mode != EVS_MONO && tmp != 0 && *lp_gainc == 0 ) -#else - if ( tmp != 0 && *lp_gainc == 0 ) -#endif { *lp_gainc = 1; move16(); diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index 456a7a902..0d38c40bc 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -87,18 +87,7 @@ void gaus_dec_fx( move32(); /* update LP filtered gains for the case of frame erasures */ -#ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st_fx->element_mode, i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ -#else - IF( st_fx->element_mode == EVS_MONO ) - { - lp_gain_updt_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ - } - ELSE - { - lp_gain_updt_ivas_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ - } -#endif /*------------------------------------------------------------------------------------------* * Updates diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index 30479dd04..21e70e083 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -191,189 +191,3 @@ void inov_decode_fx( cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); return; } -#ifndef CLEANUP_ACELP_ENC -/*======================================================================*/ -/* FUNCTION : inov_decode_ivas_fx() */ -/*-----------------------------------------------------------------------*/ -/* PURPOSE : Decode the algebraic innovation and do pitch sharpening */ -/* */ -/*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) core_brate : Core bitrate Q0 */ -/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */ -/* _ (Word16) L_frame : length of the frame Q0 */ -/* _ (Word16) i_subfr : length of the frame Q0 */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) L_subfr : subframe length */ -/* _ (Word16) sharpFlag : formant sharpening flag */ -/* _ (Word16) tc_subfr : TC subframe index */ -/* _ (Word16 *) p_Aq : LP filter coefficients Q12 */ -/* _ (Word16) tilt_code : tilt of the excitation of previous subframe Q15*/ -/* _ (Word16) pt_pitch : current subframe fractional pitch Q6 */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16 *[]) code : subframe length Q12 */ -/* _ (Word16 []) index_buf_4T : subframe length */ -/*-----------------------------------------------------------------------*/ -/* INPUT OUTPUT ARGUMENTS */ -/*-----------------------------------------------------------------------*/ - -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*=======================================================================*/ - -void inov_decode_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ -) -{ - Word16 nBits; - Word16 g1, g2; - - IF( EQ_16( L_frame, L_FRAME ) ) - { - g1 = FORMANT_SHARPENING_G1; - move16(); - g2 = FORMANT_SHARPENING_G2; - move16(); - } - ELSE - { - g1 = FORMANT_SHARPENING_G1_16k; - move16(); - g2 = FORMANT_SHARPENING_G2_16k; - move16(); - } - - IF( !Opt_AMR_WB ) - { - IF( st_fx->acelp_cfg.fcb_mode ) - { - Word16 i; - Word16 indexing_indices[8], wordcnt, bitcnt; - PulseConfig config; - test(); - test(); - test(); - IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 ) - { - IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) - { - nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr]; // Q0 - move16(); - - IF( EQ_16( nBits, 8 ) ) - { - dec_acelp_1t64_fx( st_fx, code, L_subfr ); - } - ELSE - { - dec_acelp_fast_fx( st_fx, nBits, code, L_subfr ); - } - } - ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( ( st_fx->idchan == 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) ) - { - IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 ) - { - dec_acelp_1t64_fx( st_fx, code, L_SUBFR ); - } - ELSE - { - dec_acelp_fast_fx( st_fx, st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR ); - } - } - ELSE - { - wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 4 ); // Q0 - move16(); - bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0 - move16(); - - FOR( i = 0; i < wordcnt; i++ ) - { - indexing_indices[i] = get_next_indice_fx( st_fx, 16 ); // Q0 - move16(); - } - IF( bitcnt ) - { - indexing_indices[i] = get_next_indice_fx( st_fx, bitcnt ); // Q0 - move16(); - } - config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]]; - D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect ); - } - } - ELSE - { - set16_fx( code, 0, L_SUBFR ); - } - } - ELSE - { - nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]; // Q0 - move16(); - - IF( EQ_16( nBits, 7 ) ) - { - dec_acelp_1t64_fx( st_fx, code, L_SUBFR ); - } - ELSE IF( EQ_16( nBits, 12 ) ) - { - dec_acelp_2t32_fx( st_fx, code ); - } - ELSE - { - dec_acelp_4t64_fx( st_fx, nBits, code, Opt_AMR_WB ); - } - } - } - ELSE - { - IF( EQ_32( core_brate, ACELP_6k60 ) ) - { - dec_acelp_2t32_fx( st_fx, code ); - } - ELSE IF( EQ_32( core_brate, ACELP_8k85 ) ) - { - dec_acelp_4t64_fx( st_fx, 20, code, Opt_AMR_WB ); - } - ELSE IF( EQ_32( core_brate, ACELP_12k65 ) ) - { - dec_acelp_4t64_fx( st_fx, 36, code, Opt_AMR_WB ); - } - ELSE IF( EQ_32( core_brate, ACELP_14k25 ) ) - { - dec_acelp_4t64_fx( st_fx, 44, code, Opt_AMR_WB ); - } - ELSE IF( EQ_32( core_brate, ACELP_15k85 ) ) - { - dec_acelp_4t64_fx( st_fx, 52, code, Opt_AMR_WB ); - } - ELSE IF( EQ_32( core_brate, ACELP_18k25 ) ) - { - dec_acelp_4t64_fx( st_fx, 64, code, Opt_AMR_WB ); - } - ELSE IF( EQ_32( core_brate, ACELP_19k85 ) ) - { - dec_acelp_4t64_fx( st_fx, 72, code, Opt_AMR_WB ); - } - ELSE - { - dec_acelp_4t64_fx( st_fx, 88, code, Opt_AMR_WB ); - } - } - - cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); - return; -} -#endif diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 92d6d3153..205093d6f 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -267,11 +267,7 @@ void decod_gen_2sbfr_fx( test(); IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) && !( st->tdm_LRTD_flag ) ) ) { -#ifdef CLEANUP_ACELP_ENC tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); -#else - tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); -#endif } /*--------------------------------------------------------------* @@ -297,11 +293,7 @@ void decod_gen_2sbfr_fx( * Innovation decoding *--------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC inov_decode_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR ); -#else - inov_decode_ivas_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR ); -#endif /*--------------------------------------------------------------* * Gain decoding @@ -310,21 +302,12 @@ void decod_gen_2sbfr_fx( gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); -#ifdef CLEANUP_ACELP_ENC st->tilt_code_fx = est_tilt_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */ -#else - st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */ -#endif move16(); /* update LP filtered gains for the case of frame erasures */ -#ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st->element_mode, i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); lp_gain_updt_fx( st->element_mode, add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); -#else - lp_gain_updt_ivas_fx( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); - lp_gain_updt_ivas_fx( add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); -#endif /*----------------------------------------------------------------------* * Find the total excitation diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 89af93707..578b5ff36 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -96,16 +96,7 @@ ivas_error acelp_core_enc_fx( error = IVAS_ERR_OK; -#ifdef CLEANUP_ACELP_ENC (void) hStereoTD; -#else - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && LE_32( st_fx->core_brate, SID_2k40 ) ) - { - /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */ - return error; - } -#endif /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -201,30 +192,11 @@ ivas_error acelp_core_enc_fx( move16(); } -#ifndef CLEANUP_ACELP_ENC - /* TD stereo */ - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) - { - tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; - tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; - tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; - tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf_fx; - } - ELSE -#endif { tdm_lp_reuse_flag = 0; tdm_low_rate_mode = 0; move16(); move16(); -#ifndef CLEANUP_ACELP_ENC - if ( EQ_16( st_fx->element_mode, IVAS_SCE ) && st_fx->low_rate_mode ) - { - tdm_low_rate_mode = 1; - move16(); - } -#endif tdm_Pitch_reuse_flag = 0; tdm_Pri_pitch_buf = NULL; move16(); @@ -569,26 +541,11 @@ ivas_error acelp_core_enc_fx( E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &hLPDmem->syn[M] ); Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn -#ifndef CLEANUP_ACELP_ENC - test(); - IF( st_fx->element_mode > EVS_MONO && st_fx->hTcxEnc != NULL ) - { - Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 ); // Q_syn - } -#endif /*--------------------------------------------------------------------------------------* * Modify the excitation signal when the noise is stationary *--------------------------------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC IF( NE_16( nelp_mode, 1 ) ) -#else - test(); - test(); - test(); - test(); - IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) -#endif { L_epsP[0] = L_Comp( epsP_h_fx[2], epsP_l_fx[2] ); move32(); @@ -1394,19 +1351,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ -#ifdef CLEANUP_ACELP_ENC encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); -#else - encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); -#endif } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { -#ifdef CLEANUP_ACELP_ENC encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); -#else - encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); -#endif } #ifndef CLEANUP_VBR_CAM_ENC ELSE IF( ppp_mode ) @@ -1438,11 +1387,7 @@ ivas_error acelp_core_enc_ivas_fx( move16(); /* VOICED frames in SC-VBR */ -#ifdef CLEANUP_ACELP_ENC encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); -#else - encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); -#endif } } #endif @@ -1458,11 +1403,7 @@ ivas_error acelp_core_enc_ivas_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ -#ifdef CLEANUP_ACELP_ENC encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); -#else - encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); -#endif } /* update mem_syn1_flt for ACELP core switching */ diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 98ab17afb..b4c10b9ac 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -17,14 +17,8 @@ static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, const Word16 shift, const Word16 Q_new ); -#ifndef CLEANUP_ACELP_ENC -static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, const Word16 shift, const Word16 Q_new ); -#endif static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech ); -#ifndef CLEANUP_ACELP_ENC -static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech ); -#endif static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, const Word16 qx, const Word16 qy, Word16 *qo, const Word16 len, const Word16 delta ); @@ -166,117 +160,6 @@ void acelp_core_switch_enc_fx( return; } -#ifndef CLEANUP_ACELP_ENC -void acelp_core_switch_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : input signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 shift, - Word16 Q_new ) -{ - Word16 i, j, T_op[2]; - Word16 old_exc[L_EXC], *exc; /* excitation signal buffer Qexc */ - const Word16 *inp; - Word32 cbrate; - Word16 Aq[2 * ( M + 1 )]; - LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - Word16 nb_bits; - UWord16 value; - - hLPDmem = st_fx->hLPDmem; - - /* initializations */ - exc = &old_exc[L_EXC_MEM]; - move16(); /* pointer to excitation signal in the current frame */ - Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /*now old_exc has the same scaling as st_fx->old_exc; need to change later? */ - - Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 ); /* Q12 */ - Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 ); /* Q12 */ - T_op[0] = st_fx->pitch[0]; /* Q12 */ - move16(); - T_op[1] = st_fx->pitch[1]; /* Q12 */ - move16(); - - /*----------------------------------------------------------------* - * set switching frame bitrate - *----------------------------------------------------------------*/ - - IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) /* ACELP@12k8 core */ - { - inp = inp12k8; /* Q0 */ - - IF( GT_32( st_fx->core_brate, ACELP_24k40 ) ) - { - cbrate = L_add( ACELP_24k40, 0 ); - } - ELSE - { - cbrate = L_add( st_fx->core_brate, 0 ); - } - } - ELSE /* ACELP@16k core */ - { - inp = inp16k; /* Q0 */ - - IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) - { - cbrate = L_add( ACELP_8k00, 0 ); - } - ELSE IF( LE_32( st_fx->core_brate, ACELP_14k80 ) ) - { - cbrate = L_add( ACELP_14k80, 0 ); - } - ELSE - { - cbrate = L_min( st_fx->core_brate, ACELP_22k60 ); /* Q0 */ - } - } - - IF( NE_16( st_fx->last_L_frame, L_FRAME ) ) - { - T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[0] ), 2 ) ), 1 ), 1 ); /* Q0 */ - move16(); - T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[1] ), 2 ) ), 1 ), 1 ); /* Q0 */ - move16(); - } - - /*----------------------------------------------------------------* - * Excitation encoding - *----------------------------------------------------------------*/ - - config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); - - encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); - - /*----------------------------------------------------------------* - * bit-stream: modify the layer of sub frame CELP - *----------------------------------------------------------------*/ - - i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); /* Q0 */ - - while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START ) - { - push_indice( hBstr, IND_CORE_SWITCHING_CELP_SUBFRAME, hBstr->ind_list[i].value, hBstr->ind_list[i].nb_bits ); - i++; - } - delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); - - /*----------------------------------------------------------------* - * BWE encoding - *----------------------------------------------------------------*/ - - test(); - test(); - IF( !( ( EQ_16( st_fx->last_L_frame, L_FRAME16k ) && EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) ) || EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME8k ) ) ) - { - bwe_switch_enc_ivas_fx( st_fx, (const Word16 *) st_fx->old_input_signal_fx ); - } - - return; -} -#endif /*-------------------------------------------------------------------* * encod_gen_voic_core_switch() @@ -434,13 +317,8 @@ static void encod_gen_voic_core_switch_fx( * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); -#else - inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, - h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); -#endif /*-----------------------------------------------------------------* * Gain encoding @@ -498,219 +376,6 @@ static void encod_gen_voic_core_switch_fx( return; } -#ifndef CLEANUP_ACELP_ENC -static void encod_gen_voic_core_switch_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 inp[], /* i : input signal Q0*/ - const Word16 Aq[], /* i : LP coefficients Q12*/ - const Word16 A[], /* i : unquantized A(z) filter Q12*/ - const Word16 T_op[], /* i : open loop pitch Q0*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/ - const Word32 core_bitrate, /* i : switching frame bitrate Q0*/ - const Word16 shift, - const Word16 Q_new ) -{ - Word16 res[L_SUBFR]; /* residual signal Qexc */ - Word16 Ap[M + 1]; /* A(z) with spectral expansion Q12 */ - Word16 xn[L_SUBFR]; /* Target vector for pitch search */ - Word16 xn2[L_SUBFR]; /* Target vector for codebook search */ - Word16 cn[L_SUBFR]; /* Target vector in residual domain */ - Word16 h1[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ - - Word16 code[L_SUBFR]; /* Fixed codebook excitation Q9 */ - Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */ - Word16 y2[L_SUBFR]; /* Filtered algebraic excitation */ - Word16 gain_pit; /* Pitch gain Q15 */ - Word16 voice_fac; /* Voicing factor Q15 */ - Word32 gain_code; /* Gain of code Q16 */ - Word16 gain_inov; /* inovation gain */ - Word16 i, gcode16; /* tmp variables */ - Word16 T0, T0_frac; /* close loop integer pitch and fractional part */ - Word16 T0_min, T0_max; /* pitch variables */ - - Word16 pitch, tmp16; /* floating pitch value */ - Word16 g_corr[6]; /* ACELP correl, values + gain pitch */ - Word16 clip_gain; /* ISF clip gain */ - - Word16 unbits; /* number of unused bits for PI */ - Word32 norm_gain_code; - Word16 pitch_limit_flag; - Word32 L_tmp, Lgcode; - Word16 shift_wsp; - Word16 h2[L_SUBFR + ( M + 1 )]; - Word16 dummyF[NB_SUBFR16k]; - Word16 lp_select, lp_flag; - Word16 q_h1; - LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ - BSTR_ENC_HANDLE hBstr; - - hLPDmem = st_fx->hLPDmem; - hBstr = st_fx->hBstr; - - // TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - - /*------------------------------------------------------------------* - * Initializations - *------------------------------------------------------------------*/ - - shift_wsp = add( Q_new, shift ); - - unbits = 0; - move16(); - - IF( EQ_16( L_frame, L_FRAME ) ) - { - T0_max = PIT_MAX; - move16(); - T0_min = PIT_MIN; - move16(); - } - ELSE /* L_frame == L_FRAME16k */ - { - T0_max = PIT16k_MAX; - move16(); - T0_min = PIT16k_MIN; - move16(); - } - - /*------------------------------------------------------------------* - * Calculation of LP residual (filtering through A[z] filter) - *------------------------------------------------------------------*/ - - tmp16 = st_fx->L_frame; /* Q0 */ - move16(); - st_fx->L_frame = L_SUBFR; - move16(); - calc_residu_fx( st_fx, inp, res, Aq ); - - // hTdCngEnc->burst_ho_cnt = 0; - st_fx->L_frame = tmp16; /* Q0 */ - move16(); - - /*------------------------------------------------------------------* - * ACELP subframe loop - *------------------------------------------------------------------*/ - - - Copy( res, exc, L_SUBFR ); /* Q_exc */ - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - weight_a_fx( A, Ap, GAMMA16k, M ); /* Bandwidth expansion of A(z) filter coefficients */ - find_targets_ivas_fx( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, PREEMPH_FAC_16k, xn, cn, h1 ); - } - ELSE - { - weight_a_fx( A, Ap, GAMMA1, M ); /* Bandwidth expansion of A(z) filter coefficients */ - find_targets_ivas_fx( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, TILT_FAC_FX, xn, cn, h1 ); - } - - q_h1 = sub( 14, norm_s( h1[0] ) ); - Copy_Scale_sig( h1, h2, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn, L_SUBFR, shift ); /* Q_new */ - - /*----------------------------------------------------------------* - * Close-loop pitch search and quantization - * Adaptive exc. construction - *----------------------------------------------------------------*/ - - set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */ - pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/, st_fx->element_mode, Q_new ); /* Q6 */ - - - /*-----------------------------------------------------------------* - * Find adaptive exitation - *-----------------------------------------------------------------*/ - - pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - /*-----------------------------------------------------------------* - * Gain clipping test to avoid unstable synthesis on frame erasure - * or in case of floating point encoder & fixed p. decoder - *-----------------------------------------------------------------*/ - - clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */ - - /*-----------------------------------------------------------------* - * LP filtering of the adaptive excitation, codebook target computation - *-----------------------------------------------------------------*/ - lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */ - Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/ - lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ - IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) - { - push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); - } - - /*-----------------------------------------------------------------* - * Innovation encoding - *-----------------------------------------------------------------*/ - - inov_encode_ivas_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, - h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, Q_new ); - - /*-----------------------------------------------------------------* - * Gain encoding - *-----------------------------------------------------------------*/ - IF( EQ_16( L_frame, L_FRAME ) ) - { - gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, - &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, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); - } - gp_clip_test_gain_pit_fx( st_fx->element_mode, core_bitrate, gain_pit, st_fx->clip_var_fx ); - - Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); /* Q0 */ - - // hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift ); - // Q_new or shift ?? ->Qexc - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */ - move16(); - - /*-----------------------------------------------------------------* - * Construct adaptive part of the excitation - *-----------------------------------------------------------------*/ - - FOR( i = 0; i < L_SUBFR; i++ ) - { - /* code in Q9, gain_pit in Q14 */ - L_tmp = L_mult( gcode16, code[i] ); /* Q10 */ - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */ - L_tmp = L_mac_sat( L_tmp, exc[i], gain_pit ); - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ - exc[i] = round_fx_sat( L_tmp ); /* Q_exc */ - move16(); - } - - /* write reserved bits */ - IF( unbits ) - { - push_indice( hBstr, IND_UNUSED, 0, unbits ); - } - - /*-----------------------------------------------------------------* - * long term prediction on the 2nd sub frame - *-----------------------------------------------------------------*/ - - pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ ) - { - exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */ - move16(); - } - - return; -} -#endif /*-------------------------------------------------------------------* * bwe_switch_enc() @@ -861,147 +526,6 @@ static void bwe_switch_enc_fx( return; } -#ifndef CLEANUP_ACELP_ENC -static void bwe_switch_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *new_speech_fx /* i : original input signal Q0 */ -) -{ - - Word16 k, Loverlapp_fx, d1m_fx, maxd1_fx, ind1_fx, gapsize_fx; - Word16 delta_fx, fdelay_fx; - const Word16 *hp_filter_fx; - const Word16 *fpointers_tab[6] = { hp12800_16000_fx, hp12800_32000_fx, hp12800_48000_fx, hp16000_48000_fx, hp16000_32000_fx, hp16000_48000_fx }; - Word16 tmp, shift; - const Word16 *ptmp; - Word16 tmp_mem_fx[2 * L_FILT48k], tmp_mem2_fx[2 * L_FILT48k], hb_synth_tmp_fx[480]; - Word16 Fs_kHz; - Word16 q_tmp1, q_tmp2, Qmc, Qsq; - Word32 L_tmp1, L_tmp2, L_tmp3, min_sq_cross_fx; - Word16 accA_fx, accB_fx, min_corr_fx, E1_fx, E2_fx, gain_fx; - Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */ - Word16 n, L; - BSTR_ENC_HANDLE hBstr; - - hBstr = st_fx->hBstr; - L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS ); - - /* set multiplication factor according to the sampling rate */ - tmp = extract_l( L_shr( st_fx->input_Fs, 14 ) ); - delta_fx = add( tmp, 1 ); - Fs_kHz = shl( delta_fx, 4 ); - tmp = add( tmp, i_mult2( 3, ( sub( st_fx->last_L_frame, L_FRAME ) != 0 ) ) ); - ptmp = fpointers_tab[tmp]; - move16(); - - hp_filter_fx = ptmp; - fdelay_fx = i_mult2( 16, delta_fx ); - IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) - { - fdelay_fx = i_mult2( 20, delta_fx ); - } - - n = i_mult2( N16_CORE_SW, delta_fx ); - - set16_fx( tmp_mem_fx, 0, 2 * L_FILT48k ); - set16_fx( tmp_mem2_fx, 0, 2 * L_FILT48k ); - - Loverlapp_fx = i_mult2( delta_fx, SWITCH_OVERLAP_8k * 2 ); - gapsize_fx = i_mult2( delta_fx, NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) ); - - shift = sub( add( add( shr( L, 1 ), n ), Loverlapp_fx ), gapsize_fx ); - Copy( new_speech_fx + shift, synth_subfr_bwe_fx, add( gapsize_fx, fdelay_fx ) ); - Copy( new_speech_fx + sub( shift, fdelay_fx ), tmp_mem_fx, fdelay_fx ); - - tmp = add( gapsize_fx, fdelay_fx ); - fir_fx( synth_subfr_bwe_fx, hp_filter_fx, synth_subfr_bwe_fx, tmp_mem_fx, tmp, fdelay_fx, 0, 0 ); - Copy( synth_subfr_bwe_fx + shr( fdelay_fx, 1 ), synth_subfr_bwe_fx, sub( gapsize_fx, shr( fdelay_fx, 1 ) ) ); - - tmp = i_mult2( Fs_kHz, 10 ); - fir_fx( new_speech_fx, hp_filter_fx, hb_synth_tmp_fx, tmp_mem2_fx, tmp, fdelay_fx, 1, 0 ); - - min_sq_cross_fx = L_negate( 1 ); - Qsq = 0; - move16(); - min_corr_fx = 0; - move16(); - Qmc = 0; - move16(); - d1m_fx = 0; - move16(); - - maxd1_fx = sub( tmp, add( gapsize_fx, fdelay_fx ) ); - - IF( EQ_16( delta_fx, 2 ) ) - { - maxd1_fx = shr( maxd1_fx, 1 ); - } - ELSE IF( EQ_16( delta_fx, 3 ) ) - { - maxd1_fx = extract_h( L_mult( maxd1_fx, 10923 ) ); - } - - /* find delay */ - ptmp = &hb_synth_tmp_fx[fdelay_fx]; - - FOR( k = 0; k < maxd1_fx; k++ ) - { - accA_fx = dotprod_satcont( ptmp, ptmp, 0, 0, &q_tmp1, gapsize_fx, delta_fx ); - accB_fx = dotprod_satcont( ptmp, synth_subfr_bwe_fx, 0, 0, &q_tmp2, gapsize_fx, delta_fx ); - ptmp += delta_fx; - L_tmp1 = L_mult0( accB_fx, accB_fx ); /*2*q_tmp2; */ - L_tmp2 = Mult_32_16( L_tmp1, min_corr_fx ); /*2*q_tmp2+Qmc-15 */ - L_tmp3 = Mult_32_16( min_sq_cross_fx, accA_fx ); /*Qsq+q_tmp1-15 */ - shift = s_min( add( shl( q_tmp2, 1 ), Qmc ), add( q_tmp1, Qsq ) ); - L_tmp2 = L_shr( L_tmp2, sub( add( shl( q_tmp2, 1 ), Qmc ), shift ) ); - L_tmp3 = L_shr( L_tmp3, sub( add( q_tmp1, Qsq ), shift ) ); - - IF( GE_32( L_tmp2, L_tmp3 ) ) - { - d1m_fx = k; - move16(); - min_corr_fx = accA_fx; - move16(); - Qmc = q_tmp1; - move16(); - min_sq_cross_fx = L_add( L_tmp1, 0 ); - Qsq = shl( q_tmp2, 1 ); - move16(); - } - } - - push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_DELAY, d1m_fx, AUDIODELAYBITS ); - - tmp = add( i_mult2( d1m_fx, delta_fx ), fdelay_fx ); - ptmp = &hb_synth_tmp_fx[tmp]; - move16(); - E1_fx = dotprod_satcont( synth_subfr_bwe_fx, synth_subfr_bwe_fx, 0, 0, &q_tmp1, gapsize_fx, 1 ); - E2_fx = dotprod_satcont( ptmp, ptmp, 0, 0, &q_tmp2, gapsize_fx, 1 ); - - IF( !E1_fx ) - { - E1_fx = shl( 1, 14 ); - q_tmp1 = 14; - move16(); - } - IF( !E2_fx ) - { - E2_fx = shl( 1, 14 ); - q_tmp2 = 14; - move16(); - } - - tmp = div_s( shl( 1, 14 ), E1_fx ); /*Q(29-q_tmp1) */ - L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */ - q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ - L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); - gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ - ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) ); - push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 ); - - return; -} -#endif static Word16 dotprod_satcont( const Word16 *x, /* qx */ diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 0fbd01b3a..f4b74b351 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -262,11 +262,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { -#ifdef CLEANUP_ACELP_ENC tbe_celp_exc_fx( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); -#else - tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); -#endif } pitch_buf[i_subfr / L_SUBFR] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 2d44ba36a..cc850da46 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -1052,40 +1052,13 @@ void core_switching_pre_enc_ivas_fx( *---------------------------------------------------------------------*/ void core_switching_post_enc_ivas_fx( -#ifdef CLEANUP_ACELP_ENC Encoder_State *st /* i/o: encoder state structure */ -#else - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */ - Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */ - Word16 Q_new -#endif ) { IF( EQ_16( st->core, HQ_CORE ) ) { st->use_acelp_preq = 0; move16(); -#ifndef CLEANUP_ACELP_ENC - test(); - test(); - IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */ - { - /* Memory scaling to keep everything in common q */ - Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - st->hLPDmem->mem_w0 = shl( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - move16(); - st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); - move16(); - - acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) ); - } -#endif st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 022483f82..e31578c7a 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -174,13 +174,8 @@ void encod_amr_wb_fx( * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); -#else - inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, - exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); -#endif /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index a68d5be4e..5e0a67dbc 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -77,371 +77,8 @@ static void rem_offset( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================*/ -#ifndef CLEANUP_ACELP_ENC -void encod_gen_voic_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q0*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* i/o: core synthesis Q_new*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ - Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 shift, - Word16 Q_new ) -{ - Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ - Word16 xn2_fx[L_SUBFR]; /* Target vector for codebook search */ - Word16 cn_fx[L_SUBFR]; /* Target vector in residual domain */ - Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ - Word16 h2_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ - Word16 code_fx[L_SUBFR]; /* Fixed codebook excitation */ - Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */ - Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */ - Word16 gain_pit_fx = 0; /* Pitch gain */ - move16(); - Word16 voice_fac_fx; /* Voicing factor */ - Word32 gain_code_fx = 0; /* Gain of code */ - move32(); - Word16 gain_inov_fx = 0; /* inovation gain */ - move16(); - Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ - Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/ - Word16 i, i_subfr_fx; /* tmp variables */ - Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */ - move16(); - move16(); - Word16 T0_min_fx, T0_max_fx; /* pitch variables */ - Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */ - Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */ - Word16 clip_gain_fx; /* LSF clip gain */ - const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/ - Word16 error_fx = 0; - Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */ - move16(); - move16(); - Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */ - Word16 unbits_PI_fx = 0; /* number of unused bits for PI */ - Word32 norm_gain_code_fx = 0; - move16(); - move32(); - Word16 pitch_limit_flag; - Word16 gcode16; - Word32 Ltmp; - Word32 Ltmp1; - Word32 Lgcode; - Word16 tmp1_fx; - Word16 shift_wsp; - Word16 harm_flag_acelp; - Word16 lp_select, lp_flag, L_frame; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - - /*------------------------------------------------------------------* - * Initializations - *------------------------------------------------------------------*/ - - gain_pit_fx = 0; - move16(); - gain_code_fx = L_deposit_l( 0 ); - gain_preQ_fx = 0; - move16(); - unbits_PI_fx = 0; - move16(); - error_fx = 0; - move16(); - L_frame = st_fx->L_frame; - move16(); - - - IF( EQ_16( L_frame, L_FRAME ) ) - { - T0_max_fx = PIT_MAX; - move16(); - T0_min_fx = PIT_MIN; - move16(); - } - ELSE /* L_frame == L_FRAME16k */ - { - T0_max_fx = PIT16k_MAX; - move16(); - T0_min_fx = PIT16k_MIN; - move16(); - } - lp_flag = st_fx->acelp_cfg.ltf_mode; - move16(); - - *unbits_fx = 0; - move16(); - - p_Aw_fx = Aw_fx; /* Q12 */ - p_Aq_fx = Aq_fx; /* Q12 */ - pt_pitch_fx = pitch_buf_fx; /* Q6 */ - gain_preQ_fx = 0; - move16(); - set16_fx( code_preQ_fx, 0, L_SUBFR ); - - shift_wsp = add( Q_new, shift ); - - /* set and write harmonicity flag */ - harm_flag_acelp = 0; - move16(); - - test(); - test(); - IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) ) - { - if ( GT_16( st_fx->last_harm_flag_acelp, 2 ) ) - { - harm_flag_acelp = 1; - move16(); - } - - push_indice( hBstr, IND_HARM_FLAG_ACELP, harm_flag_acelp, 1 ); - } - - /*------------------------------------------------------------------* - * ACELP subframe loop - *------------------------------------------------------------------*/ - - FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR ) - { - - /*----------------------------------------------------------------* - * Find the the excitation search target "xn" and innovation - * target in residual domain "cn" - * Compute impulse response, h1[], of weighted synthesis filter - *----------------------------------------------------------------*/ - - Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/ - - find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ - Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/ - - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn_fx, L_SUBFR, shift ); - - /*----------------------------------------------------------------* - * Close-loop pitch search and quantization - *----------------------------------------------------------------*/ - - *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, - L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ - - tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); - - /*-----------------------------------------------------------------* - * Find adaptive exitation - *-----------------------------------------------------------------*/ - - pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - /*-----------------------------------------------------------------* - * Gain clipping test to avoid unstable synthesis on frame erasure - *-----------------------------------------------------------------*/ - - clip_gain_fx = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr_fx, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); - - if ( EQ_16( st_fx->coder_type, INACTIVE ) ) - { - /* in case of AVQ inactive, limit the gain to 0.65 */ - clip_gain_fx = 2; - move16(); - } - - /*-----------------------------------------------------------------* - * LP filtering of the adaptive excitation, codebook target computation - *-----------------------------------------------------------------*/ - - lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx, - xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); - - IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) - { - push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); - } - - /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ - 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*/ - - /*-----------------------------------------------------------------* - * Transform domain contribution encoding - active frames - *-----------------------------------------------------------------*/ - - test(); - IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) ) - { - transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, - xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); - } - - /*-----------------------------------------------------------------* - * Innovation encoding - *-----------------------------------------------------------------*/ - - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, - st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift ); - - /*-----------------------------------------------------------------* - * Gain encoding - *-----------------------------------------------------------------*/ - - IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) - { - gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR, - st_fx->element_mode ); - } - ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) - { - gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); - } - ELSE - { - gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); - } - IF( st_fx->Opt_SC_VBR ) - { - if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) ) - { - /* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */ - st_fx->clip_var_fx[1] = gain_pit_fx; /*Q14*/ - move16(); - } - } - gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); - - Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ - hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */ - move16(); - - /*-----------------------------------------------------------------* - * Transform domain contribution encoding - inactive frames - *-----------------------------------------------------------------*/ - - test(); - IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) - { - transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, - Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); - } - - /*-----------------------------------------------------------------* - * Update memory of the weighting filter - *-----------------------------------------------------------------*/ - - /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ - Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/ - Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ - Ltmp = L_negate( Ltmp ); - Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ - Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */ - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ - move16(); - IF( gain_preQ_fx != 0 ) - { - tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); - - FOR( i = 0; i < L_SUBFR; i++ ) - { - /* Contribution from AVQ layer */ - Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ - - /* Compute exc2 */ - Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ - move16(); - - /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ - Ltmp = L_shl( Ltmp, 5 ); /* Q15 */ - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ - } - } - ELSE - { - /*-----------------------------------------------------------------* - * Construct adaptive part of the excitation - * Save the non-enhanced excitation for FEC_exc - *-----------------------------------------------------------------*/ - - FOR( i = 0; i < L_SUBFR; i++ ) - { - /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ - } - } - /*-----------------------------------------------------------------* - * Prepare TBE excitation - *-----------------------------------------------------------------*/ - - prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q10, Q_new, - T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, - st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); - - /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. - * Update A(z) filters - *-----------------------------------------------------------------*/ - - Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); - - p_Aw_fx += ( M + 1 ); - p_Aq_fx += ( M + 1 ); - pt_pitch_fx++; - } - - /* write reserved bits */ - WHILE( unbits_PI_fx > 0 ) - { - i = s_min( unbits_PI_fx, 16 ); - push_indice( hBstr, IND_UNUSED, 0, i ); - unbits_PI_fx -= i; - } - IF( st_fx->Opt_SC_VBR ) - { - /* SC-VBR */ - hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */ - move16(); - hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */ - move16(); - } - - return; -} -#endif - -#ifdef CLEANUP_ACELP_ENC void encod_gen_voic_fx( -#else -void encod_gen_voic_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0 / Qnew -1 */ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -554,12 +191,8 @@ void encod_gen_voic_ivas_fx( set16_fx( code_preQ_fx, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); -#ifdef CLEANUP_ACELP_ENC test(); if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) ) -#else - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) -#endif { shift_wsp = sub( shift_wsp, 1 ); } @@ -596,7 +229,6 @@ void encod_gen_voic_ivas_fx( Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, @@ -609,7 +241,6 @@ void encod_gen_voic_ivas_fx( Scale_sig( xn_fx, L_SUBFR, shift ); } ELSE -#endif { find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); @@ -639,23 +270,17 @@ void encod_gen_voic_ivas_fx( L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ move16(); -#ifdef CLEANUP_ACELP_ENC tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); -#else - tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); -#endif /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE -#endif { pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -685,7 +310,6 @@ void encod_gen_voic_ivas_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } -#ifdef CLEANUP_ACELP_ENC #ifndef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN IF( st_fx->element_mode == EVS_MONO ) { @@ -694,7 +318,6 @@ void encod_gen_voic_ivas_fx( st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #ifndef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN } -#endif #endif /*-----------------------------------------------------------------* @@ -704,27 +327,16 @@ void encod_gen_voic_ivas_fx( test(); IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) ) { -#ifdef CLEANUP_ACELP_ENC transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); -#else - transf_cdbk_enc_ivas_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, - xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); -#endif } /*-----------------------------------------------------------------* * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); -#else - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, - st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); -#endif /*-----------------------------------------------------------------* * Gain encoding @@ -760,7 +372,6 @@ void encod_gen_voic_ivas_fx( Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */ @@ -769,9 +380,6 @@ void encod_gen_voic_ivas_fx( { hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */ } -#else - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */ -#endif move16(); /*-----------------------------------------------------------------* @@ -781,20 +389,14 @@ void encod_gen_voic_ivas_fx( test(); IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) ) { -#ifdef CLEANUP_ACELP_ENC transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); -#else - transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, - Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); -#endif } /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ @@ -807,7 +409,6 @@ void encod_gen_voic_ivas_fx( hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ } ELSE -#endif { /*At this point xn has to be in Qnew @@ -892,13 +493,11 @@ void encod_gen_voic_ivas_fx( * Update A(z) filters *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); } ELSE -#endif { syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); } diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 913b208c0..24bf48838 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -22,367 +22,8 @@ static void find_cn_fx( const Word16 xn[], const Word16 Ap[], const Word16 *p_Aq *-----------------------------------------------------------------*/ #define Q_MINUS 4 -#ifndef CLEANUP_ACELP_ENC -void transf_cdbk_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ -) -{ - Word16 i, index, nBits, Nsv, Es_pred_loc; - Word16 x_in[L_SUBFR], x_tran[L_SUBFR], gcode16, stmp; - Word16 e_corr, m_corr, e_ener, m_ener, m_den, e_den; - Word16 x_norm[L_SUBFR + L_SUBFR / WIDTH_BAND]; - Word32 L_corr, L_ener, Ltmp, Ltmp1; - Word16 nq[L_SUBFR / WIDTH_BAND]; - Word32 out32[L_SUBFR]; - Word16 Qdct; - Word16 avq_bit_sFlag; - Word16 trgtSvPos; - Flag Overflow = 0; - move32(); - - avq_bit_sFlag = 0; - move16(); - if ( st_fx->element_mode > EVS_MONO ) - { - avq_bit_sFlag = 1; - move16(); - } - - /*--------------------------------------------------------------* - * Set bit-allocation - *--------------------------------------------------------------*/ - - Nsv = 8; - move16(); - nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )]; /* Q0 */ - move16(); - - /* increase # of AVQ allocated bits by unused bits from the previous subframe */ - nBits = add( nBits, *unbits ); - - /*--------------------------------------------------------------* - * Compute/Update target - * For inactive frame, find target in residual domain - * Deemphasis - *--------------------------------------------------------------*/ - - IF( EQ_16( st_fx->coder_type, INACTIVE ) ) - { - gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); - FOR( i = 0; i < L_SUBFR; i++ ) - { - /*x_tran[i] = xn[i] - *gain_pit * y1[i] - gain_code * y2[i];*/ - Ltmp = L_mult( gcode16, y2[i] ); - Ltmp = L_shl( Ltmp, add( 5, shift ) ); - Ltmp = L_negate( Ltmp ); - Ltmp = L_mac( Ltmp, xn[i], 16384 ); - Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */ - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ - x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */ - move16(); - } - find_cn_fx( x_tran, Ap, p_Aq, x_in ); - } - ELSE - { - updt_tar_fx( cn, x_in, &exc[i_subfr], *gain_pit, L_SUBFR ); - } - Deemph2( x_in, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_deemp_preQ_fx ) ); - - /*--------------------------------------------------------------* - * DCT-II - *--------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp ) - { - Copy_Scale_sig( x_in, x_tran, L_SUBFR, -Q_MINUS + 1 ); /*Q_new-1 -> Q_new-4*/ - /*Copy( x_in, x_tran, L_SUBFR );*/ - Qdct = sub( Q_new, Q_MINUS ); - } - ELSE - { - Qdct = 0; - move16(); - edct2_fx( L_SUBFR, -1, x_in, out32, &Qdct, ip_edct2_64, w_edct2_64_fx ); - Qdct = negate( Qdct ); - Copy_Scale_sig_32_16( out32, x_tran, L_SUBFR, sub( Qdct, Q_MINUS - 1 ) ); /* Output in Q_new-4 */ - Qdct = sub( Q_new, Q_MINUS ); - } - - /*--------------------------------------------------------------* - * Split algebraic vector quantizer based on RE8 lattice - *--------------------------------------------------------------*/ - - AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 ); - - /*--------------------------------------------------------------* - * Find prequantizer excitation gain - * Quantize the gain - *--------------------------------------------------------------*/ - - L_corr = L_deposit_l( 0 ); - L_ener = L_deposit_l( 0 ); - FOR( i = 0; i < Nsv * 8; i++ ) - { - /*fcorr += fx_tran[i]*(float)ix_norm[i];*/ - /*fener += (float)ix_norm[i]*(float)ix_norm[i];*/ - stmp = shl_sat( x_norm[i], Q_AVQ_OUT ); - L_corr = L_mac_sat( L_corr, x_tran[i], stmp ); - L_ener = L_mac_sat( L_ener, stmp, stmp ); - } - L_ener = L_max( L_ener, 1 ); - - /* No negative gains allowed in the quantizer*/ - L_corr = L_max( L_corr, 0 ); - - e_corr = norm_l( L_corr ); - m_corr = extract_h( L_shl( L_corr, e_corr ) ); - e_corr = sub( 30, add( e_corr, sub( Qdct, Q_AVQ_OUT ) ) ); - e_ener = norm_l( L_ener ); - m_ener = extract_h( L_shl( L_ener, e_ener ) ); - e_ener = sub( 30, e_ener ); - - IF( GT_16( m_corr, m_ener ) ) - { - m_corr = shr( m_corr, 1 ); - e_corr = add( e_corr, 1 ); - } - m_corr = div_s( m_corr, m_ener ); /* e_corr - e_ener */ - e_corr = sub( e_corr, e_ener ); - Ltmp = L_shl_sat( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */ - IF( EQ_16( st_fx->coder_type, INACTIVE ) ) - { - Ltmp1 = L_max( gain_code, 1 ); - e_den = norm_l( Ltmp1 ); - m_den = extract_h( L_shl_sat( Ltmp1, e_den ) ); - /* ensure m_corr < m_den */ - test(); - IF( m_corr > 0 && m_den > 0 ) - { - m_corr = div_s( 16384, m_den ); - e_corr = sub( 14 + 4, e_den ); - Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ - stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ - } - ELSE - { - stmp = 0; - move16(); - } - IF( GT_32( st_fx->core_brate, 56000 ) ) - { - index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */ - } - ELSE IF( GT_32( st_fx->core_brate, 42000 ) ) - { - index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */ - } - ELSE - { - index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */ - } - Ltmp = Mult_32_16( gain_code, stmp ); /* Q16 * Q12 - 15 -> Q13*/ - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/ - *gain_preQ = round_fx_sat( Ltmp ); /* Q2*/ - } - ELSE - { - IF( Es_pred < 0 ) - { - Es_pred_loc = shr( negate( Es_pred ), 2 ); /* Q8 */ - } - ELSE - { - Es_pred_loc = Es_pred; /* Q8 */ - move16(); - } - - e_den = norm_s( Es_pred_loc ); - m_den = shl( Es_pred_loc, e_den ); - /* ensure m_corr < m_den */ - test(); - IF( m_corr > 0 && m_den > 0 ) - { - m_corr = div_s( 16384, m_den ); /* 14 - 8 - e_den */ - e_corr = sub( 14 - 8, e_den ); - Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /* Q18 */ - } - ELSE - { - Ltmp = L_deposit_l( 0 ); - } - test(); - IF( LE_32( st_fx->core_brate, 42000 ) && GT_32( st_fx->core_brate, ACELP_24k40 ) ) - { - index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */ - } - ELSE - { - index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */ - } - Ltmp = L_mult( stmp, Es_pred_loc ); /* Q0*Q8 -> Q9*/ - Ltmp = L_shl( Ltmp, add( e_den, 9 ) ); /* Q18*/ - *gain_preQ = round_fx( Ltmp ); /* Q2*/ - } - push_indice( st_fx->hBstr, IND_AVQ_GAIN, index, G_AVQ_BITS ); - - /*--------------------------------------------------------------* - * Encode and multiplex subvectors into bit-stream - *--------------------------------------------------------------*/ - - trgtSvPos = Nsv - 1; - move16(); - test(); - test(); - test(); - test(); - test(); - IF( avq_bit_sFlag && GT_16( nBits, 85 ) && !harm_flag_acelp && ( EQ_16( st_fx->coder_type, GENERIC ) || EQ_16( st_fx->coder_type, TRANSITION ) || EQ_16( st_fx->coder_type, INACTIVE ) ) ) - { - trgtSvPos = 2; - avq_bit_sFlag = 2; - move16(); - move16(); - } - - AVQ_encmux_fx( st_fx->hBstr, -1, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos ); - - /* save # of AVQ unused bits for next subframe */ - *unbits = nBits; /* Q0 */ - move16(); - - /* at the last subframe, write AVQ unused bits */ - test(); - test(); - IF( EQ_16( i_subfr, 4 * L_SUBFR ) && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) && NE_16( st_fx->extl, FB_BWE_HIGHRATE ) ) - { - WHILE( *unbits > 0 ) - { - i = s_min( *unbits, 16 ); - push_indice( st_fx->hBstr, IND_UNUSED, 0, i ); - *unbits -= i; - } - } - - /*--------------------------------------------------------------* - * DCT transform - *--------------------------------------------------------------*/ - - FOR( i = 0; i < Nsv * WIDTH_BAND; i++ ) - { - x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); - move16(); - } - - test(); - test(); - test(); - IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp ) - { - Copy( x_tran, code_preQ, L_SUBFR ); /* Q_AVQ_OUT_DEC */ - } - ELSE - { - Qdct = 0; - move16(); - edct2_fx( L_SUBFR, 1, x_tran, out32, &Qdct, ip_edct2_64, w_edct2_64_fx ); - /*qdct = sub(Q_AVQ_OUT_DEC,qdct+Q_AVQ_OUT_DEC);*/ - Qdct = negate( Qdct ); - Copy_Scale_sig_32_16( out32, code_preQ, L_SUBFR, Qdct ); /* Output in Q_AVQ_OUT_DEC */ - /*qdct = Q_AVQ_OUT_DEC;*/ - } - - /*--------------------------------------------------------------* - * Preemphasise - *--------------------------------------------------------------*/ - - /* in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ - test(); - if ( ( nq[7] != 0 ) && ( GT_16( sub( st_fx->last_nq_preQ, nq[0] ), 7 ) ) ) - { - /* *mem_preemp /= 16; */ - st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 4 ); - move16(); - } - st_fx->last_nq_preQ = nq[7]; - move16(); - - preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); - - /*--------------------------------------------------------------* - * For inactive segments - * - Zero-memory filtered pre-filter excitation - * - Update of targets and gain_pit - * For inactive segments - * - Update xn[L_subfr-1] for updating the memory of the weighting filter - *--------------------------------------------------------------*/ - - IF( EQ_16( st_fx->coder_type, INACTIVE ) ) - { - /*ftemp = fcode_preQ[0] *fh1[L_SUBFR-1];*/ - Ltmp = L_mult( code_preQ[0], h1[L_SUBFR - 1] ); /*1+14+shift + Q_AVQ_OUT */ - FOR( i = 1; i < L_SUBFR; i++ ) - { - /*ftemp += fcode_preQ[i] * fh1[L_SUBFR-1-i];*/ - Ltmp = L_mac( Ltmp, code_preQ[i], h1[L_SUBFR - 1 - i] ); - } - /*fxn[L_SUBFR-1] -= *fgain_preQ * ftemp;*/ - Ltmp = L_shr( Mult_32_16( Ltmp, *gain_preQ ), sub( add( Q_AVQ_OUT_DEC, 2 ), Q_new ) ); /* (2 + 1 + 14 +shift+Q_AVQ_OUT)-(Q_AVQ_OUT+2-Q_new) = 15 + Q_new + shift */ - xn[L_SUBFR - 1] = round_fx( L_sub( L_mult( xn[L_SUBFR - 1], 32767 ), Ltmp ) ); /* -> Q_new + shift -1 */ - } - ELSE - { - conv_fx( code_preQ, h1, x_tran, L_SUBFR ); - updt_tar_HR_fx( cn, cn, code_preQ, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR ); - - updt_tar_HR_fx( xn, xn, x_tran, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR ); - *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */ - /* clip gain if necessary to avoid problems at decoder */ - test(); - if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) ) - { - *gain_pit = 15565; /* 0.95 in Q15 */ - move16(); - } - updt_tar_fx( xn, xn2, y1, *gain_pit, L_SUBFR ); - } - - st_fx->use_acelp_preq = 1; - move16(); - - return; -} -#endif -#ifdef CLEANUP_ACELP_ENC void transf_cdbk_enc_fx( -#else -void transf_cdbk_enc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -495,13 +136,11 @@ void transf_cdbk_enc_ivas_fx( * Split algebraic vector quantizer based on RE8 lattice *--------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 ); } ELSE -#endif { AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct ); } diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index bd9c429b2..00095a89d 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -374,31 +374,12 @@ void enc_pit_exc_fx( } ELSE IF( use_fcb == 2 ) { -#ifdef CLEANUP_ACELP_ENC /*-----------------------------------------------------------------* * 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, Q_new ); -#else -#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, - 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 - { - /*-----------------------------------------------------------------* - * 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 ); - } -#endif /*-----------------------------------------------------------------* * Gain encoding @@ -412,23 +393,8 @@ void enc_pit_exc_fx( * Innovation & gain encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC 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, Q_new ); -#else -#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, - 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 ); - } -#endif /*-----------------------------------------------------------------* * Gain encoding @@ -453,11 +419,7 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#ifdef CLEANUP_ACELP_ENC hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ -#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 } ELSE #endif diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 975f62337..10e458fb5 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -43,387 +43,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*---------------------------------------------------------------------------------*/ -#ifndef CLEANUP_ACELP_ENC -Word16 encod_tran_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q0*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* i/o: core synthesis Q_new*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/ - Word16 tc_subfr, /* i/o: TC subframe classification Q0*/ - Word16 position, /* i : maximum of residual signal index Q0*/ - Word16 *unbits, /* i/o: number of unused bits Q0*/ - const Word16 shift, /* i : Scaling to get 12 bits */ - const Word16 Q_new /* i : Input scaling */ -) -{ - Word16 xn[L_SUBFR]; /* Target vector for pitch search */ - Word16 xn2[L_SUBFR]; /* Target vector for codebook search */ - Word16 cn[L_SUBFR]; /* Target vector in residual domain */ - Word16 h1[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ - Word16 h2_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ - Word16 code[L_SUBFR]; /* Fixed codebook excitation */ - Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */ - Word16 y2[L_SUBFR]; /* Filtered algebraic excitation */ - Word16 gain_pit = 0, Gain_pitX2, gcode16; /* Pitch gain */ - Word16 voice_fac; /* Voicing factor */ - Word32 gain_code = 0; /* Gain of code */ - Word32 Lgcode; - Word16 gain_inov = 0; /* inovation gain */ - Word16 i, i_subfr, tmp1_fx, tmp_fx; /* tmp variables */ - Word16 unbits_ACELP; - Word16 T0_min, T0_max; /* pitch and TC variables */ - Word16 T0, T0_frac; /* close loop integer pitch and fractional part */ - Word16 *pt_pitch; /* pointer to floating pitch buffer */ - Word16 g_corr[10]; /* ACELP correlation values and gain pitch */ - Word16 clip_gain; /* LSF clip gain */ - const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */ - Word16 gain_preQ = 0; /* Gain of prequantizer excitation */ - Word16 code_preQ[L_SUBFR]; /* Prequantizer excitation */ - Word16 Jopt_flag; /* joint optimization flag */ - Word16 unbits_PI = 0; /* saved bits for PI */ - Word32 norm_gain_code = 0; - Word16 L_frame_fx; - Word16 shift_wsp; - Word32 L_tmp; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - - L_frame_fx = st_fx->L_frame; - move16(); - - /*------------------------------------------------------------------* - * Initializations - *------------------------------------------------------------------*/ - - gain_pit = 0; - move16(); - gain_code = L_deposit_l( 0 ); - gain_preQ = 0; - move16(); - unbits_PI = 0; - move16(); - IF( EQ_16( L_frame_fx, L_FRAME ) ) - { - T0_max = PIT_MAX; - move16(); - T0_min = PIT_MIN; - move16(); - } - ELSE /* L_frame == L_FRAME16k */ - { - T0_max = PIT16k_MAX; - move16(); - T0_min = PIT16k_MIN; - move16(); - } - - /**unbits = 0;move16();*/ - Jopt_flag = 0; - move16(); - unbits_ACELP = *unbits; /* Q0 */ - move16(); - *unbits = 0; - move16(); - - p_Aw = Aw_fx; /* Q12 */ - p_Aq = Aq_fx; /* Q12 */ - pt_pitch = pitch_buf_fx; /* Q6 */ - gain_preQ = 0; - move16(); - set16_fx( code_preQ, 0, L_SUBFR ); - shift_wsp = add( Q_new, shift ); - - /*----------------------------------------------------------------* - * ACELP subframe loop - *----------------------------------------------------------------*/ - - FOR( i_subfr = 0; i_subfr < L_frame_fx; i_subfr += L_SUBFR ) - { - /*----------------------------------------------------------------* - * Find the the excitation search target "xn" and innovation - * target in residual domain "cn" - * Compute impulse response, h1[], of weighted synthesis filter - *----------------------------------------------------------------*/ - - Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - - find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - - Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); - 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 ); - - /*-----------------------------------------------------------------* - * TC: subframe determination & - * adaptive/glottal part of excitation construction - *-----------------------------------------------------------------*/ - - transition_enc_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1, - h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift ); - - /*-----------------------------------------------------------------* - * Transform domain contribution encoding - active frames - *-----------------------------------------------------------------*/ - - IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) - { - transf_cdbk_enc_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, - &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); - } - - /*-----------------------------------------------------------------* - * ACELP codebook search + pitch sharpening - *-----------------------------------------------------------------*/ - - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); - - test(); - test(); - test(); - if ( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) && ( EQ_16( T0, 2 * L_SUBFR ) ) ) - { - Jopt_flag = 1; - move16(); - } - - /*-----------------------------------------------------------------* - * Quantize the gains - * Test quantized gain of pitch for pitch clipping algorithm - * Update tilt of code: 0.0 (unvoiced) to 0.5 (voiced) - *-----------------------------------------------------------------*/ - - IF( Jopt_flag == 0 ) - { - /* SQ gain_code */ - gain_enc_tc_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp ); - } - ELSE - { - IF( GT_32( st_fx->core_brate, ACELP_32k ) ) - { - /* SQ gain_pit and gain_code */ - gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp ); - } - ELSE - { - /* VQ gain_pit and gain_code */ - gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); - } - } - gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); - - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); - hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ - - /*-----------------------------------------------------------------* - * Update memory of the weighting filter - *-----------------------------------------------------------------*/ - - /*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/ - L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */ - L_tmp = L_shl( L_tmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ - L_tmp = L_negate( L_tmp ); - L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 ); - L_tmp = L_msu( L_tmp, y1[L_SUBFR - 1], gain_pit ); - L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); /* Q_new + 15 */ - hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/ - - /*-----------------------------------------------------------------* - * Construct adaptive part of the excitation - * Save the non-enhanced excitation for FEC_exc - *-----------------------------------------------------------------*/ - - /* Here, all these conditions have one purpose: to use */ - /* the most efficient loop (the one with the least ops) */ - /* This is done by upscaling gain_pit_fx and/or gain_code16 */ - /* when they don't use all 16 bits of precision */ - - /* exc Q_exc, gpit Q14, code Q12, gcode Q0 */ - IF( norm_s( gain_pit ) == 0 ) - { - FOR( i = 0; i < L_SUBFR; i++ ) - { - exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_new */ - } - } - ELSE - { - Gain_pitX2 = shl( gain_pit, 1 ); /* Q15 */ - FOR( i = 0; i < L_SUBFR; i++ ) - { - exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_new */ - } - } - - /*-----------------------------------------------------------------* - * Construct adaptive part of the excitation - * Save the non-enhanced excitation for FEC_exc - *-----------------------------------------------------------------*/ - FOR( i = 0; i < L_SUBFR; i++ ) - { - /* code in Q9, gain_pit in Q14 */ - L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ - } - - /*-----------------------------------------------------------------* - * Add the ACELP pre-quantizer contribution - *-----------------------------------------------------------------*/ - - IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) - { - tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); - FOR( i = 0; i < L_SUBFR; i++ ) - { - L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ - tmp_fx = round_fx_sat( L_tmp ); - exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ - move16(); - exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ - move16(); - } - } - - /*-----------------------------------------------------------------* - * Prepare TBE excitation - *-----------------------------------------------------------------*/ - - prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], - bwe_exc_fx, gain_preQ, code_preQ, Q10, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); - - /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. - * Update A(z) filters - *-----------------------------------------------------------------*/ - - Syn_filt_s( 1, p_Aq, M, &exc_fx[i_subfr], &syn_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); - - p_Aw += ( M + 1 ); - p_Aq += ( M + 1 ); - pt_pitch++; - } - - /* write reserved bits */ - WHILE( unbits_PI > 0 ) - { - i = s_min( unbits_PI, 16 ); - push_indice( hBstr, IND_UNUSED, 0, i ); - unbits_PI -= i; - } - - /* write TC configuration */ - IF( EQ_16( L_frame_fx, L_FRAME ) ) - { - IF( EQ_16( tc_subfr, TC_0_0 ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - } - ELSE IF( EQ_16( tc_subfr, TC_0_64 ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - } - ELSE IF( EQ_16( tc_subfr, TC_0_128 ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - } - ELSE IF( EQ_16( tc_subfr, TC_0_192 ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - } - ELSE IF( EQ_16( tc_subfr, L_SUBFR ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - } - ELSE IF( EQ_16( tc_subfr, 2 * L_SUBFR ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - } - ELSE IF( EQ_16( tc_subfr, 3 * L_SUBFR ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - } - } - ELSE /* L_frame == L_FRAME16k */ - { - IF( tc_subfr == 0 ) - { - push_indice( hBstr, IND_TC_SUBFR, 0, 2 ); - } - ELSE IF( EQ_16( tc_subfr, L_SUBFR ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 1, 2 ); - } - ELSE IF( EQ_16( tc_subfr, 2 * L_SUBFR ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 2, 2 ); - } - ELSE IF( EQ_16( tc_subfr, 3 * L_SUBFR ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 3, 2 ); - push_indice( hBstr, IND_TC_SUBFR, 0, 1 ); - } - ELSE IF( EQ_16( tc_subfr, 4 * L_SUBFR ) ) - { - push_indice( hBstr, IND_TC_SUBFR, 3, 2 ); - push_indice( hBstr, IND_TC_SUBFR, 1, 1 ); - } - } - - IF( st_fx->Opt_SC_VBR ) - { - /* SC-VBR */ - hSC_VBR->prev_ppp_gain_pit_fx = gain_pit; /* Q14 */ - move16(); - hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */ - move16(); - } - - return tc_subfr; -} -#endif -#ifdef CLEANUP_ACELP_ENC Word16 encod_tran_fx( -#else -Word16 encod_tran_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -484,9 +105,6 @@ Word16 encod_tran_ivas_fx( L_frame_fx = st_fx->L_frame; move16(); -#ifndef CLEANUP_ACELP_ENC - set16_fx( h1, 0, L_SUBFR + ( M + 1 ) ); -#endif /*------------------------------------------------------------------* * Initializations *------------------------------------------------------------------*/ @@ -528,12 +146,8 @@ Word16 encod_tran_ivas_fx( move16(); set16_fx( code_preQ, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); -#ifdef CLEANUP_ACELP_ENC test(); if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) ) -#else - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) -#endif { shift_wsp = sub( shift_wsp, 1 ); } @@ -552,7 +166,6 @@ Word16 encod_tran_ivas_fx( Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, @@ -562,7 +175,6 @@ Word16 encod_tran_ivas_fx( Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ } ELSE -#endif { find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); @@ -587,13 +199,8 @@ Word16 encod_tran_ivas_fx( * adaptive/glottal part of excitation construction *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC transition_enc_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1, h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift ); -#else - transition_enc_ivas_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1, - h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift ); -#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames @@ -601,26 +208,16 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { -#ifdef CLEANUP_ACELP_ENC transf_cdbk_enc_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); -#else - transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, - &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); -#endif } /*-----------------------------------------------------------------* * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); -#else - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); -#endif test(); test(); @@ -663,7 +260,6 @@ Word16 encod_tran_ivas_fx( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ @@ -673,22 +269,17 @@ Word16 encod_tran_ivas_fx( hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 } move16(); -#else - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 -#endif /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ /*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */ } ELSE -#endif { L_tmp = L_mult0( gcode16, y2[L_SUBFR - 1] ); } diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index de7f281f2..160814bc0 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -16,244 +16,8 @@ * * Encode unvoiced (UC) frames *-------------------------------------------------------------------*/ -#ifndef CLEANUP_ACELP_ENC -void encod_unvoiced_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *speech_fx, /* i : Input speech Q_new*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/ - const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* o : core synthesis Q_new -1 */ - Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ - const Word16 Q_new, - const Word16 shift ) -{ - Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ - Word16 h1_fx[L_SUBFR]; /* Impulse response vector */ - Word16 code_fx[L_SUBFR]; /* Fixed codebook excitation */ - Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */ - Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */ - Word16 gain_pit_fx; /* Pitch gain */ - Word16 voice_fac_fx; /* Voicing factor */ - Word32 L_gain_code_fx; /* gain of code */ - Word16 gain_inov_fx; /* inovative gain */ - Word16 cn_fx[L_SUBFR]; /* Target vector in residual domain */ - Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */ - Word16 code2[L_SUBFR]; /* Gaussian excitation */ - Word16 y22[L_SUBFR]; /* Filtered Gaussian excitation */ - Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; - const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */ - Word32 norm_gain_code_fx; - ACELP_config *acelp_cfg; - ACELP_CbkCorr g_corr; - Word32 gain_code2; - Word32 gain_code_vect[2], Ltmp, Ltmp2; - Word16 i_subfr, Q_xn, Q_new_p5, tmp2, j, i; - Word16 index, i_subfr_idx; - acelp_cfg = &( st_fx->acelp_cfg ); - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - - /*------------------------------------------------------------------* - * Initializations - *------------------------------------------------------------------*/ - gain_pit_fx = 0; - move16(); - - test(); - test(); - test(); - IF( st_fx->Opt_SC_VBR && st_fx->vad_flag == 0 && ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) || EQ_16( hSC_VBR->last_nelp_mode, 1 ) ) ) - { - /* SC_VBR - reset the encoder, to avoid memory not updated issue for the - case when UNVOICED mode is used to code inactive speech */ - CNG_reset_enc_fx( st_fx, hLPDmem, pitch_buf_fx, voice_factors_fx, 1 ); - } - - p_Aw_fx = Aw_fx; - p_Aq_fx = Aq_fx; - pt_pitch_fx = pitch_buf_fx; - move16(); - Q_xn = add( sub( Q_new, 1 ), shift ); - Q_new_p5 = add( Q_new, 5 ); - - FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) - { - /*----------------------------------------------------------------* - * Bandwidth expansion of A(z) filter coefficients - * Find the excitation search target "xn" and innovation target in residual domain "cn" - * Compute impulse response, h1[], of weighted synthesis filter - *----------------------------------------------------------------*/ - - i_subfr_idx = shr( i_subfr, 6 ); - Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - - find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - - /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ - Scale_sig( h1_fx, 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_fx, L_SUBFR, shift ); - - /*----------------------------------------------------------------* - * Unvoiced subframe processing - *----------------------------------------------------------------*/ - - IF( !uc_two_stage_flag ) - { - *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, - &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, - &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ - } - ELSE - { - /*----------------------------------------------------------------* - * Unvoiced subframe processing in two stages - *----------------------------------------------------------------*/ - /* No adaptive codebook (UC) */ - set16_fx( y1, 0, L_SUBFR ); - set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); - - /*-----------------------------------------------------------------* - * Gain clipping test to avoid unstable synthesis on frame erasure - * or in case of floating point encoder & fixed p. decoder - *-----------------------------------------------------------------*/ - - Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn ); - *pt_pitch_fx = L_SUBFR; - move16(); - - /*----------------------------------------------------------------------* - * Encode the algebraic innovation * - *----------------------------------------------------------------------*/ - - E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate ); - - E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); - - g_corr.y2y2_e = sub( g_corr.y2y2_e, 18 ); /* -18 (y2*y2: Q9*Q9) */ - g_corr.xy2_e = sub( g_corr.xy2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (xn: Q_xn y2: Q9) */ - g_corr.y1y2_e = sub( g_corr.y1y2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (y1: Q_xn y2: Q9) */ - g_corr.xx_e = sub( g_corr.xx_e, add( Q_xn, Q_xn ) ); /* -(Q_xn+Q_xn) (xn: Q_xn) */ - - assert( gain_pit_fx == 0 ); - gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); - - /*----------------------------------------------------------* - * - Compute the fixed codebook gain * - * - quantize fixed codebook gain * - *----------------------------------------------------------*/ - - index = gain_enc_uv_fx( code_fx, code2, L_SUBFR, &gain_pit_fx, &L_gain_code_fx, &gain_code2, - st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV ); /* Q0 */ - -#ifdef DEBUGGING - assert( st_fx->acelp_cfg.gains_mode[i_subfr_idx] == 7 && "Error: UC two-stage, only 5+2 gain Q is supported" ); -#endif - push_indice( st_fx->hBstr, IND_GAIN, index, st_fx->acelp_cfg.gains_mode[i_subfr_idx] ); - - gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); - - gain_code_vect[0] = L_gain_code_fx; - move32(); - gain_code_vect[1] = L_gain_code_fx; - move32(); - - /*----------------------------------------------------------* - * - voice factor (for pitch enhancement) * - *----------------------------------------------------------*/ - - E_UTIL_voice_factor( exc_fx, i_subfr, code_fx, gain_pit_fx, L_gain_code_fx, &voice_fac_fx, &( hLPDmem->tilt_code ), L_SUBFR, acelp_cfg->voice_tilt, Q_new, shift ); - - IF( st_fx->Opt_RF_ON ) - { - st_fx->hRF->rf_tilt_buf[i_subfr_idx] = hLPDmem->tilt_code; - } - - /*-----------------------------------------------------------------* - * Update memory of the weighting filter - *-----------------------------------------------------------------*/ - - /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ - Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */ - Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ - Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx ); /* Q15 + Q_xn */ - /* Add Gaussian contribution*/ - Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ - Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ - Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ - hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); /* Q_xn */ - move16(); - BASOP_SATURATE_WARNING_OFF_EVS; - hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); /*Qnew-1*/ - BASOP_SATURATE_WARNING_ON_EVS; - - /*-------------------------------------------------------* - * - Find the total excitation. * - *-------------------------------------------------------*/ - - tmp2 = shr( L_SUBFR, 1 ); - FOR( j = 0; j < 2; j++ ) - { - FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ ) - { - /* code in Q9, gain_pit in Q14; exc Q_new */ - Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ - Ltmp = L_shl( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ - Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] ); /* Q_new + Q15 */ - Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */ - Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ - Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ - } - tmp2 = L_SUBFR; - move16(); - } - } - - *tmp_noise_fx = extract_h( norm_gain_code_fx ); /* Q0 */ - voice_factors_fx[i_subfr / L_SUBFR] = 0; - move16(); - - interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR ); - - /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. - * Update A(z) filters - *-----------------------------------------------------------------*/ - - Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr], &syn_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); - - p_Aw_fx += ( M + 1 ); - p_Aq_fx += ( M + 1 ); - pt_pitch_fx++; - } - - /* SC-VBR */ - hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */ - move16(); - hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */ - move16(); - - return; -} -#endif - -#ifdef CLEANUP_ACELP_ENC void encod_unvoiced_fx( -#else -void encod_unvoiced_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -334,7 +98,6 @@ void encod_unvoiced_ivas_fx( i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, @@ -344,7 +107,6 @@ void encod_unvoiced_ivas_fx( Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ } ELSE -#endif { find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); @@ -387,19 +149,16 @@ void encod_unvoiced_ivas_fx( *pt_pitch_fx = L_SUBFR << 6; move16(); -#ifdef CLEANUP_ACELP_ENC if ( st_fx->element_mode == EVS_MONO ) { *pt_pitch_fx = L_SUBFR; move16(); } -#endif /*----------------------------------------------------------------------* * Encode the algebraic innovation * *----------------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate ); @@ -409,11 +168,6 @@ void encod_unvoiced_ivas_fx( inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); } -#else - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, - UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); -#endif E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); @@ -427,13 +181,11 @@ void encod_unvoiced_ivas_fx( move16(); assert( gain_pit_fx == 0 ); -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); } ELSE -#endif { gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); } diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index a1da64adf..0efcf795b 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -54,299 +54,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*==============================================================================*/ -#ifndef CLEANUP_ACELP_ENC -Word16 inov_encode_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 last_L_frame, /* i : length of the last frame */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12*/ - const Word16 gain_pit, /* i : adaptive excitation gain Q14*/ - Word16 *cn, /* i/o: target vector in residual domain Q_new*/ - const Word16 *exc, /* i : pointer to excitation signal frame Q_new*/ - Word16 *h2, /* i/o: weighted filter input response Q12*/ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15*/ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - const Word16 *xn2, /* i : target vector for innovation search Q_new-1+shift*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/ - Word16 *unbits, /* o : number of unused bits for PI */ - const Word16 L_subfr, /* i : subframe length */ - Word16 shift ) -{ - Word16 dn[2 * L_SUBFR]; - Word16 nBits, cmpl_flag; - Word16 stack_pulses; - Word16 g1, g2; - Word16 Rw[L_SUBFR]; - Word16 acelpautoc; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - (void) last_L_frame; - stack_pulses = 0; - move16(); - - IF( EQ_16( L_frame, L_FRAME ) ) - { - g1 = FORMANT_SHARPENING_G1; - move16(); - g2 = FORMANT_SHARPENING_G2; - move16(); - } - ELSE - { - g1 = FORMANT_SHARPENING_G1_16k; - move16(); - g2 = FORMANT_SHARPENING_G2_16k; - move16(); - } - - /*----------------------------------------------------------------* - * Update target vector for codebook search in residual domain - * Preemphasize the impulse response and include fixed-gain pitch contribution into impulse resp. h1[] (pitch sharpenning) - * Correlation between target xn2[] and impulse response h1[] - *----------------------------------------------------------------*/ - - test(); - test(); - IF( GT_32( core_brate, ACELP_13k20 ) && !Opt_AMR_WB && EQ_16( L_subfr, L_SUBFR ) ) - { - acelpautoc = 1; - move16(); - - cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_SUBFR ); - /* h2: Q11, Rw: (Rw_e)Q */ - /* Rw_e = */ E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 ); - - E_ACELP_conv( xn2, h2, cn ); - - /* dn_e -> Rw_e*Q_xn */ - /*dn_e = */ E_ACELP_toeplitz_mul_fx( Rw, cn, dn, L_SUBFR, 1 ); - } - ELSE - { - acelpautoc = 0; - move16(); - updt_tar_fx( cn, cn, &exc[i_subfr], gain_pit, L_subfr ); - /* scaling of cn[] to limit dynamic at 12 bits */ - Scale_sig( cn, L_subfr, shift ); - - cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); - corr_xh_fx( xn2, dn, h2 ); - } - - /*-----------------------------------------------------------------* - * Set complexity reduction flag to limit the number of iterations - * in algebraic innovation search - *-----------------------------------------------------------------*/ - cmpl_flag = 0; - move16(); - test(); - IF( st_fx->acelp_cfg.fcb_mode ) - { - /* set number of iterations in TD stereo, secondary channel */ - test(); - if ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) - { - cmpl_flag = 1; - move16(); - } - } - ELSE IF( EQ_16( L_frame, L_FRAME ) && EQ_16( coder_type, TRANSITION ) ) - { - test(); - test(); - if ( EQ_32( core_brate, ACELP_8k00 ) && i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) - { - cmpl_flag = 3; - move16(); - } - test(); - test(); - test(); - test(); - test(); - if ( EQ_32( core_brate, ACELP_11k60 ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || EQ_16( tc_subfr, TC_0_0 ) || ( EQ_16( i_subfr, 3 * L_SUBFR ) && EQ_16( tc_subfr, TC_0_64 ) ) ) ) - { - cmpl_flag = 3; - move16(); - } - test(); - test(); - test(); - test(); - if ( ( EQ_32( core_brate, ACELP_13k20 ) || EQ_32( core_brate, ACELP_12k15 ) ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || LE_16( tc_subfr, TC_0_64 ) ) ) - { - cmpl_flag = 3; - move16(); - } - } - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - IF( LE_32( core_brate, ACELP_32k ) ) - { - cmpl_flag = 4; - move16(); - - test(); - IF( EQ_16( coder_type, TRANSITION ) && GT_16( bwidth, WB ) ) - { - IF( LE_16( i_subfr, L_SUBFR ) ) - { - cmpl_flag = sub( cmpl_flag, 1 ); - } - ELSE - { - cmpl_flag = sub( cmpl_flag, 2 ); - } - } - } - ELSE IF( LE_32( core_brate, ACELP_48k ) ) - { - cmpl_flag = 3; - move16(); - - IF( EQ_16( coder_type, TRANSITION ) ) - { - IF( LE_16( i_subfr, L_SUBFR ) ) - { - cmpl_flag = sub( cmpl_flag, 1 ); - } - ELSE - { - cmpl_flag = sub( cmpl_flag, 2 ); - } - } - } - ELSE - { - cmpl_flag = 4; - move16(); - - IF( EQ_16( coder_type, TRANSITION ) ) - { - IF( LE_16( i_subfr, L_SUBFR ) ) - { - cmpl_flag = sub( cmpl_flag, 1 ); - } - ELSE - { - cmpl_flag = sub( cmpl_flag, 2 ); - } - } - - if ( coder_type == INACTIVE ) - { - cmpl_flag = 4; - move16(); - } - } - } - - test(); - test(); - test(); - IF( NE_16( L_frame, st_fx->last_L_frame ) && GT_32( core_brate, ACELP_13k20 ) && ( LT_32( core_brate, ACELP_32k ) || EQ_16( bwidth, WB ) ) ) - { - if ( GT_16( cmpl_flag, 1 ) ) - { - cmpl_flag = sub( cmpl_flag, 1 ); - } - } - - /*-----------------------------------------------------------------* - * Find and encode the algebraic innovation - *-----------------------------------------------------------------*/ - - set16_fx( y2, 0, L_SUBFR ); - - IF( !Opt_AMR_WB ) - { - IF( st_fx->acelp_cfg.fcb_mode ) - { - } - ELSE - { - nBits = st_fx->acelp_cfg.fixed_cdk_index[shr( i_subfr, 6 )]; - move16(); - - - IF( EQ_16( nBits, 7 ) ) - { - acelp_1t64_fx( hBstr, dn, h2, code, y2, L_SUBFR ); - } - ELSE IF( EQ_16( nBits, 12 ) ) - { - acelp_2t32_fx( hBstr, dn, h2, code, y2 ); - } - ELSE - { - *unbits = add( *unbits, acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, nBits, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ) ); - move16(); - } - } - } - ELSE - { - IF( EQ_32( core_brate, ACELP_6k60 ) ) - { - acelp_2t32_fx( hBstr, dn, h2, code, y2 ); - } - ELSE IF( ( EQ_32( core_brate, ACELP_8k85 ) ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 20, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); - } - ELSE IF( EQ_32( core_brate, ACELP_12k65 ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 36, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); - } - ELSE IF( EQ_32( core_brate, ACELP_14k25 ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 44, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); - } - ELSE IF( EQ_32( core_brate, ACELP_15k85 ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 52, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); - } - ELSE IF( EQ_32( core_brate, ACELP_18k25 ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 64, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); - } - ELSE IF( EQ_32( core_brate, ACELP_19k85 ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 72, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); - } - ELSE IF( EQ_32( core_brate, ACELP_23k05 ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); - } - ELSE IF( EQ_32( core_brate, ACELP_23k85 ) ) - { - acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, 1, Opt_AMR_WB, st_fx->element_mode ); - } - } - - /*----------------------------------------------------------------* - * Pitch sharpening - *----------------------------------------------------------------*/ - - cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); - - return stack_pulses; -} -#endif -#ifdef CLEANUP_ACELP_ENC Word16 inov_encode_fx( -#else -Word16 inov_encode_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -399,9 +108,7 @@ Word16 inov_encode_ivas_fx( move16(); } -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) -#endif { maximum_abs_16_fx( xn2, L_subfr, &max_xn2 ); IF( max_xn2 ) @@ -413,13 +120,10 @@ Word16 inov_encode_ivas_fx( Qxn = 0; move16(); } -#ifdef CLEANUP_ACELP_ENC Qcn = Q_new; move16(); -#endif } -#ifdef CLEANUP_ACELP_ENC ELSE { Q_new = 0; @@ -430,7 +134,6 @@ Word16 inov_encode_ivas_fx( Qcn = 0; move16(); } -#endif /*----------------------------------------------------------------* * Update target vector for codebook search in residual domain @@ -440,10 +143,6 @@ Word16 inov_encode_ivas_fx( test(); test(); -#ifndef CLEANUP_ACELP_ENC - Qcn = Q_new; - move16(); -#endif IF( GT_32( core_brate, ACELP_13k20 ) && !Opt_AMR_WB && EQ_16( L_subfr, L_SUBFR ) ) { acelpautoc = 1; @@ -468,7 +167,6 @@ Word16 inov_encode_ivas_fx( /* scaling of cn[] to limit dynamic at 12 bits */ Scale_sig( cn, L_subfr, shift ); -#ifdef CLEANUP_ACELP_ENC IF( st_fx->element_mode == EVS_MONO ) { cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); @@ -479,7 +177,6 @@ Word16 inov_encode_ivas_fx( move16(); } ELSE -#endif { Word16 q_h1 = sub( 14, norm_s( h2[0] ) ); Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/ @@ -631,9 +328,7 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) -#endif { Qh2 = sub( 14, norm_s( h2[0] ) ); Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 4c9b00d46..90f9222e0 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -650,11 +650,7 @@ ivas_error ivas_core_enc_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC core_switching_post_enc_ivas_fx( st ); -#else - core_switching_post_enc_ivas_fx( st, old_inp_12k8_fx[n], old_inp_16k_fx[n], A_fx[n], Q_new[n] ); -#endif /*---------------------------------------------------------------------* * WB TBE encoding diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index b1018b917..0abc63c3d 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -289,11 +289,7 @@ void encod_gen_2sbfr_fx( Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13 -#ifdef CLEANUP_ACELP_ENC tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); -#else - tbe_celp_exc_ivas( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); -#endif /*-----------------------------------------------------------------* * Find adaptive exitation @@ -327,11 +323,7 @@ void encod_gen_2sbfr_fx( * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC inov_encode_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new ); -#else - inov_encode_ivas_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new ); -#endif /*-----------------------------------------------------------------* * Gain encoding @@ -358,11 +350,7 @@ void encod_gen_2sbfr_fx( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); /*Q0*/ -#ifdef CLEANUP_ACELP_ENC hLPDmem->tilt_code = est_tilt_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ -#else - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ -#endif move16(); /*-----------------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 06630ab57..2a6c28a27 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1892,28 +1892,6 @@ void encod_nelp_ivas_fx( Word16 shift ); #endif Word16 encod_tran_fx( -#ifndef CLEANUP_ACELP_ENC - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q0*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* i/o: core synthesis Q_new*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/ - Word16 tc_subfr, /* i/o: TC subframe classification Q0*/ - Word16 position, /* i : maximum of residual signal index Q0*/ - Word16 *unbits, /* i/o: number of unused bits Q0*/ - const Word16 shift, /* i : Scaling to get 12 bits */ - const Word16 Q_new /* i : Input scaling */ -); - -Word16 encod_tran_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -2026,24 +2004,6 @@ void encod_unvoiced_fx( const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ ); -#ifndef CLEANUP_ACELP_ENC -void encod_unvoiced_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *speech_fx, /* i : Input speech Q_new*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/ - const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* o : core synthesis Q_new - 1*/ - Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ - const Word16 Q_new, - const Word16 shift ); -#endif void enc_acelp_tcx_main_fx( const Word16 new_samples[], /* i : new samples Q15*/ Encoder_State *st, /* i/o: encoder state structure */ @@ -2090,27 +2050,6 @@ ivas_error encod_ppp_ivas_fx( Word16 shift ); #endif void encod_gen_voic_fx( -#ifndef CLEANUP_ACELP_ENC - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : i speech Q0*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* i/o: core synthesis Q_new*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ - Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 shift, - Word16 Q_new ); - -void encod_gen_voic_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -2150,26 +2089,6 @@ void encod_audio_fx( const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ ); -#ifndef CLEANUP_ACELP_ENC -void encod_audio_ivas_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 speech[], /* i : input speech Q_new */ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */ - const Word16 Aq[], /* i : 12k8 Lp coefficient */ - const Word16 *res, /* i : residual signal Q_new */ - Word16 *synth, /* i/o: core synthesis Q-1 */ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new */ - Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ - Word16 *voice_factors, /* o : voicing factors Q15 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ - const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC)*/ - Word16 *lsf_new, /* i : current frame ISF vector */ - Word16 *tmp_noise, /* o : noise energy */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ - Word16 Q_new, - Word16 shift ); -#endif void stat_noise_uv_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors */ @@ -3538,33 +3457,6 @@ Word16 lp_filt_exc_enc_fx( ); Word16 inov_encode_fx( -#ifndef CLEANUP_ACELP_ENC - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 last_L_frame, /* i : length of the last frame */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : i signal bandwidth */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12*/ - const Word16 gain_pit, /* i : adaptive excitation gain Q14*/ - Word16 *cn, /* i/o: target vector in residual domain Q_new*/ - const Word16 *exc, /* i : pointer to excitation signal frame Q_new*/ - Word16 *h2, /* i/o: weighted filter i response Q12*/ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15*/ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - const Word16 *xn2, /* i : target vector for innovation search Q_new-1+shift*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/ - Word16 *unbits, /* o : number of unused bits for PI */ - const Word16 L_subfr, /* i : subframe length */ - Word16 shift ); - -Word16 inov_encode_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -3674,15 +3566,6 @@ void acelp_core_switch_enc_fx( const Word16 shift, const Word16 Q_new ); -#ifndef CLEANUP_ACELP_ENC -void acelp_core_switch_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - Word16 shift, - Word16 Q_new ); -#endif void gain_enc_amr_wb_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *xn, /* i : target vector Q_xn*/ @@ -3742,32 +3625,6 @@ void transf_cdbk_enc_fx( const Word16 shift /* i : shifting applied to y1, xn,... */ ); -#ifndef CLEANUP_ACELP_ENC -void transf_cdbk_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ -); -#endif void gain_enc_lbr_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3877,33 +3734,6 @@ void transition_enc_fx( Word16 shift /* i : downscaling needs for 12 bits convolutions */ ); -#ifndef CLEANUP_ACELP_ENC -void transition_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ -); -#endif void gain_enc_tc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 5ec3fe688..00e047e16 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -16,9 +16,6 @@ static void gain_trans_enc_fx( Word32 gain_trans32, Word16 exc[], Word16 *quant_index, Word16 *quant_sign, Word16 Q_new ); static void tc_enc_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); -#ifndef CLEANUP_ACELP_ENC -static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); -#endif /*==========================================================================*/ @@ -165,7 +162,6 @@ void transition_enc_fx( move16(); *clip_gain = 0; move16(); -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { g_corr_fx[0] = MAX16B /* 1.0f in Q15 */; @@ -177,7 +173,6 @@ void transition_enc_fx( g_corr_fx[3] = 0; } ELSE -#endif { g_corr_fx[0] = 16384; move16(); @@ -413,13 +408,11 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE -#endif { pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -470,13 +463,11 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE -#endif { pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -543,13 +534,11 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE -#endif { pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -577,13 +566,11 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE -#endif { pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -623,13 +610,11 @@ void transition_enc_fx( pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); /* Find the adaptive codebook vector - ACELP long-term prediction */ -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE -#endif { pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -868,7 +853,6 @@ void transition_enc_fx( move16(); *clip_gain = 0; move16(); -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { g_corr_fx[0] = 328 /* 0.01f in Q15 */; @@ -881,7 +865,6 @@ void transition_enc_fx( move16(); } ELSE -#endif { g_corr_fx[0] = 0; move16(); @@ -901,13 +884,11 @@ void transition_enc_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ -#ifdef CLEANUP_ACELP_ENC IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE -#endif { pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -976,836 +957,6 @@ void transition_enc_fx( return; } -#ifndef CLEANUP_ACELP_ENC -void transition_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ -) -{ - Word16 pit_flag, pit_start, pit_limit, index, nBits; - Word16 tmp, tmp1, i; - Word32 offset; - Word16 shift_wsp; - Word16 limit_flag, mult_Top, lp_select, lp_flag; - Word16 T_op[2]; /* values for two half-frames */ - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - - /* set limit_flag to 0 for restrained limits, and 1 for extended limits */ - limit_flag = 0; - move16(); - pit_start = PIT_MIN; - move16(); - - /*----------------------------------------------------------------* - * convert pitch values to 16kHz domain - *----------------------------------------------------------------*/ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) /*|| (tdm_Pri_pitch_buf != NULL && tdm_Pri_pitch_buf[0] < 0)*/ ) - { - Copy( st_fx->pitch, T_op, 2 ); - } - ELSE /* L_frame == L_FRAME16k */ - { - /*T_op[0] = (int16_t)(pitch[0] * 1.25f + 0.5f); - T_op[1] = (int16_t)(pitch[1] * 1.25f + 0.5f);*/ - T_op[0] = add( st_fx->pitch[0], mult_r( st_fx->pitch[0], 8192 /*0.25f Q15*/ ) ); - move16(); - T_op[1] = add( st_fx->pitch[1], mult_r( st_fx->pitch[1], 8192 /*0.25f Q15*/ ) ); - move16(); - } - shift_wsp = add( Q_new, shift ); - - lp_flag = st_fx->acelp_cfg.ltf_mode; - move16(); - - /*-----------------------------------------------------------------* - * TC: subrame determination for glottal shape search - * ------------------------------------------------------- - * tc_subfr == 0 - TC in 1st subframe - * tc_subfr == TC_0_0 - TC in 1st subframe + information about T0 - * tc_subfr == L_SUBFR - TC in 2nd subframe - * tc_subfr == 2*L_SUBFR - TC in 3rd subframe - * tc_subfr == 3*L_SUBFR - TC in 4th subframe - *-----------------------------------------------------------------*/ - - IF( i_subfr == 0 ) - { - mult_Top = 1; - move16(); - IF( limit_flag == 0 ) - { - test(); - IF( EQ_16( st_fx->L_frame, L_FRAME ) && LT_16( T_op[1], PIT_MIN ) ) - { - mult_Top = 2; - move16(); - } - test(); - if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && LT_16( T_op[1], PIT16k_MIN ) ) - { - mult_Top = 2; - move16(); - } - } - - limit_T0_fx( st_fx->L_frame, 8, 0, limit_flag, mult_Top * T_op[1], 0, T0_min, T0_max ); - } - - /*-----------------------------------------------------------------* - * zero adaptive excitation signal construction - *-----------------------------------------------------------------*/ - - IF( GT_16( *tc_subfr, i_subfr ) ) - { - *gain_pit_fx = 0; - move16(); - *clip_gain = 0; - move16(); - g_corr_fx[0] = MAX16B /* 1.0f in Q15 */; - move16(); - g_corr_fx[1] = 0; - move16(); - g_corr_fx[2] = MAX16B /* 1.0f in Q15 */; - move16(); - g_corr_fx[3] = 0; - move16(); - - set16_fx( &exc_fx[i_subfr], 0, L_SUBFR ); /* set excitation for current subrame to 0 */ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - set16_fx( &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], 0, (Word16) ( L_SUBFR * HIBND_ACB_L_FAC ) ); /* set past excitation buffer to 0 */ - } - ELSE - { - set16_fx( &bwe_exc_fx[i_subfr * 2], 0, L_SUBFR * 2 ); /* set past excitation buffer to 0 */ - } - - set16_fx( y1_fx, 0, L_SUBFR ); /* set filtered adaptive excitation to 0 */ - Copy( xn_fx, xn2_fx, L_SUBFR ); /* target vector for codebook search */ - *T0 = L_SUBFR; - move16(); - *T0_frac = 0; - move16(); - - **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - move16(); /* save subframe pitch values Q6 */ - } - - /*-----------------------------------------------------------------* - * glottal codebook contribution construction - *-----------------------------------------------------------------*/ - - ELSE IF( EQ_16( *tc_subfr, i_subfr ) ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - set16_fx( bwe_exc_fx - PIT_MAX * HIBND_ACB_L_FAC, 0, PIT_MAX * HIBND_ACB_L_FAC ); /* set past excitation buffer to 0 */ - } - ELSE - { - set16_fx( bwe_exc_fx - PIT16k_MAX * 2, 0, PIT16k_MAX * 2 ); /* set past excitation buffer to 0 */ - } - - tc_enc_ivas_fx( st_fx, i_subfr, tc_subfr, position, h1_fx, xn_fx, exc_fx, - y1_fx, T0_min, T0_max, T0, T0_frac, gain_pit_fx, g_corr_fx, bwe_exc_fx, Q_new ); - - IF( EQ_16( *tc_subfr, TC_0_0 ) ) - { - /* this is called only to compute unused bits */ - config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); - } - - *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); - move16(); - updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR ); - - **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - move16(); - *Jopt_flag = 1; - move16(); - } - - /*--------------------------------------------------------------* - * other subframes -> GENERIC encoding type, - * standard adaptive excitation contribution - * - exemption only in case when first glottal impulse is - * in the 1st subframe and the second one in 2nd subframe - * and later - *--------------------------------------------------------------*/ - - ELSE IF( LT_16( *tc_subfr, i_subfr ) ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - *Jopt_flag = 1; - move16(); - /* pit_flag for T0 bits number coding determination */ - test(); - IF( ( EQ_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) || ( EQ_16( sub( i_subfr, *tc_subfr ), L_SUBFR - TC_0_0 ) ) ) - { - pit_flag = 0; - move16(); - } - ELSE - { - pit_flag = L_SUBFR; - move16(); - } - - IF( EQ_16( *tc_subfr, TC_0_0 ) ) - { - IF( EQ_16( i_subfr, L_SUBFR ) ) - { - limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); - } - pit_flag = 1; - move16(); - } - - /*----------------------------------------------------------* - * if tc_subfr==0, change tc_subfr corresponding to the - * second glot. impulse position - *----------------------------------------------------------*/ - - test(); - IF( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) - { - IF( GT_16( PIT_MIN, ( *position ) ) ) - { - pit_start = sub( L_SUBFR, ( *position ) ); - } - ELSE - { - pit_start = PIT_MIN; - move16(); - } - pit_start = s_max( pit_start, PIT_MIN ); - - pit_limit = add( shl( pit_start, 1 ), *position ); - - /* Find the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - - offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) - { - bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; - move16(); - } - - test(); - IF( GT_16( ( *T0 ), sub( 2 * L_SUBFR, ( *position ) ) ) ) - { - IF( GE_16( add( ( *T0 ), ( *position ) ), 3 * L_SUBFR ) ) - { - /* second glottal impulse is in the 4th subframe */ - *tc_subfr = TC_0_192; - move16(); - } - ELSE - { - /* second glottal impulse is in the 3rd subframe */ - *tc_subfr = TC_0_128; - move16(); - } - } - ELSE IF( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) - { - /* second glottal impulse is in the 2nd subframe */ - *tc_subfr = TC_0_64; - move16(); - } - } - - IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) - { - config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); - } - - /*-----------------------------------------------------------------* - * get number of bits for pitch encoding - *-----------------------------------------------------------------*/ - - nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )]; - move16(); - - /*-----------------------------------------------------------------* - * Find adaptive part of excitation, encode pitch period - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - test(); - /* first glottal impulse is in the 1st subrame */ - IF( ( EQ_16( i_subfr, L_SUBFR ) ) && ( GE_16( *tc_subfr, TC_0_128 ) ) ) - { - /*--------------------------------------------------------* - * second glottal impulse is in the 3rd or 4th subframe - * - build exc[] in 2nd subframe - *--------------------------------------------------------*/ - - *T0 = 2 * L_SUBFR; - move16(); - *T0_frac = 0; - move16(); - *Jopt_flag = 0; - move16(); - set16_fx( &exc_fx[i_subfr], 0, (Word16) ( L_SUBFR + 1 ) ); - set16_fx( &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], 0, (Word16) ( L_SUBFR * HIBND_ACB_L_FAC ) ); - } - ELSE IF( ( EQ_16( i_subfr, L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_64 ) ) ) - { - /*--------------------------------------------------------* - * second glottal impulse is in the 2nd subframe, - * - build exc[] in 2nd subframe - *--------------------------------------------------------*/ - - IF( LT_16( add( *T0, *position ), L_SUBFR ) ) - { - /* impulse must be in the 2nd subframe (not in 1st) */ - *T0 = sub( L_SUBFR, ( *position ) ); - move16(); - *T0_frac = 0; - move16(); - } - IF( GE_16( add( *T0, *position ), 2 * L_SUBFR ) ) - { - /* impulse must be in the 2nd subframe (not in 3rd) */ - *T0 = sub( 2 * L_SUBFR - 1, ( *position ) ); - move16(); - *T0_frac = 2; - move16(); - } - - limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max for delta search */ - - /* 7bit ENCODER */ - /* index = (*T0-pit_start)*2 + *T0_frac/2;*/ - index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) ); - push_indice( hBstr, IND_PITCH, index, nBits ); - - /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - - offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) - { - bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; - move16(); - } - } - ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_128 ) ) ) - { - /*--------------------------------------------------------* - * second glottal impulse is in the 3rd subframe - * - build exc[] in 3rd subframe - *--------------------------------------------------------*/ - - pit_start = sub( 2 * L_SUBFR, ( *position ) ); - pit_flag = 0; - move16(); - - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - - IF( LT_16( add( ( *T0 ), ( *position ) ), 2 * L_SUBFR ) ) - { - /* impulse must be in the 3rd subframe (not in 2nd) */ - *T0 = sub( 2 * L_SUBFR, ( *position ) ); - move16(); - *T0_frac = 0; - move16(); - } - - IF( GE_16( add( ( *T0 ), ( *position ) ), 3 * L_SUBFR ) ) - { - /* impulse must be in the 3rd subframe (not in 4th) */ - *T0 = sub( 3 * L_SUBFR - 1, ( *position ) ); - move16(); - *T0_frac = 2; - move16(); - } - - limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max for delta search */ - - index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) ); - push_indice( hBstr, IND_PITCH, index, nBits ); - - /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - - - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) - { - bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; - move16(); - } - } - ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_192 ) ) ) - { - /*--------------------------------------------------------* - * second glottal impulse is in the 4th subframe - * - build exc[] in 3rd subframe - *--------------------------------------------------------*/ - - *T0 = 4 * L_SUBFR; - move16(); - *T0_frac = 0; - move16(); - *Jopt_flag = 0; - move16(); - set16_fx( &exc_fx[i_subfr], 0, (Word16) ( L_SUBFR + 1 ) ); - set16_fx( &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], 0, (Word16) ( L_SUBFR * HIBND_ACB_L_FAC ) ); - } - ELSE IF( ( EQ_16( i_subfr, 3 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_192 ) ) ) - { - /*--------------------------------------------------------* - * second glottal impulse is in the 4th subframe - * - build exc[] in 4th subframe - *--------------------------------------------------------*/ - - /* always T0_frac = 0 */ - pit_flag = 0; - move16(); - - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - - IF( LT_16( add( *T0, *position ), 3 * L_SUBFR ) ) - { - /* impulse must be in the 4th subframe (not in 3rd) */ - *T0 = sub( 3 * L_SUBFR, ( *position ) ); - move16(); - *T0_frac = 0; - move16(); - } - - pit_start = sub( 3 * L_SUBFR, ( *position ) ); - pit_limit = sub( 2 * L_FRAME - PIT_MAX - 2, shl( *position, 1 ) ); - - IF( LT_16( ( *T0 ), pit_limit ) ) - { - index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) ); - } - ELSE - { - index = add( sub( *T0, pit_limit ), shl( sub( pit_limit, pit_start ), 1 ) ); - *T0_frac = 0; - move16(); - } - push_indice( hBstr, IND_PITCH, index, nBits ); - - /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) - { - bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; - move16(); - } - } - ELSE IF( ( EQ_16( i_subfr, 3 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_128 ) ) ) - { - /*--------------------------------------------------------* - * second glottal impulse in the 3rd subframe - * build exc[] in 4th subframe - *--------------------------------------------------------*/ - - pit_flag = L_SUBFR; - move16(); - - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - index = delta_pit_enc_fx( 2, *T0, *T0_frac, *T0_min ); - push_indice( hBstr, IND_PITCH, index, nBits ); - - /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) - { - bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; - move16(); - } - } - - /*------------------------------------------------------------* - * first glottal impulse is NOT in the 1st subframe, - * or two impulses are in the 1st subframe - *------------------------------------------------------------*/ - - ELSE - { - test(); - IF( EQ_16( nBits, 8 ) || EQ_16( nBits, 5 ) ) - { - test(); - IF( !( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) ) - { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - } - } - ELSE - { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - } - pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); - /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) - { - bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; - move16(); - } - } - - /*-----------------------------------------------------------------* - * - gain clipping test to avoid unstable synthesis - * - LP filtering of the adaptive excitation (if non-zero) - * - codebook target computation - *-----------------------------------------------------------------*/ - - IF( *Jopt_flag == 0 ) - { - /* adaptive/TC excitation is zero */ - Copy( xn_fx, xn2_fx, L_SUBFR ); - g_corr_fx[0] = 0; - move16(); - g_corr_fx[1] = 0; - move16(); - g_corr_fx[2] = 0; - move16(); - g_corr_fx[3] = 0; - move16(); - *clip_gain = 0; - move16(); - } - ELSE - { - *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) ); - move16(); - - lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, - xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); - IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) - { - push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); - } - } - - **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - move16(); - - /*---------------------------------------------------------------------* - * fill the pitch buffer - needed for post-processing - *---------------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - IF( ( *tc_subfr >= 2 * L_SUBFR ) && ( i_subfr == 3 * L_SUBFR ) ) - { - tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - ( *pt_pitch_fx ) -= 3; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - } - ELSE IF( ( *tc_subfr == L_SUBFR ) && ( i_subfr == 2 * L_SUBFR ) ) - { - tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - ( *pt_pitch_fx ) -= 2; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - } - ELSE IF( ( *tc_subfr == TC_0_64 ) && ( i_subfr == L_SUBFR ) ) - { - tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - ( *pt_pitch_fx ) -= 1; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - } - ELSE IF( ( *tc_subfr == TC_0_128 ) && ( i_subfr == 2 * L_SUBFR ) ) - { - tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - ( *pt_pitch_fx ) -= 2; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - } - ELSE IF( ( *tc_subfr == TC_0_192 ) && ( i_subfr == 3 * L_SUBFR ) ) - { - tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - ( *pt_pitch_fx ) -= 3; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - } - } - ELSE /* L_frame == L_FRAME16k */ - { - if ( GE_16( i_subfr, 2 * L_SUBFR ) ) - { - limit_flag = 1; - move16(); - } - IF( LE_16( i_subfr, 2 * L_SUBFR ) ) - { - IF( LT_16( i_subfr, 2 * L_SUBFR ) ) - { - mult_Top = 1; - move16(); - if ( LT_16( T_op[0], PIT16k_MIN ) ) - { - mult_Top = 2; - move16(); - } - - limit_T0_fx( L_FRAME16k, 8, 0, limit_flag, mult_Top * T_op[0], 0, T0_min, T0_max ); /* TC0 second subfr. */ - } - ELSE - { - limit_T0_fx( L_FRAME16k, 8, 0, limit_flag, T_op[1], 0, T0_min, T0_max ); /* TC0 third subfr., or TC64 third subfr. */ - } - } - - /*-----------------------------------------------------------------* - * get number of bits for pitch encoding - *-----------------------------------------------------------------*/ - - nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )]; - move16(); - - /*-----------------------------------------------------------------* - * Find adaptive part of excitation, encode pitch period - *-----------------------------------------------------------------*/ - - IF( EQ_16( nBits, 10 ) ) - { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - pit16k_Q_enc_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); - } - ELSE IF( EQ_16( nBits, 8 ) ) /* tc_subfr==0 && i_subfr==L_SUBFR */ - { - /*-----------------------------------------------------------------------------* - * The pitch range is encoded absolutely with 8 bits and is divided as follows: - * PIT16k_MIN to PIT16k_FR2_TC0_2SUBFR-1 resolution 1/4 (frac = 0,1,2 or 3) - * PIT16k_FR2_TC0_2SUBFR to 2*L_SUBFR resolution 1/2 (frac = 0 or 2) - *-----------------------------------------------------------------------------*/ - - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - - IF( GT_16( *T0_max, 2 * L_SUBFR ) ) - { - *T0 = 2 * L_SUBFR; - move16(); - *T0_frac = 0; - move16(); - } - - IF( LT_16( *T0, PIT16k_FR2_TC0_2SUBFR ) ) - { - /*index = (*T0)*4 + (*T0_frac) - (PIT16k_MIN*4);*/ - index = add( shl( *T0, 2 ), sub( *T0_frac, PIT16k_MIN * 4 ) ); - } - ELSE - { - /*index = (*T0)*2 + ((*T0_frac)>>1) - (PIT16k_FR2_TC0_2SUBFR*2) + ((PIT16k_FR2_TC0_2SUBFR-PIT16k_MIN)*4);*/ - index = add( sub( add( shl( *T0, 1 ), shr( *T0_frac, 1 ) ), ( PIT16k_FR2_TC0_2SUBFR * 2 ) ), ( PIT16k_FR2_TC0_2SUBFR - PIT16k_MIN ) * 4 ); - } - push_indice( hBstr, IND_PITCH, index, nBits ); - } - ELSE IF( EQ_16( nBits, 6 ) ) - { - /* delta search */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - - index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min ); - push_indice( hBstr, IND_PITCH, index, nBits ); - } - - IF( EQ_16( nBits, 6 ) ) - { - limit_T0_fx( L_FRAME16k, 8, L_SUBFR, limit_flag, *T0, *T0_frac, T0_min, T0_max ); - } - - /*-----------------------------------------------------------------* - * - gain clipping test to avoid unstable synthesis - * - LP filtering of the adaptive excitation - * - codebook target computation - *-----------------------------------------------------------------*/ - test(); - IF( ( EQ_16( i_subfr, L_SUBFR ) ) && ( EQ_16( *T0, 2 * L_SUBFR ) ) ) - { - *gain_pit_fx = 0; - move16(); - *clip_gain = 0; - move16(); - g_corr_fx[0] = 328 /* 0.01f in Q15 */; - move16(); - g_corr_fx[1] = 0; - move16(); - g_corr_fx[2] = 328 /* 0.01f in Q15 */; - move16(); - g_corr_fx[3] = 0; - move16(); - *Jopt_flag = 0; - move16(); - - set16_fx( &exc_fx[i_subfr], 0, L_SUBFR + 1 ); /* set excitation for current subrame to 0 */ - push_indice( hBstr, IND_LP_FILT_SELECT, 0, 1 ); /* this bit is actually not needed */ - - Copy( xn_fx, xn2_fx, L_SUBFR ); /* target vector for codebook search */ - set16_fx( y1_fx, 0, L_SUBFR ); /* set filtered adaptive excitation to 0 */ - set16_fx( &bwe_exc_fx[i_subfr * 2], 0, L_SUBFR * 2 ); - } - ELSE - { - /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - offset = L_deposit_l( 0 ); - - tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ - tmp = add( 512, tmp ); /*Q8; 2 in Q8*/ - tmp = mult_r( tmp, 256 ); /*Q16->Q0; 2 in Q7*/ - - tmp1 = sub( *T0, 2 ); /*Q0*/ - tmp1 = shl( tmp1, 1 ); /*Q0 */ - - offset = add( tmp, tmp1 ); /*Q0*/ - FOR( i = 0; i < L_SUBFR * 2; i++ ) - { - /* bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - *T0 * 2 - (int) ((float) *T0_frac * 0.5f + 4 + 0.5f) + 4];move16();*/ - bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - offset + 4]; - move16(); - } - - *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new ); - move16(); - - lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, - xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); - IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) - { - push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); - } - - *Jopt_flag = 1; - move16(); - } - - /***pt_pitch = (float)(*T0) + (float)(*T0_frac)/4.0f;*/ /* save subframe pitch value */ - /***pt_pitch_fx = shl(add(*T0,shr(*T0_frac,2)),4); move16();*/ - tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - **pt_pitch_fx = tmp; - move16(); - - /*---------------------------------------------------------------------* - * fill the pitch buffer - needed for post-processing - *---------------------------------------------------------------------*/ - test(); - test(); - IF( ( EQ_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) || ( *tc_subfr == 0 && EQ_16( i_subfr, 2 * L_SUBFR ) ) ) - { - index = shr( i_subfr, 6 ); - ( *pt_pitch_fx ) -= index; - move16(); - - FOR( i = 0; i < index; i++ ) - { - **pt_pitch_fx = tmp; - move16(); - ( *pt_pitch_fx )++; - move16(); - } - } - } - } - - return; -} -#endif /*-------------------------------------------------------------------------------------------* * tc_enc() @@ -2047,228 +1198,6 @@ static void tc_enc_fx( return; } -#ifndef CLEANUP_ACELP_ENC -static void tc_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subrame index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *position, /* i/o: index of the residual signal maximum */ - const Word16 *h1, /* i : weighted filter input response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target signal Q_new-1+shift*/ - Word16 *exc_fx, /* o : glottal codebook contribution Q_new*/ - Word16 *yy1_fx, /* o : filtered glottal codebook contribution */ - Word16 *T0_min, /* o : lower pitch limit Q0*/ - Word16 *T0_max, /* o : higher pitch limit Q0*/ - Word16 *T0, /* o : close loop integer pitch Q0*/ - Word16 *T0_frac, /* o : close loop fractional part of the pitch Q0*/ - Word16 *gain_pit_fx, /* o : pitch gain (0..GAIN_PIT_MAX) Q14*/ - Word16 g_corr_fx[], /* o : correlations and -2 */ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_new*/ - Word16 Q_new /* i : input scaling */ -) -{ - - Word16 h1_fx[L_SUBFR + ( M + 1 )]; - Word16 imp_shape, imp_pos, index, nBits; - Word16 pitch_index, pitch_sign_fx; - Word32 gain_trans32; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - Flag Overflow = 0; - move32(); - imp_pos = sub( *position, i_subfr ); - /*-----------------------------------------------------------------* - * get number of bits for pitch encoding - *-----------------------------------------------------------------*/ - - nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )]; - move16(); - - /*--------------------------------------------------------------* - * Closed loop pitch search - *--------------------------------------------------------------*/ - - *T0_frac = 0; - move16(); - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - test(); - IF( ( LE_16( *T0_min, L_SUBFR ) ) || ( EQ_16( *tc_subfr, 3 * L_SUBFR ) ) ) - { - IF( EQ_16( nBits, 9 ) ) - { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - } - ELSE IF( EQ_16( nBits, 6 ) ) - { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - } - ELSE - { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - } - } - ELSE - { - *T0 = L_SUBFR; - move16(); - } - - test(); - if ( EQ_16( *tc_subfr, L_SUBFR ) && LT_16( *T0, L_SUBFR ) ) - { - *T0 = L_SUBFR; - move16(); - } - } - ELSE /* st_fx->L_frame == L_FRAME16k */ - { - IF( EQ_16( nBits, 10 ) ) - { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - } - ELSE IF( EQ_16( nBits, 6 ) ) - { - /* T0_frac with 1/2 sample resolution */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new ); - move16(); - - IF( *T0 > L_SUBFR ) - { - *T0 = L_SUBFR; - move16(); - *T0_frac = 0; - move16(); - } - } - } - - /* set tc_subfr to TC_0_0 */ - test(); - test(); - test(); - if ( i_subfr == 0 && EQ_16( st_fx->L_frame, L_FRAME ) && ( LT_16( *T0, L_SUBFR ) || EQ_16( *tc_subfr, 3 * L_SUBFR ) ) ) - { - *tc_subfr = TC_0_0; - move16(); - } - - /*--------------------------------------------------------------* - * Builds glottal codebook contribution - *--------------------------------------------------------------*/ - - set_impulse_fx( xn_fx, h1, &exc_fx[i_subfr], yy1_fx, &imp_shape, &imp_pos, &gain_trans32, Q_new ); - - /*--------------------------------------------------------------* - * quantize gain_trans and scale glottal codebook contribution - *--------------------------------------------------------------*/ - - gain_trans_enc_fx( gain_trans32, &exc_fx[i_subfr], &pitch_index, &pitch_sign_fx, Q_new ); - - /* set past excitation buffer to zeros */ - set16_fx( exc_fx - L_EXC_MEM, 0, L_EXC_MEM ); - - /*--------------------------------------------------------------* - * adapt. search of the second impulse in the same subframe - * (when appears) - *--------------------------------------------------------------*/ - - pred_lt4_tc_fx( exc_fx, *T0, *T0_frac, inter4_2_fx, imp_pos, i_subfr ); - - IF( st_fx->hBWE_TD != NULL ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR ); - } - ELSE - { - interp_code_4over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * 2], L_SUBFR ); - } - } - - /*--------------------------------------------------------------* - * compute glottal-shape codebook excitation - *--------------------------------------------------------------*/ - - Copy( h1, h1_fx, L_SUBFR + ( M + 1 ) ); - /* create filtered glottal codebook contribution */ - conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR ); - - /* gain_pit computation */ - *gain_pit_fx = corr_xy1_fx( xn_fx, yy1_fx, g_corr_fx, L_SUBFR, 0, &Overflow ); - move16(); - - /*--------------------------------------------------------------* - * Encode parameters and write indices - *--------------------------------------------------------------*/ - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - test(); - test(); - IF( ( ( i_subfr != 0 ) || ( EQ_16( *tc_subfr, TC_0_0 ) ) ) && ( NE_16( *tc_subfr, L_SUBFR ) ) ) - { - test(); - /* write pitch index */ - IF( ( GE_16( *T0, L_SUBFR ) ) && ( NE_16( *tc_subfr, 3 * L_SUBFR ) ) ) - { - push_indice( hBstr, IND_PITCH, 0, nBits ); - } - ELSE IF( EQ_16( *tc_subfr, 3 * L_SUBFR ) ) - { - IF( EQ_16( nBits, 9 ) ) - { - index = abs_pit_enc_fx( 4, 0, *T0, *T0_frac ); - } - ELSE - { - index = abs_pit_enc_fx( 2, 0, *T0, *T0_frac ); - } - push_indice( hBstr, IND_PITCH, index, nBits ); - - limit_T0_fx( L_FRAME, 8, 0, 0, *T0, 0, T0_min, T0_max ); - } - ELSE - { - IF( EQ_16( nBits, 6 ) ) - { - index = delta_pit_enc_fx( 2, *T0, *T0_frac, PIT_MIN - 1 ); - push_indice( hBstr, IND_PITCH, index, nBits ); - } - ELSE - { - index = delta_pit_enc_fx( 0, *T0, *T0_frac, PIT_MIN - 1 ); - push_indice( hBstr, IND_PITCH, index, nBits ); - } - } - } - } - ELSE /* st_fx->L_frame == L_FRAME16k */ - { - IF( EQ_16( nBits, 10 ) ) - { - pit16k_Q_enc_fx( hBstr, nBits, 1, *T0, *T0_frac, T0_min, T0_max ); - } - ELSE IF( EQ_16( nBits, 6 ) ) - { - index = add( shl( sub( *T0, PIT16k_MIN ), 1 ), shr( *T0_frac, 1 ) ); - push_indice( hBstr, IND_PITCH, index, nBits ); - } - } - push_indice( hBstr, IND_TC_IMP_SHAPE, imp_shape, 3 ); - push_indice( hBstr, IND_TC_IMP_POS, imp_pos, 6 ); - push_indice( hBstr, IND_TC_IMP_SIGN, pitch_sign_fx, 1 ); - push_indice( hBstr, IND_TC_IMP_GAIN, pitch_index, 3 ); - - *position = add( imp_pos, i_subfr ); - move16(); - return; -} -#endif /*-----------------------------------------------------------------* * gain_trans_enc() -- GitLab From 7bea8f830ecc223c392a6a9d552008628c526655 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:19:36 +0100 Subject: [PATCH 393/750] [cleanup] accept CLEANUP_VBR_CAM_ENC --- lib_com/lsf_tools_fx.c | 164 -------- lib_com/options.h | 1 - lib_com/prot_fx.h | 51 --- lib_enc/acelp_core_enc_fx.c | 128 ------- lib_enc/enc_nelp_fx.c | 142 ------- lib_enc/enc_ppp_fx.c | 184 --------- lib_enc/nelp_enc_fx.c | 736 ------------------------------------ lib_enc/prot_fx_enc.h | 33 -- 8 files changed, 1439 deletions(-) diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 7893d9b79..945f3249d 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -2962,91 +2962,6 @@ void lsf_syn_mem_backup_fx( return; } -#ifndef CLEANUP_VBR_CAM_ENC -/*-------------------------------------------------------------------* - * lsf_syn_mem_backup_fx() - * - * - *--------------------------------------------------------------------*/ - -void lsf_syn_mem_backup_ivas_fx( - Encoder_State *st_fx, /* i: state structure */ - Word16 *btilt_code_fx, /* i: tilt code Q15 */ - Word32 *gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *next_force_sf_bck_fx, /* o: */ - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ - Word16 *pstreaklen ) -{ - Word16 i; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - - *clip_var = st_fx->clip_var_fx[0]; - move16(); - - FOR( i = 0; i < M; i++ ) - { - mem_AR[i] = st_fx->mem_AR_fx[i]; // Q2.56 - move16(); - mem_MA[i] = st_fx->mem_MA_fx[i]; // Q2.56 - move16(); - lsp_new_bck[i] = lsp_new[i]; // Q15 - move16(); - lsp_mid_bck[i] = lsp_mid[i]; // Q15 - move16(); - } - - *streaklimit = st_fx->streaklimit_fx; // Q15 - move16(); - *pstreaklen = st_fx->pstreaklen; - move16(); - - FOR( i = 0; i < L_FFT; i++ ) - { - Bin_E[i] = st_fx->Bin_E_fx[i]; // Q_new + Q_SCALE - 2 - move32(); - } - - FOR( i = 0; i < ( L_FFT / 2 ); i++ ) - { - Bin_E_old[i] = st_fx->Bin_E_old_fx[i]; // Q_new + Q_SCALE - 2 - move32(); - } - - /* back-up memories */ - FOR( i = 0; i < M; i++ ) - { - mem_syn_bck[i] = hLPDmem->mem_syn[i]; // Q( st_fx->hLPDmem->q_mem_syn ) - move16(); - } - - *mem_w0_bck = hLPDmem->mem_w0; // Q( st_fx->hLPDmem->q_mem_syn ) - move16(); - - - *btilt_code_fx = hLPDmem->tilt_code; // Q15 - move16(); - *gc_threshold_fx = hLPDmem->gc_threshold; // Q16 - move16(); - Copy( st_fx->clip_var_fx, clip_var_bck_fx, 6 ); - *next_force_sf_bck_fx = st_fx->next_force_safety_net; - move16(); - - - return; -} -#endif void lsf_update_memory( Word16 narrowband, /* i : narrowband flag */ @@ -3191,85 +3106,6 @@ void lsf_syn_mem_restore_fx( return; } -#ifndef CLEANUP_VBR_CAM_ENC -void lsf_syn_mem_restore_ivas_fx( - Encoder_State *st_fx, /* o: state structure */ - Word16 btilt_code_fx, /* i: Q15 */ - Word32 gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 next_force_sf_bck_fx, /* i: */ - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 clip_var, /* i: pitch clipping state var Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */ - Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* i: synthesis filter memory Q(15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 mem_w0_bck, /* i: memory of the weighting filter Q(15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 streaklimit, /* i:LSF quantizer Q15 */ - Word16 pstreaklen /* i:LSF quantizer */ -) -{ - Word16 i; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - - /* restore lsf memories */ - st_fx->clip_var_fx[0] = clip_var; - move16(); - - FOR( i = 0; i < M; i++ ) - { - st_fx->mem_AR_fx[i] = mem_AR[i]; // 2.56 - move16(); - st_fx->mem_MA_fx[i] = mem_MA[i]; // 2.56 - move16(); - lsp_new[i] = lsp_new_bck[i]; // Q15 - move16(); - lsp_mid[i] = lsp_mid_bck[i]; // Q15 - move16(); - } - - st_fx->streaklimit_fx = streaklimit; // Q15 - move16(); - st_fx->pstreaklen = pstreaklen; - move16(); - - FOR( i = 0; i < L_FFT; i++ ) - { - st_fx->Bin_E_fx[i] = Bin_E[i]; // Q_new + Q_SCALE - 2 - move16(); - } - - FOR( i = 0; i < ( L_FFT / 2 ); i++ ) - { - st_fx->Bin_E_old_fx[i] = Bin_E_old[i]; // Q_new + Q_SCALE - 2 - move32(); - } - - /* restoring memories */ - hLPDmem->mem_w0 = mem_w0_bck; // Q( st_fx->hLPDmem->q_mem_syn ) - move16(); - - FOR( i = 0; i < M; i++ ) - { - hLPDmem->mem_syn[i] = mem_syn_bck[i]; // Q( st_fx->hLPDmem->q_mem_syn ) - move16(); - } - - move16(); - hLPDmem->tilt_code = btilt_code_fx; // Q15 - move32(); - hLPDmem->gc_threshold = gc_threshold_fx; // Q16 - Copy( clip_var_bck_fx, st_fx->clip_var_fx, 6 ); - st_fx->next_force_safety_net = next_force_sf_bck_fx; - move16(); - - return; -} -#endif /* Returns: codebook index */ Word16 tcxlpc_get_cdk( diff --git a/lib_com/options.h b/lib_com/options.h index 5b47e7fc8..df4dca23e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,7 +90,6 @@ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ -#define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ #define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ #define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 7c23158ed..c44697586 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -906,28 +906,6 @@ void lsf_syn_mem_restore_fx( Word16 pstreaklen /* i:LSF quantizer */ ); -#ifndef CLEANUP_VBR_CAM_ENC -void lsf_syn_mem_restore_ivas_fx( - Encoder_State *st_fx, /* o: state structure */ - Word16 btilt_code_fx, /* i: Q15 */ - Word32 gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 next_force_sf_bck_fx, /* i: */ - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 clip_var, /* i: pitch clipping state var Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */ - Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* i: synthesis filter memory Q(15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 mem_w0_bck, /* i: memory of the weighting filter Q(15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 streaklimit, /* i:LSF quantizer Q15 */ - Word16 pstreaklen /* i:LSF quantizer */ -); -#endif void lsf_update_memory( Word16 narrowband, /* i : narrowband flag */ const Word16 qisf[], /* i : quantized xSF coefficients */ @@ -3824,14 +3802,6 @@ void nelp_encoder_fx( Word16 *qIn1, Word16 reduce_gains ); -#ifndef CLEANUP_VBR_CAM_ENC -void nelp_encoder_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); -#endif void swb_bwe_enc_lr_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 L_m_core[], /* i : lowband synthesis */ @@ -10603,27 +10573,6 @@ Word16 ari_decode_14bits_sign_ivas( Word16 *res, Tastat *s ); -#ifndef CLEANUP_VBR_CAM_ENC -void lsf_syn_mem_backup_ivas_fx( - Encoder_State *st_fx, /* i: state structure */ - Word16 *btilt_code_fx, /* i: tilt code Q15 */ - Word32 *gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *next_force_sf_bck_fx, /* o: */ - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ - Word16 *pstreaklen ); -#endif ivas_error config_acelp1_fx( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 578b5ff36..c69349c15 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -708,20 +708,10 @@ ivas_error acelp_core_enc_ivas_fx( Word32 int_fs; Word16 nb_bits; /* parameters handling */ -#ifndef CLEANUP_VBR_CAM_ENC - /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */ - Word16 pstreaklen; -#endif Word16 sid_bw = -1; move16(); -#ifndef CLEANUP_VBR_CAM_ENC - Word16 next_force_sf_bck; -#endif Word16 uc_two_stage_flag; Word16 position; -#ifndef CLEANUP_VBR_CAM_ENC - Word16 ppp_mode, nelp_mode; -#endif Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; /* bitstream */ @@ -736,22 +726,12 @@ ivas_error acelp_core_enc_ivas_fx( Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/ Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */ Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */ -#ifndef CLEANUP_VBR_CAM_ENC - Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M]; - Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2]; - Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx; -#endif set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ); set16_fx( old_exc_fx, 0, L_EXC ); set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) ); set16_fx( syn_fx, 0, L_FRAME16k ); -#ifndef CLEANUP_VBR_CAM_ENC - Word16 tilt_code_bck_fx; - Word32 gc_threshold_bck_fx; - Word16 clip_var_bck_fx[6]; -#endif Word32 q_env_fx[NUM_ENV_CNG]; set32_fx( q_env_fx, 0, NUM_ENV_CNG ); set16_fx( exc2_fx, 0, L_FRAME16k ); @@ -874,34 +854,6 @@ ivas_error acelp_core_enc_ivas_fx( position = -1; move16(); -#ifndef CLEANUP_VBR_CAM_ENC - /* SC-VBR temporary variables */ - pstreaklen = 0; - move16(); - clip_var_fx = 0; - move16(); - mem_w0_bck_fx = 0; - move16(); - streaklimit_fx = 0; - move16(); - - /* channel-aware mode */ - reset_rf_indices_fx( st ); - - /* VBR modes */ - IF( st->Opt_SC_VBR ) - { - ppp_mode = st->hSC_VBR->ppp_mode; - nelp_mode = st->hSC_VBR->nelp_mode; - } - ELSE - { - ppp_mode = 0; - nelp_mode = 0; - } - move16(); - move16(); -#endif test(); /* TD stereo */ @@ -1167,15 +1119,7 @@ ivas_error acelp_core_enc_ivas_fx( uc_two_stage_flag = 0; move16(); -#ifndef CLEANUP_VBR_CAM_ENC - test(); - IF( !nelp_mode && !ppp_mode ) - { -#endif config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); -#ifndef CLEANUP_VBR_CAM_ENC - } -#endif /*-----------------------------------------------------------------* * After inactive period, use the most up-to-date ISPs @@ -1212,10 +1156,6 @@ ivas_error acelp_core_enc_ivas_fx( * A[z] calculation *-----------------------------------------------------------------*/ -#ifndef CLEANUP_VBR_CAM_ENC - /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */ - lsf_syn_mem_backup_ivas_fx( st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen ); -#endif IF( !tdm_lp_reuse_flag ) { #ifdef HARM_LSF_ENC @@ -1341,13 +1281,6 @@ ivas_error acelp_core_enc_ivas_fx( encod_gen_2sbfr_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); } } -#ifndef CLEANUP_VBR_CAM_ENC - ELSE IF( nelp_mode ) - { - /* SC-VBR - NELP frames */ - encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); - } -#endif ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ @@ -1357,40 +1290,6 @@ ivas_error acelp_core_enc_ivas_fx( { encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); } -#ifndef CLEANUP_VBR_CAM_ENC - ELSE IF( ppp_mode ) - { - /* SC-VBR - PPP frames */ - IF( ( error = encod_ppp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( st->hSC_VBR->bump_up ) /* PPP failed, bump up */ - { - /* restore memories of LSF quantizer and synthesis filter */ - lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen ); - - /* Configure ACELP bit allocation */ - config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); - - /* redo LSF quantization */ -#ifdef HARM_LSF_ENC - lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new ); -#else - lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new ); -#endif - - /* recalculation of LP residual (filtering through A[z] filter) */ - calc_residu_fx( st, inp, res_fx, Aq ); - st->hTdCngEnc->burst_ho_cnt = 0; - move16(); - - /* VOICED frames in SC-VBR */ - encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); - } - } -#endif 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) */ @@ -1456,12 +1355,7 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); -#ifdef CLEANUP_VBR_CAM_ENC IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) -#else - test(); - IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) -#endif { /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */ Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new @@ -1525,13 +1419,7 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); -#ifdef CLEANUP_VBR_CAM_ENC IF( ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) -#else - test(); - test(); - IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) -#endif { st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); @@ -1542,12 +1430,7 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); -#ifdef CLEANUP_VBR_CAM_ENC IF( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) -#else - test(); - IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) -#endif { /* Apply a non linearity to the SHB excitation */ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc @@ -1626,17 +1509,6 @@ ivas_error acelp_core_enc_ivas_fx( } } -#ifndef CLEANUP_VBR_CAM_ENC - /* SC-VBR update of average data rate */ - IF( EQ_16( st->vad_flag, 1 ) ) - { - /* reset in case of bitrate switching in EVS */ - if ( st->hSC_VBR != NULL ) - { - update_average_rate_fx( st->hSC_VBR, st->core_brate ); - } - } -#endif pop_wmops(); return error; diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index 60bbab86c..5181a08ff 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -171,145 +171,3 @@ void encod_nelp_fx( return; } -#ifndef CLEANUP_VBR_CAM_ENC - -void encod_nelp_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *speech_fx, - /* i : input speech */ /* Q_new-1 */ - const Word16 Aw_fx[], - /* i : weighted A(z) unquantized for subframes */ /*exp(norm_s(Aw_fx[0])+1)*/ - const Word16 Aq_fx[], - /* i : 12k8 Lp coefficient */ /*exp(norm_s(Aw_fx[0])+1)*/ - Word16 *res_fx, - /* o : residual signal */ /* Q_new */ - Word16 *synth_fx, - /* o : core synthesis */ /* Q_new */ - Word16 *tmp_noise_fx, - /* o : long-term noise energy */ /* Q8 */ - Word16 *exc_fx, - /* i/o: current non-enhanced excitation */ /* Q_new */ - Word16 *exc2_fx, - /* i/o: current enhanced excitation */ /* Q_new */ - Word16 *pitch_buf_fx, - /* o : floating pitch values for each subframe */ /* Q6 */ - Word16 *voice_factors_fx, - /* o : voicing factors */ /* Q15 */ - Word16 *bwe_exc_fx, - /* o : excitation for SWB TBE */ /* Q_new */ - Word16 Q_new, - Word16 shift ) -{ - Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ - Word16 h1_fx[L_SUBFR]; /* Impulse response vector */ - Word16 exc_nelp_fx[L_FRAME]; - - Word16 i_subfr, j; - - const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */ - Word16 saved_Q_new = Q_new; - move16(); - - Word16 reduce_gains = 0; - move16(); - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - - test(); - IF( EQ_16( st_fx->bwidth, NB ) && GE_32( st_fx->input_Fs, 16000 ) ) - { - IF( hSC_VBR->last_nelp_mode == 0 ) - { - set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 ); - } - Scale_sig( hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER * 2, sub( Q_new, st_fx->prev_Q_new ) ); /* Q_new */ - - pz_filter_sp_fx( num_nelp_lp_fx, den_nelp_lp_fx, res_fx, res_fx, hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER, NELP_LP_ORDER, L_FRAME, 3 ); /*16-Q of filter coeff*/ - } - - p_Aw_fx = Aw_fx; - p_Aq_fx = Aq_fx; - - - FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) - { - /*----------------------------------------------------------------* - * - Bandwidth expansion of A(z) filter coefficients - * - Find the excitation search target "xn" and innovation - * target in residual domain "cn" - * - Compute impulse response, h1[], of weighted synthesis filter - *----------------------------------------------------------------*/ - Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx ); - - /* scale xn[] and h1[] to avoid overflow in dot_product12() */ - Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new-1+shift */ - - IF( i_subfr == 0 ) - { - test(); - IF( EQ_16( hSC_VBR->Local_VAD, 1 ) && EQ_16( st_fx->bwidth, NB ) ) - { - reduce_gains = 1; - move16(); - } - - nelp_encoder_ivas_fx( st_fx, res_fx, exc_nelp_fx, &Q_new, reduce_gains ); - - Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new */ - } - - - *tmp_noise_fx = 0; - move16(); - - /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. - * Update A(z) filters - *-----------------------------------------------------------------*/ - Syn_filt_s( 1, p_Aq_fx, M, &exc_nelp_fx[i_subfr], &synth_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); - - p_Aw_fx += ( M + 1 ); - p_Aq_fx += ( M + 1 ); - *pitch_buf_fx = L_SUBFR_Q6; /* Q6 */ - move16(); - - pitch_buf_fx++; - } - - Copy( exc_nelp_fx, exc_fx, L_FRAME ); /* Q_new */ - - /*-----------------------------------------------------------------* - * Updates: last value of new target is stored in mem_w0 - *-----------------------------------------------------------------*/ - - hLPDmem->mem_w0 = sub_sat( shr_sat( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); - move16(); /*Q_new-1 */ - hLPDmem->tilt_code = 0; - move16(); /* purely unvoiced */ - hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; - move16(); - - Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */ - - hSC_VBR->prev_ppp_gain_pit_fx = 0; - move16(); - - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */ - move16(); - - FOR( j = 1; j < 5; j++ ) - { - hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1]; /* Q14 */ - move16(); - } - interp_code_5over2_fx( exc2_fx, bwe_exc_fx, L_FRAME ); - set16_fx( voice_factors_fx, 0, NB_SUBFR16k ); - - return; -} -#endif diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 9b62baea5..5f0976604 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -233,187 +233,3 @@ ivas_error encod_ppp_fx( return error; } -#ifndef CLEANUP_VBR_CAM_ENC - -ivas_error encod_ppp_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q_new*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *synth_fx, /* o : core synthesis Q-1*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ - Word16 Q_new, - Word16 shift ) -{ - Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ - Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ - Word16 i_subfr; /* tmp variables */ - const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/ - - Word16 k; - Word16 p_Aq_old_fx[M + 1], excQ_ppp_fx[L_FRAME], p_Aq_curr_fx[M], pitch_fx[NB_SUBFR]; - Word16 LPC_de_old_fx[M + 1], LPC_de_curr_fx[M + 1]; - Word16 shift_wsp = add( Q_new, shift ); - Word16 rate_ctrl_fx; - Word16 saved_Q_new = Q_new; - move16(); - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - ivas_error error; - - error = IVAS_ERR_OK; - move16(); - rate_ctrl_fx = hSC_VBR->rate_control; - move16(); - - /*------------------------------------------------------------------* - * ACELP subframe loop - *------------------------------------------------------------------*/ - p_Aw_fx = Aw_fx; - p_Aq_fx = Aq_fx; - FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) - { - /*----------------------------------------------------------------* - * Bandwidth expansion of A(z) filter coefficients - * Find the the excitation search target "xn" and innovation - * target in residual domain "cn" - * Compute impulse response, h1[], of weighted synthesis filter - *----------------------------------------------------------------*/ - - Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx ); - - /* scale xn[] and h1[] to avoid overflow in dot_product12() */ - Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits */ - - /* call voiced encoder at this point */ - IF( i_subfr == 0 ) /* generate the L_FRAME exc */ - { - FOR( k = 0; k < M; k++ ) - { - p_Aq_curr_fx[k] = p_Aq_fx[k + ( 3 * ( M + 1 ) ) + 1]; /* Q12 */ - move16(); - } - - E_LPC_f_lsp_a_conversion( st_fx->lsp_old_fx, p_Aq_old_fx, M ); - deemph_lpc_fx( p_Aq_curr_fx, p_Aq_old_fx, LPC_de_curr_fx, LPC_de_old_fx, 1 ); - /* both outputs LPC_de_curr_fx and LPC_de_old_fx are in Q12 */ - - - /* last frame-end lpc and curr frame-end lpc */ - IF( ( error = ppp_voiced_encoder_fx( hBstr, hSC_VBR, st_fx->bwidth, st_fx->last_coder_type_raw, st_fx->old_pitch_buf_fx, res_fx, - excQ_ppp_fx, st_fx->pitch[1], LPC_de_old_fx, LPC_de_curr_fx, exc_fx, pitch_fx, Q_new ) ) != IVAS_ERR_OK ) - { - return error; - } - - Scale_sig( exc_fx, L_FRAME, sub( saved_Q_new, Q_new ) ); /* saved_Q_new */ - if ( EQ_16( hSC_VBR->bump_up, 1 ) ) - { - i_subfr = L_FRAME; - move16(); - } - } - - IF( NE_16( hSC_VBR->bump_up, 1 ) ) - { - /*-----------------------------------------------------------------* - * Gain clipping test to avoid unstable synthesis on frame erasure - * or in case of floating point encoder & fixed p. decoder - *-----------------------------------------------------------------*/ - gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); - - - /* run the above to maintain gain clipping memories */ - gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, hSC_VBR->prev_ppp_gain_pit_fx, st_fx->clip_var_fx ); - - - /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. - * Update A(z) filters - *-----------------------------------------------------------------*/ - - Syn_filt_s( 1, p_Aq_fx, M, &excQ_ppp_fx[i_subfr], &synth_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); - - - p_Aw_fx += ( M + 1 ); - p_Aq_fx += ( M + 1 ); - } - - } /* end of subframe loop */ - - IF( hSC_VBR->bump_up ) - { - /* PPP failed, bump up */ - hSC_VBR->ppp_mode = 0; - move16(); - st_fx->core_brate = ACELP_7k20; - move16(); - hSC_VBR->pppcountE = 0; - move16(); - - IF( hSC_VBR->set_ppp_generic ) - { - st_fx->coder_type = GENERIC; - move16(); - } - ELSE - { - st_fx->coder_type = VOICED; - move16(); - } - - /* We write signalling indices again only in case of bump_up */ - /* delete previous indices */ - reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); - /* signalling matrix (writing of signalling bits) */ - signalling_enc_fx( st_fx ); - } - ELSE - { - Copy( excQ_ppp_fx, exc_fx, L_FRAME ); /* Q_new */ - - /*-----------------------------------------------------------------* - * Updates: last value of new target is stored in mem_w0 - *-----------------------------------------------------------------*/ - - hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); /*Q_new-1 */ - - Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */ - - hLPDmem->dm_fx.prev_state = 2; - move16(); /*Q0 dispMem index 0 */ - hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; - move16(); /*Q14 dispMem index 2 */ - - FOR( k = 1; k < 5; k++ ) - { - hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1]; /* Q14 */ - move16(); - } - - hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx; /* Q15 */ - move16(); - Copy( pitch_fx, pitch_buf_fx, NB_SUBFR ); - pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1]; - - interp_code_5over2_fx( exc2_fx, bwe_exc, L_FRAME ); - set16_fx( voice_factors, 0, NB_SUBFR16k ); - } - - hSC_VBR->rate_control = rate_ctrl_fx; /* Q0 */ - move16(); - - set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 ); - - return error; -} -#endif diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 60e2b29fe..dbd6c9607 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -1032,739 +1032,3 @@ void nelp_encoder_fx( return; } -#ifndef CLEANUP_VBR_CAM_ENC - -void nelp_encoder_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ) -{ - Word16 i, j; - Word16 *ptr_fx = exc_fx; - Word16 lag = 25; /* to cover 25*9 + 31 */ - move16(); - Word16 sqrt_inv_lag = 6554; /* sqrt(1/lag) in Q15 */ - move16(); - Word16 sqrt_inv_lframe_lag = 5885; /* sqrt(1/(L_FRAME-lag*9)) */ - move16(); - Word16 Gains_fx[10], gain_fac_fx; - Word16 iG1_fx, iG2_fx[2]; - Word16 fid; - Word16 fdbck_fx; - Word32 var_dB_fx; - Word32 E1_fx = 0, EL1_fx = 0, EH1_fx = 0, E2_fx = 0, E3_fx = 0, EL2_fx = 0, EH2_fx = 0; - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - Word32 RL_fx = 0, RH_fx = 0; - move32(); - move32(); - Word16 R_fx = 0; - move16(); - Word16 filtRes_fx[L_FRAME]; - Word16 ptr_tmp_fx[L_FRAME]; - - Word16 qE1 = 0, qE2 = 0, qE3 = 0, qEL1 = 0, qEL2 = 0, qEH1 = 0, qEH2 = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - Word16 qIn = 0, qGain = 0, qf = 0, qf1 = 0, qNelpGain = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - Word16 exp1, exp2, tmp1, tmp2; - Word16 f_Noise, etmp, e_Noise; - Word16 max1 = 0; - move16(); - Word32 l_nelp_gain_mem; - Word32 Ltemp = 0, Ltemp1 = 0, L_tmp = 0, L_const_1; - move32(); - move32(); - move32(); - Word16 BP1_ORDER; - Word16 rf_flag; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - RF_ENC_HANDLE hRF = st_fx->hRF; - - rf_flag = st_fx->rf_mode; - move16(); - - test(); - if ( EQ_16( hSC_VBR->last_nelp_mode, 1 ) && NE_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - hSC_VBR->last_nelp_mode = 0; - move16(); - } - - qIn = *qIn1; - move16(); - test(); - IF( EQ_16( st_fx->bwidth, NB ) ) - { - IF( hSC_VBR->last_nelp_mode != 1 ) - { - BP1_ORDER = 7; - move16(); - set32_fx( hSC_VBR->bp1_filt_mem_nb_fx, 0, BP1_ORDER * 2 ); - hSC_VBR->qprevGain_fx = 0; - move16(); - } - } - ELSE IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) - { - IF( hSC_VBR->last_nelp_mode != 1 ) - { - BP1_ORDER = 4; - move16(); - set16_fx( hSC_VBR->bp1_filt_mem_wb_fx, 0, i_mult( BP1_ORDER, 2 ) ); - } - } - - IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) ) - { - test(); - IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) - { - set16_fx( hSC_VBR->shape1_filt_mem_fx, 0, 10 ); - set16_fx( hSC_VBR->shape2_filt_mem_fx, 0, 10 ); - set16_fx( hSC_VBR->shape3_filt_mem_fx, 0, 10 ); - set16_fx( hSC_VBR->txlpf1_filt1_mem_fx, 0, 10 ); - set16_fx( hSC_VBR->txlpf1_filt2_mem_fx, 0, 10 ); - set16_fx( hSC_VBR->txhpf1_filt1_mem_fx, 0, 10 ); - set16_fx( hSC_VBR->txhpf1_filt2_mem_fx, 0, 10 ); - hSC_VBR->qprevIn_fx = 0; - move16(); - hSC_VBR->qprevGain_fx = 0; - move16(); - } - } - - /* Start Unvoiced/NELP Processing */ - test(); - IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) - { - qE1 = qIn; - move16(); - E1_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ - } - - qE1 = shl( qE1, 1 ); - - qf = qIn; - move16(); - Scale_sig( hSC_VBR->txlpf1_filt1_mem_fx, 10, ( qf - hSC_VBR->qprevIn_fx ) ); - pz_filter_sp_fx( txlpf1_num_coef_fx, txlpf1_den_coef_fx, in_fx, filtRes_fx, hSC_VBR->txlpf1_filt1_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */ - - qEL1 = qf; - move16(); - EL1_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ - } - qEL1 = shl( qEL1, 1 ); - - qf = qIn; - move16(); - Scale_sig( hSC_VBR->txhpf1_filt1_mem_fx, 10, qf - hSC_VBR->qprevIn_fx ); - pz_filter_sp_fx( txhpf1_num_coef_fx, txhpf1_den_coef_fx, in_fx, filtRes_fx, hSC_VBR->txhpf1_filt1_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */ - hSC_VBR->qprevIn_fx = qf; - move16(); - - qEH1 = qf; - move16(); - EH1_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ - } - qEH1 = shl( qEH1, 1 ); - move16(); - } - - qGain = qIn; - move16(); - qGain = shl( qGain, 1 ); - - FOR( i = 0; i < 9; i++ ) - { - Ltemp = L_deposit_l( 0 ); - FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) - { - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ - } - - /*Gains[i] = (float) sqrt(Gains[i]/lag); */ - IF( Ltemp != 0 ) - { - exp1 = norm_l( Ltemp ); - tmp1 = extract_h( L_shl( Ltemp, exp1 ) ); /*2*qGain+exp1-16 */ - exp1 = sub( exp1, 30 - qGain ); /* */ - - tmp1 = div_s( 16384, tmp1 ); /*14-2*qGain-exp1+16 */ - L_tmp = L_deposit_h( tmp1 ); - L_tmp = Isqrt_lc( L_tmp, &exp1 ); - L_tmp = Mult_32_16( L_tmp, sqrt_inv_lag ); - Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); /*Q3 */ - } - Gains_fx[i] = round_fx_sat( Ltemp ); - move16(); - } - - - Ltemp = L_deposit_l( 0 ); - FOR( j = i_mult( i, lag ); j < L_FRAME; j++ ) - { - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ - } - - /*Gains[i] = (float) sqrt(Gains[i]/(L_FRAME-(lag*i))); */ - IF( Ltemp != 0 ) - { - exp1 = norm_l( Ltemp ); - tmp1 = extract_h( L_shl( Ltemp, exp1 ) ); - exp1 = sub( exp1, 30 - qGain ); /* */ - - tmp1 = div_s( 16384, tmp1 ); - L_tmp = L_deposit_h( tmp1 ); - L_tmp = Isqrt_lc( L_tmp, &exp1 ); - L_tmp = Mult_32_16( L_tmp, sqrt_inv_lframe_lag ); - Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); - } - - Gains_fx[i] = round_fx_sat( Ltemp ); - move16(); - - IF( EQ_16( reduce_gains, 1 ) ) - { - FOR( i = 0; i < 10; i++ ) - { - Gains_fx[i] = mult( Gains_fx[i], 19661 ); - move16(); - } - } - - - qGain = 3; - move16(); - IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) ) /* if prev frame was not NELP then init mem*/ - { - hSC_VBR->nelp_gain_mem_fx = Gains_fx[0]; - move16(); - qNelpGain = qGain; - move16(); - } - - /* tmp = (float) (20.0 * (log10 (Gains[0]) - log10 (st->nelp_gain_mem) ) ); */ - /* var_dB = tmp * tmp; */ - L_tmp = L_deposit_l( Gains_fx[0] ); - L_tmp = L_max( L_tmp, 1 ); - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = sub( sub( 30, exp2 ), qGain ); - tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*log(2) in Q13 format = Q0 format */ - /*tmp1 = round_fx(L_shl(Ltemp,12)); Q12 */ - - L_tmp = L_deposit_l( hSC_VBR->nelp_gain_mem_fx ); /*Q0 */ - L_tmp = L_max( L_tmp, 1 ); - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = sub( sub( 30, exp2 ), qNelpGain ); - tmp2 = Log2_norm_lc( L_tmp ); - Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */ - Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */ - Ltemp = Mult_32_16( Ltemp1, 20480 ); /*Q11 (20 in Q10) */ - L_tmp = L_shl( Ltemp, 12 ); /*Q23 */ - var_dB_fx = Mult_32_32( L_tmp, L_tmp ); /*Q15 */ - - FOR( i = 1; i < 10; i++ ) - { - L_tmp = L_deposit_l( Gains_fx[i] ); - L_tmp = L_max( L_tmp, 1 ); - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = sub( sub( 30, exp2 ), qGain ); - tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*log(2) in Q13 format = Q0 format */ - - L_tmp = L_deposit_l( Gains_fx[i - 1] ); /*Q0 */ - L_tmp = L_max( L_tmp, 1 ); - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = sub( sub( 30, exp2 ), qGain ); - tmp2 = Log2_norm_lc( L_tmp ); - Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */ - Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */ - Ltemp = Mult_32_16( Ltemp1, 20480 ); /*Q11 (20 in Q10) */ - L_tmp = L_shl( Ltemp, 12 ); /*Q23 */ - L_tmp = Mult_32_32( L_tmp, L_tmp ); /*Q15 */ - var_dB_fx = L_add( L_tmp, var_dB_fx ); /*Q15 */ - } - - IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) ) - { - /*var_dB *= 0.111f; */ - var_dB_fx = Mult_32_16( var_dB_fx, 3637 ); /*0.111 in Q15 */ - } - ELSE - { - /*var_dB *= 0.1f; */ - var_dB_fx = Mult_32_16( var_dB_fx, 3277 ); /*0.1 in Q15 */ - } - - max1 = 0; - move16(); - FOR( i = 0; i < 10; i++ ) - { - max1 = s_max( max1, abs_s( Gains_fx[i] ) ); - } - - qf = norm_s( max1 ); - test(); - IF( ( qf == 0 ) && ( max1 == 0 ) ) - { - qf = 15; - move16(); - } - qf = sub( qf, 1 ); - qGain = add( qGain, qf ); - - Scale_sig( Gains_fx, 10, qf ); - - L_tmp = L_sub( var_dB_fx, 655360 ); /* 20 in Q15 */ - Ltemp = L_shr_r( L_tmp, 2 ); /*Q15 */ - { - /*exp = pow(2, x*log2(e)) */ - L_tmp = Mult_32_16( Ltemp, 23637 ); /*15 + 14 -15 ->Q14 */ - L_tmp = L_shl( L_tmp, 2 ); /*Q16 */ - f_Noise = L_Extract_lc( L_tmp, &e_Noise ); /*Q16 */ - etmp = extract_l( Pow2( 14, f_Noise ) ); /* Put 14 as exponent */ - e_Noise = sub( e_Noise, 14 ); /* Retreive exponent of etmp */ - - - IF( e_Noise > 0 ) - { - L_tmp = L_shl_sat( etmp, e_Noise ); /* Result in Q30 */ - L_tmp = L_add_sat( 1, L_tmp ); - - - exp1 = norm_l( L_tmp ); - tmp1 = extract_h( L_shl( L_tmp, exp1 ) ); /*exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(exp1-16)-> 30+15-exp1 */ - fdbck_fx = mult( 26870, tmp1 ); /*45-exp1+15-15=>45-exp1 */ - fdbck_fx = shr_r( fdbck_fx, 14 ); - exp1 = sub( 31, exp1 ); - } - ELSE - { - L_tmp = L_shl( etmp, add( e_Noise, 14 ) ); /* Result in Q30 */ - L_tmp = L_add( 16384, L_tmp ); - - exp1 = norm_l( L_tmp ); - tmp1 = extract_h( L_shl( L_tmp, exp1 ) ); /*14+exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(14+exp1-16)-> 16+15-exp1 */ - fdbck_fx = mult( 26870, tmp1 ); /*31-exp1+15-15=>31-exp1 */ - exp1 = sub( 31, exp1 ); - } - } - - IF( EQ_16( exp1, 31 ) ) - { - L_const_1 = 0x7fffffff; - move32(); - } - ELSE - { - L_const_1 = L_shl( 1, exp1 ); - } - - l_nelp_gain_mem = L_deposit_l( hSC_VBR->nelp_gain_mem_fx ); - IF( NE_16( qNelpGain, qGain ) ) - { - l_nelp_gain_mem = L_shl( l_nelp_gain_mem, sub( qGain, qNelpGain ) ); - } - - FOR( i = 0; i < 10; i++ ) - { - /*Gains[i] = (float)((1.0f - fdbck) * Gains[i] + fdbck * st->nelp_gain_mem); */ - L_tmp = L_sub( L_const_1, L_deposit_l( fdbck_fx ) ); /*31-exp1 */ - L_tmp = Mult_32_16( L_tmp, Gains_fx[i] ); /*exp1+qGain-15=>exp1-15+qGain */ - Ltemp1 = Mult_32_16( l_nelp_gain_mem, fdbck_fx ); /*exp1+qGain-15 */ - L_tmp = L_add( L_tmp, Ltemp1 ); - L_tmp = L_shr_r( L_tmp, ( exp1 - 15 ) ); - Gains_fx[i] = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); - move16(); - l_nelp_gain_mem = L_tmp; - } - - hSC_VBR->nelp_gain_mem_fx = round_fx( L_shl( l_nelp_gain_mem, 16 ) ); - move16(); - - Scale_sig( &hSC_VBR->nelp_gain_mem_fx, 1, -qGain ); - Scale_sig( Gains_fx, 10, -qGain ); - qGain = 0; - move16(); - - quantize_uvg_fx( Gains_fx, &iG1_fx, iG2_fx, Gains_fx, st_fx->bwidth ); - - IF( EQ_16( rf_flag, 1 ) ) - { - hRF->rf_indx_nelp_iG1[0] = iG1_fx; - move16(); - hRF->rf_indx_nelp_iG2[0][0] = iG2_fx[0]; - move16(); - hRF->rf_indx_nelp_iG2[0][1] = iG2_fx[1]; - move16(); - } - ELSE - { - push_indice( hBstr, IND_IG1, iG1_fx, 5 ); - push_indice( hBstr, IND_IG2A, iG2_fx[0], 6 ); - push_indice( hBstr, IND_IG2B, iG2_fx[1], 6 ); - } - - test(); - IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) - { - gain_fac_fx = 19005; - move16(); /* 1.16f in Q14 */ - } - ELSE - { - gain_fac_fx = 22446; - move16(); /* 1.37f in Q14 */ - } - - /* Normalize Gains_fx[10] with headroom 4 */ - /* This fills up qGain with some new value */ - normalize_arr( Gains_fx, &qGain, 10, 4 ); - - generate_nelp_excitation_fx( &( hSC_VBR->nelp_enc_seed ), Gains_fx, ptr_fx, gain_fac_fx ); - test(); - IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) - { - BP1_ORDER = 4; - move16(); - Scale_sig( hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER * 2, qGain - hSC_VBR->qprevGain_fx ); /*qf-qAdj */ - pz_filter_sp_fx( bp1_num_coef_wb_fx, bp1_den_coef_wb_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER, BP1_ORDER, L_FRAME, 2 ); - Copy( ptr_tmp_fx, ptr_fx, L_FRAME ); - } - ELSE IF( EQ_16( st_fx->bwidth, NB ) ) - { - BP1_ORDER = 7; - move16(); - Scale_sig32( hSC_VBR->bp1_filt_mem_nb_fx, BP1_ORDER * 2, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_dp_fx( bp1_num_coef_nb_fx_order7, bp1_den_coef_nb_fx_order7, ptr_fx, ptr_tmp_fx, hSC_VBR->bp1_filt_mem_nb_fx, BP1_ORDER, BP1_ORDER, L_FRAME, ( sub( 16, BP1_COEF_NB_QF_ORDER7 ) ) ); - Copy( ptr_tmp_fx, ptr_fx, L_FRAME ); - - Scale_sig( ptr_fx, L_FRAME, -1 ); /* bring exc to qgain-1 */ - *qIn1 = sub( qGain, 1 ); /* use this temp only in the parent */ - } - - E3_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - E3_fx = L_mac_sat( E3_fx, ptr_fx[i], ptr_fx[i] ); /*Q1 */ - } - qE3 = add( shl( qGain, 1 ), 1 ); - - test(); - IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) - { - Scale_sig( hSC_VBR->shape1_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( shape1_num_coef_fx, shape1_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape1_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ - Copy( ptr_tmp_fx, ptr_fx, L_FRAME ); - - qf = qGain; - move16(); - E2_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - Ltemp = L_mult0( ptr_fx[i], ptr_fx[i] ); /*Q(2*qE2+1) */ - Ltemp = L_shr_r( Ltemp, 4 ); - E2_fx = L_add( E2_fx, Ltemp ); - } - qE2 = sub( shl( qf, 1 ), 4 ); - - test(); - IF( E1_fx == 0 ) - { - R_fx = 0; - move16(); - } - ELSE IF( ( E2_fx == 0 ) && ( E1_fx != 0 ) ) - { - exp1 = norm_l( E1_fx ); - tmp1 = extract_h( L_shl( E1_fx, exp1 ) ); /*qE1+exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(qE1+exp1-16)-> 30-qE1-exp1 */ - exp1 = sub( exp1, 30 - qE1 ); - - L_tmp = L_deposit_h( tmp1 ); - L_tmp = Isqrt_lc( L_tmp, &exp1 ); - Ltemp = L_shl( L_tmp, sub( exp1, 12 ) ); - R_fx = round_fx( Ltemp ); - } - ELSE - { - exp1 = norm_l( E1_fx ); - tmp1 = extract_h( L_shl( E1_fx, exp1 ) ); /*qE1+exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(qE1+exp1-16)-> 30-qE1-exp1 */ - L_tmp = Mult_32_16( E2_fx, tmp1 ); /*qE2+30-qE1-exp1-15=>15+qE2-qE1-exp1 */ - - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE1-exp1+exp2 */ - exp2 = add( 15, add( sub( sub( qE2, qE1 ), exp1 ), exp2 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */ - R_fx = round_fx( L_tmp ); - exp1 = sub( 8, exp2 ); - } - - FOR( i = 0; i < L_FRAME; i++ ) - { - Ltemp = L_mult0( R_fx, ptr_fx[i] ); - Ltemp = L_shr_r( Ltemp, exp1 ); - filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) ); - move16(); - } - - qf1 = qGain; - move16(); - Scale_sig( hSC_VBR->txlpf1_filt2_mem_fx, 10, ( qf1 - hSC_VBR->qprevGain_fx ) ); - - pz_filter_sp_fx( txlpf1_num_coef_fx, txlpf1_den_coef_fx, filtRes_fx, ptr_tmp_fx, hSC_VBR->txlpf1_filt2_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */ - Copy( ptr_tmp_fx, filtRes_fx, L_FRAME ); - - qEL2 = qf1; - move16(); - EL2_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - EL2_fx = L_mac0_sat( EL2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEL2) */ - } - qEL2 = shl( qEL2, 1 ); - - FOR( i = 0; i < L_FRAME; i++ ) - { - Ltemp = L_mult0( R_fx, ptr_fx[i] ); - Ltemp = L_shr_r( Ltemp, exp1 ); - filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) ); - move16(); - } - - qf = qGain; - move16(); - Scale_sig( hSC_VBR->txhpf1_filt2_mem_fx, 10, ( qf - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( txhpf1_num_coef_fx, txhpf1_den_coef_fx, filtRes_fx, ptr_tmp_fx, hSC_VBR->txhpf1_filt2_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */ - - Copy( ptr_tmp_fx, filtRes_fx, L_FRAME ); - - qEH2 = qf; - move16(); - EH2_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - EH2_fx = L_mac0_sat( EH2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH2) */ - } - qEH2 = shl( qEH2, 1 ); - IF( EL2_fx == 0 ) - { - exp2 = norm_l( EL1_fx ); - L_tmp = L_shl( EL1_fx, exp2 ); - exp2 = sub( sub( 30, exp2 ), qEL1 ); - tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ - tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ - RL_fx = L_mult0( tmp1, 10 ); - } - ELSE - { - exp1 = norm_l( EL2_fx ); - tmp1 = extract_h( L_shl( EL2_fx, exp1 ) ); /*qEL2+exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(qEL2+exp1-16)-> 30-qEL2-exp1 */ - L_tmp = Mult_32_16( EL1_fx, tmp1 ); /*qEL1+30-qEL2-exp1-15=>15+qE1-qEL2-exp1 */ - - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = sub( 30, add( sub( sub( add( 30, qEL1 ), qEL2 ), exp1 ), exp2 ) ); - tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ - tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ - RL_fx = L_mult0( tmp1, 10 ); - } - - IF( EH2_fx == 0 ) - { - exp2 = norm_l( EH2_fx ); - L_tmp = L_shl( EH2_fx, exp2 ); - exp2 = sub( sub( 30, exp2 ), qEH2 ); - tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ - tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ - RH_fx = L_mult0( tmp1, 10 ); - } - ELSE - { - exp1 = norm_l( EH2_fx ); - tmp1 = extract_h( L_shl( EH2_fx, exp1 ) ); /*qEH2+exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(qEH2+exp1-16)-> 30-qEH2-exp1 */ - L_tmp = Mult_32_16( EH1_fx, tmp1 ); /*15+qEH1-qEH2-exp1 */ - - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEH1-qEH2-exp1+exp2 */ - exp2 = sub( 30, add( 30, add( sub( sub( qEH1, qEH2 ), exp1 ), exp2 ) ) ); - tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ - tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ - RH_fx = L_mult0( tmp1, 10 ); - } - - fid = 0; - move16(); - IF( LT_32( RL_fx, -12288 ) ) /* -3 in Q12 */ - { - fid = 1; - move16(); - } - ELSE IF( LT_32( RH_fx, -12288 ) ) /* -3 in Q12 */ - { - fid = 2; - move16(); - } - - IF( rf_flag == 0 ) - { - - SWITCH( fid ) - { - case 1: - /* Update other filter memory */ - Scale_sig( hSC_VBR->shape3_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( shape3_num_coef_fx, shape3_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape3_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ - - /* filter the residual to desired shape */ - Scale_sig( hSC_VBR->shape2_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( shape2_num_coef_fx, shape2_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape2_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ - Copy( ptr_tmp_fx, ptr_fx, L_FRAME ); - - BREAK; - case 2: - /* Update other filter memory */ - Scale_sig( hSC_VBR->shape2_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( shape2_num_coef_fx, shape2_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape2_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ - - /* filter the residual to desired shape */ - Scale_sig( hSC_VBR->shape3_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( shape3_num_coef_fx, shape3_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape3_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ - - Copy( ptr_tmp_fx, ptr_fx, L_FRAME ); - - BREAK; - default: - Scale_sig( hSC_VBR->shape2_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( shape2_num_coef_fx, shape2_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape2_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ - - Scale_sig( hSC_VBR->shape3_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); - pz_filter_sp_fx( shape3_num_coef_fx, shape3_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape3_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ - - BREAK; - } - - qE2 = qGain; - move16(); - - E2_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME; i++ ) - { - Ltemp = L_mult0( ptr_fx[i], ptr_fx[i] ); /*Q(2*qE2+1) */ - Ltemp = L_shr_r( Ltemp, 4 ); - E2_fx = L_add( E2_fx, Ltemp ); - } - qE2 = sub( shl( qE2, 1 ), 4 ); - - test(); - IF( E3_fx == 0 ) - { - R_fx = 0; - move16(); - } - ELSE IF( ( E2_fx == 0 ) && ( E3_fx != 0 ) ) - { - exp1 = norm_l( E3_fx ); - tmp1 = extract_h( L_shl( E3_fx, exp1 ) ); /*qE3+exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(qE3+exp1-16)-> 30-qE3-exp1 */ - exp1 = sub( exp1, 30 - qE3 ); - - L_tmp = L_deposit_h( tmp1 ); - L_tmp = Isqrt_lc( L_tmp, &exp1 ); - Ltemp = L_shl( L_tmp, sub( exp1, 12 ) ); - R_fx = round_fx( Ltemp ); - } - ELSE - { - exp1 = norm_l( E3_fx ); - tmp1 = extract_h( L_shl( E3_fx, exp1 ) ); /*qE3+exp1-16 */ - tmp1 = div_s( 16384, tmp1 ); /*14-(qE3+exp1-16)-> 30-qE3-exp1 */ - L_tmp = Mult_32_16( E2_fx, tmp1 ); /*qE2+30-qE3-exp1-15=>15+qE2-qE3-exp1 */ - - exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE3-exp1+exp2 */ - exp2 = sub( 30, add( sub( sub( add( 15, qE2 ), qE3 ), exp1 ), exp2 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */ - R_fx = round_fx( L_tmp ); - exp1 = sub( sub( sub( 31, exp2 ), 16 ), 7 ); - } - - FOR( i = 0; i < L_FRAME; i++ ) - { - L_tmp = L_mult0( R_fx, ptr_fx[i] ); - L_tmp = L_shr_r( L_tmp, exp1 + 1 ); - ptr_fx[i] = round_fx( L_shl( L_tmp, 16 ) ); - move16(); - } - *qIn1 = sub( qGain, 1 ); - move16(); - } - - IF( EQ_16( rf_flag, 1 ) ) - { - hRF->rf_indx_nelp_fid[0] = fid; - move16(); - } - ELSE - { - push_indice( hBstr, IND_NELP_FID, fid, 2 ); - } - } - - hSC_VBR->qprevGain_fx = qGain; - move16(); - - IF( rf_flag == 0 ) - { - FOR( i = 0; i < L_FRAME; i++ ) - { - exc_fx[i] = ptr_fx[i]; - move16(); - } - } - - return; -} -#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2a6c28a27..f760723be 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1874,23 +1874,6 @@ void encod_nelp_fx( Word16 Q_new, Word16 shift ); -#ifndef CLEANUP_VBR_CAM_ENC -void encod_nelp_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *speech_fx, /* i : input speech Q_new-1 */ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes exp(norm_s(Aw_fx[0])+1)*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient exp(norm_s(Aw_fx[0])+1)*/ - Word16 *res_fx, /* o : residual signal Q_new */ - Word16 *synth_fx, /* o : core synthesis Q_new */ - Word16 *tmp_noise_fx, /* o : long-term noise energy Q8 */ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new */ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6 */ - Word16 *voice_factors_fx, /* o : voicing factors Q15 */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new */ - Word16 Q_new, - Word16 shift ); -#endif Word16 encod_tran_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ @@ -2033,22 +2016,6 @@ ivas_error encod_ppp_fx( const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ ); -#ifndef CLEANUP_VBR_CAM_ENC -ivas_error encod_ppp_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q_new*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *synth_fx, /* o : core synthesis Q-1*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ - Word16 Q_new, - Word16 shift ); -#endif void encod_gen_voic_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ -- GitLab From 55d7e4802679d8364712ef4894a7a8ed1315ccf3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:20:27 +0100 Subject: [PATCH 394/750] [cleanup] accept FIX_1454_FIX_STEREO_TO_FOA_JBM --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index df4dca23e..f3de7b9eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ -#define FIX_1454_FIX_STEREO_TO_FOA_JBM /* VA: issue 1454: fix buggy stereo to FOA in JBM */ #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()*/ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 996c637af..e8c5f634f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1859,11 +1859,7 @@ ivas_error ivas_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { -#ifdef FIX_1454_FIX_STEREO_TO_FOA_JBM ivas_stereo2sba_fx( p_tc_fx, p_output_fx, *nSamplesRendered ); -#else - ivas_stereo2sba_fx( p_output_fx, p_output_fx, *nSamplesRendered ); -#endif } } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) -- GitLab From a616f1e57cf5680d29896eddc95d7993b18a2f33 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:21:06 +0100 Subject: [PATCH 395/750] [cleanup] accept FIX_1461_CNG_BW_SWITCHING --- lib_com/options.h | 1 - lib_enc/ivas_cpe_enc_fx.c | 4 ---- lib_enc/ivas_stereo_dft_enc_fx.c | 2 -- 3 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f3de7b9eb..b1240136e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ -#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_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 7792f57d3..813cae04b 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -127,9 +127,7 @@ ivas_error ivas_cpe_enc_fx( Word16 old_wsp_fx[CPE_CHANNELS][L_WSP]; Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp; Word16 Q_new[CPE_CHANNELS] = { 0 }; -#ifdef FIX_1461_CNG_BW_SWITCHING Word16 NFFT_inner; -#endif move16(); move16(); Word16 q_com, shift, q_min, gb; @@ -1132,12 +1130,10 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) { /* Reconfigure DFT Stereo for inactive frames */ -#ifdef FIX_1461_CNG_BW_SWITCHING /* -- nbands may need to be updated here in case the bandwidth was changed due to inactive frames */ NFFT_inner = shl( inner_frame_tbl[sts[0]->bwidth], 1 ); hCPE->hStereoDft->nbands = stereo_dft_band_config_fx( hCPE->hStereoDft->band_limits, hCPE->hStereoDft->hConfig->band_res, NFFT_inner, ENC ); move16(); -#endif IF( EQ_32( sts[0]->core_brate, SID_2k40 ) ) { stereo_dft_config_fx( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 56dd1bab9..8f6c7663e 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -3849,7 +3849,6 @@ static void stereo_dft_enc_compute_prm_fx( hStereoDft->nrg_past_pos = ( pos + 1 ) % STEREO_DFT_NRG_PAST_LEN; move16(); -#ifdef FIX_1461_CNG_BW_SWITCHING /* Replicate last band for remaining bands in case the bandwidth is higher after SID/NODATA is considered */ FOR( i = hStereoDft->nbands; i < STEREO_DFT_BAND_MAX; i++ ) { @@ -3858,7 +3857,6 @@ static void stereo_dft_enc_compute_prm_fx( pSideGain[i] = pSideGain[i - 1]; move32(); } -#endif /*------------------------------------------------------------------* -- GitLab From 06e649d7e68381c8a757632271f430b111e583cc Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:21:45 +0100 Subject: [PATCH 396/750] [cleanup] accept FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES --- lib_com/options.h | 1 - lib_dec/fd_cng_dec_fx.c | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b1240136e..dc6590218 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ -#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_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 88748bcec..471600ca3 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1095,11 +1095,7 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { -#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES cngNoiseLevel[j] = L_shl_r( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#else - cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#endif move32(); } } @@ -1710,11 +1706,7 @@ void perform_noise_estimation_dec_ivas_fx( FOR( p = 0; p < npart; p++ ) { temp = L_shl( msPeriodog[p], q_shift ); -#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ -#else - msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ -#endif move32(); } } @@ -1792,11 +1784,7 @@ void perform_noise_estimation_dec_ivas_fx( L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) ); IF( LT_32( L_tmp, msNoiseEst[p] ) ) { -#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/ -#else - msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/ -#endif move32(); temp_q_msNoiseEst[p] = sub( add( hFdCngDec->msNoiseEst_exp, scale ), 15 ); move16(); @@ -1819,11 +1807,7 @@ void perform_noise_estimation_dec_ivas_fx( L_tmp = L_shr_sat( hFdCngDec->msPeriodog_ST_fx[p], sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_ST_exp ) ); /*Q31 - hFdCngDec->msPeriodog_ST_exp*/ IF( LT_32( L_tmp, msNoiseEst[p] ) ) { -#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ -#else - msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/ -#endif move32(); } } -- GitLab From 85f8fc0d3dccdfd27b81edc4e97cbb31c47d41d2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 08:23:02 -0500 Subject: [PATCH 397/750] add missing switch --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..bd6baedbc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,8 +123,8 @@ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ -#define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ - +#define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsolete CAM code from IVAS */ +#define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ -- GitLab From ae491916def8d938d732d2ad306e2e3b3c3dcd27 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:23:48 +0100 Subject: [PATCH 398/750] [cleanup] accept FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC --- lib_com/log2.c | 5 ----- lib_com/options.h | 1 - lib_enc/swb_pre_proc_fx.c | 2 -- 3 files changed, 8 deletions(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index ce6b821ea..6f398df1e 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -57,15 +57,10 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val { Word16 i, a; Word16 y; -#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC - if ( L_x <= 0 ) - L_x = L_deposit_h( 0x4000 ); -#else if ( L_x > 0 ) /* There are many cases in the code where L_x == 0 */ assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ L_x = L_max( L_x, 0x40000000 ); -#endif L_x = L_shr( L_x, 9 ); a = extract_l( L_x ); /* Extract b10-b24 of fraction */ a = lshr( a, 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index dc6590218..db62d3aa6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ -#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_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ #define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index ffdb1d454..04d546ffa 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,9 +1125,7 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } -#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC exp = norm_l( CldfbHB_fx ); -#endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); -- GitLab From b7780192f033c1f64dc20734aa9c3097a9fe0f0d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:25:21 +0100 Subject: [PATCH 399/750] [cleanup] accept FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE --- lib_com/ivas_pca_tools_fx.c | 8 ------ lib_com/options.h | 1 - lib_dec/bass_psfilter_fx.c | 4 --- lib_dec/ivas_stereo_cng_dec_fx.c | 25 ------------------- lib_dec/ivas_stereo_dft_dec_fx.c | 4 --- lib_dec/ivas_stereo_ica_dec_fx.c | 4 --- lib_enc/ivas_ism_param_enc_fx.c | 8 ------ lib_enc/ivas_stereo_td_enc_fx.c | 13 ---------- lib_enc/ivas_td_low_rate_enc_fx.c | 4 --- .../ivas_dirac_dec_binaural_functions_fx.c | 16 ------------ 10 files changed, 87 deletions(-) diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index a265a1496..854578bfa 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -1375,11 +1375,7 @@ void pca_enc_s3_fx( q_ang_2surv_fx( ph1_fx, n1, ph1_q_fx, ind1 ); -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE tmp = mac_r( L_mac( L_mult( q_fx[1], q_fx[1] ), q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ); // Q15 + Q15 - Q15 -> Q15 -#else - tmp = add( add( mult( q_fx[1], q_fx[1] ), mult( q_fx[2], q_fx[2] ) ), mult( q_fx[3], q_fx[3] ) ); // Q15 + Q15 - Q15 -> Q15 -#endif r_e = 0; move16(); r_fx = Sqrt16( tmp, &r_e ); @@ -1433,11 +1429,7 @@ void pca_enc_s3_fx( q_ang_2surv_fx( ph2_fx, n2[i], ph2_q_fx + 2 * i, ind2 + 2 * i ); } -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE r_fx = Sqrt16( mac_r( L_mult( q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ), &r_e ); -#else - r_fx = Sqrt16( add( mult( q_fx[2], q_fx[2] ), mult( q_fx[3], q_fx[3] ) ), &r_e ); -#endif v_fx = BASOP_Util_Divide1616_Scale( q_fx[2], r_fx, &v_e ); v_e = add( v_e, sub( 0, r_e ) ); diff --git a/lib_com/options.h b/lib_com/options.h index db62d3aa6..4512bbc76 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,7 +104,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */ #define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ #define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 29672d3e0..d2558f47c 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -1041,11 +1041,7 @@ Word16 res_bpf_adapt_ivas_fx( bpf_error_ratio = ONE_IN_Q14; // Q13 move16(); } -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE bpf_error_ratio = mac_r( L_mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ); -#else - bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); -#endif hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio; move16(); diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index d08b38852..7edb49a92 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -119,9 +119,7 @@ static void stereo_dft_generate_comfort_noise_fx( Word32 tmp32_1, tmp32_2; Word16 q_div, q_sqrt1, q_sqrt2, q_sqrt, sqrt_res; Word16 q_shift, q_shift_1, q_shift_2, min_q; -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE Word16 tmp16, tmp_p, tmp_s; -#endif hFdCngCom = st->hFdCngDec->hFdCngCom; push_wmops( "DFT_CNG" ); @@ -164,11 +162,7 @@ static void stereo_dft_generate_comfort_noise_fx( } ELSE { -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE hStereoDft->g_state_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), A_GFILT_FX, hStereoDft->g_state_fx[b] ); /* Q15 */ -#else - hStereoDft->g_state_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), mult( A_GFILT_FX, hStereoDft->g_state_fx[b] ) ); /* Q15 */ -#endif move16(); } @@ -195,21 +189,13 @@ static void stereo_dft_generate_comfort_noise_fx( } ELSE { -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ -#else - hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ -#endif move16(); } } ELSE { -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */ -#else - hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */ -#endif move16(); } } @@ -241,7 +227,6 @@ static void stereo_dft_generate_comfort_noise_fx( } LR_ratio = extract_h( tdm_ratio_tabl_fx[hStereoCng->last_tdm_idx] ); /* Q15 */ -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE tmp16 = shr( hStereoDft->g_state_fx[b], 2 ); tmp_p = add( ONE_IN_Q13, tmp16 ); tmp_s = sub( ONE_IN_Q13, tmp16 ); @@ -251,16 +236,6 @@ static void stereo_dft_generate_comfort_noise_fx( L_mac( L_mult( tmp_p, tmp_p ), gamma, tmp16 ), L_mac( L_mult( tmp_s, tmp_s ), gamma, tmp16 ), &c_e ); -#else - c = BASOP_Util_Divide3232_Scale( - L_add( L_mult( add( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ), - add( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ) ), - L_shr( L_mult( gamma, gamma ), 4 ) ), - L_add( L_mult( sub( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ), - sub( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ) ), - L_shr( L_mult( gamma, gamma ), 4 ) ), - &c_e ); -#endif q_sqrt = c_e; move16(); sqrt_res = Sqrt16( mult( c, hStereoCng->cm_fx[b] ), &q_sqrt ); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 491dcca1c..a8548e0f1 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -3719,11 +3719,7 @@ void stereo_dft_dec_sid_coh_fx( pred_fx = add( pred_fx, shl( mult( ( *pptr_fx++ ), cohBandq_fx[i] ), 2 ) ); /*q-13*/ } /* Weighted intra/inter-frame prediction */ -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE pred_fx = mac_r( L_mult( alpha_fx, pred_fx ), sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ); /*q-13*/ -#else - pred_fx = add( mult( alpha_fx, pred_fx ), mult( sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ) ); /*q-13*/ -#endif /* Read residual index from bitstream */ IF( LT_16( *nb_bits, nr_of_sid_stereo_bits ) ) /* If the bit limit is reached, res_index = 0 is assumed for remaining indices */ { diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index fc02a8ba4..5f39c179e 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -193,11 +193,7 @@ void stereo_tca_dec_fx( IF( currentNCShift != 0 ) { -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE currentNCShift = mac_r( L_mult( 19660 /* 0.6 in Q15 */, prevNCShift ), 13106 /* 0.4 in Q15 */, currentNCShift ); /* Q0 */ -#else - currentNCShift = add( mult( 19660 /* 0.6 in Q15 */, prevNCShift ), mult( 13106 /* 0.4 in Q15 */, currentNCShift ) ); /* Q0 */ -#endif } prevNCShift = hStereoTCA->interp_dec_prevNCShift; /* Q0 */ diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index f29313147..dbe3f541e 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -292,11 +292,7 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = L_add( tmp, 2 * EVS_PI_FX ); } -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ); // Q14 -#else - cardioid_left[i] = add( shr( alpha, 1 ), mult( sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ) ); // Q14 -#endif move16(); IF( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) @@ -304,11 +300,7 @@ void ivas_param_ism_stereo_dmx_fx( Word16 last_cardioid_right; last_cardioid_right = sub( ONE_IN_Q14 /* 1.0f in Q14 */, last_cardioid_left ); /* Smoothing */ -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE cardioid_left[i] = mac_r( L_mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), 8192 /* 0.25f in Q15 */, last_cardioid_left ); // Q14 -#else - cardioid_left[i] = add( mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), mult( 8192 /* 0.25f in Q15 */, last_cardioid_left ) ); // Q14 -#endif move16(); Word32 grad_32 = L_mult( sub( cardioid_left[i], last_cardioid_left ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ); /* Q14+Q16 = Q30 */ /* for the right cardioid, multiply with -1 */ /* Cardioids sum up to 1 */ diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index b26b688dc..ceaf24790 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -396,15 +396,9 @@ void tdm_configure_enc_fx( hStereoTD->tdm_use_IAWB_Ave_lpc = 0; /* Flag initialisation */ move16(); -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE sts[0]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx ); move16(); sts[1]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx ); -#else - sts[0]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), mult( 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx ) ); - move16(); - sts[1]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), mult( 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx ) ); -#endif move16(); test(); @@ -801,21 +795,14 @@ static void tdm_downmix_plain_ivas_fx( ) { Word16 i; -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE Word16 One_m_Ratio_fx16, ratio_L_fx16; One_m_Ratio_fx16 = extract_h( One_m_Ratio_fx ); ratio_L_fx16 = extract_h( ratio_L_fx ); -#endif FOR( i = start_index; i < end_index; i++ ) { -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE FR_Y_fx[i] = mac_r( L_mult( Right_in_fx[i], One_m_Ratio_fx16 ), Left_in_fx[i], ratio_L_fx16 ); LR_X_fx[i] = msu_r( L_mult( Left_in_fx[i], One_m_Ratio_fx16 ), Right_in_fx[i], ratio_L_fx16 ); -#else - FR_Y_fx[i] = add( mult( Right_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Left_in_fx[i], extract_h( ratio_L_fx ) ) ); - LR_X_fx[i] = sub( mult( Left_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Right_in_fx[i], extract_h( ratio_L_fx ) ) ); -#endif move16(); move16(); } diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 0abc63c3d..5eb5ae562 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -312,11 +312,7 @@ void encod_gen_2sbfr_fx( lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); /* update long-term pitch gain for speech/music classifier */ -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE st->hSpMusClas->lowrate_pitchGain = mac_r( L_mult( 29491, st->hSpMusClas->lowrate_pitchGain ), 3277 /*Q15*/, gain_pit ); // Q14 -#else - st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14 -#endif move16(); /*-----------------------------------------------------------------* diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 815c01c7b..46506a6a5 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2931,21 +2931,13 @@ static void ivas_dirac_dec_binaural_process_output_fx( { Word16 gain; /* Mixing using the formulated processing matrix M */ -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ); // Q11 -#else - gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ) ); // Q11 -#endif outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result move32(); move32(); -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ); // Q11 -#else - gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ) ); // Q11 -#endif // interpVal * hDiracDecBin->processMtxIm[chA][chB][bin]; outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result @@ -2956,11 +2948,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( LT_16( bin, max_band_decorr ) && LT_16( chB, 2 ) ) { -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ); // Q11 -#else - gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ) ); // Q11 -#endif // interpVal * hDiracDecBin->processMtxDecRe[chA][chB][bin]; outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result @@ -2968,11 +2956,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( move32(); move32(); -#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ); // Q11 -#else - gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ) ); // Q11 -#endif outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result move32(); -- GitLab From 9c8929f9e54000b340dc7a71a7ae0b6922fe9bb8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:26:09 +0100 Subject: [PATCH 400/750] [cleanup] accept FIX_2252_LP_CNG_STARTS_SID --- lib_com/options.h | 1 - lib_dec/decision_matrix_dec_fx.c | 2 -- lib_dec/init_dec_fx.c | 7 ------- lib_dec/ivas_decision_matrix_dec_fx.c | 2 -- 4 files changed, 12 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4512bbc76..3ddb84525 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,7 +104,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */ #define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index cddc16314..055f1325f 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -84,11 +84,9 @@ void decision_matrix_dec_fx( { st->L_frame = L_FRAME16k; move16(); -#ifdef FIX_2252_LP_CNG_STARTS_SID st->nb_subfr = NB_SUBFR16k; move16(); st->bwidth = s_max( st->bwidth, WB ); -#endif } } ELSE diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 933bfda72..716308bdd 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -91,7 +91,6 @@ ivas_error init_decoder_fx( move16(); st_fx->ini_frame = 0; move16(); -#ifdef FIX_2252_LP_CNG_STARTS_SID IF( st_fx->element_mode == EVS_MONO ) { st_fx->bwidth = NB; @@ -112,12 +111,6 @@ ivas_error init_decoder_fx( #endif move16(); } -#else - st_fx->bwidth = NB; - move16(); - st_fx->last_bwidth = NB; - move16(); -#endif st_fx->extl_brate = 0; move16(); diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index fadd9d008..d6f1f8f49 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -115,11 +115,9 @@ void ivas_decision_matrix_dec_fx( { st->L_frame = L_FRAME16k; move16(); -#ifdef FIX_2252_LP_CNG_STARTS_SID st->nb_subfr = NB_SUBFR16k; move16(); st->bwidth = s_max( st->bwidth, WB ); -#endif } ELSE { -- GitLab From 06cecdc441a70c03e4d039b403324830b3bcd14d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 15 Jan 2026 14:26:38 +0100 Subject: [PATCH 401/750] clang patch --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 8365436c2..0d99494dd 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6987,7 +6987,7 @@ static ivas_error renderIsmToSba( Word8 position_changed; Word16 ambiOrderOut; Word16 numOutChannels; - pan_vector_fx currentPanGains_fx = { 0 }; //Solve Clang-18 warnings + pan_vector_fx currentPanGains_fx = { 0 }; // Solve Clang-18 warnings ivas_error error; error = IVAS_ERR_OK; move32(); -- GitLab From 2f5925a9505a3491aecf50c9f13bc5b186a6ace7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:26:52 +0100 Subject: [PATCH 402/750] [cleanup] accept FIX_1381_BWD --- lib_com/options.h | 1 - lib_enc/bw_detect_fx.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3ddb84525..59b074d26 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,7 +104,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_1381_BWD /* VA: issue 1381: apply no hysteresis in BWD at higher bitrates also in mono MASA and OMASA */ #define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 37b79491a..2e04b986f 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -18,9 +18,7 @@ *-------------------------------------------------------------------*/ #define BWD_MIN_BRATE_WIDER_BW_MDCT IVAS_48k -#ifdef FIX_1381_BWD #define BWD_MIN_BRATE_WIDER_BW_MASA IVAS_48k -#endif #define BWD_MIN_BRATE_WIDER_BW_ISM IVAS_32k #define BWD_MAX_BRATE_WIDER_BW_MDCT IVAS_80k #define BWD_MAX_BRATE_WIDER_BW_ISM IVAS_64k @@ -77,17 +75,11 @@ void bw_detect_fx( test(); test(); test(); -#ifdef FIX_1381_BWD test(); test(); -#endif if ( st->ini_frame > 0 && ( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_MDCT ) || mct_on ) ) || -#ifdef FIX_1381_BWD ( st->is_ism_format && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_ISM ) ) || ( EQ_16( ivas_format, MASA_FORMAT ) && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_MASA ) ) ) ) -#else - ( EQ_16( ivas_format, ISM_FORMAT ) && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_ISM ) ) ) ) -#endif { bwd_count_wider_bw = BWD_COUNT_WIDER_BW_MDCT; move16(); -- GitLab From 7a19593357fcd0d274d6a3a87d3d8323cb2fb827 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:27:40 +0100 Subject: [PATCH 403/750] [cleanup] accept FIX_2285_CODE_DECODER_INIT_BW --- lib_com/options.h | 1 - lib_dec/init_dec_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 59b074d26..54457fc1b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,7 +104,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2285_CODE_DECODER_INIT_BW /* VA: basop issue 2285: fix core-decoder initialization bandwidth */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ #define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 716308bdd..52f977d59 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -100,15 +100,9 @@ ivas_error init_decoder_fx( } ELSE { -#ifdef FIX_2285_CODE_DECODER_INIT_BW st_fx->bwidth = WB; move16(); st_fx->last_bwidth = WB; -#else - st_fx->bwidth = NB; - move16(); - st_fx->last_bwidth = NB; -#endif move16(); } st_fx->extl_brate = 0; -- GitLab From ae82a1142812450ca7f30436675777769718e025 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:29:35 +0100 Subject: [PATCH 404/750] [cleanup] accept FIX_2297_SBA_SCALING_32KHZ --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 12 ------------ lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ---- 3 files changed, 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 54457fc1b..55a2c54af 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,7 +106,6 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ -#define FIX_2297_SBA_SCALING_32KHZ /* VA: basop issue 2297: Fix scaling factor before the SBA decoder for output_Fs = 32 or 16 */ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e8c5f634f..2104fc451 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -401,11 +401,7 @@ ivas_error ivas_dec_fx( move16(); FOR( i = 0; i < 2; i++ ) { -#ifdef FIX_2297_SBA_SCALING_32KHZ s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 ) /* Guard bits */; -#else - s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ -#endif } FOR( i = 0; i < 2; i++ ) { @@ -971,11 +967,7 @@ ivas_error ivas_dec_fx( move16(); FOR( i = 0; i < 2; i++ ) { -#ifdef FIX_2297_SBA_SCALING_32KHZ s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], output_frame ) - 11 /* Guard bits */ ); -#else - s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); -#endif } FOR( i = 0; i < 2; i++ ) { @@ -1452,11 +1444,7 @@ ivas_error ivas_dec_fx( move16(); FOR( i = 0; i < 2; i++ ) { -#ifdef FIX_2297_SBA_SCALING_32KHZ s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 /* Guard bits */ ); -#else - s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); -#endif } FOR( i = 0; i < 2; i++ ) { diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 37bc17138..5bb141207 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1285,11 +1285,7 @@ void ivas_sba_dirac_stereo_dec_fx( move16(); FOR( i = 0; i < CPE_CHANNELS; i++ ) { -#ifdef FIX_2297_SBA_SCALING_32KHZ s = s_min( s, L_norm_arr( output[i], output_frame ) - Q11 ) /* Guard bits */; -#else - s = s_min( s, L_norm_arr( output[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */ -#endif } FOR( i = 0; i < CPE_CHANNELS; i++ ) { -- GitLab From d3143b034262806b5d0f8bec4e11d5d2bda94602 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:30:52 +0100 Subject: [PATCH 405/750] [cleanup] accept OPT_2181_MATRIX_TRANSP_1_MUL --- lib_com/options.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 45 ------------------- 2 files changed, 46 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 55a2c54af..09e2691e7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,7 +118,6 @@ /* #################### Start BASOP optimization switches ############################ */ -#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ #define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ #define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 46506a6a5..04e609b9c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4360,25 +4360,16 @@ static void matrixTransp1Mul_fx( Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -#ifdef OPT_2181_MATRIX_TRANSP_1_MUL Word64 tmp64; Word16 common_lsh, q; q = add( add( q_A, q_B ), 1 ); common_lsh = sub( 63, q ); move16(); -#else - Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - Word64 tmp64_1, tmp64_2; - Word16 tmp16, q_common = 63; - move16(); -#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { -#ifdef OPT_2181_MATRIX_TRANSP_1_MUL tmp64 = W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ); tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bre_fx[1][chB] ); tmp64 = W_mac_32_32( tmp64, Aim_fx[0][chA], Bim_fx[0][chB] ); @@ -4392,30 +4383,6 @@ static void matrixTransp1Mul_fx( tmp_outIm_fx[chA][chB] = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); move64(); common_lsh = s_min( common_lsh, W_norm( tmp_outIm_fx[chA][chB] ) ); -#else - tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) - tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bim_fx[0][chB] ), Aim_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) - tmp_outRe_fx[chA][chB] = W_add( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 ) - move64(); - tmp16 = W_norm( tmp_outRe_fx[chA][chB] ); - tmp_outRe_fx[chA][chB] = W_shl( tmp_outRe_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) ) - move64(); - q_tmp_outRe_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) ); - move16(); - q_common = s_min( q_tmp_outRe_fx[chA][chB], q_common ); - - - tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), Are_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) - tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ), Aim_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) - tmp_outIm_fx[chA][chB] = W_sub( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 ) - move64(); - tmp16 = W_norm( tmp_outIm_fx[chA][chB] ); - tmp_outIm_fx[chA][chB] = W_shl( tmp_outIm_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) ) - move64(); - q_tmp_outIm_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) ); - move16(); - q_common = s_min( q_tmp_outIm_fx[chA][chB], q_common ); -#endif } } #ifdef OPT_2185_MATRIX_OUT_SCALING @@ -4425,30 +4392,18 @@ static void matrixTransp1Mul_fx( { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { -#ifdef OPT_2181_MATRIX_TRANSP_1_MUL outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], common_lsh ) ); move32(); outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], common_lsh ) ); move32(); -#else - outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], s_max( -63, sub( q_common, q_tmp_outRe_fx[chA][chB] ) ) ) ); - move32(); - outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], s_max( -63, sub( q_common, q_tmp_outIm_fx[chA][chB] ) ) ) ); - move32(); -#endif #ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, outRe_fx[chA][chB] ); not_zero = L_or( not_zero, outIm_fx[chA][chB] ); #endif } } -#ifdef OPT_2181_MATRIX_TRANSP_1_MUL *q_out = sub( add( q, common_lsh ), 32 ); move16(); -#else - *q_out = sub( q_common, 32 ); - move16(); -#endif #ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { -- GitLab From ed1d09090cef88761170cf657ce4f25ff5e451e9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:31:36 +0100 Subject: [PATCH 406/750] [cleanup] accept OPT_2182_MATRIX_SCALE_OPS --- lib_com/options.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 100 ------------------ 2 files changed, 101 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 09e2691e7..002635abc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,7 +118,6 @@ /* #################### Start BASOP optimization switches ############################ */ -#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ #define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 04e609b9c..c1f2d7026 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -117,17 +117,11 @@ static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaE static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_fx /*q_Ein*/, Word16 q_Ein, Word32 CinRe_fx /*q_Cin*/, Word32 CinIm_fx /*q_Cin*/, Word16 q_Cin, Word32 Eout1_fx /*q_Eout*/, Word32 Eout2_fx /*q_Eout*/, Word16 q_Eout, Word32 CoutRe_fx /*q_Cout*/, Word32 CoutIm_fx /*q_Cout*/, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*Q31*/, Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word16 *q_M, const Word16 regularizationFactor_fx /*Q14*/ ); -#ifdef OPT_2182_MATRIX_SCALE_OPS static void matrixScale_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A ); -#endif static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); -#ifdef OPT_2182_MATRIX_SCALE_OPS static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); -#else -static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 Ascale, Word32 Bscale, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); -#endif /*------------------------------------------------------------------------- @@ -2235,24 +2229,14 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } /* Make matrix multiplication M*Cx*M' to determine resulting covariance matrix of processing input with M */ -#ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( Mre_fx, Mim_fx, &q_M ); matrixScale_fx( CxRe_fx, CxIm_fx, &q_Cx ); -#endif matrixMul_fx( Mre_fx, Mim_fx, &q_M, CxRe_fx, CxIm_fx, &q_Cx, tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); -#ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); matrixTransp2Mul_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, resultMtxRe_fx, resultMtxIm_fx, &q_res ); -#else - matrixTransp2Mul_fx( - tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, - 1 /*int Ascale*/, - 0 /*int Bscale*/, - resultMtxRe_fx, resultMtxIm_fx, &q_res ); -#endif /* When below the frequency limit where decorrelation is applied, we inject the decorrelated * residual (or missing) signal component. The procedure is active when there are not enough independent @@ -4240,7 +4224,6 @@ static void matrixDiagMul_fx( return; } -#ifdef OPT_2182_MATRIX_SCALE_OPS static void matrixScale_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ @@ -4254,7 +4237,6 @@ static void matrixScale_fx( *q_A = add( *q_A, shift ); move16(); } -#endif static void matrixMul_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ @@ -4267,26 +4249,7 @@ static void matrixMul_fx( Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) { -#ifdef OPT_2182_MATRIX_SCALE_OPS - Word16 chA, chB; -#else Word16 chA, chB; - Word16 min_q_shift1, min_q_shift2; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); - - min_q_shift1 = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); - min_q_shift2 = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 ); - - scale_sig32( Are_fx[0], size, min_q_shift1 ); - scale_sig32( Aim_fx[0], size, min_q_shift1 ); - scale_sig32( Bre_fx[0], size, min_q_shift2 ); - scale_sig32( Bim_fx[0], size, min_q_shift2 ); - - *q_A = add( *q_A, min_q_shift1 ); - *q_B = add( *q_B, min_q_shift2 ); - move16(); - move16(); -#endif #ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; #endif @@ -4332,9 +4295,7 @@ static void matrixMul_fx( move16(); } #else -#ifdef OPT_2182_MATRIX_SCALE_OPS Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; -#endif if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { *q_out = Q31; @@ -4422,7 +4383,6 @@ static void matrixTransp1Mul_fx( return; } -#ifdef OPT_2182_MATRIX_SCALE_OPS static void matrixTransp2Mul_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ @@ -4433,47 +4393,9 @@ static void matrixTransp2Mul_fx( Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) -#else -static void matrixTransp2Mul_fx( - Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ - Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ - Word16 *q_A, - Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ - Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ - Word16 *q_B, - Word32 Ascale, - Word32 Bscale, - Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ - Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ - Word16 *q_out ) -#endif { -#ifdef OPT_2182_MATRIX_SCALE_OPS Word16 chA, chB; // Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; -#else - Word16 chA, chB; - Word16 min_q_shift; - Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; - - IF( Ascale == 1 ) - { - min_q_shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); - scale_sig32( Are_fx[0], size, min_q_shift ); - scale_sig32( Aim_fx[0], size, min_q_shift ); - *q_A = add( *q_A, min_q_shift ); - move16(); - } - - IF( Bscale == 1 ) - { - min_q_shift = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 ); - scale_sig32( Bre_fx[0], size, min_q_shift ); - scale_sig32( Bim_fx[0], size, min_q_shift ); - *q_B = add( *q_B, min_q_shift ); - move16(); - } -#endif #ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; #endif @@ -4518,9 +4440,7 @@ static void matrixTransp2Mul_fx( move16(); } #else -#ifdef OPT_2182_MATRIX_SCALE_OPS Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; -#endif if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { *q_out = Q31; @@ -5029,10 +4949,8 @@ static void formulate2x2MixingMatrix_fx( q_temp = sub( add( q_ky, q_GhatQ ), 31 ); /* A = Ky' * G_hat * Q * Kx (see publication) */ -#ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); matrixScale_fx( Kxre_fx, Kxim_fx, &q_Kx ); -#endif matrixMul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Kxre_fx, Kxim_fx, &q_Kx, Are_fx, Aim_fx, &q_A ); /* Find nearest orthonormal matrix P to A = Ky' * G_hat * Q * Kx @@ -5090,10 +5008,8 @@ static void formulate2x2MixingMatrix_fx( div_fx[0] = L_min( div_fx[0], thresh ); // q_div div_fx[1] = L_min( div_fx[1], thresh ); // q_div -#ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( Are_fx, Aim_fx, &q_A ); matrixScale_fx( Ure_fx, Uim_fx, &q_U ); -#endif matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp ); exp = L_norm_arr( div_fx, BINAURAL_CHANNELS ); @@ -5157,17 +5073,10 @@ static void formulate2x2MixingMatrix_fx( } } -#ifdef OPT_2182_MATRIX_SCALE_OPS matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ -#else - matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, - 0 /*int Ascale*/, - 0 /*int Bscale*/, - Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ -#endif /* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */ #if ( BINAURAL_CHANNELS != 2 ) @@ -5298,23 +5207,14 @@ static void formulate2x2MixingMatrix_fx( } } -#ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( KyRe_fx, KyIm_fx, &q_ky ); matrixScale_fx( Pre_fx, Pim_fx, &q_P ); -#endif matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp ); -#ifdef OPT_2182_MATRIX_SCALE_OPS matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, Mre_fx, Mim_fx, q_M ); -#else - matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, - 1 /*int Ascale*/, - 0 /*int Bscale*/, - Mre_fx, Mim_fx, q_M ); -#endif return; } -- GitLab From 537a1baf7be297fa3047b46f2585d25184892933 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:32:35 +0100 Subject: [PATCH 407/750] [cleanup] accept OPT_2185_MATRIX_OUT_SCALING --- lib_com/options.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 52 ------------------- 2 files changed, 53 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 002635abc..cb57e4f47 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,7 +118,6 @@ /* #################### Start BASOP optimization switches ############################ */ -#define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index c1f2d7026..1e685c703 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4184,9 +4184,7 @@ static void matrixDiagMul_fx( { Word16 chA, chB; -#ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; -#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4196,29 +4194,18 @@ static void matrixDiagMul_fx( imOut_fx[chA][chB] = Mpy_32_32( imIn_fx[chA][chB], D_fx[chB] ); move32(); move32(); -#ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, reOut_fx[chA][chB] ); not_zero = L_or( not_zero, imOut_fx[chA][chB] ); -#endif } } *q_Out = sub( add( q_In, q_D ), 31 ); move16(); -#ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { *q_Out = Q31; move16(); } -#else - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); - if ( L_and( is_zero_arr( reOut_fx[0], size ), is_zero_arr( imOut_fx[0], size ) ) ) - { - *q_Out = Q31; - move16(); - } -#endif return; @@ -4250,9 +4237,7 @@ static void matrixMul_fx( Word16 *q_out ) { Word16 chA, chB; -#ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; -#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4279,29 +4264,18 @@ static void matrixMul_fx( Are_fx[chA][1], Bim_fx[1][chB] ); move32(); #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ -#ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, outRe_fx[chA][chB] ); not_zero = L_or( not_zero, outIm_fx[chA][chB] ); -#endif } } *q_out = sub( add( *q_A, *q_B ), 31 ); move16(); -#ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { *q_out = Q31; move16(); } -#else - Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; - if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) - { - *q_out = Q31; - move16(); - } -#endif return; } @@ -4346,9 +4320,7 @@ static void matrixTransp1Mul_fx( common_lsh = s_min( common_lsh, W_norm( tmp_outIm_fx[chA][chB] ) ); } } -#ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; -#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) @@ -4357,28 +4329,17 @@ static void matrixTransp1Mul_fx( move32(); outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], common_lsh ) ); move32(); -#ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, outRe_fx[chA][chB] ); not_zero = L_or( not_zero, outIm_fx[chA][chB] ); -#endif } } *q_out = sub( add( q, common_lsh ), 32 ); move16(); -#ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { *q_out = Q31; move16(); } -#else - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); - if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) - { - *q_out = Q31; - move16(); - } -#endif return; } @@ -4396,9 +4357,7 @@ static void matrixTransp2Mul_fx( { Word16 chA, chB; // Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; -#ifdef OPT_2185_MATRIX_OUT_SCALING Word32 not_zero = 0; -#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) @@ -4424,29 +4383,18 @@ static void matrixTransp2Mul_fx( Are_fx[chA][1], Bim_fx[chB][1] ); move32(); #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ -#ifdef OPT_2185_MATRIX_OUT_SCALING not_zero = L_or( not_zero, outRe_fx[chA][chB] ); not_zero = L_or( not_zero, outIm_fx[chA][chB] ); -#endif } } *q_out = sub( add( *q_A, *q_B ), 31 ); move16(); -#ifdef OPT_2185_MATRIX_OUT_SCALING if ( !not_zero ) { *q_out = Q31; move16(); } -#else - Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; - if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) - { - *q_out = Q31; - move16(); - } -#endif return; } -- GitLab From f2fc635b6427ba9f3da8651d94d9d613d39cb539 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:34:36 +0100 Subject: [PATCH 408/750] [cleanup] accept BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST --- lib_com/options.h | 1 - lib_enc/ivas_mcmasa_enc_fx.c | 87 ------------------------------------ 2 files changed, 88 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index cb57e4f47..432de79da 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -120,7 +120,6 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ -#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ #define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 98451f773..b9e2f9757 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -69,7 +69,6 @@ static void ivas_mcmasa_dmx_fx( const Word16 nchan_transport, const Word16 nchan_inp ); -#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ @@ -79,16 +78,6 @@ static void compute_cov_mtx_fx( CovarianceMatrix pCOVls[MASA_FREQUENCY_BANDS], /* o : Output matrix, contains upper part of cov mtx */ Word16 inp_exp, /*Stores exponent for temp*/ Word16 *band_grouping ); -#else -static void compute_cov_mtx_fx( - Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] */ - Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] */ - const Word16 freq, /* i : Freq to process */ - const Word16 N, /* i : Number of channels */ - CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */ - Word16 inp_exp /*Stores exponent for temp*/ -); -#endif static void computeIntensityVector_enc_fx( const Word16 *band_grouping, @@ -928,11 +917,7 @@ void ivas_mcmasa_param_est_enc_fx( Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; -#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST Word16 mrange[2]; -#else - Word16 mrange[2], brange[2]; -#endif Word16 numSubFramesForRatio; CovarianceMatrix COVls[MASA_FREQUENCY_BANDS]; Word32 absCOVls_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; @@ -1077,7 +1062,6 @@ void ivas_mcmasa_param_est_enc_fx( } inp_q = add( inp_q, sf ); -#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix */ assert( mrange[1] - mrange[0] == 1 ); @@ -1099,28 +1083,6 @@ void ivas_mcmasa_param_est_enc_fx( hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] ); } } -#else - /* Compute covariance matrix */ - FOR( i = 0; i < num_freq_bands; i++ ) - { - brange[0] = hMcMasa->band_grouping[i]; - move16(); - brange[1] = hMcMasa->band_grouping[i + 1]; - move16(); - FOR( j = brange[0]; j < brange[1]; j++ ) - { - compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, j, numAnalysisChannels, &( COVls[i] ), sub( 31, inp_q ) ); - } - - - /* Store energies for guiding metadata encoding */ - FOR( j = 0; j < numAnalysisChannels; j++ ) - { - move32(); - hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] ); - } - } -#endif IF( !hMcMasa->separateChannelEnabled ) { @@ -2126,7 +2088,6 @@ static void ivas_mcmasa_dmx_fx( return; } -#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( @@ -2192,54 +2153,6 @@ static void compute_cov_mtx_fx( } -#else -/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ -static void compute_cov_mtx_fx( - Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ - Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] (inp_exp) */ - const Word16 freq, /* i : Freq to process */ - const Word16 N, /* i : Number of channels */ - CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */ - Word16 inp_exp /*Stores exponent for temp*/ -) -{ - Word16 i, j; - Word64 temp64_1, temp64_2; - Word16 tmp_16, max_exp; - Word16 temp_exp = shl( inp_exp, 1 ); - FOR( i = 0; i < N; i++ ) - { - FOR( j = i; j < N; j++ ) - { - temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp - temp64_2 = W_deposit32_h( COVls->xr_fx[i][j] ); // exp:COVls->xr_e[i][j] - max_exp = s_max( COVls->xr_e[i][j], temp_exp ); - temp64_2 = W_shl( temp64_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp - temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp - tmp_16 = W_norm( temp64_1 ); - - COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16 - COVls->xr_e[i][j] = sub( max_exp, tmp_16 ); - move32(); - move16(); - - temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp - temp64_2 = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j] - max_exp = s_max( COVls->xi_e[i][j], temp_exp ); - temp64_2 = W_shl( temp64_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp - temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp - tmp_16 = W_norm( temp64_1 ); - - COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16 - COVls->xi_e[i][j] = sub( max_exp, tmp_16 ); - move32(); - } - } - return; -} -#endif static void computeIntensityVector_enc_fx( const Word16 *band_grouping, -- GitLab From 66671fe3c2033c0bd710c14fbf65c9e9852b38e9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 15 Jan 2026 14:37:40 +0100 Subject: [PATCH 409/750] formatting --- apps/decoder.c | 32 +++++++++---------- lib_com/options.h | 6 ++-- lib_com/prot_fx.h | 6 ++-- lib_com/swb_tbe_com_fx.c | 10 +++--- lib_com/trans_direct_fx.c | 4 +-- lib_com/trans_inv_fx.c | 2 +- lib_dec/gain_dec_fx.c | 2 +- lib_dec/ivas_init_dec_fx.c | 2 +- lib_enc/acelp_core_enc_fx.c | 2 +- lib_enc/enc_acelpx_fx.c | 2 +- lib_enc/enc_gain_fx.c | 4 +-- lib_enc/ivas_mcmasa_enc_fx.c | 1 - lib_enc/ivas_omasa_enc_fx.c | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 8 ++--- lib_rend/ivas_hrtf_fx.c | 1 - lib_rend/lib_rend_fx.c | 2 +- 16 files changed, 42 insertions(+), 44 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0b8a1d018..65344333d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3857,31 +3857,31 @@ static ivas_error load_hrtf_from_file( } } - if ( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; - if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - return error; - } - - if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) + if ( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); + fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } - else + + if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) { - destroy_hrtf_statistics( hHrtfStatistics ); + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); + return error; + } + else + { + destroy_hrtf_statistics( hHrtfStatistics ); + } } } } -} -return IVAS_ERR_OK; + return IVAS_ERR_OK; } diff --git a/lib_com/options.h b/lib_com/options.h index 432de79da..301bee4d8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,9 +118,9 @@ /* #################### Start BASOP optimization switches ############################ */ -#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ -#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ -#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ +#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ +#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ +#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c44697586..708a5e211 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4788,8 +4788,8 @@ Word16 est_tilt_fx( const Word16 *code, /* i : algebraic exctitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ ); /* o : tilt of the code */ @@ -6784,7 +6784,7 @@ void gain_dec_lbr_fx( ); void lp_gain_updt_fx( - const Word16 element_mode, /* i : element mode */ + const Word16 element_mode, /* i : element mode */ const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 4d005d6b7..d65434759 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -392,7 +392,7 @@ void flip_and_downmix_generic_fx( { L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ - output[i] = round_fx( L_tmp ); /*Qx */ + output[i] = round_fx( L_tmp ); /*Qx */ move16(); i++; j++; @@ -512,7 +512,7 @@ void flip_and_downmix_generic_fx32( test(); L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ - output[i] = L_tmp; /*Qx */ + output[i] = L_tmp; /*Qx */ move32(); i++; j++; @@ -6035,7 +6035,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ #endif j = extract_l( L_shr( L_tmp, 23 ) ); @@ -6052,7 +6052,7 @@ void create_random_vector_fx( } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); @@ -6070,7 +6070,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c index fe526d372..c84cd9efa 100644 --- a/lib_com/trans_direct_fx.c +++ b/lib_com/trans_direct_fx.c @@ -82,8 +82,8 @@ void direct_transform_fx( wl_fx = wh_fx - 1; /*Q15*/ shift = extract_l( L_mult0( 3, segment_length4 ) ); /*Q0*/ - sh_fx = &in32_r16_fx[segment_length2]; /*Q*/ - sl_fx2 = sh_fx - 1; /*Q*/ + sh_fx = &in32_r16_fx[segment_length2]; /*Q*/ + sl_fx2 = sh_fx - 1; /*Q*/ FOR( i = 0; i < segment_length4; i++ ) diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 50e272bd7..34d424f26 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -1065,7 +1065,7 @@ void Inverse_Transform( /* This previous loop fills the output buffer from [seg_len_div4..seg_len-seg_len_div4-1] */ out_segment = &out_alias[segment_length_div4]; /*q_out*/ - in_segment += segment_length_div2; /*Q*/ + in_segment += segment_length_div2; /*Q*/ FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ ) { diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 8f75cdaa8..cd19197cd 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -991,7 +991,7 @@ void gain_dec_lbr_fx( /*=======================================================================*/ void lp_gain_updt_fx( - const Word16 element_mode, /* i : element mode */ + const Word16 element_mode, /* i : element mode */ const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index a5e28c136..b32406a20 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3555,7 +3555,7 @@ void ivas_destroy_dec_fx( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); -/* HRTF statistics */ + /* HRTF statistics */ ivas_HRTF_statistics_binary_close_fx( &st_ivas->hHrtfStatistics ); /* Config. Renderer */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index c69349c15..25928d3d2 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1119,7 +1119,7 @@ ivas_error acelp_core_enc_ivas_fx( uc_two_stage_flag = 0; move16(); - config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); /*-----------------------------------------------------------------* * After inactive period, use the most up-to-date ISPs diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index c03553898..a5b11f3b0 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -292,7 +292,7 @@ static void E_ACELP_1pulse_searchx_fx( /*alp0 = *alp + R[0]; INDIRECT(1);*/ ps0 = *ps; /* Qdn */ move16(); - alp0 = L_deposit_h( *alp ); /* Q22 */ + alp0 = L_deposit_h( *alp ); /* Q22 */ alp0 = L_mac_sat( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ /* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */ move16(); diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c index 5a8a08596..2e1a5019b 100644 --- a/lib_enc/enc_gain_fx.c +++ b/lib_enc/enc_gain_fx.c @@ -361,7 +361,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ IF( EQ_16( pit_res_max, 6 ) ) { cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ - fraction = frac1; /*Q0*/ + fraction = frac1; /*Q0*/ move16(); FOR( i = ( frac1 + step ); i <= frac2; i += step ) @@ -379,7 +379,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ ELSE { cor_max = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/ - fraction = frac1; /*Q0*/ + fraction = frac1; /*Q0*/ move16(); FOR( i = ( frac1 + step ); i <= frac2; i += step ) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index b9e2f9757..a33fa9094 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2153,7 +2153,6 @@ static void compute_cov_mtx_fx( } - static void computeIntensityVector_enc_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/ diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 0e1caa1f7..a0ea4e8cd 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1541,7 +1541,7 @@ static void ivas_omasa_dmx_fx( { g1 = interpolator[k]; move16(); - g2 = sub( MAX_WORD16, g1 ); /*q15*/ + g2 = sub( MAX_WORD16, g1 ); /*q15*/ data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_mac( L_mult( g1, gains[j] ), g2, prev_gains[i][j] ) /*q31*/, data_in[i][k] ) ); /*Qx*/ move32(); } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 1e685c703..24eab4297 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2916,8 +2916,8 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word16 gain; /* Mixing using the formulated processing matrix M */ gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ); // Q11 - outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result - outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result + outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result + outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result move32(); move32(); @@ -2941,8 +2941,8 @@ static void ivas_dirac_dec_binaural_process_output_fx( move32(); gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ); // Q11 - outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result - outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result + outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result + outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result move32(); move32(); } diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 8bce30d53..d240d64ef 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -476,4 +476,3 @@ void ivas_HRTF_statistics_binary_close_fx( return; } - diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 23c4ef0c4..101015fd0 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9934,7 +9934,7 @@ void IVAS_REND_Close( ivas_combined_orientation_close_fx( &hIvasRend->hCombinedOrientationData ); -/* Parametric binauralizer HRTF filters */ + /* Parametric binauralizer HRTF filters */ ivas_HRTF_td_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ); ivas_HRTF_CRend_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) ); ivas_HRTF_fastconv_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); -- GitLab From 9e56f466123c2b1b014494eff02d60c8ec0923b5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 08:57:02 -0500 Subject: [PATCH 410/750] add FIX_1478_UNINIT_ON_BFI to the harm code --- lib_com/gs_noisefill_fx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index c9c9a89ca..fd296e1a4 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1150,11 +1150,19 @@ void highband_exc_dct_in_ivas_fx( test(); IF( bfi || LT_32( core_brate, 6000 ) || ( LT_32( core_brate, 8600 ) && EQ_16( coder_type, UNVOICED ) ) ) { +#ifndef FIX_1478_UNINIT_ON_BFI set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */ +#else + set16_fx( noisepb, 13107, last_bin ); /*0.4 in Q15 */ +#endif } ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) || ( GSC_IVAS_mode > 0 && EQ_16( GSC_noisy_speech, 1 ) ) ) { +#ifndef FIX_1478_UNINIT_ON_BFI set16_fx( noisepb, 13107 /*0.4f*/, MBANDS_GN16k ); +#else + set16_fx( noisepb, 13107 /*0.4f*/, last_bin ); +#endif } ELSE { @@ -1171,7 +1179,11 @@ void highband_exc_dct_in_ivas_fx( IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) ) { +#ifndef FIX_1478_UNINIT_ON_BFI set16_fx( noisepb, 3277, MBANDS_GN ); +#else + set16_fx( noisepb, 3277, last_bin ); +#endif } test(); -- GitLab From d51b093cd572f7e3cfe7c91ec8c38f72b03f9c15 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jan 2026 15:56:41 +0100 Subject: [PATCH 411/750] fix FIX_2320_OOB_SCE_SWITCHING --- lib_com/options.h | 1 + lib_enc/ivas_corecoder_enc_reconfig_fx.c | 47 ++++++++++++++++++++++-- lib_enc/ivas_cpe_enc_fx.c | 16 +++++++- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..806e6261c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,6 +145,7 @@ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ +#define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 2efae00e2..c2763aa5b 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -227,6 +227,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx( Word16 q_com_cpe = Q15, q_com_cpe32 = Q31; move16(); move16(); +#ifdef FIX_2320_OOB_SCE_SWITCHING + Word16 len_fir = NS2SA_FX2( hEncoderConfig->input_Fs, DELAY_FIR_RESAMPL_NS ); +#endif IF( nSCE_old > 0 ) { FOR( k = 0; k < nSCE_old; k++ ) @@ -236,8 +239,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ); +#ifdef FIX_2320_OOB_SCE_SWITCHING + shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ) ), Q1 ); + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ +#else shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ +#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ); @@ -247,8 +255,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32, shift ); move16(); q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 ); +#ifdef FIX_2320_OOB_SCE_SWITCHING + shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, add( input_frame, len_fir ) ), Q1 ); + scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ +#else shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ +#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32, shift ); move16(); q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 ); @@ -267,8 +280,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ); +#ifdef FIX_2320_OOB_SCE_SWITCHING + shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ) ), Q1 ); + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ +#else shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ +#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ); @@ -278,8 +296,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32, shift ); move16(); q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 ); +#ifdef FIX_2320_OOB_SCE_SWITCHING + shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, add( input_frame, len_fir ) ), Q1 ); + scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ +#else shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ + scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ +#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32, shift ); move16(); q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 ); @@ -294,10 +317,18 @@ ivas_error ivas_corecoder_enc_reconfig_fx( scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com; move16(); - scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ +#ifdef FIX_2320_OOB_SCE_SWITCHING + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ +#else + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ +#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com; move16(); - Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ +#ifdef FIX_2320_OOB_SCE_SWITCHING + Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, add( shl( input_frame, 1 ), len_fir ), Q6 ); /* Q6 + q_com */ +#else + Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ +#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com ); st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( Q6, q_com ); move16(); @@ -314,10 +345,18 @@ ivas_error ivas_corecoder_enc_reconfig_fx( scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com; move16(); - scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ +#ifdef FIX_2320_OOB_SCE_SWITCHING + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ +#else + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ +#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com; move16(); +#ifdef FIX_2320_OOB_SCE_SWITCHING + Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, add( shl( input_frame, 1 ), len_fir ), Q6 ); /* Q6 + q_com */ +#else Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ +#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com ); st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( Q6, q_com ); move16(); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 7792f57d3..fd0a9b01a 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -437,10 +437,18 @@ ivas_error ivas_cpe_enc_fx( * Temporal inter-channel alignment, stereo adjustment *----------------------------------------------------------------*/ +#ifdef FIX_2320_OOB_SCE_SWITCHING + Word16 len_input_buff = add( shl( input_frame, 1 ), NS2SA_FX2( hEncoderConfig->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, len_input_buff ), L_norm_arr( sts[1]->input_buff32_fx, len_input_buff ) ); + q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); + scale_sig32( sts[1]->input_buff32_fx, len_input_buff, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ + scale_sig32( sts[0]->input_buff32_fx, len_input_buff, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ +#else shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ +#endif sts[0]->q_inp32 = sts[1]->q_inp32 = sts[0]->q_old_inp32 = sts[1]->q_old_inp32 = q_min; move16(); move16(); @@ -449,11 +457,17 @@ ivas_error ivas_cpe_enc_fx( stereo_tca_enc_fx( hCPE, input_frame ); +#ifdef FIX_2320_OOB_SCE_SWITCHING + shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, len_input_buff ), sts[0]->q_inp32 ), 16 ); + shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, len_input_buff ), sts[1]->q_inp32 ), 16 ) ); + Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, len_input_buff, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift + Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, len_input_buff, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift +#else shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) ); Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift - +#endif sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = shift; move16(); move16(); -- GitLab From f58f7608c19937c12b89857eca05f1bb0635a014 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jan 2026 16:07:10 +0100 Subject: [PATCH 412/750] simplification --- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 27 +++++++++++------------- lib_enc/ivas_cpe_enc_fx.c | 15 ++++++------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index c2763aa5b..76e388498 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -227,9 +227,6 @@ ivas_error ivas_corecoder_enc_reconfig_fx( Word16 q_com_cpe = Q15, q_com_cpe32 = Q31; move16(); move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING - Word16 len_fir = NS2SA_FX2( hEncoderConfig->input_Fs, DELAY_FIR_RESAMPL_NS ); -#endif IF( nSCE_old > 0 ) { FOR( k = 0; k < nSCE_old; k++ ) @@ -240,8 +237,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ); #ifdef FIX_2320_OOB_SCE_SWITCHING - shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ) ), Q1 ); - scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ + shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame ), Q1 ); + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ #else shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ @@ -256,8 +253,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 ); #ifdef FIX_2320_OOB_SCE_SWITCHING - shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, add( input_frame, len_fir ) ), Q1 ); - scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ + shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame ), Q1 ); + scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ #else shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ @@ -281,8 +278,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ); #ifdef FIX_2320_OOB_SCE_SWITCHING - shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ) ), Q1 ); - scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ + shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame ), Q1 ); + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ #else shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ @@ -297,8 +294,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 ); #ifdef FIX_2320_OOB_SCE_SWITCHING - shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, add( input_frame, len_fir ) ), Q1 ); - scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ + shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame ), Q1 ); + scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ #else shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ @@ -318,14 +315,14 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com; move16(); #ifdef FIX_2320_OOB_SCE_SWITCHING - scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ #else scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ #endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com; move16(); #ifdef FIX_2320_OOB_SCE_SWITCHING - Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, add( shl( input_frame, 1 ), len_fir ), Q6 ); /* Q6 + q_com */ + Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */ #else Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ #endif @@ -346,14 +343,14 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com; move16(); #ifdef FIX_2320_OOB_SCE_SWITCHING - scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ #else scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ #endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com; move16(); #ifdef FIX_2320_OOB_SCE_SWITCHING - Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, add( shl( input_frame, 1 ), len_fir ), Q6 ); /* Q6 + q_com */ + Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */ #else Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ #endif diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index fd0a9b01a..569a924f8 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -438,11 +438,10 @@ ivas_error ivas_cpe_enc_fx( *----------------------------------------------------------------*/ #ifdef FIX_2320_OOB_SCE_SWITCHING - Word16 len_input_buff = add( shl( input_frame, 1 ), NS2SA_FX2( hEncoderConfig->input_Fs, DELAY_FIR_RESAMPL_NS ) ); - shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, len_input_buff ), L_norm_arr( sts[1]->input_buff32_fx, len_input_buff ) ); + shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); - scale_sig32( sts[1]->input_buff32_fx, len_input_buff, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ - scale_sig32( sts[0]->input_buff32_fx, len_input_buff, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ + scale_sig32( sts[1]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ + scale_sig32( sts[0]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ #else shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); @@ -458,10 +457,10 @@ ivas_error ivas_cpe_enc_fx( stereo_tca_enc_fx( hCPE, input_frame ); #ifdef FIX_2320_OOB_SCE_SWITCHING - shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, len_input_buff ), sts[0]->q_inp32 ), 16 ); - shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, len_input_buff ), sts[1]->q_inp32 ), 16 ) ); - Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, len_input_buff, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift - Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, len_input_buff, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift + shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), sts[0]->q_inp32 ), 16 ); + shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ), sts[1]->q_inp32 ), 16 ) ); + Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift + Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift #else shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) ); -- GitLab From d9eff1b9d35ab9a7b81dffc090c34d8f5a143d7c Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jan 2026 16:21:42 +0100 Subject: [PATCH 413/750] fix FIX_2318_CLANG_DECODER --- apps/decoder.c | 3 +++ lib_com/options.h | 1 + 2 files changed, 4 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 65344333d..38face83f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -913,6 +913,9 @@ static bool parseCmdlIVAS_dec( arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->non_diegetic_pan_enabled = false; arg->non_diegetic_pan_gain = 0.f; +#ifdef FIX_2318_CLANG_DECODER + arg->non_diegetic_pan_gain_fx = 0; +#endif arg->tsmEnabled = false; arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; arg->aeSequence.count = 0; diff --git a/lib_com/options.h b/lib_com/options.h index 301bee4d8..78d83c6f8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,6 +97,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ /* #################### End BE switches ################################## */ -- GitLab From 79f3351a1eadf6c0a051cfca49b686199cd1ddae Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 10:22:00 -0500 Subject: [PATCH 414/750] remove IVAS version of comp_and_apply --- lib_com/gs_gains_fx.c | 3 ++- lib_com/gs_noisefill_fx.c | 8 +++++--- lib_com/options.h | 2 +- lib_com/prot_fx.h | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 55ced4ea0..c8c6a1f2f 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -136,6 +136,7 @@ void Comp_and_apply_gain_fx( return; } +#ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ @@ -234,7 +235,7 @@ void Comp_and_apply_gain_ivas_fx( return; } - +#endif /*========================================================================*/ /* FUNCTION : Ener_per_band_comp_fx() */ diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index c9c9a89ca..33ca81ebe 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1352,9 +1352,10 @@ void highband_exc_dct_in_ivas_fx( move16(); } } - +#ifndef FIX_2338_HARM_GSC_GAIN_COMP IF( EQ_16( element_mode, EVS_MONO ) ) { +#endif Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); IF( exc_wo_nf != NULL ) @@ -1362,6 +1363,7 @@ void highband_exc_dct_in_ivas_fx( Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } +#ifndef FIX_2338_HARM_GSC_GAIN_COMP } ELSE { @@ -1369,7 +1371,7 @@ void highband_exc_dct_in_ivas_fx( move16(); Word16 Q_old = *Q_exc; move16(); - Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); + Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); FIX_2338_HARM_GSC_GAIN_COMP IF( exc_wo_nf != NULL ) { @@ -1392,7 +1394,7 @@ void highband_exc_dct_in_ivas_fx( Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); } } - +#endif /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..cc6e63ec6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,7 +145,7 @@ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ - +#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 588617196..4ca9e13f6 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1764,7 +1764,7 @@ void Comp_and_apply_gain_fx( const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 Q_exc ); - +#ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ @@ -1773,7 +1773,7 @@ void Comp_and_apply_gain_ivas_fx( const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 *Q_exc ); - +#endif void pre_echo_att_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*/ -- GitLab From cbe1ea06f96af9383b8ce606b66f546b32d0c886 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jan 2026 16:52:42 +0100 Subject: [PATCH 415/750] clang-format --- lib_com/gs_gains_fx.c | 2 +- lib_com/options.h | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8057d2a22..57e6a2690 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1271,7 +1271,7 @@ Word16 gsc_gaindec_fx( /*----------------------------------------------------------------------* * Copy the true Q values in the specific bands *----------------------------------------------------------------------*/ - + y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/ move16(); y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/ diff --git a/lib_com/options.h b/lib_com/options.h index 0645ff282..583a9d0dc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,6 +97,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ /* #################### End BE switches ################################## */ @@ -110,22 +111,20 @@ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ +#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ +#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ /* ##################### End NON-BE switches ########################### */ -/* ################## End MAINTENANCE switches ######################### */ - -/* clang-format on */ - /* #################### Start BASOP optimization switches ############################ */ -#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ -#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ -#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ -#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ +#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ +#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ /* #################### End BASOP optimization switches ############################ */ +/* ################## End MAINTENANCE switches ######################### */ + +/* clang-format on */ #endif -- GitLab From ec27c09b8d01fb2a2b279a90fbe3c8adc3d7b8f4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jan 2026 16:58:48 +0100 Subject: [PATCH 416/750] clang-format --- lib_dec/acelp_core_switch_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index a16143727..d2353fd73 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -878,7 +878,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ); cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn ); - + Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 ); cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn ); } -- GitLab From e0b0a2f79795ec4fc91e164a18a22debeecdc173 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 12:44:31 -0500 Subject: [PATCH 417/750] fix clang-format issue --- lib_com/gs_noisefill_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 33ca81ebe..ddb7980b7 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1371,7 +1371,8 @@ void highband_exc_dct_in_ivas_fx( move16(); Word16 Q_old = *Q_exc; move16(); - Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); FIX_2338_HARM_GSC_GAIN_COMP + Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); + FIX_2338_HARM_GSC_GAIN_COMP IF( exc_wo_nf != NULL ) { -- GitLab From 181180dd8e4ff803c80b149222f2c415598d7979 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jan 2026 18:47:16 +0100 Subject: [PATCH 418/750] optimization --- lib_enc/ivas_cpe_enc_fx.c | 48 ++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 010d1e2e2..842c4be34 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -130,7 +130,10 @@ ivas_error ivas_cpe_enc_fx( Word16 NFFT_inner; move16(); move16(); - Word16 q_com, shift, q_min, gb; +#ifdef FIX_2320_OOB_SCE_SWITCHING + Word16 input_frame_2; +#endif + Word16 i, j, q_com, shift, q_min, gb; error = IVAS_ERR_OK; move32(); @@ -156,6 +159,9 @@ ivas_error ivas_cpe_enc_fx( * Initialization - general *-----------------------------------------------------------------*/ +#ifdef FIX_2320_OOB_SCE_SWITCHING + input_frame_2 = shl( input_frame, 1 ); +#endif set16_fx( q_re_im_buf, 0, CPE_CHANNELS ); tdm_SM_or_LRTD_Pri = 0; @@ -178,7 +184,7 @@ ivas_error ivas_cpe_enc_fx( set16_fx( voicing_fr_fx[0], 0, NB_SUBFR ); set16_fx( voicing_fr_fx[1], 0, NB_SUBFR ); - FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) { set16_zero_fx( fft_buff_fx[i], 2 * L_FFT ); set16_zero_fx( old_inp_16k_16fx[i], L_INP ); @@ -252,9 +258,9 @@ ivas_error ivas_cpe_enc_fx( move16(); } - FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) { - FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { set_zero_fx( realBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX ); set_zero_fx( imagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX ); @@ -408,8 +414,13 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB ); +#ifdef FIX_2320_OOB_SCE_SWITCHING + shift = L_norm_arr( sts[1]->old_input_signal32_fx, input_frame_2 ); + shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, input_frame_2 ) ); +#else shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) ); shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) ); +#endif IF( LT_16( shift, gb ) ) { @@ -436,10 +447,10 @@ ivas_error ivas_cpe_enc_fx( *----------------------------------------------------------------*/ #ifdef FIX_2320_OOB_SCE_SWITCHING - shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ) ); + shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); - scale_sig32( sts[1]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ - scale_sig32( sts[0]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ + scale_sig32( sts[1]->input_buff32_fx, input_frame_2, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ + scale_sig32( sts[0]->input_buff32_fx, input_frame_2, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ #else shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); @@ -455,10 +466,10 @@ ivas_error ivas_cpe_enc_fx( stereo_tca_enc_fx( hCPE, input_frame ); #ifdef FIX_2320_OOB_SCE_SWITCHING - shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), sts[0]->q_inp32 ), 16 ); - shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ), sts[1]->q_inp32 ), 16 ) ); - Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift - Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift + shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), sts[0]->q_inp32 ), 16 ); + shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ), sts[1]->q_inp32 ), 16 ) ); + Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift + Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift #else shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) ); @@ -728,12 +739,9 @@ ivas_error ivas_cpe_enc_fx( move16(); /* Determine the energy ratio between the 2 channels */ - tdm_ratio_idx = stereo_tdm_ener_analysis_fx( - ivas_format, - hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */ + tdm_ratio_idx = stereo_tdm_ener_analysis_fx( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */ /* Compute the downmix signal based on the ratio index */ - Word16 tdm_SM_flag; IF( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) { @@ -855,11 +863,19 @@ ivas_error ivas_cpe_enc_fx( // Normalise the input buffer from Q15 Word16 input_norm, q_inp; //, common_q, fir_delay_len; +#ifdef FIX_2320_OOB_SCE_SWITCHING + input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, input_frame_2 ); +#else input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) ); +#endif q_inp = sub( add( Q15, input_norm ), 16 ); // Rescale the old input, input and FIR delay section of input buffer +#ifdef FIX_2320_OOB_SCE_SWITCHING + Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, input_frame_2, sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp +#else Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp +#endif // Update the Q-factors sts[0]->q_inp = q_inp; @@ -1207,7 +1223,7 @@ ivas_error ivas_cpe_enc_fx( } } - FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) + FOR( i = 0; i < CPE_CHANNELS; i++ ) { Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 ); // Q(-1) -> Q15 } -- GitLab From 7f57cc0f445362c5329d56a1e5db570cac4d2065 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 13:59:44 -0500 Subject: [PATCH 419/750] fix --- lib_com/gs_noisefill_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index ddb7980b7..f7de75348 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1372,7 +1372,6 @@ void highband_exc_dct_in_ivas_fx( Word16 Q_old = *Q_exc; move16(); Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); - FIX_2338_HARM_GSC_GAIN_COMP IF( exc_wo_nf != NULL ) { -- GitLab From a7a6d7902699a44738ae13ff6c4b7b82244733e1 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 13:59:55 -0500 Subject: [PATCH 420/750] fix --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2c470dc81..b7d351596 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,7 @@ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ -#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +/*#define FIX_2338_HARM_GSC_GAIN_COMP*/ /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ -- GitLab From ce81a6d36a9fece60b775eb29d1c1b89ac67be4b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 15:00:09 -0500 Subject: [PATCH 421/750] fix --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b7d351596..2c470dc81 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,7 @@ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ -/*#define FIX_2338_HARM_GSC_GAIN_COMP*/ /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ -- GitLab From f3c5c278e75ee194381d8041d2cda75f580c4701 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 09:45:39 +0200 Subject: [PATCH 422/750] Fix basop issue 2333 by adding a missing free --- lib_com/options.h | 1 + lib_rend/ivas_mcmasa_ana_fx.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a884d61ec..d48194109 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,6 +100,7 @@ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ +#define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index b2a4e0d00..54a8f485e 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -431,6 +431,17 @@ void ivas_mcmasa_ana_close( free( ( *hMcMasa )->direction_vector_m_fx[i] ); ( *hMcMasa )->direction_vector_m_fx[i] = NULL; +#ifdef FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK + + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + free( ( *hMcMasa )->direction_vector_e[i][j] ); + ( *hMcMasa )->direction_vector_e[i][j] = NULL; + } + + free( ( *hMcMasa )->direction_vector_e[i] ); + ( *hMcMasa )->direction_vector_e[i] = NULL; +#endif } FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) -- GitLab From 9f78f55e851d83c17a0b72a41369f3d48a190c54 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 09:39:44 +0100 Subject: [PATCH 423/750] fix build --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 6 +----- lib_enc/ivas_cpe_enc_fx.c | 11 +++-------- lib_enc/ivas_ism_enc_fx.c | 11 +++-------- lib_enc/ivas_sce_enc_fx.c | 12 ++++-------- 5 files changed, 12 insertions(+), 30 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7b1a94c61..ec26cdf06 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6005,7 +6005,7 @@ ivas_error pre_proc_front_ivas_fx( const Word16 lf_E_LR_fx_q, /* i : Q factor of per bin spectrum energy in lf, LR channels */ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN band_energies_LR_fx_q*/ - const Word16 band_energies_LR_fx_q, /* o : Q facttors of energy in critical bands without minimum noise floor */ + const Word16 band_energies_LR_fx_q, /* o : Q factors of energy in critical bands without minimum noise floor */ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 88d57bdaa..d17b4d358 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -120,7 +120,7 @@ ivas_error pre_proc_front_ivas_fx( const Word16 lf_E_LR_fx_q, /* i : Q factor of per bin spectrum energy in lf, LR channels */ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN band_energies_LR_fx_q*/ - const Word16 band_energies_LR_fx_q, /* o : Q facttors of energy in critical bands without minimum noise floor */ + const Word16 band_energies_LR_fx_q, /* o : Q factors of energy in critical bands without minimum noise floor */ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ @@ -208,10 +208,6 @@ ivas_error pre_proc_front_ivas_fx( Word16 Qfact_PS, q_lf_E_fx; Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX]; Word32 bckr_temp[NB_BANDS]; -#ifdef DEBUG_MODE_INFO - Word32 *in_buff_temp; - Word16 in_q_temp; -#endif #ifndef HARM_PREPROC mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 813cae04b..f0ba8fc26 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -923,18 +923,13 @@ ivas_error ivas_cpe_enc_fx( &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, - band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] -#ifdef DEBUG_MODE_INFO - , - ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) -#endif - ); - e_old_wsp[n] = sub( Q15, q_old_wsp ); - move16(); + band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); IF( error != IVAS_ERR_OK ) { return error; } + e_old_wsp[n] = sub( Q15, q_old_wsp ); + move16(); } /*making Q common*/ diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 6a1d1e676..be2e223f3 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -252,18 +252,13 @@ ivas_error ivas_ism_enc_fx( error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] -#ifdef DEBUG_MODE_INFO - , - st->id_element -#endif - ); - e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); - move16(); + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); IF( error != IVAS_ERR_OK ) { return error; } + e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); + move16(); IF( st_ivas->hEncoderConfig->Opt_DTX_ON ) { diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 2457fef6e..144e86643 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -245,6 +245,7 @@ ivas_error ivas_sce_enc_fx( /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ + set16_fx( old_wsp_fx[0], 0, L_WSP ); q_old_wsp = Q15; move16(); @@ -254,18 +255,13 @@ ivas_error ivas_sce_enc_fx( &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] -#ifdef DEBUG_MODE_INFO - , - st->id_element -#endif - ); - e_old_wsp[0] = sub( Q15, q_old_wsp ); - move16(); + st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } + e_old_wsp[0] = sub( Q15, q_old_wsp ); + move16(); /* sanity check -> DTX not supported for more than one SCEs/CPEs */ IF( sub( add( st_ivas->nSCE, st_ivas->nCPE ), 1 ) > 0 ) -- GitLab From 27be50e0717a2dd3fbbdbca5df22de11f372db5f Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 11:02:10 +0200 Subject: [PATCH 424/750] Fix basop issue 2332 and similar cases by using precomputed sizes correctly. --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a884d61ec..5bffa59ff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,6 +100,7 @@ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ +#define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 101015fd0..2435e6a7d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11132,7 +11132,11 @@ static void intermidiate_ext_dirac_render( IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) { +#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND + Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); +#else Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ) ); +#endif scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, shift ); move16(); @@ -11149,7 +11153,11 @@ static void intermidiate_ext_dirac_render( IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { +#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND + tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len ); +#else tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); +#endif scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); /* Q(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth + tmp) */ h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp ); move16(); @@ -11171,7 +11179,11 @@ static void intermidiate_ext_dirac_render( move16(); IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) { +#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND + Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len ); +#else Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); +#endif scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift ); move16(); -- GitLab From e4f5568388519865dfc7e41924cd88871da438b7 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 11:09:48 +0200 Subject: [PATCH 425/750] Remove unnecessary code. --- lib_rend/lib_rend_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 2435e6a7d..5fac50a8e 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11142,6 +11142,7 @@ static void intermidiate_ext_dirac_render( move16(); } +#ifndef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND Word16 num_channels_dir = hDirACRend->num_outputs_dir; move16(); @@ -11150,7 +11151,7 @@ static void intermidiate_ext_dirac_render( num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; move16(); } - +#endif IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { #ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND -- GitLab From 1587355652f70ddd70e10a7eed681b3fe8affe82 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 10:54:53 +0100 Subject: [PATCH 426/750] FIX_2344_ALIGN_PREPROC --- lib_com/ivas_prot_fx.h | 4 +- lib_com/options.h | 1 + lib_enc/ivas_core_enc_fx.c | 20 +++++ lib_enc/ivas_core_pre_proc_fx.c | 145 +++++++++++++++++++++++++++----- 4 files changed, 147 insertions(+), 23 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 9934f6e46..89a477f52 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5870,8 +5870,8 @@ ivas_error ivas_compute_core_buffers_fx( Word32 epsP[M + 1], /* i/o: LP prediction errors */ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ - Word16 Q_old_inp_16k, - Word16 Q_r[2], + const Word16 Q_old_inp_16k, + const Word16 Q_r[2], Word16 *Q_new ); diff --git a/lib_com/options.h b/lib_com/options.h index a884d61ec..de2306030 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,6 +100,7 @@ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ +#define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 7dd2bcb04..05a28cdf5 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -230,6 +230,24 @@ ivas_error ivas_core_enc_fx( #endif Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } + +#ifdef FIX_2344_ALIGN_PREPROC + Word32 last_element_brate_tmp = last_element_brate; + move32(); + IF( EQ_32( ivas_format, SBA_FORMAT ) ) + { + last_element_brate_tmp = element_brate; + move32(); + } + + IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), + IVAS_ERR_OK ) ) + { + return error; + } +#else IF( EQ_32( ivas_format, SBA_FORMAT ) ) { IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, @@ -250,6 +268,8 @@ ivas_error ivas_core_enc_fx( return error; } } +#endif + test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || EQ_16( st->element_mode, IVAS_SCE ) ) { diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 9857c3e12..28d8d4a0a 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -111,6 +111,7 @@ ivas_error pre_proc_ivas_fx( lMemRecalc_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_NS ); move16(); } + /*----------------------------------------------------------------* * Selection of internal ACELP Fs (12.8 kHz or 16 kHz) *----------------------------------------------------------------*/ @@ -163,6 +164,26 @@ ivas_error pre_proc_ivas_fx( move16(); } +#ifdef FIX_2344_ALIGN_PREPROC + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + total_brate_tmp = ACELP_16k40; + move16(); + } + ELSE + { + total_brate_tmp = ACELP_9k60; + move16(); + } + + test(); + test(); + test(); + IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) ) + { + configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp ); + } +#else test(); test(); test(); @@ -182,6 +203,7 @@ ivas_error pre_proc_ivas_fx( { configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 ); } +#endif if ( st->ini_frame == 0 ) { @@ -224,6 +246,7 @@ ivas_error pre_proc_ivas_fx( * IC frames selection * enforce TC frames in case of switching *-----------------------------------------------------------------*/ + test(); test(); test(); @@ -284,7 +307,6 @@ ivas_error pre_proc_ivas_fx( move16(); } - /*---------------------------------------------------------------------* * Decision matrix (selection of technologies) *---------------------------------------------------------------------*/ @@ -305,6 +327,7 @@ ivas_error pre_proc_ivas_fx( /* core selection */ ivas_decision_matrix_enc_fx( st, element_brate, fft_buff_fx, enerBuffer_fx, e_enerBuffer, last_element_mode ); + test(); test(); if ( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */ @@ -396,14 +419,14 @@ ivas_error pre_proc_ivas_fx( } } - /*-----------------------------------------------------------------* * Update of ACELP harmonicity counter (used in ACELP transform codebook @32kbps) *-----------------------------------------------------------------*/ + test(); test(); test(); - IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << 8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) ) + IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << Q8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) ) { st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 ); /* Q0 */ move16(); @@ -471,6 +494,7 @@ ivas_error pre_proc_ivas_fx( } } +#ifndef FIX_2344_ALIGN_PREPROC /* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */ test(); test(); @@ -479,7 +503,7 @@ ivas_error pre_proc_ivas_fx( st->sharpFlag = 1; move16(); } - +#endif /* TD stereo, secondary channel - due to lack of signaling bits, sharpFlag is always 1 */ test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) @@ -514,6 +538,7 @@ ivas_error pre_proc_ivas_fx( /*-----------------------------------------------------------------* * Compute core-coder buffers at internal sampling rate *-----------------------------------------------------------------*/ + IF( st->tcxonly == 0 ) { sr_core_tmp = INT_FS_16k; @@ -567,16 +592,28 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); +#ifndef FIX_2344_ALIGN_PREPROC Word16 Q_inp_12k8 = *Q_new; move16(); Word16 Q_inp_16k = *Q_new; move16(); +#endif + IF( !flag_16k_smc ) { - error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, - A_fx, Aw_fx, - epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); +#ifdef FIX_2344_ALIGN_PREPROC + Word16 Q_inp_12k8 = *Q_new; + move16(); + Word16 Q_inp_16k; +#endif + error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); +#ifdef FIX_2344_ALIGN_PREPROC + IF( error != IVAS_ERR_OK ) + { + return error; + } +#endif + IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) { Scale_sig( old_inp_16k_fx, L_INP, sub( Q_inp_12k8, Q_inp_16k ) ); @@ -589,11 +626,12 @@ ivas_error pre_proc_ivas_fx( } move16(); +#ifndef FIX_2344_ALIGN_PREPROC IF( error != IVAS_ERR_OK ) { return error; } - +#endif test(); IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -601,6 +639,7 @@ ivas_error pre_proc_ivas_fx( move16(); } } + test(); IF( !( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) ) { @@ -681,11 +720,13 @@ ivas_error pre_proc_ivas_fx( return error; } + /*-------------------------------------------------------------------* * ivas_compute_core_buffers() * * Compute core-coder buffers at internal sampling rate *--------------------------------------------------------------------*/ + ivas_error ivas_compute_core_buffers_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ @@ -700,8 +741,8 @@ ivas_error ivas_compute_core_buffers_fx( Word32 epsP_fx[M + 1], /* i/o: LP prediction errors Q_r*/ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 Q_old_inp_16k, - Word16 Q_r[2], + const Word16 Q_old_inp_16k, + const Word16 Q_r[2], Word16 *Q_new ) { Word16 *inp_16k_fx, *new_inp_16k_fx; @@ -716,19 +757,28 @@ ivas_error ivas_compute_core_buffers_fx( Word16 Q_tmp, mem_decim16k_size, size_modified; Word16 epsP_h[M + 1]; Word16 epsP_l[M + 1]; - +#ifdef FIX_2344_ALIGN_PREPROC + Word16 i, shift, Q_min; + Word16 preemp_len, inp_max; +#else Word16 headroom = 1, preemp_len = 0, inp_max = 0; move16(); move16(); move16(); +#endif Word16 *preemp_start_idx = NULL; +#ifdef FIX_2344_ALIGN_PREPROC + Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; +#else Word32 sig_out[960], max_32; - /*Word16 Q_exp, Q_wsp_exp*/; +#endif + +#ifndef FIX_2344_ALIGN_PREPROC set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k ); set16_fx( epsP_h, 0, M + 1 ); set16_fx( epsP_l, 0, M + 1 ); set16_fx( input_buf_fx, 0, L_FRAME48k * 2 ); - +#endif Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) ); Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) ); @@ -754,9 +804,9 @@ ivas_error ivas_compute_core_buffers_fx( /*---------------------------------------------------------------* * Preprocessing at other sampling frequency rate (16/25.6/32kHz) *----------------------------------------------------------------*/ + IF( st->tcxonly == 0 ) { - L_frame_tmp = L_FRAME16k; move16(); } @@ -845,14 +895,23 @@ ivas_error ivas_compute_core_buffers_fx( Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#ifdef FIX_2344_ALIGN_PREPROC + size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - lMemRecalc_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#else + size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#endif Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); IF( lMemRecalc > 0 ) { +#ifdef FIX_2344_ALIGN_PREPROC + size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#else size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#endif } set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); @@ -936,6 +995,7 @@ ivas_error ivas_compute_core_buffers_fx( move16(); } +#ifndef FIX_2344_ALIGN_PREPROC test(); test(); @@ -948,10 +1008,21 @@ ivas_error ivas_compute_core_buffers_fx( { headroom = add( headroom, 1 ); } + +#endif test(); +#ifdef FIX_2344_ALIGN_PREPROC + IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) +#else test(); IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) +#endif { +#ifdef FIX_2344_ALIGN_PREPROC + preemp_len = 0; + move16(); +#endif + IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */ @@ -1037,8 +1108,11 @@ ivas_error ivas_compute_core_buffers_fx( maximum_abs_32_fx( sig_out, preemp_len, &max_32 ); inp_max = s_max( extract_h( max_32 ), 1 ); +#ifdef FIX_2344_ALIGN_PREPROC + shift = sub( norm_s( inp_max ), 1 /* headroom */ ); +#else Word16 shift = sub( norm_s( inp_max ), headroom ); - Word16 Q_min, i; +#endif shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min ); @@ -1063,8 +1137,13 @@ ivas_error ivas_compute_core_buffers_fx( Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new ); } +#ifdef FIX_2344_ALIGN_PREPROC + ELSE /* keep memory up-to-date in case of bitrate switching */ +#else ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */ +#endif { +#ifndef FIX_2344_ALIGN_PREPROC IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */ @@ -1075,7 +1154,9 @@ ivas_error ivas_compute_core_buffers_fx( st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */ move16(); } - ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) + ELSE +#endif + IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { st->mem_preemph16k_fx = 0; move16(); @@ -1098,7 +1179,9 @@ ivas_error ivas_compute_core_buffers_fx( IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { /* update signal buffers */ +#ifndef FIX_2344_ALIGN_PREPROC Word16 shift; +#endif shift = negate( *Q_new ); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -1134,6 +1217,14 @@ ivas_error ivas_compute_core_buffers_fx( analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); } +#ifdef FIX_2344_ALIGN_PREPROC + FOR( i = 0; i < M + 1; i++ ) + { + epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); + move32(); + } + +#endif /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ @@ -1148,20 +1239,30 @@ ivas_error ivas_compute_core_buffers_fx( /* update old input signal @16kHz buffer */ test(); test(); +#ifndef FIX_2344_ALIGN_PREPROC test(); +#endif IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); st->exp_old_inp_16k = 0; move16(); } +#ifdef FIX_2344_ALIGN_PREPROC + ELSE IF( EQ_32( sr_core, INT_FS_16k ) ) +#else ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) ) +#endif { Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM ); st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1) move16(); } +#ifdef FIX_2344_ALIGN_PREPROC + ELSE +#else ELSE IF( GT_32( input_Fs, 8000 ) ) +#endif { lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) ); @@ -1178,6 +1279,8 @@ ivas_error ivas_compute_core_buffers_fx( { Copy( new_inp_resamp16k_fx, new_inp_resamp16k_out_fx, L_FRAME16k ); } + +#ifndef FIX_2344_ALIGN_PREPROC test(); IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -1187,6 +1290,6 @@ ivas_error ivas_compute_core_buffers_fx( move32(); } } - +#endif return IVAS_ERR_OK; } -- GitLab From 045769d5a48cfcf221ab333168af5bc0b764196b Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 12:04:40 +0200 Subject: [PATCH 427/750] Fix basop issue 2329 by changing check to check for structure. --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..b18fb9694 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define FIX_BASOP_2329_UNINIT_VALUE /* Nokia: basop issue 2329: Fix issue by checking for structure instead of length */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 101015fd0..fd343ee5c 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11185,7 +11185,11 @@ static void intermidiate_ext_dirac_render( move16(); } +#ifdef FIX_BASOP_2329_UNINIT_VALUE + IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx ) +#else IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) +#endif { Word16 shift, norm1, norm2; Word32 tmp1, tmp2; -- GitLab From 05959814aaec0e252b20434c0723db4f73edd8bf Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 16 Jan 2026 11:11:24 +0100 Subject: [PATCH 428/750] [fix] add #ifdef _MSC_VER around setvbuf() call --- lib_util/render_config_reader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 26291be99..e98b103fd 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1997,7 +1997,9 @@ ivas_error RenderConfigReader_read( pTemp = (char *) calloc( file_size + 1, sizeof( char ) ); acIdx = 0; roomAcHasFgCount = roomAcHasAcEnvCount = FALSE; +#ifdef _MSC_VER setvbuf( pRenderConfigReader->pConfigFile, pConfig_str, _IONBF, sizeof( char ) ); /* Work-around for VS bug that gives incorrect ftell for UNIX-style line endings */ +#endif /* read file line by line */ while ( fgets( pConfig_str, file_size, pRenderConfigReader->pConfigFile ) != NULL ) -- GitLab From 19900d340debff41bb3b4e34f1d0d3f45abaa36c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 11:27:38 +0100 Subject: [PATCH 429/750] updates --- lib_com/ivas_prot_fx.h | 16 +++++++++-- lib_enc/ivas_core_enc_fx.c | 10 ++----- lib_enc/ivas_core_pre_proc_front_fx.c | 12 ++++++++ lib_enc/ivas_core_pre_proc_fx.c | 40 +++++++++++++++++++-------- lib_enc/ivas_cpe_enc_fx.c | 17 ++++++++---- lib_enc/ivas_ism_enc_fx.c | 15 +++++++--- lib_enc/ivas_sce_enc_fx.c | 25 +++++++++++++++++ 7 files changed, 106 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 70ec25d85..09dc6d3b3 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5856,7 +5856,11 @@ ivas_error ivas_mct_enc_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ); +#ifdef FIX_2344_ALIGN_PREPROC +void ivas_compute_core_buffers_fx( +#else ivas_error ivas_compute_core_buffers_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */ @@ -5871,7 +5875,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ const Word16 Q_old_inp_16k, - const Word16 Q_r[2], + Word16 Q_r[2], Word16 *Q_new ); @@ -5961,7 +5965,11 @@ void ivas_mct_enc_close_fx( MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ ); +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_front_ivas_fx( +#else ivas_error pre_proc_front_ivas_fx( +#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -6017,7 +6025,11 @@ ivas_error pre_proc_front_ivas_fx( Word16 *Q_new /* i/o : Q factor of speech buffers */ ); +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_ivas_fx( +#else ivas_error pre_proc_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ @@ -6046,7 +6058,7 @@ ivas_error pre_proc_ivas_fx( const Word16 e_enerBuffer, /* i : Q value of energy buffer */ Word16 fft_buff_fx[2 * L_FFT], /* i : FFT buffer Qx*/ const Word16 cor_map_sum_fx, /* i : speech/music clasif. parameter Q8*/ - Word16 *Q_new /* i/o : Q factor of speech buffers */ + Word16 *Q_new /* i/o: Q factor of speech buffers */ ); void ivas_initialize_handles_enc_fx( diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 05a28cdf5..30d8f315e 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -240,13 +240,9 @@ ivas_error ivas_core_enc_fx( move32(); } - IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), - IVAS_ERR_OK ) ) - { - return error; - } + pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ); #else IF( EQ_32( ivas_format, SBA_FORMAT ) ) { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index d17b4d358..e621a4bdc 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -76,7 +76,11 @@ static Word16 get_zero_flag( const Word32 arr[], const Word16 len ) * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) *--------------------------------------------------------------------*/ +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_front_ivas_fx( +#else ivas_error pre_proc_front_ivas_fx( +#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -1476,11 +1480,15 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Compute core-coder buffers at internal sampling rate */ +#ifdef FIX_2344_ALIGN_PREPROC + ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); +#else error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } +#endif *epsP_fx_q = add( Q_r[0], 1 ); move16(); @@ -1571,7 +1579,11 @@ ivas_error pre_proc_front_ivas_fx( free( temp1F_icatdmResampBuf_fx ); #endif pop_wmops(); +#ifdef FIX_2344_ALIGN_PREPROC + return; +#else return error; +#endif } diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 63c7b839a..adfabb741 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -46,7 +46,11 @@ * Decision matrix, Preprocessing at other Fs, core switching decision, ...) *--------------------------------------------------------------------*/ +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_ivas_fx( +#else ivas_error pre_proc_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ @@ -75,20 +79,23 @@ ivas_error pre_proc_ivas_fx( const Word16 e_enerBuffer, /* i : Q value of energy buffer */ Word16 fft_buff_fx[2 * L_FFT], /* i : FFT buffer Qx*/ const Word16 cor_map_sum_fx, /* i : speech/music clasif. parameter Q8*/ - Word16 *Q_new /* i/o : Q factor of speech buffers */ + Word16 *Q_new /* i/o: Q factor of speech buffers */ ) { Word16 L_look, element_mode, lMemRecalc_12k8; Word16 *inp_16k_fx, *new_inp_12k8_fx, *inp_12k8_fx; /* pointers to current frame and new data */ Word16 *wsp_fx; /* weighted input signal buffer */ Word32 sr_core_tmp, total_brate_tmp; +#ifndef FIX_2344_ALIGN_PREPROC ivas_error error; +#endif push_wmops( "pre_proc" ); +#ifndef FIX_2344_ALIGN_PREPROC error = IVAS_ERR_OK; move32(); - +#endif /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ @@ -607,13 +614,14 @@ ivas_error pre_proc_ivas_fx( Word16 Q_inp_12k8 = *Q_new; move16(); Word16 Q_inp_16k; -#endif - error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); -#ifdef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return error; - } + + ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); +#else + error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, + A_fx, Aw_fx, + epsP_fx, + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); + #endif IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) @@ -719,7 +727,11 @@ ivas_error pre_proc_ivas_fx( } pop_wmops(); +#ifdef FIX_2344_ALIGN_PREPROC + return; +#else return error; +#endif } @@ -729,7 +741,11 @@ ivas_error pre_proc_ivas_fx( * Compute core-coder buffers at internal sampling rate *--------------------------------------------------------------------*/ +#ifdef FIX_2344_ALIGN_PREPROC +void ivas_compute_core_buffers_fx( +#else ivas_error ivas_compute_core_buffers_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/ @@ -744,7 +760,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ const Word16 Q_old_inp_16k, - const Word16 Q_r[2], + Word16 Q_r[2], Word16 *Q_new ) { Word16 *inp_16k_fx, *new_inp_16k_fx; @@ -1292,6 +1308,8 @@ ivas_error ivas_compute_core_buffers_fx( move32(); } } -#endif return IVAS_ERR_OK; +#else + return; +#endif } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index f0ba8fc26..40e443317 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -918,16 +918,23 @@ ivas_error ivas_cpe_enc_fx( { front_vad_flag = 0; } + move16(); + +#ifndef FIX_2344_ALIGN_PREPROC + error = +#endif + pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], + &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], + realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], + fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, + band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); - error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], - &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], - realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], - fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, - band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); +#ifndef FIX_2344_ALIGN_PREPROC IF( error != IVAS_ERR_OK ) { return error; } +#endif e_old_wsp[n] = sub( Q15, q_old_wsp ); move16(); } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index be2e223f3..2cfed0ac5 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -244,19 +244,26 @@ ivas_error ivas_ism_enc_fx( Scale_sig( &A_fx[sce_id][0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[sce_id][0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } #endif + set16_fx( old_wsp_fx[sce_id][0], 0, L_WSP ); q_old_wsp = Q15; move16(); Word16 q_fr_bands[2]; - error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], - &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], - realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); +#ifndef FIX_2344_ALIGN_PREPROC + error = +#endif + pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], + &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], + realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); +#ifndef FIX_2344_ALIGN_PREPROC IF( error != IVAS_ERR_OK ) { return error; } +#endif + e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); move16(); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 144e86643..48dfc9ba7 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -251,6 +251,30 @@ ivas_error ivas_sce_enc_fx( move16(); Word16 q_fr_bands[2]; +#ifdef FIX_2344_ALIGN_PREPROC + Word16 front_vad_flag, force_front_vad, front_vad_dtx_flag; + IF( st_ivas->hSpar != NULL ) + { + front_vad_flag = st_ivas->hSpar->front_vad_flag; + force_front_vad = st_ivas->hSpar->force_front_vad; + front_vad_dtx_flag = st_ivas->hSpar->front_vad_dtx_flag; + } + ELSE + { + front_vad_flag = 0; + force_front_vad = 0; + front_vad_dtx_flag = 0; + } + move16(); + move16(); + move16(); + + pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0], + &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], + realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], + fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, + front_vad_flag, force_front_vad, front_vad_dtx_flag, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); +#else error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0], &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], @@ -260,6 +284,7 @@ ivas_error ivas_sce_enc_fx( { return error; } +#endif e_old_wsp[0] = sub( Q15, q_old_wsp ); move16(); -- GitLab From 7dbb483cf9faf788cc20ef62043941e4f4670671 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 12:41:20 +0200 Subject: [PATCH 430/750] Fix basop issue 2328 by changing variable assignment. --- lib_com/options.h | 1 + lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..dde04da64 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT /* Nokia: basop issue 2328: Fix MSAN error by correcting the variable assignment */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index de25c56e5..daaa9ee4c 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -211,7 +211,11 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT + dirac_output_synthesis_state->cy_auto_diff_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); +#else dirac_output_synthesis_state->cy_auto_dir_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); +#endif move16(); } ELSE -- GitLab From 7030b1086c7d2bc47899688561647208f8dd918f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 11:49:25 +0100 Subject: [PATCH 431/750] fix build --- lib_enc/ivas_core_pre_proc_front_fx.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index e621a4bdc..5cce1c590 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -161,7 +161,9 @@ ivas_error pre_proc_front_ivas_fx( STEREO_CLASSIF_HANDLE hStereoClassif; Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */ Word16 LR_localVAD; +#ifndef FIX_2344_ALIGN_PREPROC ivas_error error; +#endif Word16 *signal_in_fx; Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ @@ -171,7 +173,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ #else Word16 *temp1F_icatdmResampBuf_fx; - Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ + Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ #endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; @@ -229,21 +231,30 @@ ivas_error pre_proc_front_ivas_fx( Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; Word16 Q_inp_const = -1; move16(); +#ifdef FIX_2344_ALIGN_PREPROC + Word16 headroom, preemp_len, inp_max; +#else Word16 headroom = 0, preemp_len = 0, inp_max = 0; move16(); move16(); move16(); +#endif Word16 *preemp_start_idx = NULL; +#ifdef FIX_2344_ALIGN_PREPROC + Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; +#else Word32 sig_out[960], max_32; +#endif push_wmops( "pre_proc_front" ); /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ +#ifndef FIX_2344_ALIGN_PREPROC error = IVAS_ERR_OK; move32(); - +#endif cldfbScale.lb_scale = Q31; cldfbScale.hb_scale = Q31; move16(); @@ -548,12 +559,17 @@ ivas_error pre_proc_front_ivas_fx( * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1 *-----------------------------------------------------------------*/ +#ifndef FIX_2344_ALIGN_PREPROC *Q_new = 0; move16(); set32_fx( sig_out, 0, 960 ); - +#endif headroom = 2; move16(); +#ifdef FIX_2344_ALIGN_PREPROC + preemp_len = 0; + move16(); +#endif st->mem_preemph_fx_q_inp = shl_sat( st->mem_preemph_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/ move16(); @@ -640,6 +656,7 @@ ivas_error pre_proc_front_ivas_fx( preemp_len = L_FRAME + L_FILT; move16(); } + st->mem_preemph_fx = shl_sat( st->mem_preemph_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */ move16(); st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/ @@ -1333,12 +1350,11 @@ ivas_error pre_proc_front_ivas_fx( * 1st stage speech/music classification (GMM model) *----------------------------------------------------------------*/ - SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; shift = getScaleFactor32( PS_fx, 128 ); scale_sig32( PS_fx, 128, shift ); Qfact_PS = add( Qfact_PS, shift ); - smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */ + smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, st->hSpMusClas->past_PS_Q ); /* Q0 */ #ifdef DEBUGGING if ( st->idchan == 0 ) -- GitLab From 6225b9111f290e057e68da17ffef961f33c3b3e6 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 13:10:43 +0200 Subject: [PATCH 432/750] Fix basop issue 2327 by correcting loop end condition. --- lib_com/options.h | 1 + lib_rend/ivas_omasa_ana_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..38ca61c41 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define FIX_BASOP_2327_WRONG_LOOP_END /* Nokia: basop inssue 2327: Correct loop end to solve MSAN error */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index b1405a309..c3ce78d64 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -719,7 +719,11 @@ static void ivas_omasa_dmx_fx( } max_e = in_e[0]; move16(); +#ifdef FIX_BASOP_2327_WRONG_LOOP_END + FOR( l = 1; l < input_frame; l++ ) +#else FOR( l = 1; l < L_FRAME48k; l++ ) +#endif { IF( LT_16( max_e, in_e[l] ) ) { @@ -728,7 +732,11 @@ static void ivas_omasa_dmx_fx( } } +#ifdef FIX_BASOP_2327_WRONG_LOOP_END + FOR( l = 0; l < input_frame; l++ ) +#else FOR( l = 0; l < L_FRAME48k; l++ ) +#endif { data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) move32(); -- GitLab From ef48de6448e776cd074746d348d411c60cd8dcf1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 12:21:21 +0100 Subject: [PATCH 433/750] fix sanitizer error --- lib_enc/ivas_core_pre_proc_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index adfabb741..76bf25027 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1013,7 +1013,10 @@ ivas_error ivas_compute_core_buffers_fx( move16(); } -#ifndef FIX_2344_ALIGN_PREPROC +#ifdef FIX_2344_ALIGN_PREPROC + *Q_new = 0; + move16(); +#else test(); test(); @@ -1028,6 +1031,7 @@ ivas_error ivas_compute_core_buffers_fx( } #endif + test(); #ifdef FIX_2344_ALIGN_PREPROC IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) -- GitLab From 2708b6c50f4fe5427080441a2764ec4d66901ff3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 13:27:40 +0100 Subject: [PATCH 434/750] fix within FIX_2344_ALIGN_PREPROC --- lib_enc/ivas_core_enc_fx.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 30d8f315e..c640d8a2e 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -232,11 +232,11 @@ ivas_error ivas_core_enc_fx( } #ifdef FIX_2344_ALIGN_PREPROC - Word32 last_element_brate_tmp = last_element_brate; + Word32 last_element_brate_tmp = element_brate; move32(); IF( EQ_32( ivas_format, SBA_FORMAT ) ) { - last_element_brate_tmp = element_brate; + last_element_brate_tmp = last_element_brate; move32(); } @@ -760,16 +760,21 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch - Q_shb_spch = add( Q_shb_spch, shift ); - - IF( st->hBWE_FD ) +#ifdef FIX_2344_ALIGN_PREPROC + IF( st->tcxonly == 0 ) +#endif { - shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); - st->Q_old_wtda = add( st->Q_old_wtda, shift ); - move16(); - Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch + Q_shb_spch = add( Q_shb_spch, shift ); + + IF( st->hBWE_FD ) + { + shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); + st->Q_old_wtda = add( st->Q_old_wtda, shift ); + move16(); + Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda + } } /* SWB TBE encoder */ -- GitLab From 82a40dbcdb703099e725328f34d759bbad05fa11 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 14:38:16 +0200 Subject: [PATCH 435/750] Fix basop issue 2326 by changing scaling to apply to only correct number of channels and samples --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..fcd34f775 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define FIX_BASOP_2326_WRONG_SIG_LENGTH /* Nokia: basop issue 2326: Fix issue by using correct signal length in multiple places */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 101015fd0..ef08dae06 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9112,8 +9112,15 @@ static ivas_error renderInputMasa( } copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); +#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH + FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) + { + Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + } +#else Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ +#endif // scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); @@ -9137,9 +9144,15 @@ static ivas_error renderInputMasa( masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; move16(); } +#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH + FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) + { + Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ +#else FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ +#endif } scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ @@ -9164,8 +9177,15 @@ static ivas_error renderInputMasa( copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); +#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH + FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) + { + Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + } +#else Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ +#endif scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); -- GitLab From 80b1e7bd566b041585d5dd628041ba65d98962cb Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 14:42:50 +0200 Subject: [PATCH 436/750] Adjust changes for clang format. --- lib_rend/lib_rend_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index ef08dae06..24d9cfbc2 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9148,12 +9148,13 @@ static ivas_error renderInputMasa( FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + } #else FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ -#endif } +#endif scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ -- GitLab From fc9d1c14572f65ed4732dc9da668d192d43b99ce Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 16 Jan 2026 14:03:09 +0100 Subject: [PATCH 437/750] fix MSAN error for custom loudspeaker setup structure --- apps/renderer.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 8da507bbe..defefda25 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1257,8 +1257,8 @@ int main( /* Set up output custom layout configuration */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - floatToFixed_arrL_app( args.outConfig.outSetupCustom.azimuth, args.outConfig.outSetupCustom.azimuth_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS ); - floatToFixed_arrL_app( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL_app( args.outConfig.outSetupCustom.azimuth, args.outConfig.outSetupCustom.azimuth_fx, Q22, args.outConfig.outSetupCustom.num_spk ); + floatToFixed_arrL_app( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, args.outConfig.outSetupCustom.num_spk ); if ( ( error = IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend, args.outConfig.outSetupCustom ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); @@ -1362,8 +1362,8 @@ int main( if ( args.inConfig.multiChannelBuses[i].audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - floatToFixed_arrL_app( args.inConfig.inSetupCustom.azimuth, args.inConfig.inSetupCustom.azimuth_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS ); - floatToFixed_arrL_app( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL_app( args.inConfig.inSetupCustom.azimuth, args.inConfig.inSetupCustom.azimuth_fx, Q22, args.inConfig.inSetupCustom.num_spk ); + floatToFixed_arrL_app( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, args.inConfig.inSetupCustom.num_spk ); if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); @@ -2763,6 +2763,13 @@ static CmdlnArgs defaultArgs( args.inConfig.inSetupCustom.num_spk = 0; args.inConfig.inSetupCustom.num_lfe = 0; + for ( i = 0; i < RENDERER_MAX_INPUT_CHANNELS; i++ ) + { + args.inConfig.inSetupCustom.azimuth[i] = 0.f; + args.inConfig.inSetupCustom.azimuth_fx[i] = 0; + args.inConfig.inSetupCustom.elevation[i] = 0.f; + args.inConfig.inSetupCustom.elevation_fx[i] = 0; + } args.inConfig.numAudioObjects = 0; args.inConfig.numAmbisonicsBuses = 0; args.inConfig.numMultiChannelBuses = 0; @@ -2771,6 +2778,13 @@ static CmdlnArgs defaultArgs( args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; args.outConfig.outSetupCustom.num_spk = 0; args.outConfig.outSetupCustom.num_lfe = 0; + for ( i = 0; i < RENDERER_MAX_OUTPUT_CHANNELS; i++ ) + { + args.outConfig.outSetupCustom.azimuth[i] = 0.f; + args.outConfig.outSetupCustom.azimuth_fx[i] = 0; + args.outConfig.outSetupCustom.elevation[i] = 0.f; + args.outConfig.outSetupCustom.elevation_fx[i] = 0; + } for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) { args.inConfig.ambisonicsBuses[i].audioConfig = IVAS_AUDIO_CONFIG_INVALID; -- GitLab From cdd71fa4215e93342f7165d43571a53a431510b0 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 15:16:03 +0200 Subject: [PATCH 438/750] Fix basop issue 2324 by setting exponent to zero correctly. --- lib_com/options.h | 1 + lib_enc/ivas_mcmasa_enc_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..ebd4cd13b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define FIX_BASOP_2324_MISSING_SET_TO_ZERO /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index a33fa9094..bcaa0e49f 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1021,6 +1021,14 @@ void ivas_mcmasa_param_est_enc_fx( move32(); hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0; move32(); +#ifdef FIX_BASOP_2324_MISSING_SET_TO_ZERO + hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] = 0; + move16(); + hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] = 0; + move16(); + hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] = 0; + move16(); +#endif } /* Reset variable */ -- GitLab From 16125242ba9ce4c0cab3869f0e5bc2af4bccea15 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 16 Jan 2026 14:21:34 +0100 Subject: [PATCH 439/750] update copyright to 2026 --- LICENSE.md | 2 +- apps/ambi_converter.c | 2 +- apps/decoder.c | 2 +- apps/encoder.c | 2 +- apps/encoder_fmtsw.c | 2 +- apps/isar_post_rend.c | 2 +- apps/renderer.c | 2 +- lib_basop/basop32.c | 2 +- lib_basop/basop32.h | 2 +- lib_basop/enh40.c | 2 +- lib_basop/enh40.h | 2 +- lib_basop/move.h | 2 +- lib_basop/stl.h | 2 +- lib_basop/typedef.h | 2 +- lib_com/basop_com_lpc.c | 2 +- lib_com/basop_lsf_tools.c | 2 +- lib_com/basop_proto_func.h | 2 +- lib_com/basop_settings.h | 2 +- lib_com/basop_tcx_utils.c | 2 +- lib_com/basop_util.c | 2 +- lib_com/basop_util.h | 2 +- lib_com/bitstream_fx.c | 2 +- lib_com/cldfb_fx.c | 2 +- lib_com/cnst.h | 2 +- lib_com/common_api_types.h | 2 +- lib_com/core_com_config_fx.c | 2 +- lib_com/deemph_fx.c | 2 +- lib_com/delay_comp_fx.c | 2 +- lib_com/disclaimer.c | 2 +- lib_com/enr_1_az_fx.c | 2 +- lib_com/env_adj_fx.c | 2 +- lib_com/env_stab_fx.c | 2 +- lib_com/env_stab_trans_fx.c | 2 +- lib_com/fft_cldfb_fx.c | 2 +- lib_com/fft_fx.c | 2 +- lib_com/fill_spectrum_fx.c | 2 +- lib_com/findpulse_fx.c | 2 +- lib_com/frame_ener_fx.c | 2 +- lib_com/get_gain_fx.c | 2 +- lib_com/gs_gains_fx.c | 2 +- lib_com/gs_preech_fx.c | 2 +- lib_com/hp50_fx.c | 2 +- lib_com/hq2_bit_alloc_fx.c | 2 +- lib_com/hq2_core_com_fx.c | 2 +- lib_com/hq2_noise_inject_fx.c | 2 +- lib_com/hq_tools_fx.c | 2 +- lib_com/ifft_rel_fx.c | 2 +- lib_com/int_lsp_fx.c | 2 +- lib_com/interleave_spectrum_fx.c | 2 +- lib_com/interpol_fx.c | 2 +- lib_com/isf_dec_amr_wb_fx.c | 2 +- lib_com/ivas_agc_com_fx.c | 2 +- lib_com/ivas_arith_fx.c | 2 +- lib_com/ivas_avq_pos_reorder_com_fx.c | 2 +- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_cov_smooth_fx.c | 2 +- lib_com/ivas_dirac_com_fx.c | 2 +- lib_com/ivas_entropy_coder_common_fx.c | 2 +- lib_com/ivas_error.h | 2 +- lib_com/ivas_error_utils.h | 2 +- lib_com/ivas_fb_mixer_fx.c | 2 +- lib_com/ivas_filters_fx.c | 2 +- lib_com/ivas_ism_com_fx.c | 2 +- lib_com/ivas_lfe_com_fx.c | 2 +- lib_com/ivas_limiter_fx.c | 2 +- lib_com/ivas_masa_com_fx.c | 2 +- lib_com/ivas_mc_com_fx.c | 2 +- lib_com/ivas_mc_param_com_fx.c | 2 +- lib_com/ivas_mcmasa_com_fx.c | 2 +- lib_com/ivas_mct_com_fx.c | 2 +- lib_com/ivas_mdct_core_com_fx.c | 2 +- lib_com/ivas_mdct_imdct_fx.c | 2 +- lib_com/ivas_mdft_imdft_fx.c | 2 +- lib_com/ivas_omasa_com_fx.c | 2 +- lib_com/ivas_osba_com_fx.c | 2 +- lib_com/ivas_pca_tools_fx.c | 2 +- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_qmetadata_com_fx.c | 2 +- lib_com/ivas_qspherical_com_fx.c | 2 +- lib_com/ivas_rom_com.h | 2 +- lib_com/ivas_rom_com_fx.c | 2 +- lib_com/ivas_rotation_com_fx.c | 2 +- lib_com/ivas_sba_config_fx.c | 2 +- lib_com/ivas_sns_com_fx.c | 2 +- lib_com/ivas_spar_com_fx.c | 2 +- lib_com/ivas_spar_com_quant_util_fx.c | 2 +- lib_com/ivas_stat_com.h | 2 +- lib_com/ivas_stereo_dft_com_fx.c | 2 +- lib_com/ivas_stereo_eclvq_com_fx.c | 2 +- lib_com/ivas_stereo_ica_com_fx.c | 2 +- lib_com/ivas_stereo_mdct_bands_com_fx.c | 2 +- lib_com/ivas_stereo_mdct_stereo_com_fx.c | 2 +- lib_com/ivas_stereo_psychlpc_com_fx.c | 2 +- lib_com/ivas_stereo_td_bit_alloc_fx.c | 2 +- lib_com/ivas_tools_fx.c | 2 +- lib_com/ivas_transient_det_fx.c | 2 +- lib_com/lag_wind_fx.c | 2 +- lib_com/lerp_fx.c | 2 +- lib_com/logqnorm_fx.c | 2 +- lib_com/longarith.c | 2 +- lib_com/lpc_tools_fx.c | 2 +- lib_com/lsf_tools_fx.c | 2 +- lib_com/mime.h | 2 +- lib_com/mslvq_com_fx.c | 2 +- lib_com/nelp_fx.c | 2 +- lib_com/options.h | 2 +- lib_com/ppp_fx.c | 2 +- lib_com/prot_fx.h | 2 +- lib_com/reordvct_fx.c | 2 +- lib_com/rom_basop_util.c | 2 +- lib_com/rom_basop_util.h | 2 +- lib_com/rom_com.h | 2 +- lib_com/rom_com_fx.c | 2 +- lib_com/scale_mem_fx.c | 2 +- lib_com/stat_com.h | 2 +- lib_com/swb_bwe_com_fx.c | 2 +- lib_com/swb_bwe_com_lr_fx.c | 2 +- lib_com/tcx_mdct_window_fx.c | 2 +- lib_com/tools_fx.c | 2 +- lib_debug/debug.c | 2 +- lib_debug/debug.h | 2 +- lib_debug/sba_debug.c | 2 +- lib_debug/sba_debug.h | 2 +- lib_debug/snr.c | 2 +- lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/ari_hm_dec_fx.c | 2 +- lib_dec/init_dec_fx.c | 2 +- lib_dec/ivas_agc_dec_fx.c | 2 +- lib_dec/ivas_core_dec_fx.c | 2 +- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 2 +- lib_dec/ivas_cpe_dec_fx.c | 2 +- lib_dec/ivas_decision_matrix_dec_fx.c | 2 +- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 2 +- lib_dec/ivas_entropy_decoder_fx.c | 2 +- lib_dec/ivas_init_dec_fx.c | 2 +- lib_dec/ivas_ism_dec_fx.c | 2 +- lib_dec/ivas_ism_dtx_dec_fx.c | 2 +- lib_dec/ivas_ism_metadata_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 2 +- lib_dec/ivas_ism_renderer_fx.c | 2 +- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_dec/ivas_lfe_dec_fx.c | 2 +- lib_dec/ivas_lfe_plc_fx.c | 2 +- lib_dec/ivas_ls_custom_dec_fx.c | 2 +- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/ivas_mc_param_dec_fx.c | 2 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 +- lib_dec/ivas_mcmasa_dec_fx.c | 2 +- lib_dec/ivas_mct_core_dec_fx.c | 2 +- lib_dec/ivas_mct_dec_fx.c | 2 +- lib_dec/ivas_mct_dec_mct_fx_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- lib_dec/ivas_mono_dmx_renderer_fx.c | 2 +- lib_dec/ivas_objectRenderer_internal_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 2 +- lib_dec/ivas_osba_dec_fx.c | 2 +- lib_dec/ivas_out_setup_conversion_fx.c | 2 +- lib_dec/ivas_output_config_fx.c | 2 +- lib_dec/ivas_pca_dec_fx.c | 2 +- lib_dec/ivas_post_proc_fx.c | 2 +- lib_dec/ivas_qmetadata_dec_fx.c | 2 +- lib_dec/ivas_qspherical_dec_fx.c | 2 +- lib_dec/ivas_range_uni_dec_fx.c | 2 +- lib_dec/ivas_rom_dec.h | 2 +- lib_dec/ivas_rom_dec_fx.c | 2 +- lib_dec/ivas_sba_dec_fx.c | 2 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 +- lib_dec/ivas_sba_rendering_internal_fx.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_sns_dec_fx.c | 2 +- lib_dec/ivas_spar_decoder_fx.c | 2 +- lib_dec/ivas_spar_md_dec_fx.c | 2 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/ivas_stereo_adapt_GR_dec_fx.c | 2 +- lib_dec/ivas_stereo_cng_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 2 +- lib_dec/ivas_stereo_dft_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_plc_fx.c | 2 +- lib_dec/ivas_stereo_eclvq_dec_fx.c | 2 +- lib_dec/ivas_stereo_esf_dec_fx.c | 2 +- lib_dec/ivas_stereo_ica_dec_fx.c | 2 +- lib_dec/ivas_stereo_icbwe_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 2 +- lib_dec/ivas_stereo_switching_dec_fx.c | 2 +- lib_dec/ivas_stereo_td_dec_fx.c | 2 +- lib_dec/ivas_svd_dec_fx.c | 2 +- lib_dec/ivas_tcx_core_dec_fx.c | 2 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 +- lib_dec/jbm_jb4_circularbuffer.h | 2 +- lib_dec/jbm_jb4_circularbuffer_fx.c | 2 +- lib_dec/jbm_jb4_inputbuffer.h | 2 +- lib_dec/jbm_jb4_inputbuffer_fx.c | 2 +- lib_dec/jbm_jb4_jmf.h | 2 +- lib_dec/jbm_jb4_jmf_fx.c | 2 +- lib_dec/jbm_jb4sb.h | 2 +- lib_dec/jbm_jb4sb_fx.c | 2 +- lib_dec/jbm_pcmdsp_apa.h | 2 +- lib_dec/jbm_pcmdsp_apa_fx.c | 2 +- lib_dec/jbm_pcmdsp_fifo.h | 2 +- lib_dec/jbm_pcmdsp_similarityestimation.h | 2 +- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- lib_dec/jbm_pcmdsp_window.h | 2 +- lib_dec/jbm_pcmdsp_window_fx.c | 2 +- lib_dec/lib_dec.h | 2 +- lib_dec/lib_dec_fx.c | 2 +- lib_dec/rom_dec.h | 2 +- lib_dec/rom_dec_fx.c | 2 +- lib_dec/stat_dec.h | 2 +- lib_enc/cod4t64_fast_fx.c | 2 +- lib_enc/detect_transient_fx.c | 2 +- lib_enc/gp_clip_fx.c | 2 +- lib_enc/igf_scf_enc.c | 2 +- lib_enc/init_enc_fx.c | 2 +- lib_enc/isf_enc_amr_wb_fx.c | 2 +- lib_enc/ivas_agc_enc_fx.c | 2 +- lib_enc/ivas_core_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 2 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 2 +- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_decision_matrix_enc_fx.c | 2 +- lib_enc/ivas_dirac_enc_fx.c | 2 +- lib_enc/ivas_enc_cov_handler_fx.c | 2 +- lib_enc/ivas_enc_fx.c | 2 +- lib_enc/ivas_entropy_coder_fx.c | 2 +- lib_enc/ivas_front_vad_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 2 +- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- lib_enc/ivas_ism_enc_fx.c | 2 +- lib_enc/ivas_ism_metadata_enc_fx.c | 2 +- lib_enc/ivas_ism_param_enc_fx.c | 2 +- lib_enc/ivas_lfe_enc_fx.c | 2 +- lib_enc/ivas_masa_enc_fx.c | 2 +- lib_enc/ivas_mc_param_enc_fx.c | 2 +- lib_enc/ivas_mc_paramupmix_enc_fx.c | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 2 +- lib_enc/ivas_mct_core_enc_fx.c | 2 +- lib_enc/ivas_mct_enc_fx.c | 2 +- lib_enc/ivas_mct_enc_mct_fx.c | 2 +- lib_enc/ivas_mdct_core_enc_fx.c | 2 +- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_osba_enc_fx.c | 2 +- lib_enc/ivas_pca_enc_fx.c | 2 +- lib_enc/ivas_qmetadata_enc_fx.c | 2 +- lib_enc/ivas_qspherical_enc_fx.c | 2 +- lib_enc/ivas_range_uni_enc_fx.c | 2 +- lib_enc/ivas_rom_enc.h | 2 +- lib_enc/ivas_rom_enc_fx.c | 2 +- lib_enc/ivas_sba_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 2 +- lib_enc/ivas_sns_enc_fx.c | 2 +- lib_enc/ivas_spar_encoder_fx.c | 2 +- lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/ivas_stat_enc.h | 2 +- lib_enc/ivas_stereo_adapt_GR_enc_fx.c | 2 +- lib_enc/ivas_stereo_classifier_fx.c | 2 +- lib_enc/ivas_stereo_cng_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 2 +- lib_enc/ivas_stereo_dft_td_itd_fx.c | 2 +- lib_enc/ivas_stereo_dmx_evs_fx.c | 2 +- lib_enc/ivas_stereo_eclvq_enc_fx.c | 2 +- lib_enc/ivas_stereo_ica_enc_fx.c | 2 +- lib_enc/ivas_stereo_icbwe_enc_fx.c | 2 +- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 2 +- lib_enc/ivas_stereo_mdct_igf_enc_fx.c | 2 +- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 2 +- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_enc/ivas_stereo_td_analysis_fx.c | 2 +- lib_enc/ivas_stereo_td_enc_fx.c | 2 +- lib_enc/ivas_tcx_core_enc_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- lib_enc/lib_enc.h | 2 +- lib_enc/lib_enc_fx.c | 2 +- lib_enc/nelp_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- lib_enc/rom_enc.h | 2 +- lib_enc/rom_enc_fx.c | 2 +- lib_enc/stat_enc.h | 2 +- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- lib_isar/isar_MSPred.c | 2 +- lib_isar/isar_PerceptualModel.c | 2 +- lib_isar/isar_PredDecoder.c | 2 +- lib_isar/isar_PredEncoder.c | 2 +- lib_isar/isar_RMSEnvGrouping.c | 2 +- lib_isar/isar_cnst.h | 2 +- lib_isar/isar_lc3plus_common.c | 2 +- lib_isar/isar_lc3plus_common.h | 2 +- lib_isar/isar_lc3plus_dec.c | 2 +- lib_isar/isar_lc3plus_dec.h | 2 +- lib_isar/isar_lc3plus_enc.c | 2 +- lib_isar/isar_lc3plus_enc.h | 2 +- lib_isar/isar_lc3plus_payload.c | 2 +- lib_isar/isar_lc3plus_payload.h | 2 +- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/isar_lcld_encoder.c | 2 +- lib_isar/isar_lcld_prot.h | 2 +- lib_isar/isar_prot.h | 2 +- lib_isar/isar_rom_lcld_tables.c | 2 +- lib_isar/isar_rom_lcld_tables.h | 2 +- lib_isar/isar_rom_post_rend.c | 2 +- lib_isar/isar_rom_post_rend.h | 2 +- lib_isar/isar_splitRend_lcld_dec.c | 2 +- lib_isar/isar_splitRend_lcld_enc.c | 2 +- lib_isar/isar_splitRendererPLC.c | 2 +- lib_isar/isar_splitRendererPost.c | 2 +- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/isar_splitRenderer_utils.c | 2 +- lib_isar/isar_stat.h | 2 +- lib_isar/lib_isar_post_rend.c | 2 +- lib_isar/lib_isar_post_rend.h | 2 +- lib_isar/lib_isar_pre_rend.c | 2 +- lib_isar/lib_isar_pre_rend.h | 2 +- lib_rend/ivas_allrad_dec_fx.c | 2 +- lib_rend/ivas_binRenderer_internal_fx.c | 2 +- lib_rend/ivas_cldfb_ring_buffer.c | 2 +- lib_rend/ivas_crend_fx.c | 2 +- lib_rend/ivas_dirac_ana_fx.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 2 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 2 +- lib_rend/ivas_dirac_onsets_dec_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 +- lib_rend/ivas_dirac_rend_fx.c | 2 +- lib_rend/ivas_efap_fx.c | 2 +- lib_rend/ivas_hrtf_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_objectRenderer_fx.c | 2 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 2 +- lib_rend/ivas_objectRenderer_mix_fx.c | 2 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 2 +- lib_rend/ivas_objectRenderer_sources_fx.c | 2 +- lib_rend/ivas_objectRenderer_vec_fx.c | 2 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/ivas_orient_trk_fx.c | 2 +- lib_rend/ivas_output_init_fx.c | 2 +- lib_rend/ivas_prot_rend_fx.h | 2 +- lib_rend/ivas_reflections_fx.c | 2 +- lib_rend/ivas_render_config_fx.c | 2 +- lib_rend/ivas_reverb_delay_line_fx.c | 2 +- lib_rend/ivas_reverb_fft_filter_fx.c | 2 +- lib_rend/ivas_reverb_filter_design_fx.c | 2 +- lib_rend/ivas_reverb_fx.c | 2 +- lib_rend/ivas_reverb_iir_filter_fx.c | 2 +- lib_rend/ivas_reverb_utils_fx.c | 2 +- lib_rend/ivas_rom_TdBinauralRenderer.h | 2 +- lib_rend/ivas_rom_TdBinauralRenderer_fx.c | 2 +- lib_rend/ivas_rom_binauralRenderer.h | 2 +- lib_rend/ivas_rom_binauralRenderer_fx.c | 2 +- lib_rend/ivas_rom_binaural_crend_head.h | 2 +- lib_rend/ivas_rom_binaural_crend_head_fx.c | 2 +- lib_rend/ivas_rom_rend.h | 2 +- lib_rend/ivas_rom_rend_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 2 +- lib_rend/ivas_sba_rendering_fx.c | 2 +- lib_rend/ivas_shoebox_fx.c | 2 +- lib_rend/ivas_stat_rend.h | 2 +- lib_rend/ivas_td_decorr_fx.c | 2 +- lib_rend/ivas_td_ring_buffer_fx.c | 2 +- lib_rend/ivas_vbap_fx.c | 2 +- lib_rend/lib_rend.h | 2 +- lib_rend/lib_rend_fx.c | 2 +- lib_util/aeid_file_reader.c | 2 +- lib_util/aeid_file_reader.h | 2 +- lib_util/ambi_convert.c | 2 +- lib_util/ambi_convert.h | 2 +- lib_util/audio_file_reader.c | 2 +- lib_util/audio_file_reader.h | 2 +- lib_util/audio_file_writer.c | 2 +- lib_util/audio_file_writer.h | 2 +- lib_util/bitstream_reader.c | 2 +- lib_util/bitstream_reader.h | 2 +- lib_util/bitstream_writer.c | 2 +- lib_util/bitstream_writer.h | 2 +- lib_util/cmdl_tools.c | 2 +- lib_util/cmdl_tools.h | 2 +- lib_util/cmdln_parser.c | 2 +- lib_util/cmdln_parser.h | 2 +- lib_util/evs_rtp_payload.c | 2 +- lib_util/evs_rtp_payload.h | 2 +- lib_util/g192.c | 2 +- lib_util/g192.h | 2 +- lib_util/hrtf_file_reader.c | 2 +- lib_util/hrtf_file_reader.h | 2 +- lib_util/ism_file_reader.c | 2 +- lib_util/ism_file_reader.h | 2 +- lib_util/ism_file_writer.c | 2 +- lib_util/ism_file_writer.h | 2 +- lib_util/ivas_bpool.c | 2 +- lib_util/ivas_bpool.h | 2 +- lib_util/ivas_queue.c | 2 +- lib_util/ivas_queue.h | 2 +- lib_util/ivas_rtp_api.h | 2 +- lib_util/ivas_rtp_file.c | 2 +- lib_util/ivas_rtp_file.h | 2 +- lib_util/ivas_rtp_internal.h | 2 +- lib_util/ivas_rtp_payload.c | 2 +- lib_util/ivas_rtp_pi_data.c | 2 +- lib_util/ivas_rtp_pi_data.h | 2 +- lib_util/jbm_file_reader.c | 2 +- lib_util/jbm_file_reader.h | 2 +- lib_util/jbm_file_writer.c | 2 +- lib_util/jbm_file_writer.h | 2 +- lib_util/ls_custom_file_reader.c | 2 +- lib_util/ls_custom_file_reader.h | 2 +- lib_util/masa_file_reader.c | 2 +- lib_util/masa_file_reader.h | 2 +- lib_util/masa_file_writer.c | 2 +- lib_util/masa_file_writer.h | 2 +- lib_util/mime_io.c | 2 +- lib_util/mime_io.h | 2 +- lib_util/mutex.h | 2 +- lib_util/obj_edit_file_reader.c | 2 +- lib_util/obj_edit_file_reader.h | 2 +- lib_util/render_config_reader.c | 2 +- lib_util/render_config_reader.h | 2 +- lib_util/rotation_file_reader.c | 2 +- lib_util/rotation_file_reader.h | 2 +- lib_util/rtpdump.c | 2 +- lib_util/rtpdump.h | 2 +- lib_util/split_rend_bfi_file_reader.c | 2 +- lib_util/split_rend_bfi_file_reader.h | 2 +- lib_util/split_render_file_read_write.c | 2 +- lib_util/split_render_file_read_write.h | 2 +- lib_util/tinywavein_c.h | 2 +- lib_util/tinywaveout_c.h | 2 +- lib_util/vector3_pair_file_reader.c | 2 +- lib_util/vector3_pair_file_reader.h | 2 +- readme.txt | 2 +- 431 files changed, 431 insertions(+), 431 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index ca74eaf48..21616d00d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 816f96619..84f319238 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/decoder.c b/apps/decoder.c index 65344333d..c3a5434cb 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/encoder.c b/apps/encoder.c index 35347dec5..4f7ea89bf 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 80e1e9a9c..da63039f3 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 5c5d4ccc2..a9b7a5fa8 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/renderer.c b/apps/renderer.c index 8da507bbe..ace6a7393 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_basop/basop32.c b/lib_basop/basop32.c index eebc16849..27b499276 100644 --- a/lib_basop/basop32.c +++ b/lib_basop/basop32.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_basop/basop32.h b/lib_basop/basop32.h index 9bbf24f1c..7fe294167 100644 --- a/lib_basop/basop32.h +++ b/lib_basop/basop32.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_basop/enh40.c b/lib_basop/enh40.c index 570f4b211..57df99e5c 100644 --- a/lib_basop/enh40.c +++ b/lib_basop/enh40.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_basop/enh40.h b/lib_basop/enh40.h index 9c3742f3e..8cfb0c600 100644 --- a/lib_basop/enh40.h +++ b/lib_basop/enh40.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_basop/move.h b/lib_basop/move.h index fc4d4e18b..7f1003119 100644 --- a/lib_basop/move.h +++ b/lib_basop/move.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_basop/stl.h b/lib_basop/stl.h index d2f82d674..6badc3bcf 100644 --- a/lib_basop/stl.h +++ b/lib_basop/stl.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_basop/typedef.h b/lib_basop/typedef.h index 6ff6832e6..9968d4c84 100644 --- a/lib_basop/typedef.h +++ b/lib_basop/typedef.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_com_lpc.c b/lib_com/basop_com_lpc.c index 589d95707..398d75327 100644 --- a/lib_com/basop_com_lpc.c +++ b/lib_com/basop_com_lpc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_lsf_tools.c b/lib_com/basop_lsf_tools.c index a982e0f41..db40e08ef 100644 --- a/lib_com/basop_lsf_tools.c +++ b/lib_com/basop_lsf_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_proto_func.h b/lib_com/basop_proto_func.h index 549cc7ac0..845d14a27 100644 --- a/lib_com/basop_proto_func.h +++ b/lib_com/basop_proto_func.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_settings.h b/lib_com/basop_settings.h index fa809240a..79544c078 100644 --- a/lib_com/basop_settings.h +++ b/lib_com/basop_settings.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c index 5478dd1fe..7fa5e12be 100644 --- a/lib_com/basop_tcx_utils.c +++ b/lib_com/basop_tcx_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 0bf796702..551dbdeef 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index c63e62747..426516248 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 030c4746d..8f985c6ce 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 72a828102..49ca0627c 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 051b6024f..14cad4e9d 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 887d87119..aac5939fc 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/core_com_config_fx.c b/lib_com/core_com_config_fx.c index 90fc306b7..1afa2f1a9 100644 --- a/lib_com/core_com_config_fx.c +++ b/lib_com/core_com_config_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/deemph_fx.c b/lib_com/deemph_fx.c index 8442897c5..e141f9a67 100644 --- a/lib_com/deemph_fx.c +++ b/lib_com/deemph_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/delay_comp_fx.c b/lib_com/delay_comp_fx.c index fd5330aed..6d82271ba 100644 --- a/lib_com/delay_comp_fx.c +++ b/lib_com/delay_comp_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index ce456fb49..00bc46b47 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enr_1_az_fx.c b/lib_com/enr_1_az_fx.c index bb2f9ea19..108e25c3a 100644 --- a/lib_com/enr_1_az_fx.c +++ b/lib_com/enr_1_az_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_adj_fx.c b/lib_com/env_adj_fx.c index 0926ee071..0cf2906d5 100644 --- a/lib_com/env_adj_fx.c +++ b/lib_com/env_adj_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_stab_fx.c b/lib_com/env_stab_fx.c index f8e1e0ba4..33c3435db 100644 --- a/lib_com/env_stab_fx.c +++ b/lib_com/env_stab_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_stab_trans_fx.c b/lib_com/env_stab_trans_fx.c index 498301ef9..63b35b0d5 100644 --- a/lib_com/env_stab_trans_fx.c +++ b/lib_com/env_stab_trans_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft_cldfb_fx.c b/lib_com/fft_cldfb_fx.c index 230dd7ac5..0be5e2194 100644 --- a/lib_com/fft_cldfb_fx.c +++ b/lib_com/fft_cldfb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 6213e7a64..651820c6a 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fill_spectrum_fx.c b/lib_com/fill_spectrum_fx.c index 6bf0af303..e41eca0af 100644 --- a/lib_com/fill_spectrum_fx.c +++ b/lib_com/fill_spectrum_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/findpulse_fx.c b/lib_com/findpulse_fx.c index 64a311431..e95daaa69 100644 --- a/lib_com/findpulse_fx.c +++ b/lib_com/findpulse_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 163142bbf..6e7a6f2a2 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c index 7db540b19..7cf27be0b 100644 --- a/lib_com/get_gain_fx.c +++ b/lib_com/get_gain_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 57e6a2690..98b086e41 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 5a35108ec..c496a3777 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index cbc0dd179..1622a7b1e 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c index e4c671a74..40df76cae 100644 --- a/lib_com/hq2_bit_alloc_fx.c +++ b/lib_com/hq2_bit_alloc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index 3cf943725..db2397897 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index 7fc9f8fe9..c3b373d51 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index efdbea428..cc5f483ea 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ifft_rel_fx.c b/lib_com/ifft_rel_fx.c index e47f07128..933925b11 100644 --- a/lib_com/ifft_rel_fx.c +++ b/lib_com/ifft_rel_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c index 81c57c60f..d591389c0 100644 --- a/lib_com/int_lsp_fx.c +++ b/lib_com/int_lsp_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/interleave_spectrum_fx.c b/lib_com/interleave_spectrum_fx.c index c12623f0d..8847b9f5b 100644 --- a/lib_com/interleave_spectrum_fx.c +++ b/lib_com/interleave_spectrum_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/interpol_fx.c b/lib_com/interpol_fx.c index 5a78eb9bb..78c277a21 100644 --- a/lib_com/interpol_fx.c +++ b/lib_com/interpol_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/isf_dec_amr_wb_fx.c b/lib_com/isf_dec_amr_wb_fx.c index 5ab82ee6d..0d623b3f6 100644 --- a/lib_com/isf_dec_amr_wb_fx.c +++ b/lib_com/isf_dec_amr_wb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index 567adeb6b..35a4f1581 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_arith_fx.c b/lib_com/ivas_arith_fx.c index c708976da..aa261f69d 100644 --- a/lib_com/ivas_arith_fx.c +++ b/lib_com/ivas_arith_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_avq_pos_reorder_com_fx.c b/lib_com/ivas_avq_pos_reorder_com_fx.c index 25f8be3ad..5d05618e1 100644 --- a/lib_com/ivas_avq_pos_reorder_com_fx.c +++ b/lib_com/ivas_avq_pos_reorder_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 8af9b0247..f2cf7ca5c 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index 422717f8e..c81de6347 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 35a2cd4aa..cf256b368 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index 7519e9703..0ea623d29 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 1b69f35ef..3e965151e 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_error_utils.h b/lib_com/ivas_error_utils.h index 0c3d5ce04..791bc458d 100644 --- a/lib_com/ivas_error_utils.h +++ b/lib_com/ivas_error_utils.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index 2dcd8476b..3f1cb29e5 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index f9e35c65a..ffbdf7187 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 10c1f04b2..840949990 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c index 03b92a10f..8047af53f 100644 --- a/lib_com/ivas_lfe_com_fx.c +++ b/lib_com/ivas_lfe_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_limiter_fx.c b/lib_com/ivas_limiter_fx.c index fdd1bb97c..0ef37acdf 100644 --- a/lib_com/ivas_limiter_fx.c +++ b/lib_com/ivas_limiter_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index f55e99153..eb08f15bb 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c index c04ded09c..ffb526554 100644 --- a/lib_com/ivas_mc_com_fx.c +++ b/lib_com/ivas_mc_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c index 7cb186b58..01f8614cd 100644 --- a/lib_com/ivas_mc_param_com_fx.c +++ b/lib_com/ivas_mc_param_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mcmasa_com_fx.c b/lib_com/ivas_mcmasa_com_fx.c index 23a3800fb..b611b1290 100644 --- a/lib_com/ivas_mcmasa_com_fx.c +++ b/lib_com/ivas_mcmasa_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mct_com_fx.c b/lib_com/ivas_mct_com_fx.c index 81a56df14..bcfada29e 100644 --- a/lib_com/ivas_mct_com_fx.c +++ b/lib_com/ivas_mct_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdct_core_com_fx.c b/lib_com/ivas_mdct_core_com_fx.c index fe313eecd..ec623fbf1 100644 --- a/lib_com/ivas_mdct_core_com_fx.c +++ b/lib_com/ivas_mdct_core_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdct_imdct_fx.c b/lib_com/ivas_mdct_imdct_fx.c index 960b823ae..fde3edadd 100644 --- a/lib_com/ivas_mdct_imdct_fx.c +++ b/lib_com/ivas_mdct_imdct_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index d80d8a156..49d1cbbf1 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c index 7bbf287ac..e5986879b 100644 --- a/lib_com/ivas_omasa_com_fx.c +++ b/lib_com/ivas_omasa_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_osba_com_fx.c b/lib_com/ivas_osba_com_fx.c index 2f81a9574..5527f5389 100644 --- a/lib_com/ivas_osba_com_fx.c +++ b/lib_com/ivas_osba_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index 854578bfa..4669b86a3 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index ec26cdf06..790d5c479 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index f1a0a7609..93c3bd806 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c index 6a965850e..2a0e7797c 100644 --- a/lib_com/ivas_qspherical_com_fx.c +++ b/lib_com/ivas_qspherical_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index a145e0ca1..6081e450a 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 9ba733779..4ef543df7 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 2377e272b..4106e5d05 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 7e1fac44b..2658644cc 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index 57c4cd66e..652b095c1 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 6ca8fcc3f..4733e4fa0 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 93a62acd2..50820e240 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 4b232ecc9..2d8df33a0 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c index a23b5b700..c85ccf53f 100644 --- a/lib_com/ivas_stereo_dft_com_fx.c +++ b/lib_com/ivas_stereo_dft_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index 8328e220f..7d528f5b9 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 8b5e15908..705c1756d 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_mdct_bands_com_fx.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c index 43f2f16c7..09c9d94c2 100644 --- a/lib_com/ivas_stereo_mdct_bands_com_fx.c +++ b/lib_com/ivas_stereo_mdct_bands_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_mdct_stereo_com_fx.c b/lib_com/ivas_stereo_mdct_stereo_com_fx.c index 0a773169d..02d141da2 100644 --- a/lib_com/ivas_stereo_mdct_stereo_com_fx.c +++ b/lib_com/ivas_stereo_mdct_stereo_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_psychlpc_com_fx.c b/lib_com/ivas_stereo_psychlpc_com_fx.c index df5140895..3a130b8cb 100644 --- a/lib_com/ivas_stereo_psychlpc_com_fx.c +++ b/lib_com/ivas_stereo_psychlpc_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index 52933a593..45dfb3110 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 685508404..52a84a92d 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 9faba6131..2b200933a 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lag_wind_fx.c b/lib_com/lag_wind_fx.c index 3685cb834..a83b90b9b 100644 --- a/lib_com/lag_wind_fx.c +++ b/lib_com/lag_wind_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lerp_fx.c b/lib_com/lerp_fx.c index 632593c6f..2015a074c 100644 --- a/lib_com/lerp_fx.c +++ b/lib_com/lerp_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c index 70def05ae..4b096ac35 100644 --- a/lib_com/logqnorm_fx.c +++ b/lib_com/logqnorm_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/longarith.c b/lib_com/longarith.c index a922c2b4a..193c358cb 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index bb4cec6c2..5b3b8a1c0 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 945f3249d..c1638a269 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/mime.h b/lib_com/mime.h index 7d21f6aac..803e54cb0 100644 --- a/lib_com/mime.h +++ b/lib_com/mime.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index bbca86159..956f87251 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/nelp_fx.c b/lib_com/nelp_fx.c index 39d57299e..03b80f7de 100644 --- a/lib_com/nelp_fx.c +++ b/lib_com/nelp_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..930fcaf47 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ppp_fx.c b/lib_com/ppp_fx.c index 2f44e1081..12a35b393 100644 --- a/lib_com/ppp_fx.c +++ b/lib_com/ppp_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9c207b71e..1a194d468 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/reordvct_fx.c b/lib_com/reordvct_fx.c index 62eb2f352..e89e9ed38 100644 --- a/lib_com/reordvct_fx.c +++ b/lib_com/reordvct_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c index eb79cc026..321658f7a 100644 --- a/lib_com/rom_basop_util.c +++ b/lib_com/rom_basop_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_basop_util.h b/lib_com/rom_basop_util.h index 63b55fe59..ffbc7292a 100644 --- a/lib_com/rom_basop_util.h +++ b/lib_com/rom_basop_util.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 1ba9251d3..a61ee76af 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c index f1fdf7f78..eff398b33 100644 --- a/lib_com/rom_com_fx.c +++ b/lib_com/rom_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 52ba436de..9047c7ea4 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 2a37faef6..a85d6c7c0 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index cc8b22db6..a413064d2 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index 1326b31a9..4baf7f9a2 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tcx_mdct_window_fx.c b/lib_com/tcx_mdct_window_fx.c index 6075d034b..dd3ad48fe 100644 --- a/lib_com/tcx_mdct_window_fx.c +++ b/lib_com/tcx_mdct_window_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 4d5107de7..cd5ad9667 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/debug.c b/lib_debug/debug.c index f9b0e34c3..59ca6252e 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/debug.h b/lib_debug/debug.h index f1a40606b..5d905d0e4 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c index 18892a0d5..5f7e846ae 100644 --- a/lib_debug/sba_debug.c +++ b/lib_debug/sba_debug.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/sba_debug.h b/lib_debug/sba_debug.h index 2be427d52..850e7ab67 100644 --- a/lib_debug/sba_debug.h +++ b/lib_debug/sba_debug.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/snr.c b/lib_debug/snr.c index cf15a2907..743a632a6 100644 --- a/lib_debug/snr.c +++ b/lib_debug/snr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index c5d367699..71d8729aa 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ari_hm_dec_fx.c b/lib_dec/ari_hm_dec_fx.c index ecbf0b6b7..f2b1a0110 100644 --- a/lib_dec/ari_hm_dec_fx.c +++ b/lib_dec/ari_hm_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 52f977d59..e031fd696 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index eb6f6693f..c091579e4 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 2fda2e5f3..cdfb16699 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 288cd9a03..6e6ac9d35 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 8e94de138..450079744 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index d6f1f8f49..06f11158a 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index d799df603..d61e3ff4b 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 7d389ec0f..b18a76052 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_entropy_decoder_fx.c b/lib_dec/ivas_entropy_decoder_fx.c index f8bf3c091..ea350ff4a 100644 --- a/lib_dec/ivas_entropy_decoder_fx.c +++ b/lib_dec/ivas_entropy_decoder_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index b32406a20..6e6031712 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index a00a857b6..b087ab906 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index f69fe17ea..b98640b7a 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index c89eb8c49..4fe9e5767 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index d5257f9ee..00c95d6dc 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 8b7c773fc..bd1b654e9 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 2104fc451..dd0ca93f3 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 2fa66e34c..31ad2acf2 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index b50fe2120..0d3da5e33 100755 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ls_custom_dec_fx.c b/lib_dec/ivas_ls_custom_dec_fx.c index 5ad390f9a..b6ae99039 100644 --- a/lib_dec/ivas_ls_custom_dec_fx.c +++ b/lib_dec/ivas_ls_custom_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 31a6c45ee..140eb764d 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index b66cfae01..ea889cc7b 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 8eaf0577a..608644c72 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c index d12b190c6..b4fa9d08c 100644 --- a/lib_dec/ivas_mcmasa_dec_fx.c +++ b/lib_dec/ivas_mcmasa_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index 5f764533a..2bba7429b 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 214b1d2bb..5e2264916 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 8f8d3c7b1..f4d289ee2 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 41fed3e0c..c085d5674 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 63cf7f87a..36d5bd48a 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index ac58b9dfd..999fe3824 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 8f0785769..f06e1ec85 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index c6abf897b..622cd88c8 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 01f78da05..a8fe1d0b0 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 932f07606..b57f4100b 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index fc531c34d..e5cab04c0 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index b23cced7f..b6eb91fd9 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index 261133d93..7974350ce 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_qspherical_dec_fx.c b/lib_dec/ivas_qspherical_dec_fx.c index f443cc81d..f0a7b03f6 100644 --- a/lib_dec/ivas_qspherical_dec_fx.c +++ b/lib_dec/ivas_qspherical_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c index 7b6d428db..540c33123 100644 --- a/lib_dec/ivas_range_uni_dec_fx.c +++ b/lib_dec/ivas_range_uni_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 0b29588b2..04613f1a5 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_rom_dec_fx.c b/lib_dec/ivas_rom_dec_fx.c index 3209278ed..f86a8ee88 100644 --- a/lib_dec/ivas_rom_dec_fx.c +++ b/lib_dec/ivas_rom_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 8df43f1a4..789c0e954 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index bc59901c9..dfc51cc74 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 7cfe4f821..d595b8ae5 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 8d5f7d0c3..75266dcef 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index b86234ec9..1120c4eb9 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten FORschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index bea27a067..bc819763b 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index e90f69550..15e156557 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 47a74c60b..1f406c338 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c index 57166fae4..064f31719 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 7edb49a92..bf09e2336 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 32321454c..125063b3f 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index a8548e0f1..b578f52c3 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 5eb94868e..4ded8044f 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_eclvq_dec_fx.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c index 9d777c9b7..f487d2f0c 100644 --- a/lib_dec/ivas_stereo_eclvq_dec_fx.c +++ b/lib_dec/ivas_stereo_eclvq_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_esf_dec_fx.c b/lib_dec/ivas_stereo_esf_dec_fx.c index d4219f1e6..a438c3e5c 100644 --- a/lib_dec/ivas_stereo_esf_dec_fx.c +++ b/lib_dec/ivas_stereo_esf_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 5f39c179e..9345fccae 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 8cf565a5e..0dc9e7886 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index d8c1ad18f..c1dc964af 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 6ea211cb2..654f2bd13 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index e8fddd58c..63e9e792e 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index 0c91bd3c4..39b861ace 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index b7a0eaedf..422617f7a 100755 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 3b4cc87f3..eb0c7462c 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 205093d6f..6273cd186 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_circularbuffer.h b/lib_dec/jbm_jb4_circularbuffer.h index 36325c8c7..4817f1649 100644 --- a/lib_dec/jbm_jb4_circularbuffer.h +++ b/lib_dec/jbm_jb4_circularbuffer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_circularbuffer_fx.c b/lib_dec/jbm_jb4_circularbuffer_fx.c index 943419684..b26e8c49e 100644 --- a/lib_dec/jbm_jb4_circularbuffer_fx.c +++ b/lib_dec/jbm_jb4_circularbuffer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_inputbuffer.h b/lib_dec/jbm_jb4_inputbuffer.h index 93174a082..efd782488 100644 --- a/lib_dec/jbm_jb4_inputbuffer.h +++ b/lib_dec/jbm_jb4_inputbuffer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_inputbuffer_fx.c b/lib_dec/jbm_jb4_inputbuffer_fx.c index 3e16f8ef5..9dc813022 100644 --- a/lib_dec/jbm_jb4_inputbuffer_fx.c +++ b/lib_dec/jbm_jb4_inputbuffer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_jmf.h b/lib_dec/jbm_jb4_jmf.h index 255c8a39a..a55991780 100644 --- a/lib_dec/jbm_jb4_jmf.h +++ b/lib_dec/jbm_jb4_jmf.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_jmf_fx.c b/lib_dec/jbm_jb4_jmf_fx.c index 086c76e5a..ba17c5cd8 100644 --- a/lib_dec/jbm_jb4_jmf_fx.c +++ b/lib_dec/jbm_jb4_jmf_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h index f579a5f25..ced9edadb 100644 --- a/lib_dec/jbm_jb4sb.h +++ b/lib_dec/jbm_jb4sb.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4sb_fx.c b/lib_dec/jbm_jb4sb_fx.c index c4b33817c..e93e4f7cf 100644 --- a/lib_dec/jbm_jb4sb_fx.c +++ b/lib_dec/jbm_jb4sb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 2fdc1f625..220d301a7 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 8adcb9a3e..27fc1afa0 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h index 80a3ddb90..77e9b655c 100644 --- a/lib_dec/jbm_pcmdsp_fifo.h +++ b/lib_dec/jbm_pcmdsp_fifo.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index 5b3b6ac61..5ab60f3be 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index f6a15302a..16fd9193f 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h index 2d0d0be0b..c18d11ec7 100644 --- a/lib_dec/jbm_pcmdsp_window.h +++ b/lib_dec/jbm_pcmdsp_window.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_window_fx.c b/lib_dec/jbm_pcmdsp_window_fx.c index 62565ba52..73faf37e2 100644 --- a/lib_dec/jbm_pcmdsp_window_fx.c +++ b/lib_dec/jbm_pcmdsp_window_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 5bbfd604e..d89bd37c2 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 17a8d966e..4a99ce5f2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rom_dec.h b/lib_dec/rom_dec.h index b4c7e4780..cfa8455bf 100644 --- a/lib_dec/rom_dec.h +++ b/lib_dec/rom_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rom_dec_fx.c b/lib_dec/rom_dec_fx.c index 01be2c7cc..f3539d640 100644 --- a/lib_dec/rom_dec_fx.c +++ b/lib_dec/rom_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 57072b9a4..429070d85 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod4t64_fast_fx.c b/lib_enc/cod4t64_fast_fx.c index 0cf8074f6..4bba58255 100644 --- a/lib_enc/cod4t64_fast_fx.c +++ b/lib_enc/cod4t64_fast_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 71c56cecf..173092cdf 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index d565fea0c..11f5fe90c 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index 16f2560d1..c9a549e5a 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 07ae94937..b58fe5177 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c index d58998565..bbb734f9c 100644 --- a/lib_enc/isf_enc_amr_wb_fx.c +++ b/lib_enc/isf_enc_amr_wb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index e5af93e39..52e5fbea5 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 7dd2bcb04..ddbe6e782 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index d17b4d358..dd9af7647 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 7e13ed80a..a72585986 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 2efae00e2..9ac247820 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index f0ba8fc26..a097f7bee 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 17704e9bf..79448bd19 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 91c44fcf7..5e9c82f7a 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 32360fd41..2d652a683 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index fde0d8bd5..cde223784 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c index ddd4df2de..eb4b00cf8 100644 --- a/lib_enc/ivas_entropy_coder_fx.c +++ b/lib_enc/ivas_entropy_coder_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 1e68a3905..b6df30eda 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index e4d8b13ee..06df36fe5 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 72f362fd7..940cf63f8 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index be2e223f3..a157749c4 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 5876f130f..f4866c7f3 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index dbe3f541e..2d149d030 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 9d05dbfc4..9ed990f8a 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index cb3b6e563..ef6514e63 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 0c4073fc0..f17bee69a 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index 7e9af16a3..2776799ed 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index a33fa9094..100d6b6bb 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index d4fd50dbf..2ab37c67e 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 534450f79..58552eb7f 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index de906bde1..5b2642030 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 81d8757e0..19f52647f 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index a0ea4e8cd..f49e9ebbc 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 51ed0954e..1f19fa21d 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index e9fbfac46..7228d134e 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 4753e5276..7bc4560cf 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c index 09d61c610..5a9c3bb4f 100644 --- a/lib_enc/ivas_qspherical_enc_fx.c +++ b/lib_enc/ivas_qspherical_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c index 949625722..2efcf8f23 100644 --- a/lib_enc/ivas_range_uni_enc_fx.c +++ b/lib_enc/ivas_range_uni_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index d1e644a93..cd296fa14 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_rom_enc_fx.c b/lib_enc/ivas_rom_enc_fx.c index 671e20a00..6829a16ce 100644 --- a/lib_enc/ivas_rom_enc_fx.c +++ b/lib_enc/ivas_rom_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index 574d10f96..c2a63a2e0 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 144e86643..dd07017e5 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 0beb13759..01ff6b24e 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index d23d69a20..3b65bc438 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index f5cc2ba80..2d68dc00b 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 7096198a9..c984a5ea3 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c index 3e4a5040d..bf54b6901 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index 88469e818..9538302fa 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c index 929d35b91..c9f4fe9a1 100644 --- a/lib_enc/ivas_stereo_cng_enc_fx.c +++ b/lib_enc/ivas_stereo_cng_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 8f6c7663e..729df8737 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 09d5f0c91..b1f709bd9 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 94a57b036..ac42b9679 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index f04f65b13..e7d359059 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c index 05f9dc80d..bdc9be253 100644 --- a/lib_enc/ivas_stereo_eclvq_enc_fx.c +++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 32d70a8b7..c50ea4c0c 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 2d6c17d9f..61a2f0490 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index e764649df..705635d88 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index 39f4f4149..397d72c32 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 055e22593..31f337521 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 8507bc58c..d99a95d7a 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index 1eff3cd9e..e9a6cd843 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index ceaf24790..92bd08afd 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 18d79f26d..b4defbc1c 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 5eb5ae562..b14a2d27d 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 8cf6be1cd..c5f124e57 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index fdadb6695..3c6baff39 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index dbd6c9607..45e132898 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 82443f044..0b607089f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h index f92243a5a..526136e69 100644 --- a/lib_enc/rom_enc.h +++ b/lib_enc/rom_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/rom_enc_fx.c b/lib_enc/rom_enc_fx.c index 4af957800..9c7f3f53e 100644 --- a/lib_enc/rom_enc_fx.c +++ b/lib_enc/rom_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index bcd7ed72c..be38f731c 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 4c0061c60..639e470fe 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_MSPred.c b/lib_isar/isar_MSPred.c index aaa26903b..6698a12b3 100644 --- a/lib_isar/isar_MSPred.c +++ b/lib_isar/isar_MSPred.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index 54265bc5e..bed0d5630 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index 5e68d90c9..0f8ac0f0a 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 4a75ca0d8..1cad13a8c 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 28685b23e..c5a3b1ded 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index f666b453e..449577f43 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index f7fe0db32..68e160538 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index 3b52e5b3f..5af4f80a8 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 2ac21e4d3..7f158cc04 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index 8328b1fa7..461e15dc8 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 54dd6df23..9795833a3 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h index 6dd08733f..793da7b9f 100644 --- a/lib_isar/isar_lc3plus_enc.h +++ b/lib_isar/isar_lc3plus_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c index 2493aa6a3..0a201b074 100644 --- a/lib_isar/isar_lc3plus_payload.c +++ b/lib_isar/isar_lc3plus_payload.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h index 580a58ca6..7ebdb3342 100644 --- a/lib_isar/isar_lc3plus_payload.h +++ b/lib_isar/isar_lc3plus_payload.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index e70633669..e296a2e0d 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index e3296db25..13dbb1a83 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index 90d0c1d63..d16d32326 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index fb7bfc11b..43990c55b 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_rom_lcld_tables.c b/lib_isar/isar_rom_lcld_tables.c index 5fd334447..d3b596b40 100644 --- a/lib_isar/isar_rom_lcld_tables.c +++ b/lib_isar/isar_rom_lcld_tables.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_rom_lcld_tables.h b/lib_isar/isar_rom_lcld_tables.h index a2cbe5f25..0b8a46bb6 100644 --- a/lib_isar/isar_rom_lcld_tables.h +++ b/lib_isar/isar_rom_lcld_tables.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c index 5591fbb3a..2e4bf8ab8 100644 --- a/lib_isar/isar_rom_post_rend.c +++ b/lib_isar/isar_rom_post_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h index a08bb174f..b7bca73bd 100644 --- a/lib_isar/isar_rom_post_rend.h +++ b/lib_isar/isar_rom_post_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index 07017803e..b4047a750 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index 567cec0a4..32346f887 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 418242d60..d29a52722 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index bb3a57a66..380b9f976 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 1f7014bab..f657e7d4b 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index fc0ecf0d5..f8359c18f 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index e91184f4c..484948588 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 1f0b01a83..7292f1a66 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index ba22fba6a..c4bfcf699 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 05b98f6a4..f9858f413 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index f06877bbe..e085852d1 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index a93f3092a..34563e8c3 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -1,7 +1,7 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_binRenderer_internal_fx.c b/lib_rend/ivas_binRenderer_internal_fx.c index 1ac6d5bbf..14818c7c3 100644 --- a/lib_rend/ivas_binRenderer_internal_fx.c +++ b/lib_rend/ivas_binRenderer_internal_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index d3c18a4f9..e6de5e65d 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 2a4e26937..b90b9deb8 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 52bedea05..9bdbc987e 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 24eab4297..011d4b253 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index a4f703a28..bd5585c08 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index 1e105ba22..5abc1f73e 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index de25c56e5..5372c3830 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 83ce8af45..6c2f9781e 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index c85d89b85..c5bbfb2ea 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index d240d64ef..537323af5 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index bb2cd94c2..b645be551 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index b2a4e0d00..1e0becc38 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 6f7e7a0cf..9c76335e0 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index 00036a8cd..d5abb8fce 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index ac2067c00..a0a57d0a2 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index 185cba09e..1c899f95b 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 015d227a2..f91ed65fa 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c index ded14eb09..81268e578 100644 --- a/lib_rend/ivas_objectRenderer_vec_fx.c +++ b/lib_rend/ivas_objectRenderer_vec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index b1405a309..5b0d42793 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 201f5a826..571106b6c 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 0ac341e39..5b3dec0d1 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 039b251ca..b393971b7 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index c342d5ca2..22a332ab1 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 9a6f79fea..81f66bf60 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index 5e7b206c8..d3a0f5bb2 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index 6453b32d7..dcf13c153 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 3b896a137..6d23b0053 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 773f59276..9ffd74322 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index f4f0cf516..e4ce77b65 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 52cb0f130..05b3f8af6 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index f3d675a99..176dc1f3e 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c index 954ae2759..980b69242 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 30746b3d8..178a50b7c 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c index 3c090f204..37b472fc9 100644 --- a/lib_rend/ivas_rom_binauralRenderer_fx.c +++ b/lib_rend/ivas_rom_binauralRenderer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index ae97fc0fe..a0f13e471 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 9be532b79..28ebb28e0 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index d52ade0db..7a1cf8971 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index c8114e0be..18c018f29 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 5e82d304e..50b0b0f84 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index c60e68090..f4fab9d6e 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index 631e5351e..e6def409e 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 8b7580a4f..1a6e33e72 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 4f51a8b5f..d2ebd34d8 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 78fde65d8..98905d25e 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index fdbd4f530..19b4b1f56 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index ff8ce19bd..3ce6d0bb3 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 101015fd0..e7534b558 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/aeid_file_reader.c b/lib_util/aeid_file_reader.c index 6f877452e..4433ced8d 100644 --- a/lib_util/aeid_file_reader.c +++ b/lib_util/aeid_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/aeid_file_reader.h b/lib_util/aeid_file_reader.h index 55a141284..789b166f4 100644 --- a/lib_util/aeid_file_reader.h +++ b/lib_util/aeid_file_reader.h @@ -1,7 +1,7 @@ #pragma once /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 713e88f60..08572b883 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 95a447f15..eb8d094f8 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index 0b6e44660..f342c64c4 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_reader.h b/lib_util/audio_file_reader.h index 571c1e765..376b649b8 100644 --- a/lib_util/audio_file_reader.h +++ b/lib_util/audio_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_writer.c b/lib_util/audio_file_writer.c index eb9301834..e008aa886 100644 --- a/lib_util/audio_file_writer.c +++ b/lib_util/audio_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_writer.h b/lib_util/audio_file_writer.h index 2622992ce..62c74f1a8 100644 --- a/lib_util/audio_file_writer.h +++ b/lib_util/audio_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_reader.c b/lib_util/bitstream_reader.c index 6d40260b5..2a452abb6 100644 --- a/lib_util/bitstream_reader.c +++ b/lib_util/bitstream_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_reader.h b/lib_util/bitstream_reader.h index fb6f9f9b9..51159dd5b 100644 --- a/lib_util/bitstream_reader.h +++ b/lib_util/bitstream_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_writer.c b/lib_util/bitstream_writer.c index bff9f461b..13981bd01 100644 --- a/lib_util/bitstream_writer.c +++ b/lib_util/bitstream_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_writer.h b/lib_util/bitstream_writer.h index f3efd4ddf..0d7d47472 100644 --- a/lib_util/bitstream_writer.h +++ b/lib_util/bitstream_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index 945bda07d..c58b4d25a 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdl_tools.h b/lib_util/cmdl_tools.h index 327acb93d..8248d07c4 100644 --- a/lib_util/cmdl_tools.h +++ b/lib_util/cmdl_tools.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c index 1b9eb7a92..a52c9514c 100644 --- a/lib_util/cmdln_parser.c +++ b/lib_util/cmdln_parser.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdln_parser.h b/lib_util/cmdln_parser.h index 2627d5566..2222735fa 100644 --- a/lib_util/cmdln_parser.h +++ b/lib_util/cmdln_parser.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/evs_rtp_payload.c b/lib_util/evs_rtp_payload.c index 280ddb323..fef44d646 100644 --- a/lib_util/evs_rtp_payload.c +++ b/lib_util/evs_rtp_payload.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/evs_rtp_payload.h b/lib_util/evs_rtp_payload.h index f97d9b7a6..00f634574 100644 --- a/lib_util/evs_rtp_payload.h +++ b/lib_util/evs_rtp_payload.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/g192.c b/lib_util/g192.c index 5a8ed1065..3779b417f 100644 --- a/lib_util/g192.c +++ b/lib_util/g192.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/g192.h b/lib_util/g192.h index e6ad2b4ee..93ba57c8e 100644 --- a/lib_util/g192.h +++ b/lib_util/g192.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 02e99ae84..45a59b249 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index c503caa73..d404395e0 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index d0caaa889..ce4b6fd3b 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_reader.h b/lib_util/ism_file_reader.h index c785cc294..561eba40f 100644 --- a/lib_util/ism_file_reader.h +++ b/lib_util/ism_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index ed098c601..acbd7ec59 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_writer.h b/lib_util/ism_file_writer.h index 6bf1a3e31..dbebe1bad 100644 --- a/lib_util/ism_file_writer.h +++ b/lib_util/ism_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_bpool.c b/lib_util/ivas_bpool.c index 9db909f53..0ba94528f 100644 --- a/lib_util/ivas_bpool.c +++ b/lib_util/ivas_bpool.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_bpool.h b/lib_util/ivas_bpool.h index 30cf4962b..06281b453 100644 --- a/lib_util/ivas_bpool.h +++ b/lib_util/ivas_bpool.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_queue.c b/lib_util/ivas_queue.c index b17cf3e21..7c8be93af 100644 --- a/lib_util/ivas_queue.c +++ b/lib_util/ivas_queue.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_queue.h b/lib_util/ivas_queue.h index 1c6b77504..a1df80035 100644 --- a/lib_util/ivas_queue.h +++ b/lib_util/ivas_queue.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h index a697087ab..f196539fb 100644 --- a/lib_util/ivas_rtp_api.h +++ b/lib_util/ivas_rtp_api.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index d694463a6..37d03a385 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index f5c5dc70e..a3742c6c8 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_rtp_internal.h b/lib_util/ivas_rtp_internal.h index c373304a8..afa4c3c60 100644 --- a/lib_util/ivas_rtp_internal.h +++ b/lib_util/ivas_rtp_internal.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 8f28e38d2..137c44119 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index c4e377bae..b533d07c2 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index efdbde2eb..4f156a9de 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_reader.c b/lib_util/jbm_file_reader.c index 68caf5ae7..556d8cd67 100644 --- a/lib_util/jbm_file_reader.c +++ b/lib_util/jbm_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_reader.h b/lib_util/jbm_file_reader.h index e824e1eee..f6ecee961 100644 --- a/lib_util/jbm_file_reader.h +++ b/lib_util/jbm_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_writer.c b/lib_util/jbm_file_writer.c index 9d11dad90..da27b218c 100644 --- a/lib_util/jbm_file_writer.c +++ b/lib_util/jbm_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_writer.h b/lib_util/jbm_file_writer.h index aca768a1a..7dd339ad3 100644 --- a/lib_util/jbm_file_writer.h +++ b/lib_util/jbm_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 5c1ac6ae0..38e76642b 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ls_custom_file_reader.h b/lib_util/ls_custom_file_reader.h index 46b20a4ff..d5ead2841 100644 --- a/lib_util/ls_custom_file_reader.h +++ b/lib_util/ls_custom_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index d782cdfd0..a7253ecd2 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_reader.h b/lib_util/masa_file_reader.h index 7510598c3..d430a9194 100644 --- a/lib_util/masa_file_reader.h +++ b/lib_util/masa_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index a1c4d7054..371fb201e 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_writer.h b/lib_util/masa_file_writer.h index 74d098388..c2d51d394 100644 --- a/lib_util/masa_file_writer.h +++ b/lib_util/masa_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 3e837ca45..9b20aaeb5 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/mime_io.h b/lib_util/mime_io.h index dbd21c9c7..d3b0d7a58 100644 --- a/lib_util/mime_io.h +++ b/lib_util/mime_io.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/mutex.h b/lib_util/mutex.h index 82094b61c..64f5d2c58 100644 --- a/lib_util/mutex.h +++ b/lib_util/mutex.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/obj_edit_file_reader.c b/lib_util/obj_edit_file_reader.c index fee43f23c..22163d23d 100644 --- a/lib_util/obj_edit_file_reader.c +++ b/lib_util/obj_edit_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** -(C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, +(C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h index 016425c2e..352202ef5 100644 --- a/lib_util/obj_edit_file_reader.h +++ b/lib_util/obj_edit_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** -(C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, +(C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 26291be99..05018fcb1 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 3a7ee1017..c533f1393 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 4385a9f83..5530371b0 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rotation_file_reader.h b/lib_util/rotation_file_reader.h index 8d6206bd6..4cb9e5f6a 100644 --- a/lib_util/rotation_file_reader.h +++ b/lib_util/rotation_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rtpdump.c b/lib_util/rtpdump.c index 0b818ee19..df51a1972 100644 --- a/lib_util/rtpdump.c +++ b/lib_util/rtpdump.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rtpdump.h b/lib_util/rtpdump.h index 366f95d57..8ddfde750 100644 --- a/lib_util/rtpdump.h +++ b/lib_util/rtpdump.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 6a86738e0..ec9755019 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h index 0956b6b3d..57e6294f8 100644 --- a/lib_util/split_rend_bfi_file_reader.h +++ b/lib_util/split_rend_bfi_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 75fd30d88..d33c2b6dc 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 0ea113e89..bfb0a191c 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/tinywavein_c.h b/lib_util/tinywavein_c.h index 1ff6f26bb..6e0e69beb 100644 --- a/lib_util/tinywavein_c.h +++ b/lib_util/tinywavein_c.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/tinywaveout_c.h b/lib_util/tinywaveout_c.h index a3982ba19..bbb97c603 100644 --- a/lib_util/tinywaveout_c.h +++ b/lib_util/tinywaveout_c.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index 737ef91af..c6758b6b1 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/vector3_pair_file_reader.h b/lib_util/vector3_pair_file_reader.h index 6515d32d5..af4a6c991 100644 --- a/lib_util/vector3_pair_file_reader.h +++ b/lib_util/vector3_pair_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/readme.txt b/readme.txt index f2c21eab2..f30b97b28 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other -- GitLab From c93eec3464ebb91f8616749c0ba28a8038f345cb Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 14:27:22 +0100 Subject: [PATCH 440/750] fix within FIX_2344_ALIGN_PREPROC --- lib_enc/ivas_core_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index c640d8a2e..dc3502265 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -761,7 +761,7 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); #ifdef FIX_2344_ALIGN_PREPROC - IF( st->tcxonly == 0 ) + IF( st->tcxonly == 0 || hStereoICBWE != NULL ) #endif { shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); -- GitLab From 0c87fc659efbe5a6a12231fb5121aec641d24b7e Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jan 2026 15:28:34 +0200 Subject: [PATCH 441/750] Fix basop issue 2323 by using correct init size. --- lib_com/options.h | 1 + lib_enc/ivas_dirac_enc_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..45a13d2cb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT /* Nokia/FhG: basop issue 2323: Use correct init size */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 91c44fcf7..cd3f40ddd 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -1574,9 +1574,17 @@ void computeDiffuseness_mdft_fx( set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) ); set16_fx( intensity_slow_e, 0, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) ); set_zero_fx( intensity_slow_abs, MASA_FREQUENCY_BANDS ); +#ifdef FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT + set16_fx( intensity_slow_abs_e, 0, MASA_FREQUENCY_BANDS ); +#else set16_fx( intensity_slow_abs_e, 0, no_col_avg_diff ); +#endif set_zero_fx( energy_slow, MASA_FREQUENCY_BANDS ); +#ifdef FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT + set16_fx( energy_slow_e, 0, MASA_FREQUENCY_BANDS ); +#else set16_fx( energy_slow_e, 0, no_col_avg_diff ); +#endif FOR( i = 0; i < no_col_avg_diff; ++i ) { -- GitLab From b87e5972bcb40aa5bb52e9bea3c9c408a94391dd Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 15:23:20 +0100 Subject: [PATCH 442/750] fix HARM_NON_LINEARITY --- lib_com/options.h | 1 + lib_com/prot_fx.h | 19 ++++++++-------- lib_com/swb_tbe_com_fx.c | 43 +++++++++++++++++++++++-------------- lib_dec/acelp_core_dec_fx.c | 4 ++++ lib_enc/acelp_core_enc_fx.c | 4 ++++ 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ffac0ff4e..49b6d9802 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9c207b71e..8076cd1ea 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3165,16 +3165,17 @@ void ScaleShapedWB_fx( ); void non_linearity_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + const Word16 Q_inp, /* i : scaling of input */ + const Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ ); +#ifndef HARM_NON_LINEARITY void non_linearity_ivas_fx( const Word16 i[], /* i : i signal Q_inp */ Word32 output[], /* o : output signal 2*Q_inp */ @@ -3185,7 +3186,7 @@ void non_linearity_ivas_fx( Word16 *voice_factors, /* i : Voice Factors */ const Word16 L_frame /* i : ACELP frame length */ ); - +#endif void interp_code_5over2_fx( const Word16 inp_code[], /* i : i vector */ Word16 interp_code[], /* o : output vector */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index d65434759..0ad5eff5d 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -5327,6 +5327,7 @@ void ScaleShapedWB_fx( return; } +#ifndef HARM_NON_LINEARITY /*-------------------------------------------------------------------* * non_linearity() * @@ -5399,7 +5400,7 @@ static Word32 non_linearity_scaled_copy( } return prev_scale; } - +#endif /*-------------------------------------------------------------------* * non_linearity() @@ -5407,9 +5408,13 @@ static Word32 non_linearity_scaled_copy( * Apply a non linearity to the SHB excitation * -------------------------------------------------------------------*/ +#ifdef HARM_NON_LINEARITY +static Word32 non_linearity_scaled_copy( +#else static Word32 non_linearity_scaled_copy_ivas( +#endif const Word16 input[], - Word16 j, + const Word16 j, const Word16 length, Word32 output[], Word32 prev_scale, @@ -5419,7 +5424,6 @@ static Word32 non_linearity_scaled_copy_ivas( Word16 i; Word32 L_tmp; - IF( en_abs ) { FOR( i = 0; i < j; i++ ) @@ -5507,6 +5511,7 @@ static Word32 non_linearity_scaled_copy_ivas( move32(); } } + return prev_scale; } @@ -5533,16 +5538,16 @@ static Word32 non_linearity_scaled_copy_ivas( /*==========================================================================*/ void non_linearity_fx( - const Word16 input[], /* i : input signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : input length */ - Word32 *pPrevScale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ - + const Word16 input[], /* i : input signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : input length */ + Word32 *pPrevScale, /* i/o: memory Q30 */ + const Word16 Q_inp, /* i : scaling of input */ + const Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ ) +#ifndef HARM_NON_LINEARITY { Word16 i, j; Word16 max_val = 0; @@ -5783,6 +5788,7 @@ void non_linearity_ivas_fx( const Word16 L_frame /* i : ACELP frame length */ ) +#endif { Word16 i, j; Word16 max_val = 0; @@ -5820,7 +5826,6 @@ void non_linearity_ivas_fx( move16(); /* 0.94*4 in Q12 */ } - FOR( i = 0; i < nframes; i++ ) { v_fac = add( v_fac, shr( voice_factors[i], 3 ) ); /* Q12 */ @@ -5837,7 +5842,6 @@ void non_linearity_ivas_fx( prev_scale = *pPrevScale; move32(); - /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */ FOR( i = j = 0; i < length_half; i++ ) @@ -5851,7 +5855,6 @@ void non_linearity_ivas_fx( max_val = s_max( max_val, tmp ); } - IF( GT_16( max_val, shl_sat( 1, Q_inp ) ) ) { exp = norm_s( max_val ); @@ -5866,6 +5869,7 @@ void non_linearity_ivas_fx( sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ + test(); IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ { @@ -5875,7 +5879,6 @@ void non_linearity_ivas_fx( } ELSE { - /* Computing log2(scale) */ IF( j == 0 ) { @@ -5912,7 +5915,11 @@ void non_linearity_ivas_fx( } } +#ifdef HARM_NON_LINEARITY + prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs ); +#else prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs ); +#endif max_val = 0; move16(); @@ -5989,7 +5996,11 @@ void non_linearity_ivas_fx( } } +#ifdef HARM_NON_LINEARITY + prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); +#else prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); +#endif *pPrevScale = prev_scale; move32(); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index c5d367699..035800779 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2286,7 +2286,11 @@ ivas_error acelp_core_dec_fx( ELSE { Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_exc) */ +#ifdef HARM_NON_LINEARITY + non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); +#else non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); +#endif exp = sub( L_norm_arr( bwe_exc_extended_fx + L_FRAME32k, NL_BUFF_OFFSET ), 16 ); Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, exp ); /* Q(2 * Q_exc) -> Q(q_old_bwe_exc_extended_fx) */ st->hBWE_TD->q_old_bwe_exc_extended_fx = add( shl( st->Q_exc, 1 ), exp ); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 93b4b46e3..28e8eeb08 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1434,7 +1434,11 @@ ivas_error acelp_core_enc_ivas_fx( { /* Apply a non linearity to the SHB excitation */ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc +#ifdef HARM_NON_LINEARITY + non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); +#else non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); +#endif Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc } -- GitLab From 308dc44c392347db3b4f1c6331ee1cf361ff3296 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 20:36:23 +0100 Subject: [PATCH 443/750] temp. fix to keep BE until #1504 (FLP) is solved --- lib_enc/ivas_core_enc_fx.c | 3 ++- lib_enc/ivas_core_pre_proc_fx.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index dc3502265..57191757d 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -761,7 +761,8 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); #ifdef FIX_2344_ALIGN_PREPROC - IF( st->tcxonly == 0 || hStereoICBWE != NULL ) + IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become: + // IF( st->tcxonly == 0 ) #endif { shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 76bf25027..92e7dab6e 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1134,6 +1134,7 @@ ivas_error ivas_compute_core_buffers_fx( shift = sub( norm_s( inp_max ), 1 /* headroom */ ); #else Word16 shift = sub( norm_s( inp_max ), headroom ); + Word16 Q_min, i; #endif shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); -- GitLab From 7738e1ea85313cfe14744174b66248d57931992b Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 21:15:42 +0100 Subject: [PATCH 444/750] fix EVS BE --- lib_com/prot_fx.h | 3 + lib_com/swb_tbe_com_fx.c | 107 +++++++++++++++++++++++++------- lib_dec/acelp_core_dec_fx.c | 6 +- lib_dec/dec_acelp_tcx_main_fx.c | 4 ++ lib_enc/acelp_core_enc_fx.c | 6 +- lib_enc/enc_acelp_tcx_main_fx.c | 6 +- 6 files changed, 108 insertions(+), 24 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8076cd1ea..2599d8b12 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3165,6 +3165,9 @@ void ScaleShapedWB_fx( ); void non_linearity_fx( +#ifdef HARM_NON_LINEARITY + const Word16 element_mode, /* i : element mode */ +#endif const Word16 i[], /* i : i signal Q_inp */ Word32 output[], /* o : output signal 2*Q_inp */ const Word16 length, /* i : i length */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 0ad5eff5d..5323e59da 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -5327,7 +5327,7 @@ void ScaleShapedWB_fx( return; } -#ifndef HARM_NON_LINEARITY + /*-------------------------------------------------------------------* * non_linearity() * @@ -5336,7 +5336,7 @@ void ScaleShapedWB_fx( static Word32 non_linearity_scaled_copy( const Word16 input[], - Word16 j, + const Word16 j, const Word16 length, Word32 output[], Word32 prev_scale, @@ -5346,7 +5346,6 @@ static Word32 non_linearity_scaled_copy( Word16 i; Word32 L_tmp; - IF( en_abs ) { FOR( i = 0; i < j; i++ ) @@ -5398,21 +5397,18 @@ static Word32 non_linearity_scaled_copy( move32(); } } + return prev_scale; } -#endif + /*-------------------------------------------------------------------* * non_linearity() * - * Apply a non linearity to the SHB excitation + * Apply a non linearity to the SHB excitation in IVAS formats * -------------------------------------------------------------------*/ -#ifdef HARM_NON_LINEARITY -static Word32 non_linearity_scaled_copy( -#else static Word32 non_linearity_scaled_copy_ivas( -#endif const Word16 input[], const Word16 j, const Word16 length, @@ -5538,6 +5534,9 @@ static Word32 non_linearity_scaled_copy_ivas( /*==========================================================================*/ void non_linearity_fx( +#ifdef HARM_NON_LINEARITY + const Word16 element_mode, /* i : element mode */ +#endif const Word16 input[], /* i : input signal Q_inp */ Word32 output[], /* o : output signal 2*Q_inp */ const Word16 length, /* i : input length */ @@ -5810,6 +5809,9 @@ void non_linearity_ivas_fx( Word32 prev_scale; Word16 length_half; Word16 sc_factor; +#ifdef HARM_NON_LINEARITY + Word16 cond; +#endif IF( EQ_16( L_frame, L_FRAME16k ) ) { @@ -5867,11 +5869,37 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } +#ifdef HARM_NON_LINEARITY + cond = 0; + move16(); + IF( element_mode == EVS_MONO ) + { + if ( GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) + { + cond = 1; + move16(); + } + } + ELSE + { + sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ + sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ + if ( GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) + { + cond = 1; + move16(); + } + } + + test(); + IF( prev_scale <= 0 || cond ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ +#else sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ test(); IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ +#endif { scale_step = 16384; move16(); /* Q14 */ @@ -5916,10 +5944,15 @@ void non_linearity_ivas_fx( } #ifdef HARM_NON_LINEARITY - prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs ); -#else - prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs ); + IF( element_mode == EVS_MONO ) + { + prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs ); + } + ELSE #endif + { + prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs ); + } max_val = 0; move16(); @@ -5947,12 +5980,39 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } - /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ - sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */ - sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ +#ifdef HARM_NON_LINEARITY + cond = 0; + move16(); + IF( element_mode == EVS_MONO ) + { + if ( GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) + { + cond = 1; + move16(); + } + } + ELSE + { + sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */ + sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ + + if ( GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ + { + cond = 1; + move16(); + } + } + + test(); + IF( prev_scale <= 0 || cond ) +#else + /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ + sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */ + sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ test(); IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ +#endif { scale_step = 16384; move16(); /*Q14 */ @@ -5997,10 +6057,15 @@ void non_linearity_ivas_fx( } #ifdef HARM_NON_LINEARITY - prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); -#else - prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); + IF( element_mode == EVS_MONO ) + { + prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); + } + ELSE #endif + { + prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); + } *pPrevScale = prev_scale; move32(); @@ -6046,7 +6111,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ #endif j = extract_l( L_shr( L_tmp, 23 ) ); @@ -6063,7 +6128,7 @@ void create_random_vector_fx( } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); @@ -6081,7 +6146,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 035800779..0646713cc 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2281,13 +2281,17 @@ ivas_error acelp_core_dec_fx( { IF( EQ_16( st->element_mode, EVS_MONO ) ) { +#ifdef HARM_NON_LINEARITY + non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); +#else non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); +#endif } ELSE { Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_exc) */ #ifdef HARM_NON_LINEARITY - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); + non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); #else non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); #endif diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 94d4486b1..b475a31d7 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -479,7 +479,11 @@ Word16 dec_acelp_tcx_frame_fx( test(); IF( st->core == ACELP_CORE && st->igf != 0 && st->con_tcx == 0 ) { +#ifdef HARM_NON_LINEARITY + non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame ); +#else non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame ); +#endif /* update the old BWE exe memory */ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); } diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 28e8eeb08..6a96a81d0 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -620,7 +620,11 @@ ivas_error acelp_core_enc_fx( IF( !st_fx->Opt_SC_VBR ) { /* Apply a non linearity to the SHB excitation */ +#ifdef HARM_NON_LINEARITY + non_linearity_fx( st_fx->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame ); +#else non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame ); +#endif } test(); if ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, FRAME_NO_DATA ) ) @@ -1435,7 +1439,7 @@ ivas_error acelp_core_enc_ivas_fx( /* Apply a non linearity to the SHB excitation */ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc #ifdef HARM_NON_LINEARITY - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); + non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); #else non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); #endif diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c index da8443f06..5e3c9241b 100644 --- a/lib_enc/enc_acelp_tcx_main_fx.c +++ b/lib_enc/enc_acelp_tcx_main_fx.c @@ -63,15 +63,19 @@ void enc_acelp_tcx_main_fx( { core_encode_twodiv_fx( new_samples, st, st->coder_type, Aw, vad_hover_flag, Q_new, shift ); } + /*-----------------------------------------------------------------* * Apply non linearity to the SHB excitation *-----------------------------------------------------------------*/ - test(); IF( EQ_16( st->core, ACELP_CORE ) && st->igf != 0 ) { +#ifdef HARM_NON_LINEARITY + non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame ); +#else non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame ); +#endif /* update the old BWE exe memory */ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/ -- GitLab From b6dcb71409d4f252ae60b2ef3560fd1152f9f1ee Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 17 Jan 2026 14:04:13 +0100 Subject: [PATCH 445/750] simplification --- lib_com/swb_tbe_com_fx.c | 42 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 5323e59da..85aa858f0 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -5811,18 +5811,19 @@ void non_linearity_ivas_fx( Word16 sc_factor; #ifdef HARM_NON_LINEARITY Word16 cond; + Word32 prev_scale_factor; #endif IF( EQ_16( L_frame, L_FRAME16k ) ) { - nframes = 5; + nframes = NB_SUBFR16k; move16(); ths = 17817; move16(); /* 0.87*5 in Q12 */ } ELSE { - nframes = 4; + nframes = NB_SUBFR; move16(); ths = 15400; move16(); /* 0.94*4 in Q12 */ @@ -5870,29 +5871,19 @@ void non_linearity_ivas_fx( } #ifdef HARM_NON_LINEARITY - cond = 0; - move16(); IF( element_mode == EVS_MONO ) { - if ( GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) - { - cond = 1; - move16(); - } + prev_scale_factor = Mult_32_16( prev_scale, 32 ); } ELSE { - sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ - if ( GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) - { - cond = 1; - move16(); - } + sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ + sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ + prev_scale_factor = L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ); /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ } test(); - IF( prev_scale <= 0 || cond ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ + IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) ) #else sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ @@ -5981,30 +5972,19 @@ void non_linearity_ivas_fx( } #ifdef HARM_NON_LINEARITY - cond = 0; - move16(); IF( element_mode == EVS_MONO ) { - if ( GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) - { - cond = 1; - move16(); - } + prev_scale_factor = Mult_32_16( prev_scale, 32 ); } ELSE { sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */ sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ - - if ( GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ - { - cond = 1; - move16(); - } + prev_scale_factor = L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ); /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ } test(); - IF( prev_scale <= 0 || cond ) + IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) ) #else /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */ -- GitLab From a9803e23495cdce15fb91bfc74c4f7c6dec8f813 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 17 Jan 2026 15:58:05 +0100 Subject: [PATCH 446/750] harmonize cng_params_upd_fx() and cng_params_postupd_fx() --- lib_com/cng_exc_fx.c | 30 ++++++++++++++++++++++++------ lib_com/prot_fx.h | 12 ++++++++---- lib_dec/acelp_core_dec_fx.c | 5 +++++ lib_dec/dec_LPD_fx.c | 11 +++++++++++ lib_dec/ivas_tcx_core_dec_fx.c | 11 +++++++++++ lib_enc/acelp_core_enc_fx.c | 21 +++++++++++++++++++++ lib_enc/core_enc_ol_fx.c | 11 +++++++++++ lib_enc/ivas_tcx_core_enc_fx.c | 10 ++++++++++ 8 files changed, 101 insertions(+), 10 deletions(-) diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index f96fba710..4d2d76baa 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -180,12 +180,14 @@ IF( GT_16( element_mode, IVAS_SCE ) ) { return; } + /*---------------------------------------------------------------------* * Generate white noise vector *---------------------------------------------------------------------*/ /*for ( i=0; icore_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); +#else IF( EQ_16( st->element_mode, EVS_MONO ) ) { cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, @@ -2332,6 +2336,7 @@ ivas_error acelp_core_dec_fx( st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); } +#endif /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index 6a610063c..07372eae0 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -934,16 +934,27 @@ void decoder_LPD_fx( E_LPC_lev_dur( r_h, r_l, A, NULL, M, NULL ); E_LPC_a_lsp_conversion( A, lsptmp, &xspnew_uw[0], M ); Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 ); + +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 ); +#else cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); +#endif } ELSE { +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 ); +#else cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); +#endif } /* Set 16k LSP flag for CNG buffer */ diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 3b4cc87f3..f1c760993 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -753,13 +753,24 @@ void stereo_tcx_core_dec_fx( IF( st->hTdCngDec != NULL ) { +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); +#else cng_params_upd_ivas_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); +#endif } } ELSE IF( st->hTdCngDec != NULL ) { +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); +#else cng_params_upd_ivas_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); +#endif } + /* Set 16k LSP flag for CNG buffer */ // st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = ( st->L_frame == L_FRAME ? 0 : 1 ); IF( EQ_16( st->L_frame, L_FRAME ) ) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 6a96a81d0..6e1709ce1 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -274,8 +274,14 @@ ivas_error acelp_core_enc_fx( IF( EQ_16( st_fx->cng_type, LP_CNG ) ) { /* Run CNG post parameter update */ +#ifdef HARM_NON_LINEARITY + cng_params_postupd_fx( hTdCngEnc->ho_circ_ptr, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, + hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx, EVS_MONO, -1 ); +#else cng_params_postupd_fx( hTdCngEnc->ho_circ_ptr, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx ); +#endif + /* encode CNG parameters */ CNG_enc_fx( st_fx, Aq_fx, inp_fx, ener_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw ); @@ -642,9 +648,14 @@ ivas_error acelp_core_enc_fx( IF( hTdCngEnc != NULL && ( st_fx->Opt_DTX_ON != 0 ) && ( GT_32( st_fx->core_brate, SID_2k40 ) ) ) { /* update CNG parameters in active frames */ +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, + Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); +#else cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate ); +#endif IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { @@ -972,7 +983,11 @@ ivas_error acelp_core_enc_ivas_fx( IF( st->cng_type == LP_CNG ) { /* Run CNG post parameter update */ +#ifdef HARM_NON_LINEARITY + cng_params_postupd_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#else cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#endif /* encode CNG parameters */ CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw ); @@ -1488,10 +1503,16 @@ ivas_error acelp_core_enc_ivas_fx( st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc; move16(); } + +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, + q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#else cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#endif IF( EQ_16( st->L_frame, L_FRAME ) ) { diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index cdecaf3d6..ce0a8f23e 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -460,18 +460,29 @@ void core_encode_openloop_fx( E_LPC_lev_dur( r_h, r_l, A, NULL, M, NULL ); E_LPC_a_lsp_conversion( A, lsptmp, lsp_new, M ); Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 ); + +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, + Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); +#else cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate ); +#endif } ELSE { +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, + Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); +#else cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate ); +#endif } IF( EQ_16( st->L_frame, L_FRAME ) ) diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 18d79f26d..733a64376 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -634,17 +634,27 @@ void stereo_tcx_core_enc( E_LPC_a_lsp_conversion( A_fx, lsptmp_fx, lsp_new_fx, M ); Residu3_fx( A_fx, buf_fx + L_LP - L_FRAME, res_fx, L_FRAME, 0 ); +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, + Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#else cng_params_upd_ivas_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#endif Q_exc = Q_r; move16(); } ELSE { +#ifdef HARM_NON_LINEARITY + cng_params_upd_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, + st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#else cng_params_upd_ivas_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#endif } IF( EQ_16( st->L_frame, L_FRAME ) ) -- GitLab From 82b98c43b5e2e9b1f84af74719b616ddb69d4488 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 18 Jan 2026 17:34:51 +0100 Subject: [PATCH 447/750] simplification --- lib_com/swb_tbe_com_fx.c | 1 - lib_enc/acelp_core_enc_fx.c | 11 + lib_enc/amr_wb_enc_fx.c | 4 + lib_enc/cng_enc_fx.c | 501 ++++++++++++++++++++++++------------ lib_enc/prot_fx_enc.h | 9 +- 5 files changed, 354 insertions(+), 172 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 85aa858f0..60ac7bd81 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -5810,7 +5810,6 @@ void non_linearity_ivas_fx( Word16 length_half; Word16 sc_factor; #ifdef HARM_NON_LINEARITY - Word16 cond; Word32 prev_scale_factor; #endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 6e1709ce1..67def7a08 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -97,6 +97,9 @@ ivas_error acelp_core_enc_fx( error = IVAS_ERR_OK; (void) hStereoTD; +#ifdef HARM_NON_LINEARITY + (void) ener_fx; +#endif /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -283,7 +286,11 @@ ivas_error acelp_core_enc_fx( #endif /* encode CNG parameters */ +#ifdef HARM_NON_LINEARITY + CNG_enc_fx( st_fx, Aq_fx, inp_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw ); +#else CNG_enc_fx( st_fx, Aq_fx, inp_fx, ener_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw ); +#endif /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc_fx, exc2_fx, &hTdCngEnc->lp_ener_fx, st_fx->last_core_brate, @@ -990,7 +997,11 @@ ivas_error acelp_core_enc_ivas_fx( #endif /* encode CNG parameters */ +#ifdef HARM_NON_LINEARITY + CNG_enc_fx( st, Aq, inp, lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw ); +#else CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw ); +#endif /* comfort noise generation */ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate, diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 72f981259..c1865862f 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -471,7 +471,11 @@ void amr_wb_enc_fx( IF( EQ_32( st->core_brate, SID_1k75 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) { /* encode CNG parameters */ +#ifdef HARM_NON_LINEARITY + CNG_enc_fx( st, Aq, inp, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw ); +#else CNG_enc_fx( st, Aq, inp, ener, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw ); +#endif /* comfort noise generation */ CNG_exc_fx( st->core_brate, L_FRAME, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc, exc2, &hTdCngEnc->lp_ener_fx, diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index de211162b..10275fb85 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1,6 +1,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ + #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ @@ -8,9 +9,9 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -//#include "basop_mpy.h" - #include + + /*---------------------------------------------------------------------* * Local constants *---------------------------------------------------------------------*/ @@ -20,18 +21,24 @@ #define INT_H 50 #define INT_L 8 + /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ + static void shb_CNG_encod_fx( Encoder_State *st_fx, const Word16 update_fx ); static Word16 shb_DTX_fx( Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k ); static Word16 shb_DTX_ivas_fx( Encoder_State *st, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k_fx ); static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); + + /*---------------------------------------------------------------------* * CNG_enc() * * Confort noise generation for the coder *---------------------------------------------------------------------*/ + +#ifndef HARM_NON_LINEARITY void CNG_enc_fx( Encoder_State *st_fx, /* i/o: State structure */ Word16 Aq[], /* o : LP coefficients Q12 */ @@ -1169,11 +1176,13 @@ void CNG_enc_fx( } void CNG_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: State structure */ - Word16 Aq[], /* o : LP coefficients Q12 */ - const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ - // Word32 L_ener, /* i : residual energy from Levinson-Durbin Q6 */ - const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */ +#else +void CNG_enc_fx( +#endif + Encoder_State *st_fx, /* i/o: State structure */ + Word16 Aq[], /* o : LP coefficients Q12 */ + const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ + const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */ Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ Word16 *allow_cn_step, /* o : allow CN step Q0 */ @@ -1207,9 +1216,14 @@ void CNG_enc_ivas_fx( Word16 max_idx[2]; Word16 ftmp_fx; Word16 lsp_tmp[M]; +#ifdef HARM_NON_LINEARITY + Word32 dev, max_dev, dist; + Word16 dev16, max_dev16, dist16; +#else Word32 dev; Word32 max_dev; Word32 dist; +#endif Word16 max_idx1[2]; Word16 fft_io[L_FRAME16k]; Word16 *ptR, *ptI; @@ -1233,6 +1247,10 @@ void CNG_enc_ivas_fx( Word64 w_temp; Word32 inv_frame_len; Word32 L_ener; +#ifdef HARM_NON_LINEARITY + Word16 *pt_res; + const Word16 *pt_sp; +#endif step_inv = 0; move16(); @@ -1256,7 +1274,6 @@ void CNG_enc_ivas_fx( move16(); st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx; move16(); - /* Temp variables for floating point functions */ lp_ener_thr_scale = 8; /* 4.0f*/ /* Q1 */ move16(); @@ -1266,58 +1283,91 @@ void CNG_enc_ivas_fx( move16(); } - w_temp = 1; - move64(); - - FOR( j = 0; j < st_fx->L_frame; j++ ) +#ifdef HARM_NON_LINEARITY + IF( st_fx->element_mode == EVS_MONO ) { - w_temp = W_mac0_16_16( w_temp, speech[j], speech[j] ); + pt_sp = speech; + L_ener = L_deposit_l( 1 ); + /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/ + IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + FOR( j = 0; j < 128; j++ ) + { + L_tmp = L_mult0( *pt_sp, *pt_sp ); + pt_sp++; + L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); + pt_sp++; + L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ + } + } + ELSE /* L_FRAME16k */ + { + FOR( j = 0; j < 80; j++ ) + { + L_tmp = L_mult0( *pt_sp, *pt_sp ); + pt_sp++; + L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); + pt_sp++; + L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ + } + } } - exp = W_norm( w_temp ); + ELSE +#endif + { + w_temp = 1; + move64(); - inv_frame_len = 0; - move32(); + FOR( j = 0; j < st_fx->L_frame; j++ ) + { + w_temp = W_mac0_16_16( w_temp, speech[j], speech[j] ); + } + exp = W_norm( w_temp ); - SWITCH( st_fx->L_frame ) - { - case L_FRAME25_6k: - inv_frame_len = ONE_BY_L_FRAME25_6k_Q31; - move16(); - BREAK; - case L_FRAME: - inv_frame_len = ONE_BY_L_FRAME_Q31; - move16(); - BREAK; - case L_FRAME48k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; - move16(); - BREAK; - case 240: - inv_frame_len = ONE_BY_240_Q31; - move16(); - BREAK; - case L_FRAME32k: - inv_frame_len = ONE_BY_L_FRAME32k_Q31; - move16(); - BREAK; - case L_FRAME16k: - inv_frame_len = ONE_BY_L_FRAME16k_Q31; - move16(); - BREAK; - case L_FRAME8k: - inv_frame_len = ONE_BY_L_FRAME8k_Q31; - move16(); - BREAK; - case L_FRAME4k: - inv_frame_len = ONE_BY_L_FRAME4k_Q31; - move16(); - BREAK; - default: - inv_frame_len = divide3216( 1, st_fx->L_frame ); + inv_frame_len = 0; + move32(); + + SWITCH( st_fx->L_frame ) + { + case L_FRAME25_6k: + inv_frame_len = ONE_BY_L_FRAME25_6k_Q31; + move16(); + BREAK; + case L_FRAME: + inv_frame_len = ONE_BY_L_FRAME_Q31; + move16(); + BREAK; + case L_FRAME48k: + inv_frame_len = ONE_BY_L_FRAME48k_Q31; + move16(); + BREAK; + case 240: + inv_frame_len = ONE_BY_240_Q31; + move16(); + BREAK; + case L_FRAME32k: + inv_frame_len = ONE_BY_L_FRAME32k_Q31; + move16(); + BREAK; + case L_FRAME16k: + inv_frame_len = ONE_BY_L_FRAME16k_Q31; + move16(); + BREAK; + case L_FRAME8k: + inv_frame_len = ONE_BY_L_FRAME8k_Q31; + move16(); + BREAK; + case L_FRAME4k: + inv_frame_len = ONE_BY_L_FRAME4k_Q31; + move16(); + BREAK; + default: + inv_frame_len = divide3216( 1, st_fx->L_frame ); + } + L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */ + L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */ + L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */ } - L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */ - L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */ - L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */ hi = norm_l( L_ener ); lo = Log2_norm_lc( L_shl( L_ener, hi ) ); @@ -1374,6 +1424,7 @@ void CNG_enc_ivas_fx( * Find CNG spectral envelope * Find LSP median *-----------------------------------------------------------------*/ + test(); test(); IF( ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) && GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) ) @@ -1456,6 +1507,7 @@ void CNG_enc_ivas_fx( * Quantize CNG spectral envelope (only in SID frame) * Quantize the LSF vector *-----------------------------------------------------------------*/ + *allow_cn_step = 0; move16(); test(); @@ -1493,7 +1545,6 @@ void CNG_enc_ivas_fx( } } - test(); IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) { @@ -1531,6 +1582,7 @@ void CNG_enc_ivas_fx( * CNG spectral envelope update * Find A(z) coefficients *---------------------------------------------------------------------*/ + test(); test(); IF( ( st_fx->last_core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->last_core_brate, SID_1k75 ) || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) @@ -1635,17 +1687,42 @@ void CNG_enc_ivas_fx( IF( hTdCngEnc->burst_ho_cnt > 0 ) { +#ifdef HARM_NON_LINEARITY + IF( st_fx->element_mode == EVS_MONO ) + { + /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ + /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/ + /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */ + L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 ); + IF( NE_16( lp_ener_thr_scale, 8 ) ) + { + L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) ); + } + L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx ); + } + ELSE + { + L_tmp1 = 0; + move16(); + } +#else /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ +#endif test(); test(); +#ifdef HARM_NON_LINEARITY + IF( ( hDtxEnc->first_CNG > 0 || ( st_fx->element_mode == EVS_MONO ) ) && L_tmp1 > 0 ) +#else IF( ( hDtxEnc->first_CNG > 0 || ( st_fx->element_mode == EVS_MONO ) ) && w_temp > 0 ) +#endif { *allow_cn_step = s_or( *allow_cn_step, 1 ); move16(); } } + test(); IF( *allow_cn_step == 0 && hTdCngEnc->ho_hist_size > 0 ) { @@ -1798,18 +1875,43 @@ void CNG_enc_ivas_fx( } } - dist = 0; /*Q15 */ - move32(); - max_dev = 0; /*Q15 */ - move32(); - FOR( i = 0; i < M; i++ ) +#ifdef HARM_NON_LINEARITY + IF( st_fx->element_mode == EVS_MONO ) { - dev = L_abs( L_sub( L_deposit_l( lsp_tmp[i] ), L_deposit_l( lsp_new[i] ) ) ); /*Q15 */ - dist = L_add( dist, dev ); /*Q15 */ - if ( GT_32( dev, max_dev ) ) + dist16 = 0; /*Q15 */ + move16(); + max_dev16 = 0; /*Q15 */ + move16(); + move16(); + FOR( i = 0; i < M; i++ ) { - max_dev = dev; - move32(); + dev16 = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ + dist16 = add_sat( dist16, dev16 ); /*Q15 */ + if ( GT_16( dev16, max_dev16 ) ) + { + max_dev16 = dev16; + move16(); + } + } + dist = L_deposit_l( dist16 ); + max_dev = L_deposit_l( max_dev16 ); + } + ELSE +#endif + { + dist = 0; /*Q15 */ + move32(); + max_dev = 0; /*Q15 */ + move32(); + FOR( i = 0; i < M; i++ ) + { + dev = L_abs( L_sub( L_deposit_l( lsp_tmp[i] ), L_deposit_l( lsp_new[i] ) ) ); /*Q15 */ + dist = L_add( dist, dev ); /*Q15 */ + if ( GT_32( dev, max_dev ) ) + { + max_dev = dev; + move32(); + } } } @@ -1865,6 +1967,7 @@ void CNG_enc_ivas_fx( Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */ /* Q15 */ } } + IF( st_fx->Opt_AMR_WB != 0 ) { E_LPC_f_isp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); @@ -1872,8 +1975,13 @@ void CNG_enc_ivas_fx( ELSE { E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); - exp = sub( Q14, norm_s( Aq[0] ) ); - Scale_sig( Aq, M + 1, sub( Q12, exp ) ); // Q12 +#ifdef HARM_NON_LINEARITY + IF( st_fx->element_mode != EVS_MONO ) +#endif + { + exp = sub( Q14, norm_s( Aq[0] ) ); + Scale_sig( Aq, M + 1, sub( Q12, exp ) ); // Q12 + } } tmp_loop = shr( st_fx->L_frame, 6 ); @@ -1881,6 +1989,7 @@ void CNG_enc_ivas_fx( { Copy( Aq, &Aq[i * ( M + 1 )], M + 1 ); } + /*-----------------------------------------------------------------* * Find residual signal * Calculate residual signal energy per sample @@ -1956,72 +2065,127 @@ void CNG_enc_ivas_fx( /* calculate the residual signal energy */ /*enr = dotp( res, res, L_frame ) / L_frame; */ - w_temp = 1; - move64(); - FOR( j = 0; j < st_fx->L_frame; j++ ) +#ifdef HARM_NON_LINEARITY + IF( st_fx->element_mode == EVS_MONO ) { - w_temp = W_mac0_16_16( w_temp, res[j], res[j] ); - } - exp = W_norm( w_temp ); - - SWITCH( st_fx->L_frame ) - { - case L_FRAME25_6k: - inv_frame_len = ONE_BY_L_FRAME25_6k_Q31; - move16(); - BREAK; - case L_FRAME: - inv_frame_len = ONE_BY_L_FRAME_Q31; - move16(); - BREAK; - case L_FRAME48k: - inv_frame_len = ONE_BY_L_FRAME48k_Q31; - move16(); - BREAK; - case 240: - inv_frame_len = ONE_BY_240_Q31; - move16(); - BREAK; - case L_FRAME32k: - inv_frame_len = ONE_BY_L_FRAME32k_Q31; - move16(); - BREAK; - case L_FRAME16k: - inv_frame_len = ONE_BY_L_FRAME16k_Q31; - move16(); - BREAK; - case L_FRAME8k: - inv_frame_len = ONE_BY_L_FRAME8k_Q31; - move16(); - BREAK; - case L_FRAME4k: - inv_frame_len = ONE_BY_L_FRAME4k_Q31; - move16(); - BREAK; - default: - inv_frame_len = divide3216( 1, st_fx->L_frame ); - } - L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */ - L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */ - L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */ + Word16 maxv, scale; - /* convert log2 of residual signal energy */ - /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ - - IF( L_ener == 0 ) - { - enr = -850; /*log(0.1) base 2 in Q8*/ + maxv = 0; move16(); + FOR( i = 0; i < st_fx->L_frame; i++ ) + { + maxv = s_max( maxv, abs_s( res[i] ) ); + } + scale = norm_s( maxv ); + pt_res = res; + L_ener = L_deposit_l( 1 ); + IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + FOR( j = 0; j < 128; j++ ) + { + tmpv = shl( *pt_res, scale ); + L_tmp = L_mult0( tmpv, tmpv ); + pt_res++; + tmpv = shl( *pt_res, scale ); + L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ + pt_res++; + L_ener = L_add_sat( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */ + } + } + ELSE /* L_FRAME16k */ + { + FOR( j = 0; j < 160; j++ ) + { + tmpv = shl( *pt_res, scale ); + L_tmp = L_mult0( tmpv, tmpv ); + pt_res++; + tmpv = shl( *pt_res, scale ); + L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ + pt_res++; + L_ener = L_add_sat( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */ + } + } + + /* convert log2 of residual signal energy */ + /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ + hi = norm_l( L_ener ); + lo = Log2_norm_lc( L_shl( L_ener, hi ) ); + hi = sub( 29, hi ); /* log2 exp in Q2*(Q_new+scale) */ + hi = sub( hi, shl( add( Q_new, scale ), 1 ) ); /* Q0 */ + L_tmp = L_Comp( hi, lo ); /* Q16 */ + enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ } ELSE +#endif { - hi = norm_l( L_ener ); - lo = Log2_norm_lc( L_shl( L_ener, hi ) ); - hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */ - hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */ - L_tmp = L_Comp( hi, lo ); /* Q16 */ - enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ + w_temp = 1; + move64(); + FOR( j = 0; j < st_fx->L_frame; j++ ) + { + w_temp = W_mac0_16_16( w_temp, res[j], res[j] ); + } + exp = W_norm( w_temp ); + + SWITCH( st_fx->L_frame ) + { + case L_FRAME25_6k: + inv_frame_len = ONE_BY_L_FRAME25_6k_Q31; + move16(); + BREAK; + case L_FRAME: + inv_frame_len = ONE_BY_L_FRAME_Q31; + move16(); + BREAK; + case L_FRAME48k: + inv_frame_len = ONE_BY_L_FRAME48k_Q31; + move16(); + BREAK; + case 240: + inv_frame_len = ONE_BY_240_Q31; + move16(); + BREAK; + case L_FRAME32k: + inv_frame_len = ONE_BY_L_FRAME32k_Q31; + move16(); + BREAK; + case L_FRAME16k: + inv_frame_len = ONE_BY_L_FRAME16k_Q31; + move16(); + BREAK; + case L_FRAME8k: + inv_frame_len = ONE_BY_L_FRAME8k_Q31; + move16(); + BREAK; + case L_FRAME4k: + inv_frame_len = ONE_BY_L_FRAME4k_Q31; + move16(); + BREAK; + default: + inv_frame_len = divide3216( 1, st_fx->L_frame ); + } + L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */ + L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */ + L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */ + + /* convert log2 of residual signal energy */ + /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ + + IF( L_ener == 0 ) + { + enr = -850; /*log(0.1) base 2 in Q8*/ + move16(); + } + ELSE + { + hi = norm_l( L_ener ); + lo = Log2_norm_lc( L_shl( L_ener, hi ) ); + hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */ + hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */ + L_tmp = L_Comp( hi, lo ); /* Q16 */ + enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ + } } + /* update the circular buffer of old energies */ hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr; move16(); /* Q8 */ @@ -2029,6 +2193,7 @@ void CNG_enc_ivas_fx( /*-----------------------------------------------------------------* * Quantize residual signal energy (only in SID frame) *-----------------------------------------------------------------*/ + test(); IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) { @@ -2368,6 +2533,8 @@ void CNG_enc_ivas_fx( return; } + + /*---------------------------------------------------------------------* * swb_CNG_enc() * @@ -2948,7 +3115,6 @@ static Word16 shb_DTX_ivas_fx( { Word16 i; Word16 update; - Word16 allow_cn_step = 0; move16(); Word16 shb_old_speech_fx[( ACELP_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 4]; @@ -3011,7 +3177,11 @@ static Word16 shb_DTX_ivas_fx( } ELSE { +#ifdef HARM_NON_LINEARITY + att_fx = 1664; /*6.5 in Q8*/ +#else att_fx = -1664; // Q8 +#endif move16(); } @@ -3019,8 +3189,6 @@ static Word16 shb_DTX_ivas_fx( IF( st->hDtxEnc->first_CNG == 0 ) { - - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; // Q8 hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; // Q8 hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; // Q8 @@ -3030,6 +3198,7 @@ static Word16 shb_DTX_ivas_fx( move16(); move16(); } + IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) ) { allow_cn_step = 1; @@ -3067,47 +3236,45 @@ static Word16 shb_DTX_ivas_fx( hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 ); update = 0; - move16(); move16(); IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - test(); - test(); - test(); - IF( st->hDtxEnc->first_CNG == 0 ) - { - update = 1; - move16(); - } - ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) - { - hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); - update = 1; - move16(); - move16(); - } - ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) - { - update = 1; - move16(); - } - ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) - { - update = 1; - move16(); - } - ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) - { - update = 1; - move16(); - } - ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) - { - update = 1; - move16(); - } + { test(); + test(); + test(); + IF( st->hDtxEnc->first_CNG == 0 ) + { + update = 1; + move16(); + } + ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) + { + hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); + update = 1; + move16(); + move16(); + } + ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) + { + update = 1; + move16(); + } + ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) + { + update = 1; + move16(); + } + ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) + { + update = 1; + move16(); + } + ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) + { + update = 1; + move16(); + } hTdCngEnc->last_SID_bwidth = st->bwidth; move16(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 82443f044..d60fdc565 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1781,6 +1781,7 @@ void reset_rf_indices_fx( ); void CNG_enc_fx( +#ifndef HARM_NON_LINEARITY Encoder_State *st_fx, /* i/o: State structure */ Word16 Aq[], /* o : LP coefficients Q12 */ const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */ @@ -1794,10 +1795,10 @@ void CNG_enc_fx( Word16 *sid_bw ); void CNG_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: State structure */ - Word16 Aq[], /* o : LP coefficients Q12 */ - const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */ - // Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */ +#endif + Encoder_State *st_fx, /* i/o: State structure */ + Word16 Aq[], /* o : LP coefficients Q12 */ + const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */ const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */ Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ -- GitLab From ffe011f5103370e7356278d4033507445fd7cd26 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 18 Jan 2026 18:02:47 +0100 Subject: [PATCH 448/750] harmonize swb_CNG_enc_fx() --- lib_com/prot_fx.h | 3 +- lib_enc/acelp_core_enc_fx.c | 5 ++ lib_enc/cng_enc_fx.c | 152 ++++++++++++++++++++++++------------ lib_enc/cod_tcx_fx.c | 4 + lib_enc/hq_hr_enc_fx.c | 4 + lib_enc/igf_enc_fx.c | 4 + lib_enc/ivas_core_enc_fx.c | 4 + lib_enc/prot_fx_enc.h | 3 +- 8 files changed, 128 insertions(+), 51 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 65a9079ac..6f48321b6 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10721,12 +10721,13 @@ void writeTCXparam_fx( const Word16 target_bitsTCX10[2], const Word16 pre_past_flag ); +#ifndef HARM_NON_LINEARITY void calculate_hangover_attenuation_gain_ivas_fx( Encoder_State *st, /* i : encoder state structure */ Word16 *att, /* o : attenuation factor */ const Word16 vad_hover_flag /* i : VAD hangover flag */ ); - +#endif void init_coder_ace_plus_ivas_fx( Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 67def7a08..104e9bc96 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1266,7 +1266,12 @@ ivas_error acelp_core_enc_ivas_fx( *---------------------------------------------------------------*/ calc_residu_fx( st, inp, res_fx, Aq ); + +#ifdef HARM_NON_LINEARITY + calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); +#else calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); +#endif IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) ) { diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 10275fb85..730ad75c2 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -28,8 +28,10 @@ static void shb_CNG_encod_fx( Encoder_State *st_fx, const Word16 update_fx ); static Word16 shb_DTX_fx( Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k ); +#ifndef HARM_NON_LINEARITY static Word16 shb_DTX_ivas_fx( Encoder_State *st, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k_fx ); static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); +#endif /*---------------------------------------------------------------------* @@ -1408,6 +1410,7 @@ void CNG_enc_fx( move16(); } } + /* update the pointer to circular buffer of old LSP vectors */ hTdCngEnc->cng_hist_ptr = add( hTdCngEnc->cng_hist_ptr, 1 ); move16(); @@ -2513,6 +2516,7 @@ void CNG_enc_fx( /*-----------------------------------------------------------------* * Updates *-----------------------------------------------------------------*/ + /* update the SID frames counter */ test(); IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) @@ -2534,7 +2538,7 @@ void CNG_enc_fx( return; } - +#ifndef HARM_NON_LINEARITY /*---------------------------------------------------------------------* * swb_CNG_enc() * @@ -2657,6 +2661,7 @@ static void shb_CNG_encod_fx( * * Decide if encoding SHB SID or not *---------------------------------------------------------------------*/ + static Word16 shb_DTX_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ @@ -2836,13 +2841,16 @@ static Word16 shb_DTX_fx( return ( update_fx ); } +#endif /*---------------------------------------------------------------------* * calculate_hangover_attenuation_gain_fx() * * *---------------------------------------------------------------------*/ + void calculate_hangover_attenuation_gain_fx( +#ifndef HARM_NON_LINEARITY Encoder_State *st, /* i : encoder state structure */ Word16 *att, /* o : attenuation factor Q15 */ const Word16 vad_hover_flag /* i : VAD hangover flag */ @@ -2885,9 +2893,10 @@ void calculate_hangover_attenuation_gain_fx( } void calculate_hangover_attenuation_gain_ivas_fx( - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor Q15 */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ +#endif + Encoder_State *st, /* i : encoder state structure */ + Word16 *att, /* o : attenuation factor Q15 */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ ) { Word16 lim, result_e; @@ -2909,6 +2918,22 @@ void calculate_hangover_attenuation_gain_ivas_fx( *att = extract_h( L_shl_sat( L_tmp, result_e ) ); move16(); } +#ifdef HARM_NON_LINEARITY + ELSE IF( st->element_mode == EVS_MONO ) + { + Word16 offset = 5; + move16(); + test(); + if ( EQ_16( st->bwidth, WB ) && st->hDtxEnc->CNG_mode >= 0 ) + { + offset = st->hDtxEnc->CNG_mode; + move16(); + } + assert( st->hTdCngEnc->burst_ho_cnt > 0 ); + *att = CNG_burst_att_fx[offset][st->hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/ + move16(); + } +#endif ELSE { test(); @@ -2938,10 +2963,21 @@ void calculate_hangover_attenuation_gain_ivas_fx( return; } + +#ifdef HARM_NON_LINEARITY +/*---------------------------------------------------------------------* + * swb_CNG_enc() + * + * SWB DTX/CNG encoding + *---------------------------------------------------------------------*/ + +void swb_CNG_enc_fx( +#else void swb_CNG_enc_ivas_fx( +#endif Encoder_State *st, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ ) { Word16 shb_SID_updt; @@ -2955,10 +2991,18 @@ void swb_CNG_enc_ivas_fx( IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) { /* decide if SHB SID encoding or not */ +#ifdef HARM_NON_LINEARITY + shb_SID_updt = shb_DTX_fx( st, shb_speech_fx, syn_12k8_16k_fx ); +#else shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx ); +#endif /* SHB CNG encoding */ +#ifdef HARM_NON_LINEARITY + shb_CNG_encod_fx( st, shb_SID_updt ); +#else shb_CNG_encod_ivas_fx( st, shb_SID_updt ); +#endif } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) ) { @@ -2988,7 +3032,11 @@ void swb_CNG_enc_ivas_fx( * SID parameters encoding for SHB signal *---------------------------------------------------------------------*/ +#ifdef HARM_NON_LINEARITY +static void shb_CNG_encod_fx( +#else static void shb_CNG_encod_ivas_fx( +#endif Encoder_State *st, /* i/o: State structure */ const Word16 update /* i : SID update flag */ ) @@ -2996,17 +3044,17 @@ static void shb_CNG_encod_ivas_fx( Word16 idx_ener = 0; move16(); BSTR_ENC_HANDLE hBstr = st->hBstr; - Word16 ener_mid_dec_thr_fx; IF( EQ_16( update, 1 ) ) { IF( st->element_mode == EVS_MONO ) { - /* 6.0 in Q8 -> 1510 */ - /* 0.9 in Q15 29491 */ - /* ( 1 / log10(2.0) ) * 0.1 in Q15 ->10886 */ +#ifdef HARM_NON_LINEARITY + idx_ener = shr( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 9797 ), 1510 ), 8 ); /* Q0 */ +#else idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */ +#endif } ELSE { @@ -3017,7 +3065,6 @@ static void shb_CNG_encod_ivas_fx( idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 22938 ), 8 ); /* Q0 */ } - if ( LT_16( st->bwidth, SWB ) ) { idx_ener = 0; @@ -3078,6 +3125,7 @@ static void shb_CNG_encod_ivas_fx( push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 ); push_indice( hBstr, IND_SID_BW, 1, 1 ); delete_indice( hBstr, IND_CNG_ENV1 ); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); @@ -3086,6 +3134,7 @@ static void shb_CNG_encod_ivas_fx( { push_indice( hBstr, IND_UNUSED, 0, 2 ); } + st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); st->hTdCngEnc->ho_sid_bw = L_or( st->hTdCngEnc->ho_sid_bw, 0x1L ); move32(); @@ -3101,16 +3150,21 @@ static void shb_CNG_encod_ivas_fx( return; } + /*---------------------------------------------------------------------* * shb_DTX() * * Decide if encoding SHB SID or not *---------------------------------------------------------------------*/ +#ifdef HARM_NON_LINEARITY +static Word16 shb_DTX_fx( +#else static Word16 shb_DTX_ivas_fx( +#endif Encoder_State *st, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ ) { Word16 i; @@ -3163,7 +3217,6 @@ static Word16 shb_DTX_ivas_fx( exp = sub( 30 - 1, exp ); shb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - test(); IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { @@ -3240,41 +3293,42 @@ static Word16 shb_DTX_ivas_fx( move16(); IF( EQ_32( st->core_brate, SID_2k40 ) ) - { test(); - test(); - test(); - IF( st->hDtxEnc->first_CNG == 0 ) - { - update = 1; - move16(); - } - ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) - { - hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); - update = 1; - move16(); - move16(); - } - ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) - { - update = 1; - move16(); - } - ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) - { - update = 1; - move16(); - } - ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) - { - update = 1; - move16(); - } - ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) - { - update = 1; - move16(); - } + { + test(); + test(); + test(); + IF( st->hDtxEnc->first_CNG == 0 ) + { + update = 1; + move16(); + } + ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) + { + hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); + update = 1; + move16(); + move16(); + } + ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) + { + update = 1; + move16(); + } + ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) + { + update = 1; + move16(); + } + ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) + { + update = 1; + move16(); + } + ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) + { + update = 1; + move16(); + } hTdCngEnc->last_SID_bwidth = st->bwidth; move16(); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index e1a246817..8e40d9530 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3617,7 +3617,11 @@ void QuantizeTCXSpectrum_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { +#ifdef HARM_NON_LINEARITY + calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); +#else calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); +#endif *gain_tcx_fx = mult( *gain_tcx_fx, att_fx ); move16(); } diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index d9a1dd5b7..8f70a5b36 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -337,7 +337,11 @@ void hq_hr_enc_ivas_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { +#ifdef HARM_NON_LINEARITY + calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); +#else calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); +#endif v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */ } diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 6c55e8b31..0adf23deb 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -4137,7 +4137,11 @@ void IGFEncApplyMono_ivas_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { +#ifdef HARM_NON_LINEARITY + calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); +#else calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); +#endif } IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 7dd2bcb04..8d4d4fbd7 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -796,7 +796,11 @@ ivas_error ivas_core_enc_fx( { /* SHB DTX/CNG encoder */ Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 +#ifdef HARM_NON_LINEARITY + swb_CNG_enc_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); +#else swb_CNG_enc_ivas_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); +#endif } /*-------------------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index d60fdc565..1738de1dd 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -645,12 +645,13 @@ void swb_CNG_enc_fx( const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */ ); +#ifndef HARM_NON_LINEARITY void swb_CNG_enc_ivas_fx( Encoder_State *st, /* i/o: State structure */ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ ); - +#endif void swb_pre_proc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *input_fx, /* i : original i signal */ -- GitLab From ab189c20b0f2f52c6ac55087af6c38ae2ca9cbdf Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 18 Jan 2026 18:06:57 +0100 Subject: [PATCH 449/750] comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index eb3a6128c..8d7e4d3d6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,7 +102,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ -#define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() */ +#define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ /* #################### End BE switches ################################## */ -- GitLab From 83a26e8a49144361cc9a086ad745e3ec6f1a16b3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 18 Jan 2026 18:41:28 +0100 Subject: [PATCH 450/750] harmonize swb_CNG_dec_fx() --- lib_com/prot_fx.h | 3 +- lib_dec/cng_dec_fx.c | 390 +++++++++++++++++++++++++++---------- lib_dec/ivas_core_dec_fx.c | 4 + 3 files changed, 292 insertions(+), 105 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6f48321b6..604b7c97b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6167,6 +6167,7 @@ void swb_CNG_dec_fx( const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ); +#ifndef HARM_NON_LINEARITY void swb_CNG_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ @@ -6174,7 +6175,7 @@ void swb_CNG_dec_ivas_fx( const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ); - +#endif void td_cng_dec_init_fx( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 0006bacbb..a88605896 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -9,9 +9,11 @@ #include "prot_fx.h" #include "ivas_cnst.h" +#ifndef HARM_NON_LINEARITY /*Temporary location to be move in prot* when merge is done*/ void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); +#endif /*-----------------------------------------------------------------* * Local function prototypes @@ -19,7 +21,10 @@ void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); +#ifndef HARM_NON_LINEARITY static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); +#endif + /*-----------------------------------------------------------------* * CNG_dec_fx() @@ -723,7 +728,11 @@ void swb_CNG_dec_fx( { st_fx->last_vad_fx = 1; move16(); +#ifdef HARM_NON_LINEARITY + st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 ); +#else st_fx->hTdCngDec->burst_cnt_fx = add( st_fx->hTdCngDec->burst_cnt_fx, 1 ); +#endif move16(); if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) ) { @@ -735,6 +744,7 @@ void swb_CNG_dec_fx( return; } +#ifndef HARM_NON_LINEARITY void swb_CNG_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ @@ -772,6 +782,7 @@ void swb_CNG_dec_ivas_fx( return; } +#endif /*---------------------------------------------------------------------* * shb_CNG_decod() @@ -780,12 +791,17 @@ void swb_CNG_dec_ivas_fx( *---------------------------------------------------------------------*/ static void shb_CNG_decod_fx( - Decoder_State *st_fx, /* i/o: State structure */ +#ifdef HARM_NON_LINEARITY + Decoder_State *st, /* i/o: State structure */ +#else + Decoder_State *st_fx, /* i/o: State structure */ +#endif const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ) +#ifndef HARM_NON_LINEARITY { Word16 i; Word16 idx_ener_fx; @@ -1052,6 +1068,7 @@ static void shb_CNG_decod_ivas_fx( Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn ) +#endif { Word16 i; Word16 idx_ener; @@ -1074,6 +1091,9 @@ static void shb_CNG_decod_ivas_fx( Word16 exp, exp1; Word16 fra; Word32 L_tmp; +#ifdef HARM_NON_LINEARITY + Word16 tmp_16, tmp_16_2, step_fx16, gain_fx16, ener_fx16; +#endif Word16 allow_cn_step_fx; Word16 q; TD_BWE_DEC_HANDLE hBWE_TD; @@ -1099,8 +1119,14 @@ static void shb_CNG_decod_ivas_fx( /* de-quantization of SHB CNG parameters */ IF( st->element_mode == EVS_MONO ) { +#ifdef HARM_NON_LINEARITY + L_tmp = L_mult( idx_ener, 27400 ); /*Q14 */ + hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */ + move16(); +#else hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11 move32(); +#endif } ELSE { @@ -1114,10 +1140,25 @@ static void shb_CNG_decod_ivas_fx( interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 ); interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) +#ifdef HARM_NON_LINEARITY + IF( st->element_mode == EVS_MONO ) { - shb_lspCNG_fx[i] = add( mult_r( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ), mult_r( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ) ); // Q14 - move16(); + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + tmp_16_2 = mult( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ); /*Q14*/ + tmp_16 = mult( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ); /*Q14*/ + shb_lspCNG_fx[i] = add( tmp_16_2, tmp_16 ); + move16(); /*Q14*/ + } + } + ELSE +#endif + { + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + shb_lspCNG_fx[i] = add( mult_r( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ), mult_r( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ) ); // Q14 + move16(); + } } IF( LE_16( hTdCngDec->shb_dtx_count_fx, 1000 ) ) @@ -1129,80 +1170,162 @@ static void shb_CNG_decod_ivas_fx( E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/ E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER ); - Copy_Scale_sig( shb_lpcCNG_fx, hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */ - +#ifdef HARM_NON_LINEARITY + IF( st->element_mode != EVS_MONO ) +#endif + { + Copy_Scale_sig( shb_lpcCNG_fx, hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */ + } Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ /* SHB energy estimation */ - wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) +#ifdef HARM_NON_LINEARITY + IF( st->element_mode == EVS_MONO ) { + wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ FOR( i = 0; i < L_FRAME32k; i++ ) { wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */ } - } - exp = norm_l( wb_ener_fx ); - fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); - exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) ); - wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */ - Word32 wb_ener32_fx = L_shl( wb_ener16_fx, 3 ); /*wb_ener_fx in Q11 */ - if ( EQ_16( st->first_CNG, 0 ) ) - { - hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx; - move32(); /*Q11 */ - } - if ( GT_32( L_abs( L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) ) /* 12.0f in Q11 */ - { - allow_cn_step_fx = 1; - move16(); - } + exp = norm_l( wb_ener_fx ); + fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); + exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) ); + wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); + wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */ + if ( !st->first_CNG ) + { + hTdCngDec->wb_cng_ener_fx = wb_ener16_fx; + move16(); /*Q8 */ + } + if ( GT_16( abs_s( sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ) ), 3072 ) ) + { + allow_cn_step_fx = 1; + move16(); + } - IF( EQ_16( allow_cn_step_fx, 1 ) ) - { - hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx; - move32(); /*Q11 */ + IF( EQ_16( allow_cn_step_fx, 1 ) ) + { + hTdCngDec->wb_cng_ener_fx = wb_ener16_fx; + move16(); /*Q8 */ + } + ELSE + { + tmp_16 = sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ); /*Q8 */ + tmp_16 = mult_r( tmp_16, 29491 ); /*Q8 */ + hTdCngDec->wb_cng_ener_fx = add( hTdCngDec->wb_cng_ener_fx, tmp_16 ); /*Q8 */ + move16(); + } + + test(); + test(); + IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && ( st->bfi == 0 ) ) + { + hTdCngDec->last_wb_cng_ener_fx = hTdCngDec->wb_cng_ener_fx; + move16(); + + if ( !st->first_CNG ) + { + hTdCngDec->shb_cng_ener_fx = hTdCngDec->last_shb_cng_ener_fx; + move16(); + } + } + + gain_fx16 = sub( hTdCngDec->wb_cng_ener_fx, hTdCngDec->last_wb_cng_ener_fx ); /* Q8 */ + if ( GT_16( gain_fx16, 15 ) ) + { + gain_fx = 15; + move16(); + } + step_fx16 = sub( add( gain_fx16, hTdCngDec->last_shb_cng_ener_fx ), hTdCngDec->shb_cng_ener_fx ); /*Q8 */ + + test(); + IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) ) + { + hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, step_fx16 ); /* Q8 */ + move16(); + } + ELSE + { + hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, mult( 8192, step_fx16 ) ); /*Q8 */ + move16(); + } } ELSE +#endif { - tmp = L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ); /*Q11 */ - tmp = Mpy_32_16_1( tmp, 29491 ); /*Q11 */ - hTdCngDec->wb_cng_ener_fx_32 = L_add( hTdCngDec->wb_cng_ener_fx_32, tmp ); /*Q11 */ - move32(); - } - test(); - test(); - IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && EQ_16( st->bfi, 0 ) ) - { - hTdCngDec->last_wb_cng_ener_fx_32 = hTdCngDec->wb_cng_ener_fx_32; /* Q11 */ - move32(); + wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) + { + FOR( i = 0; i < L_FRAME32k; i++ ) + { + wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */ + } + } + exp = norm_l( wb_ener_fx ); + fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); + exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) ); + wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); + wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */ + Word32 wb_ener32_fx = L_shl( wb_ener16_fx, 3 ); /*wb_ener_fx in Q11 */ + if ( EQ_16( st->first_CNG, 0 ) ) + { + hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx; + move32(); /*Q11 */ + } + if ( GT_32( L_abs( L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) ) /* 12.0f in Q11 */ + { + allow_cn_step_fx = 1; + move16(); + } - if ( !st->first_CNG ) + IF( EQ_16( allow_cn_step_fx, 1 ) ) { - hTdCngDec->shb_cng_ener_fx_32 = hTdCngDec->last_shb_cng_ener_fx_32; /* Q11 */ + hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx; + move32(); /*Q11 */ + } + ELSE + { + tmp = L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ); /*Q11 */ + tmp = Mpy_32_16_1( tmp, 29491 ); /*Q11 */ + hTdCngDec->wb_cng_ener_fx_32 = L_add( hTdCngDec->wb_cng_ener_fx_32, tmp ); /*Q11 */ move32(); } - } - gain_fx = L_sub( hTdCngDec->wb_cng_ener_fx_32, hTdCngDec->last_wb_cng_ener_fx_32 ); /*Q11 */ - if ( GT_32( gain_fx, 30720 ) ) - { - gain_fx = 30720; - move32(); - } - step_fx = L_sub( L_add( gain_fx, hTdCngDec->last_shb_cng_ener_fx_32 ), hTdCngDec->shb_cng_ener_fx_32 ); /*Q11 */ - test(); - IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) ) - { - hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, step_fx ); /* Q11 */ - move32(); - } - ELSE - { - hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, L_shr( step_fx, 2 ) ); /*Q11 */ - move32(); + test(); + test(); + IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && EQ_16( st->bfi, 0 ) ) + { + hTdCngDec->last_wb_cng_ener_fx_32 = hTdCngDec->wb_cng_ener_fx_32; /* Q11 */ + move32(); + + if ( !st->first_CNG ) + { + hTdCngDec->shb_cng_ener_fx_32 = hTdCngDec->last_shb_cng_ener_fx_32; /* Q11 */ + move32(); + } + } + + gain_fx = L_sub( hTdCngDec->wb_cng_ener_fx_32, hTdCngDec->last_wb_cng_ener_fx_32 ); /*Q11 */ + if ( GT_32( gain_fx, 30720 ) ) + { + gain_fx = 30720; + move32(); + } + step_fx = L_sub( L_add( gain_fx, hTdCngDec->last_shb_cng_ener_fx_32 ), hTdCngDec->shb_cng_ener_fx_32 ); /*Q11 */ + + test(); + IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) ) + { + hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, step_fx ); /* Q11 */ + move32(); + } + ELSE + { + hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, L_shr( step_fx, 2 ) ); /*Q11 */ + move32(); + } } + /* generate white noise excitation */ FOR( i = 0; i < L_FRAME16k; i++ ) { @@ -1238,56 +1361,110 @@ static void shb_CNG_decod_ivas_fx( } } - ener_fx = hTdCngDec->shb_cng_ener_fx_32; - move32(); /*Q11 */ - IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) ) +#ifdef HARM_NON_LINEARITY + IF( st->element_mode == EVS_MONO ) { - i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */ - ener_fx = L_add( hTdCngDec->shb_cng_ener_fx_32, Mpy_32_16_1( L_sub( hTdCngDec->last_shb_ener_fx_32, hTdCngDec->shb_cng_ener_fx_32 ), sin_table256_fx[i] ) ); /*Q11 */ - hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 ); - move16(); - } + ener_fx16 = hTdCngDec->shb_cng_ener_fx; + move16(); /*Q8 */ + IF( hTdCngDec->trans_cnt_fx > 0 ) + { + i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */ + ener_fx16 = add_sat( hTdCngDec->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( hTdCngDec->last_shb_ener_fx, hTdCngDec->shb_cng_ener_fx ) ) ); /*Q8 */ + hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 ); + move16(); + } - tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */ - IF( GT_32( tmp, 32767 ) ) - abort(); - Word16 tmp_16; - tmp_16 = (Word16) tmp; - move16(); - L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */ - L_tmp = L_shr( L_tmp, 6 ); /*Q16 */ - L_tmp = L_add( L_tmp, L_shl( 10, 16 ) ); - if ( ( L_tmp < 0 ) ) - { - L_tmp = 0; - move32(); + tmp_16 = mult( 3277, ener_fx16 ); /*Q8 */ + L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */ + L_tmp = L_shr( L_tmp, 6 ); /*Q16 */ + L_tmp = L_add( L_tmp, 10 << 16 ); + if ( L_tmp < 0 ) + { + L_tmp = 0; + move32(); + } + fra = L_Extract_lc( L_tmp, &exp ); + L_tmp = L_shl_sat( Pow2( exp, fra ), 5 ); /*Q5 */ + L_tmp = L_shr( L_tmp, 10 ); + if ( !L_tmp ) + { + L_tmp = 1; /*Q5 */ + } + exp = norm_l( L_tmp ); + L_tmp = L_shl( L_tmp, exp ); /*Q31*/ + tmp_16 = extract_h( L_tmp ); /*Q15*/ + exp = sub( exp, 16 ); + exp1 = norm_s( ener_excSHB_fx ); + fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/ + + IF( GT_16( fra, tmp_16 ) ) + { + fra = shr( fra, 1 ); /*Q15*/ + exp1 = sub( exp1, 1 ); + } + tmp_16 = div_s( fra, tmp_16 ); /*Q15*/ + + L_tmp = L_deposit_h( tmp_16 ); /*Q31 */ + tmp = sub( add( 5, exp ), add( q, exp1 ) ); + L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */ } - fra = L_Extract_lc( L_tmp, &exp ); - L_tmp = L_shr( Pow2( exp, fra ), 5 ); /*Q5 */ - if ( !L_tmp ) + ELSE +#endif { - L_tmp = 1; - move32(); /*Q5 */ - } - exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q31*/ - tmp_16 = extract_h( L_tmp ); /*Q15*/ - exp = sub( exp, 16 ); - exp1 = norm_s( ener_excSHB_fx ); - fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/ + ener_fx = hTdCngDec->shb_cng_ener_fx_32; + move32(); /*Q11 */ + IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) ) + { + i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */ + ener_fx = L_add( hTdCngDec->shb_cng_ener_fx_32, Mpy_32_16_1( L_sub( hTdCngDec->last_shb_ener_fx_32, hTdCngDec->shb_cng_ener_fx_32 ), sin_table256_fx[i] ) ); /*Q11 */ + hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 ); + move16(); + } - IF( GT_16( fra, tmp_16 ) ) - { - fra = shr( fra, 1 ); /*Q15*/ - exp1 = sub( exp1, 1 ); + tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */ + IF( GT_32( tmp, 32767 ) ) + abort(); +#ifndef HARM_NON_LINEARITY + Word16 tmp_16; +#endif + tmp_16 = (Word16) tmp; + move16(); + L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */ + L_tmp = L_shr( L_tmp, 6 ); /*Q16 */ + L_tmp = L_add( L_tmp, L_shl( 10, 16 ) ); + if ( L_tmp < 0 ) + { + L_tmp = 0; + move32(); + } + fra = L_Extract_lc( L_tmp, &exp ); + L_tmp = L_shr( Pow2( exp, fra ), 5 ); /*Q5 */ + if ( !L_tmp ) + { + L_tmp = 1; + move32(); /*Q5 */ + } + exp = norm_l( L_tmp ); + L_tmp = L_shl( L_tmp, exp ); /*Q31*/ + tmp_16 = extract_h( L_tmp ); /*Q15*/ + exp = sub( exp, 16 ); + exp1 = norm_s( ener_excSHB_fx ); + fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/ + + IF( GT_16( fra, tmp_16 ) ) + { + fra = shr( fra, 1 ); /*Q15*/ + exp1 = sub( exp1, 1 ); + } + tmp_16 = div_s( fra, tmp_16 ); /*Q15*/ + + L_tmp = L_deposit_h( tmp_16 ); /*Q31 */ + tmp_16 = sub( add( 5, exp ), add( q, exp1 ) ); + L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */ + hTdCngDec->shb_cng_gain_fx_32 = ener_fx; + move32(); } - tmp_16 = div_s( fra, tmp_16 ); /*Q15*/ - L_tmp = L_deposit_h( tmp_16 ); /*Q31 */ - tmp_16 = sub( add( 5, exp ), add( q, exp1 ) ); - L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */ - hTdCngDec->shb_cng_gain_fx_32 = ener_fx; - move32(); FOR( i = 0; i < L_FRAME16k; i++ ) { shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp_16 ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */ @@ -1317,7 +1494,12 @@ static void shb_CNG_decod_ivas_fx( interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); } - Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ +#ifdef HARM_NON_LINEARITY + IF( st->element_mode != EVS_MONO ) +#endif + { + Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ + } ResetSHBbuffer_Dec_fx( st->hBWE_TD, st->extl ); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 2fda2e5f3..7921a9044 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1186,7 +1186,11 @@ ivas_error ivas_core_dec_fx( Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 +#ifdef HARM_NON_LINEARITY + swb_CNG_dec_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); +#else swb_CNG_dec_ivas_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); +#endif test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) -- GitLab From c074f054e05125e4900fea9079a73e074cd12812 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 18 Jan 2026 21:01:09 +0100 Subject: [PATCH 451/750] fixes --- lib_dec/cng_dec_fx.c | 22 ++++++++++++++++------ lib_dec/ivas_core_dec_fx.c | 10 +++++++++- lib_enc/cng_enc_fx.c | 17 +++++++++++++++-- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index a88605896..27c528b24 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -1233,7 +1233,7 @@ static void shb_CNG_decod_ivas_fx( gain_fx16 = sub( hTdCngDec->wb_cng_ener_fx, hTdCngDec->last_wb_cng_ener_fx ); /* Q8 */ if ( GT_16( gain_fx16, 15 ) ) { - gain_fx = 15; + gain_fx16 = 15; move16(); } step_fx16 = sub( add( gain_fx16, hTdCngDec->last_shb_cng_ener_fx ), hTdCngDec->shb_cng_ener_fx ); /*Q8 */ @@ -1336,7 +1336,6 @@ static void shb_CNG_decod_ivas_fx( /* synthesis filtering */ Syn_filt_s( 0, shb_lpcCNG_fx, LPC_SHB_ORDER, excTmp_fx, excSHB_fx, L_FRAME16k, hBWE_TD->state_lpc_syn_fx, 1 ); - /* synthesis signal gain shaping */ L_tmp = 0; move32(); @@ -1405,12 +1404,12 @@ static void shb_CNG_decod_ivas_fx( tmp_16 = div_s( fra, tmp_16 ); /*Q15*/ L_tmp = L_deposit_h( tmp_16 ); /*Q31 */ - tmp = sub( add( 5, exp ), add( q, exp1 ) ); + tmp_16 = sub( add( 5, exp ), add( q, exp1 ) ); L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */ } ELSE -#endif { +#endif ener_fx = hTdCngDec->shb_cng_ener_fx_32; move32(); /*Q11 */ IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) ) @@ -1463,7 +1462,9 @@ static void shb_CNG_decod_ivas_fx( L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */ hTdCngDec->shb_cng_gain_fx_32 = ener_fx; move32(); +#ifdef HARM_NON_LINEARITY } +#endif FOR( i = 0; i < L_FRAME16k; i++ ) { @@ -1496,10 +1497,19 @@ static void shb_CNG_decod_ivas_fx( #ifdef HARM_NON_LINEARITY IF( st->element_mode != EVS_MONO ) -#endif { - Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ + IF( EQ_32( st->output_Fs, 32000 ) ) + { + Scale_sig( shb_synth_fx, L_FRAME32k, -3 ); /* Qx - 3 */ + } + ELSE + { + Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ + } } +#else + Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ +#endif ResetSHBbuffer_Dec_fx( st->hBWE_TD, st->extl ); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 7921a9044..ad82719e2 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1181,7 +1181,11 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 +#ifdef HARM_NON_LINEARITY + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 +#else + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 +#endif Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 @@ -1195,7 +1199,11 @@ ivas_error ivas_core_dec_fx( test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { +#ifdef HARM_NON_LINEARITY + Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], output_frame, ( Q11 ) ); // Q11 +#else Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, ( Q11 ) ); // Q11 +#endif } Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, negate( sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ) ); // Q0 diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 730ad75c2..13c961a0b 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2852,8 +2852,8 @@ static Word16 shb_DTX_fx( void calculate_hangover_attenuation_gain_fx( #ifndef HARM_NON_LINEARITY Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor Q15 */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ + Word16 *att, /* o : attenuation factor Q15 */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ ) { Word16 offset; @@ -3302,7 +3302,11 @@ static Word16 shb_DTX_ivas_fx( update = 1; move16(); } +#ifdef HARM_NON_LINEARITY + ELSE IF( st->element_mode != EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 ) +#else ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) +#endif { hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); update = 1; @@ -3319,6 +3323,15 @@ static Word16 shb_DTX_ivas_fx( update = 1; move16(); } +#ifdef HARM_NON_LINEARITY + ELSE IF( st->element_mode == EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 ) + { + hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); + update = 1; + move16(); + move16(); + } +#endif ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) { update = 1; -- GitLab From 044a26d8cc132b084ea811ffe502e8e046b1bdc2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 19 Jan 2026 11:07:34 +0100 Subject: [PATCH 452/750] introduce macro --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index a112a55d0..2522e06f4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,6 +97,7 @@ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ +#define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ -- GitLab From b5aca16b8bdcae419eaafd662a621212d8d5d77b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 19 Jan 2026 11:13:57 +0100 Subject: [PATCH 453/750] introduce macro to switch --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..8ea131856 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 0d99494dd..d566e9c51 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6987,7 +6987,11 @@ static ivas_error renderIsmToSba( Word8 position_changed; Word16 ambiOrderOut; Word16 numOutChannels; +#ifdef FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE pan_vector_fx currentPanGains_fx = { 0 }; // Solve Clang-18 warnings +#else + pan_vector_fx currentPanGains_fx; +#endif ivas_error error; error = IVAS_ERR_OK; move32(); -- GitLab From cdee93223d32170984940e30013fc62b204cd806 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 19 Jan 2026 11:17:42 +0100 Subject: [PATCH 454/750] resolve conflicts --- lib_com/options.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4108e0d26..e70cb9714 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,14 +98,11 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ -<<<<<<< HEAD -#define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ -======= #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ ->>>>>>> origin +#define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ /* #################### End BE switches ################################## */ -- GitLab From a00e78e244f91e7065a641ddd09c15a701db3ef7 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 19 Jan 2026 12:43:03 +0200 Subject: [PATCH 455/750] Init related length variables to zero. --- lib_rend/ivas_dirac_rend_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 83ce8af45..e280a989b 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -856,6 +856,11 @@ ivas_error ivas_dirac_alloc_mem_fx( /* Prototypes */ hDirAC_mem->proto_direct_buffer_f_fx = NULL; hDirAC_mem->proto_diffuse_buffer_f_fx = NULL; +#ifdef FIX_BASOP_2329_UNINIT_VALUE + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len = 0; + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len = 0; + hDirAC_mem->proto_diffuse_buffer_f_len = 0; +#endif test(); test(); IF( NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_32( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) -- GitLab From 21c04e32b2573e80d7789a5104e2e5469c4a60b5 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 19 Jan 2026 12:48:22 +0200 Subject: [PATCH 456/750] Reorder a bit to make flow logical. --- lib_rend/ivas_mcmasa_ana_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 54a8f485e..8b6659b3e 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -423,12 +423,6 @@ void ivas_mcmasa_ana_close( ( *hMcMasa )->direction_vector_m_fx[i][j] = NULL; } - FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) - { - free( ( *hMcMasa )->buffer_intensity_real_fx[i][j] ); - ( *hMcMasa )->buffer_intensity_real_fx[i][j] = NULL; - } - free( ( *hMcMasa )->direction_vector_m_fx[i] ); ( *hMcMasa )->direction_vector_m_fx[i] = NULL; #ifdef FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK @@ -442,6 +436,12 @@ void ivas_mcmasa_ana_close( free( ( *hMcMasa )->direction_vector_e[i] ); ( *hMcMasa )->direction_vector_e[i] = NULL; #endif + + FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) + { + free( ( *hMcMasa )->buffer_intensity_real_fx[i][j] ); + ( *hMcMasa )->buffer_intensity_real_fx[i][j] = NULL; + } } FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) -- GitLab From 54b8e2604e166a7e26271c65ad8fac7b5a3cce8e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 12:14:40 +0100 Subject: [PATCH 457/750] two fixes to restore BE --- lib_enc/cng_enc_fx.c | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 13c961a0b..bd8467eff 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1304,13 +1304,16 @@ void CNG_enc_fx( } ELSE /* L_FRAME16k */ { - FOR( j = 0; j < 80; j++ ) + FOR( i = 0; i < 2; i++ ) { - L_tmp = L_mult0( *pt_sp, *pt_sp ); - pt_sp++; - L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); - pt_sp++; - L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ + FOR( j = 0; j < 80; j++ ) + { + L_tmp = L_mult0( *pt_sp, *pt_sp ); + pt_sp++; + L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); + pt_sp++; + L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ + } } } } @@ -1690,36 +1693,12 @@ void CNG_enc_fx( IF( hTdCngEnc->burst_ho_cnt > 0 ) { -#ifdef HARM_NON_LINEARITY - IF( st_fx->element_mode == EVS_MONO ) - { - /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ - /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/ - /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */ - L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 ); - IF( NE_16( lp_ener_thr_scale, 8 ) ) - { - L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) ); - } - L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx ); - } - ELSE - { - L_tmp1 = 0; - move16(); - } -#else /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ -#endif test(); test(); -#ifdef HARM_NON_LINEARITY - IF( ( hDtxEnc->first_CNG > 0 || ( st_fx->element_mode == EVS_MONO ) ) && L_tmp1 > 0 ) -#else IF( ( hDtxEnc->first_CNG > 0 || ( st_fx->element_mode == EVS_MONO ) ) && w_temp > 0 ) -#endif { *allow_cn_step = s_or( *allow_cn_step, 1 ); move16(); -- GitLab From ebf3b995fbe6dba60f6e9e4c7c92aeed0efe82d4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 12:34:26 +0100 Subject: [PATCH 458/750] revert a change in CNG_enc_fx() --- lib_enc/cng_enc_fx.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index bd8467eff..1bc7cab41 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1693,8 +1693,26 @@ void CNG_enc_fx( IF( hTdCngEnc->burst_ho_cnt > 0 ) { - /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ - w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ +#ifdef HARM_NON_LINEARITY + IF( st_fx->element_mode == EVS_MONO ) + { + /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ + /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/ + /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */ + L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 ); + IF( NE_16( lp_ener_thr_scale, 8 ) ) + { + L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) ); + } + L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx ); + w_temp = W_deposit32_l( L_tmp1 ); + } + ELSE +#endif + { + /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ + w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ + } test(); test(); -- GitLab From 21ddb8fa389093a16ba272d47451ea8e0e8fc4af Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 08:16:57 -0500 Subject: [PATCH 459/750] Reducing probability of single frame post filter mode change during audio frames --- lib_com/options.h | 1 + lib_com/prot_fx.h | 5 ++++- lib_dec/LD_music_post_filter_fx.c | 17 ++++++++++++++++- lib_dec/acelp_core_dec_fx.c | 5 ++++- lib_dec/amr_wb_dec_fx.c | 5 ++++- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2c470dc81..e0d91123b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,6 +117,7 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2338_HARM_GSC_GAIN_COMP_PART2 /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS, reducing MLD regressions */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 4fea02ccf..0bcae103a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7944,7 +7944,10 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + const Word16 element_mode, /* i : IVAS element mode Q0 */ +#endif + const Word16 Qdct /* i : i scaling Q0 */ ); void Prep_music_postP_fx( diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index fe6433768..01a5a1bd2 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -48,6 +48,9 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + const Word16 element_mode, /* i : IVAS element mode Q0 */ +#endif const Word16 Qdct /* i : input scaling Q0 */ ) { @@ -69,6 +72,9 @@ void LD_music_post_filter_fx( Word16 mant, exp1, s_ave, tmp16, old_tmp16; Word16 diff_sc; Word16 old_tmp16_1; +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + Word16 previous_flag; +#endif move16(); move16(); move16(); @@ -93,8 +99,17 @@ void LD_music_post_filter_fx( /*------------------------------------------------------------------------* * Find signal classification *------------------------------------------------------------------------*/ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + previous_flag = hMusicPF->LDm_last_music_flag; +#endif music_flag2 = stab_est_fx( LG_etot, hMusicPF->LDm_lt_diff_etot_fx, &hMusicPF->LDm_mem_etot_fx, &hMusicPF->LDm_nb_thr_3, &hMusicPF->LDm_nb_thr_1, hMusicPF->LDm_thres_fx, &hMusicPF->LDm_last_music_flag, 1 ); - +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + /* delay going back to 0 by one frame, prevent single frame switching during audio segment */ + if ( EQ_16( Last_coder_type, AUDIO ) && EQ_16( coder_type, AUDIO ) && EQ_16( previous_flag, 1 ) && music_flag2 == 0 && element_mode > EVS_MONO ) + { + music_flag2 = previous_flag; + } +#endif test(); if ( LT_32( core_brate, ACELP_6k60 ) || NE_16( Last_coder_type, AUDIO ) ) { diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index c5d367699..1832662e6 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1213,8 +1213,11 @@ ivas_error acelp_core_dec_fx( } /* LD music post-filter */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, st->element_mode, last_coder_type, qdct ); +#else LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); - +#endif /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS { diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index db508ec27..7926ea137 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -586,8 +586,11 @@ ivas_error amr_wb_dec_fx( Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, st_fx->element_mode, pitch_buf_fx, hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &Qdct ); /* LD music post-filter */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, EVS_MONO, Qdct ); +#else LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, Qdct ); - +#endif /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ Post_music_postP_fx( dct_buffer_fx, exc2_fx, mem_tmp_fx, st_fx->mem_syn2_fx, Aq_fx, syn_fx, &st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn_clas_estim_fx, 1, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, -- GitLab From 8785d158544d237164d2380e9b0adc4a746be64f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 08:21:31 -0500 Subject: [PATCH 460/750] fix clang-format --- lib_com/prot_fx.h | 2 +- lib_dec/LD_music_post_filter_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a5fc7489e..ddf300830 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7947,7 +7947,7 @@ void LD_music_post_filter_fx( #ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 const Word16 element_mode, /* i : IVAS element mode Q0 */ #endif - const Word16 Qdct /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ ); void Prep_music_postP_fx( diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 01a5a1bd2..47c1fb06a 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -49,9 +49,9 @@ void LD_music_post_filter_fx( const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ #ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - const Word16 element_mode, /* i : IVAS element mode Q0 */ + const Word16 element_mode, /* i : IVAS element mode Q0 */ #endif - const Word16 Qdct /* i : input scaling Q0 */ + const Word16 Qdct /* i : input scaling Q0 */ ) { Word32 fr_bands[MBANDS_GN_LD]; /*2*Qdct+10*/ -- GitLab From bb8bbf0339f6caab9bf3d9c91806f66a0ca9ea33 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 14:41:41 +0100 Subject: [PATCH 461/750] HARM_COREDECODER_FUNCTIONS --- lib_com/options.h | 1 + lib_com/prot_fx.h | 6 ++-- lib_dec/dec_post_fx.c | 20 +++++++----- lib_dec/dec_prm_fx.c | 4 +++ lib_dec/dec_tran_fx.c | 4 +++ lib_dec/dlpc_avq_fx.c | 5 +++ lib_dec/gain_dec_fx.c | 73 ++++++++++++++++++++++++++++++++----------- 7 files changed, 86 insertions(+), 27 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a112a55d0..82096b939 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1a194d468..9209746d5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6763,6 +6763,7 @@ void gain_dec_tc_fx( Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ ); +#ifndef HARM_COREDECODER_FUNCTIONS void gain_dec_tc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ @@ -6773,7 +6774,7 @@ void gain_dec_tc_ivas_fx( Word16 *gain_inov_fx, /* o : unscaled innovation gain */ Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ ); - +#endif void gain_dec_mless_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ @@ -8780,6 +8781,7 @@ Word16 decode_lpc_avq_fx( Word16 *param_lpc /* o : lpc parameters */ ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 decode_lpc_avq_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ @@ -8788,7 +8790,7 @@ Word16 decode_lpc_avq_ivas_fx( const Word16 element_mode, /* i : element mode */ const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ ); - +#endif void vlpc_1st_dec( Word16 index, /* i : codebook index */ Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index bb24978b2..14a7b958f 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -34,8 +34,9 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); - +#ifndef HARM_COREDECODER_FUNCTIONS static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); +#endif /*-------------------------------------------------------------------------- @@ -445,7 +446,11 @@ static void Dec_formant_postfilt_fx( } /* Controls short term pst filter gain and compute parcor0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero ); +#else calc_st_filt_ivas_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero, -1 ); +#endif /* 1/A(gamma1) filtering, mem_stp is updated */ resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) ); @@ -1290,22 +1295,20 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain * controls gain : computation of energy impulse response as * SUMn (abs (h[n])) and computes parcor0 *---------------------------------------------------------------------------- */ + static void calc_st_filt_local_fx( Word16 *apond2, /* i : coefficients of numerator Q12 */ - Word16 *apond1, /* i : coefficients of denominator Q12 */ + Word16 *apond1, /* i : coefficients of denominator Q12 */ Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15*/ - Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx */ - Word16 *mem_zero /* i : All zero memory */ + Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx */ + Word16 *mem_zero /* i : All zero memory */ ) { Word32 L_g0; - Word16 h[LONG_H_ST]; - Word16 g0, temp; Word16 i; - temp = sub( 2, norm_s( apond2[0] ) ); /* compute i.r. of composed filter apond2 / apond1 */ @@ -1337,6 +1340,7 @@ static void calc_st_filt_local_fx( return; } +#ifndef HARM_COREDECODER_FUNCTIONS static void calc_st_filt_ivas_fx( Word16 *apond2, /* i : coefficients of numerator Q12 */ Word16 *apond1, /* i : coefficients of denominator Q12 */ @@ -1391,6 +1395,8 @@ static void calc_st_filt_ivas_fx( return; } +#endif + /*---------------------------------------------------------------------------- * filt_mu * diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 6b6748b80..1fe960d7d 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -52,7 +52,11 @@ void getLPCparam_fx( { IF( st->lpcQuantization == 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + decode_lpc_avq_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); +#else decode_lpc_avq_ivas_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); +#endif } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) { diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 110c6e97f..93a9cf8ca 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -145,6 +145,9 @@ void decod_tran_fx( IF( Jopt_flag == 0 ) { /* 2/3-bit decoding */ +#ifdef HARM_COREDECODER_FUNCTIONS + gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); +#else IF( st_fx->element_mode == EVS_MONO ) { gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); @@ -153,6 +156,7 @@ void decod_tran_fx( { gain_dec_tc_ivas_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } +#endif } ELSE { diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c index 97b41d98b..2b1264218 100644 --- a/lib_dec/dlpc_avq_fx.c +++ b/lib_dec/dlpc_avq_fx.c @@ -146,6 +146,7 @@ static Word16 pack4bits_fx( } Word16 decode_lpc_avq_fx( +#ifndef HARM_COREDECODER_FUNCTIONS Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc /* o : lpc parameters */ @@ -285,6 +286,7 @@ Word16 decode_lpc_avq_fx( } Word16 decode_lpc_avq_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ @@ -324,6 +326,7 @@ Word16 decode_lpc_avq_ivas_fx( param_lpc[j] = q_type; j = add( j, 1 ); } + test(); IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 ) { @@ -338,6 +341,7 @@ Word16 decode_lpc_avq_ivas_fx( j = add( j, 1 ); move16(); } + /* Decode quantization indices */ IF( q_type == 0 ) @@ -362,6 +366,7 @@ Word16 decode_lpc_avq_ivas_fx( } j = add( j, 1 ); } + /* * 2nd stage decoding is skipped if: * - we are in low bitrate mode and no joint SNS coding is used diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index cd19197cd..3ac75b9c7 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -90,7 +90,8 @@ void Es_pred_dec_fx( /*======================================================================================*/ void gain_dec_tc_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ +#ifndef HARM_COREDECODER_FUNCTIONS + Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 i_subfr_fx, /* i : subframe number */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ @@ -222,6 +223,7 @@ void gain_dec_tc_fx( /*======================================================================================*/ void gain_dec_tc_ivas_fx( +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 i_subfr_fx, /* i : subframe number */ @@ -245,8 +247,10 @@ void gain_dec_tc_ivas_fx( /*----------------------------------------------------------------* * find number of bits for gain dequantization *----------------------------------------------------------------*/ - nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / 64 )]; + + nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / L_SUBFR )]; move16(); + /*-----------------------------------------------------------------* * calculate the predicted gain code *-----------------------------------------------------------------*/ @@ -264,7 +268,6 @@ void gain_dec_tc_ivas_fx( *gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); move16(); /* gain_inov in Q12 */ - /* Ei = 10 * (float)log10( Ecode );*/ e_tmp = norm_l( L_tmp1 ); f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/ @@ -279,6 +282,7 @@ void gain_dec_tc_ivas_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ @@ -286,23 +290,40 @@ void gain_dec_tc_ivas_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); + /*------------------------------------------------------------------------------------------* * Select the gain quantization table and dequantize the gain *------------------------------------------------------------------------------------------*/ - /* index = (Word16)get_indice( st_fx,"gain_code", i_subfr_fx, ACELP_CORE);move16();*/ index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/ - - IF( GT_16( nBits, 3 ) ) +#ifdef HARM_COREDECODER_FUNCTIONS + IF( st_fx->element_mode == EVS_MONO ) { - wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); - wgain_code = shl( wgain_code, add( expg, 12 ) ); /* wgain_code in Q12*/ + IF( GT_16( nBits, 3 ) ) + { + wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); + wgain_code = shl_sat( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/ + } + ELSE /* nBits == 3 */ + { + wgain_code = tbl_gain_code_tc_fx[index]; /*Q13*/ + move16(); + } } - ELSE /* nBits == 3 */ + ELSE +#endif { - wgain_code = shr( tbl_gain_code_tc_fx[index], 1 ); // Q12 - move16(); + IF( GT_16( nBits, 3 ) ) + { + wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); + wgain_code = shl( wgain_code, add( expg, 12 ) ); /* wgain_code in Q12*/ + } + ELSE /* nBits == 3 */ + { + wgain_code = shr( tbl_gain_code_tc_fx[index], 1 ); // Q12 + move16(); + } } /*-----------------------------------------------------------------* @@ -310,8 +331,18 @@ void gain_dec_tc_ivas_fx( *-----------------------------------------------------------------*/ /* *gain_code *= gcode0;*/ - L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */ - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */ +#ifdef HARM_COREDECODER_FUNCTIONS + IF( st_fx->element_mode == EVS_MONO ) + { + L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/ + } + ELSE +#endif + { + L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */ + *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */ + } move32(); /**norm_gain_code = *gain_code / *gain_inov;*/ @@ -353,8 +384,9 @@ void gain_dec_tc_ivas_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ + void gain_dec_mless_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ + Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ const Word16 coder_type, /* i : coding type */ const Word16 i_subfr_fx, /* i : subframe number */ @@ -431,6 +463,7 @@ void gain_dec_mless_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ @@ -528,6 +561,7 @@ void gain_dec_mless_fx( L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ } + /*-----------------------------------------------------------------* * calculate the predicted gain code *-----------------------------------------------------------------*/ @@ -540,6 +574,7 @@ void gain_dec_mless_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ @@ -650,6 +685,7 @@ void gain_dec_lbr_fx( * calculate prediction of gcode * search for the best codeword *-----------------------------------------------------------------*/ + test(); IF( i_subfr == 0 ) { @@ -698,7 +734,6 @@ void gain_dec_lbr_fx( gcode0_fx = round_fx( L_shl( L_tmp, 11 ) ); /* Q8 */ - /*-----------------------------------------------------------------* * gcode0 = pow(10.0, gcode0/20) * = pow(2, 3.321928*gcode0/20) @@ -775,6 +810,7 @@ void gain_dec_lbr_fx( * gcode0 = pow(10.0, dotp(b, aux, n_pred) * = pow(2, 3.321928*dotp(b, aux, n_pred) *-----------------------------------------------------------------*/ + L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */ L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ @@ -848,6 +884,7 @@ void gain_dec_lbr_fx( * gcode0 = pow(10.0, dotp(b, aux, n_pred) * = pow(2, 3.321928*dotp(b, aux, n_pred) *-----------------------------------------------------------------*/ + L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */ L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ @@ -879,7 +916,6 @@ void gain_dec_lbr_fx( n_pred = 8; move16(); - cdbk_fx = gp_gamma_4sfr_6b_fx; /*Q14*/ IF( EQ_16( nBits, 7 ) ) @@ -984,7 +1020,6 @@ void gain_dec_lbr_fx( /* _ (Word16 *) lp_gainp : LP-filtered pitch gain(FEC) Q14 */ /* _ (Word16 *) lp_gainc : LP-filtered code gain (FEC) Q3 */ /*-----------------------------------------------------------------------*/ - /*-----------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ @@ -1275,7 +1310,7 @@ void gain_dec_SQ_fx( *---------------------------------------------------------------------*/ void gain_dec_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ + Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ @@ -1305,6 +1340,7 @@ void gain_dec_amr_wb_fx( /*-----------------------------------------------------------------* * Select the gain quantization table *-----------------------------------------------------------------*/ + nbits = 7; move16(); t_qua_gain = t_qua_gain7b_fx; @@ -1364,6 +1400,7 @@ void gain_dec_amr_wb_fx( /*-----------------------------------------------------------------* * Decode code gain *-----------------------------------------------------------------*/ + qua_en = t_qua_gain[( index2 + 1 )]; move16(); -- GitLab From d786b13bad5403c6910950c1ddee76d8e8c7dddf Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 19 Jan 2026 14:42:25 +0100 Subject: [PATCH 462/750] correct instrumentation --- lib_rend/lib_rend_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 28ee99d8c..a4afac9eb 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6952,10 +6952,9 @@ static ivas_error renderIsmToSba( Word8 position_changed; Word16 ambiOrderOut; Word16 numOutChannels; -#ifdef FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE - pan_vector_fx currentPanGains_fx = { 0 }; // Solve Clang-18 warnings -#else pan_vector_fx currentPanGains_fx; +#ifdef FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE + set32_fx( currentPanGains_fx, 0, MAX_OUTPUT_CHANNELS ); #endif ivas_error error; error = IVAS_ERR_OK; -- GitLab From 2529d7d463f75d76b720788c012f62649f56d742 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 15:07:00 +0100 Subject: [PATCH 463/750] HARM_COREDECODER_FUNCTIONS --- lib_com/prot_fx.h | 11 ++-- lib_dec/core_dec_init_fx.c | 4 ++ lib_dec/dec_post_fx.c | 103 ++++++++++++++++++-------------- lib_dec/dec_prm_fx.c | 4 ++ lib_dec/waveadjust_fec_dec_fx.c | 3 +- 5 files changed, 74 insertions(+), 51 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9209746d5..028556b88 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6180,10 +6180,11 @@ void concealment_init_x( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); +#ifdef HARM_COREDECODER_FUNCTIONS void concealment_init_ivas_fx( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); - +#endif void concealment_update_x( const Word16 bfi, const Word16 core, @@ -6563,6 +6564,7 @@ void formant_post_filt_fx( const Word16 off_flag /* i : off flag */ ); +#ifndef HARM_COREDECODER_FUNCTIONS void Filt_mu_fx( Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ @@ -6576,7 +6578,7 @@ void Filt_mu_ivas_fx( Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ Word16 L_subfr, /* i : the length of subframe */ const Word16 extl ); - +#endif void scale_st_fx( const Word16 *sig_in, /* i : postfilter i signal */ Word16 *sig_out, /* i/o: postfilter o signal */ @@ -8776,13 +8778,14 @@ Word16 dlpc_avq_fx( Word32 sr_core ); Word16 decode_lpc_avq_fx( +#ifndef HARM_COREDECODER_FUNCTIONS Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc /* o : lpc parameters */ ); -#ifndef HARM_COREDECODER_FUNCTIONS Word16 decode_lpc_avq_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ @@ -8790,7 +8793,7 @@ Word16 decode_lpc_avq_ivas_fx( const Word16 element_mode, /* i : element mode */ const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ ); -#endif + void vlpc_1st_dec( Word16 index, /* i : codebook index */ Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 22fed24cb..2ff4ce84f 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1978,7 +1978,11 @@ void open_decoder_LPD_ivas_fx( IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) { +#ifdef HARM_COREDECODER_FUNCTIONS + concealment_init_x( st->hTcxDec->L_frameTCX, st->hPlcInfo ); +#else concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo ); +#endif } } ELSE diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 14a7b958f..596b8574c 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -34,7 +34,10 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); -#ifndef HARM_COREDECODER_FUNCTIONS + +#ifdef HARM_COREDECODER_FUNCTIONS +static void Filt_mu_fx( Word16 *sig_in, Word16 *sig_out, Word16 parcor0, Word16 L_subfr ); +#else static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); #endif @@ -73,11 +76,13 @@ void Init_post_filter_fx( return; } + /*-------------------------------------------------------------------------- * NB_post_filt: * * Main routine to perform post filtering on NB synthesis *--------------------------------------------------------------------------*/ + void nb_post_filt_fx( const Word16 L_frame, /* i : frame length */ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ @@ -133,7 +138,6 @@ void nb_post_filt_fx( move16(); } - /* run the post filter */ p_Aq = Aq; // Q12 move16(); @@ -149,10 +153,10 @@ void nb_post_filt_fx( j = add( j, 1 ); } - return; } + /*---------------------------------------------------------------------------- * Dec_postfilt() * @@ -176,15 +180,16 @@ void nb_post_filt_fx( * 1. search around 1st subframe delay (3 integer values) * 2. search around best integer with fract. delays (1/8) *----------------------------------------------------------------------------*/ + static void Dec_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ const Word16 t0, /* i : pitch delay given by coder Q0 */ const Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q0 */ - const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ + const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ Word16 *sig_out, /* o : postfiltered output Q15*/ const Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ const Word16 gamma2, /* i : short term postfilt. num. weighting factor Q15*/ - const Word16 Gain_factor, /* i : Gain Factor (Q15) */ + const Word16 Gain_factor, /* i : Gain Factor (Q15) */ const Word16 disable_hpf ) { /* Local variables and arrays */ @@ -192,14 +197,11 @@ static void Dec_postfilt_fx( Word16 apond2[LONG_H_ST]; // Q12 Word16 sig_ltp[L_SUBFR + 1]; /* H0 output signal */ Word16 res2[SIZ_RES2]; // Q0 - Word16 *sig_ltp_ptr; Word16 *res2_ptr; Word16 *ptr_mem_stp; - Word16 parcor0; // Q15 - /* Init pointers and restore memories */ res2_ptr = res2 + DECMEM_RES2; ptr_mem_stp = hPFstat->mem_stp + L_SYN_MEM - 1; @@ -245,10 +247,10 @@ static void Dec_postfilt_fx( /* Update for next subframe */ Copy( &res2[L_SUBFR], hPFstat->mem_res2, DECMEM_RES2 ); - return; } + /*-------------------------------------------------------------------------- * formant_post_filt_fx: * @@ -468,7 +470,12 @@ static void Dec_formant_postfilt_fx( } /* Tilt filtering */ +#ifdef HARM_COREDECODER_FUNCTIONS + Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR ); +#else Filt_mu_ivas_fx( resynth, sig_out, parcor0, L_SUBFR, -1 ); +#endif + IF( scale_down ) { Scale_sig( sig_out, L_SUBFR, 1 ); @@ -477,10 +484,10 @@ static void Dec_formant_postfilt_fx( /* Gain control */ scale_st_fx( signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR ); - return; } + /*------------------------------------------------------------------------------------ * modify_pst_param() * @@ -499,7 +506,6 @@ static void modify_pst_param_fx( Word16 lp_noiseQ12; Word32 L_tmp; - test(); IF( NE_16( coder_type, INACTIVE ) && LT_16( lp_noise, LP_NOISE_THR_FX ) ) { @@ -539,20 +545,21 @@ static void modify_pst_param_fx( *gain_factor = extract_h( L_shl( L_tmp, 7 ) ); /* Q24=>Q31=>Q15 */ - return; } + /*---------------------------------------------------------------------------- * pst_ltp_fx * * Perform harmonic postfilter *----------------------------------------------------------------------------*/ + static void pst_ltp_fx( Word16 t0, /* i : pitch delay given by coder Q0 */ Word16 *ptr_sig_in, /* i : postfilter i filter (residu2) Qx */ - Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */ - Word16 gain_factor /* i : Gain Factor (Q15) */ + Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */ + Word16 gain_factor /* i : Gain Factor (Q15) */ ) { Word32 L_temp; @@ -575,7 +582,6 @@ static void pst_ltp_fx( Word16 off_yup; Word16 nb_sh_sig; - /* i signal justified on 13 bits */ ptr_sig = ptr_sig_in - DECMEM_RES2; // Qx nb_sh_sig = getScaleFactor16( ptr_sig, DECMEM_RES2 + L_SUBFR ); @@ -592,7 +598,6 @@ static void pst_ltp_fx( /* Sub optimal delay search */ search_del_fx( t0, ptr_sig_cadr, <pdel, &phase, &num_gltp, &den_gltp, &sh_num, &sh_den, y_up, &off_yup ); - IF( num_gltp == 0 ) { Copy( ptr_sig_in, ptr_sig_pst0, L_SUBFR ); @@ -608,7 +613,6 @@ static void pst_ltp_fx( /* Filtering with long filter */ compute_ltp_l_fx( ptr_sig_cadr, ltpdel, phase, ptr_sig_pst0, &num2_gltp, &den2_gltp, &sh_num2, &sh_den2 ); - IF( EQ_16( select_ltp_fx( num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2 ), 1 ) ) { /* select short filter */ @@ -677,15 +681,19 @@ static void pst_ltp_fx( /** filtering by H0(z) = harmonic filter **/ filt_plt_fx( ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt ); } + + return; } + /*---------------------------------------------------------------------------- * search_del_fx: * * Computes best (shortest) integer LTP delay + fine search *---------------------------------------------------------------------------*/ + static void search_del_fx( - Word16 t0, /* i : pitch delay given by coder Q0 */ + Word16 t0, /* i : pitch delay given by coder Q0 */ Word16 *ptr_sig_in, /* i : i signal (with delay line) */ Word16 *ltpdel, /* o : delay = *ltpdel - *phase / f_up */ Word16 *phase, /* o : phase */ @@ -720,7 +728,6 @@ static void search_del_fx( Word16 i_max, lambda, phi, phi_max, ioff; Word16 temp; - /*------------------------------------- * Computes energy of current signal *-------------------------------------*/ @@ -752,6 +759,7 @@ static void search_del_fx( * Selects best of 3 integer delays * Maximum of 3 numerators around t0 *-------------------------------------*/ + lambda = sub( t0, 1 ); ptr_sig_past = ptr_sig_in - lambda; L_num_int = L_deposit_l( -1 ); @@ -952,7 +960,6 @@ static void search_del_fx( ptr_L_den1 = L_den1; ptr_y_up = y_up; - /* if den_max = 0 : will be selected and declared unvoiced */ /* if num!=0 & den=0 : will be selected and declared unvoiced */ /* degenerated seldom cases, switch off LT is OK */ @@ -1030,6 +1037,7 @@ static void search_del_fx( /*--------------------------------------------------- * test if normalized crit0[iopt] > THRESHCRIT *--------------------------------------------------*/ + test(); IF( num_max == 0 || LE_16( den_max, 1 ) ) { @@ -1098,30 +1106,28 @@ static void search_del_fx( move16(); } - return; } + /*---------------------------------------------------------------------------- * filt_plt_fx: * * Perform long term postfilter *----------------------------------------------------------------------------*/ + static void filt_plt_fx( Word16 *s_in, /* i : i signal with past Qx */ Word16 *s_ltp, /* i : filtered signal with gain 1 Qx*/ Word16 *s_out, /* o : signal Qx */ - Word16 gain_plt /* i : filter gain Q15 */ + Word16 gain_plt /* i : filter gain Q15 */ ) { - /* Local variables */ Word32 L_acc; - Word16 n; Word16 gain_plt_1; - gain_plt_1 = sub( 32767, gain_plt ); // Q15 gain_plt_1 = add( gain_plt_1, 1 ); /* 2**15 (1 - g) */ @@ -1133,7 +1139,6 @@ static void filt_plt_fx( move16(); /* no overflow */ } - return; } @@ -1144,6 +1149,7 @@ static void filt_plt_fx( * compute delayed signal, num & den of gain for fractional delay * with long interpolation filter *----------------------------------------------------------------------------*/ + static void compute_ltp_l_fx( Word16 *s_in, /* i/o: signal with past */ Word16 ltpdel, /* i : delay factor */ @@ -1219,10 +1225,10 @@ static void compute_ltp_l_fx( move16(); move16(); - return; } + /*---------------------------------------------------------------------------- * select_ltp_fx: * @@ -1230,23 +1236,22 @@ static void compute_ltp_l_fx( * with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1 * and gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2 *----------------------------------------------------------------------------*/ -static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain */ - Word16 num1, /* i : numerator of gain1 Q(sh_num1) */ - Word16 den1, /* i : denominator of gain1 Q(sh_den1) */ - Word16 sh_num1, /* i : just. factor for num1 */ - Word16 sh_den1, /* i : just. factor for den1 */ - Word16 num2, /* i : numerator of gain2 Q(sh_num2) */ - Word16 den2, /* i : denominator of gain2 Q(sh_den2) */ - Word16 sh_num2, /* i : just. factor for num2 */ - Word16 sh_den2 /* i : just. factor for den2 */ +/* o : 1 = 1st gain, 2 = 2nd gain */ +static Word16 select_ltp_fx( + Word16 num1, /* i : numerator of gain1 Q(sh_num1) */ + Word16 den1, /* i : denominator of gain1 Q(sh_den1) */ + Word16 sh_num1, /* i : just. factor for num1 */ + Word16 sh_den1, /* i : just. factor for den1 */ + Word16 num2, /* i : numerator of gain2 Q(sh_num2) */ + Word16 den2, /* i : denominator of gain2 Q(sh_den2) */ + Word16 sh_num2, /* i : just. factor for num2 */ + Word16 sh_den2 /* i : just. factor for den2 */ ) { Word32 L_temp1, L_temp2; Word32 L_temp; - Word16 temp1, temp2; - IF( den2 == 0 ) { return 1; @@ -1288,6 +1293,7 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain return temp1; } + /*---------------------------------------------------------------------------- * calc_st_filt_local_fx * @@ -1336,7 +1342,6 @@ static void calc_st_filt_local_fx( } } - return; } @@ -1403,7 +1408,12 @@ static void calc_st_filt_ivas_fx( * tilt filtering with : (1 + mu z-1) * (1/1-|mu|) * computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1]) *---------------------------------------------------------------------------*/ + +#ifdef HARM_COREDECODER_FUNCTIONS +static void Filt_mu_fx( +#else void Filt_mu_fx( +#endif Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -1411,14 +1421,11 @@ void Filt_mu_fx( ) { Word32 L_acc, L_temp, L_fact; - Word16 *ptrs; - Word16 n; Word16 mu, mu2, ga, temp; Word16 fact, sh_fact; - IF( parcor0 > 0 ) { mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15 @@ -1464,10 +1471,10 @@ void Filt_mu_fx( BASOP_SATURATE_WARNING_ON_EVS; } - return; } +#ifndef HARM_COREDECODER_FUNCTIONS void Filt_mu_ivas_fx( Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ @@ -1557,12 +1564,16 @@ void Filt_mu_ivas_fx( return; } + +#endif + /*---------------------------------------------------------------------------- * scale_st_fx() * * control of the subframe gain * gain[n] = AGC_FAC_FX * gain[n-1] + (1 - AGC_FAC_FX) g_in/g_out *---------------------------------------------------------------------------*/ + void scale_st_fx( const Word16 *sig_in, /* i : postfilter i signal Qx */ Word16 *sig_out, /* i/o: postfilter o signal Qx */ @@ -1570,12 +1581,11 @@ void scale_st_fx( Word16 L_subfr ) { Word32 L_acc, L_temp; - Word16 i; Word16 scal_in, scal_out; Word16 s_g_in, s_g_out, temp, sh_g0, g0; Word16 gain = 0; - + move16(); /* compute i gain */ L_acc = L_deposit_l( 0 ); @@ -1654,10 +1664,10 @@ void scale_st_fx( *gain_prec = gain; move16(); - return; } + /*---------------------------------------------------------------------------- * blend_subfr2_fx() * @@ -1677,6 +1687,7 @@ void blend_subfr2_fx( move16(); move16(); move16(); + FOR( i = 0; i < L_SUBFR / 2; i++ ) { sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 1fe960d7d..91a5a671f 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -1007,7 +1007,11 @@ void dec_prm_fx( { IF( st->lpcQuantization == 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + decode_lpc_avq_fx( st, st->numlpc, param_lpc, 0, EVS_MONO, 0 ); +#else decode_lpc_avq_fx( st, st->numlpc, param_lpc ); +#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index b103b4c93..c6b658a2d 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -839,7 +839,7 @@ void concealment_init_x( return; } - +#ifndef HARM_COREDECODER_FUNCTIONS void concealment_init_ivas_fx( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ) @@ -898,6 +898,7 @@ void concealment_init_ivas_fx( } return; } +#endif static Word16 own_random_fix( /* o : output random value */ Word16 *seed /* i/o: random seed Q0 */ -- GitLab From 71937120271b134855ec92260203678b5cb4dbd0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 09:11:55 -0500 Subject: [PATCH 464/750] fix wrong parameter in LD_music_post_filter_fx call --- lib_dec/acelp_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index f3d49dd41..f133ced32 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1214,7 +1214,7 @@ ivas_error acelp_core_dec_fx( /* LD music post-filter */ #ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, st->element_mode, last_coder_type, qdct ); + LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, st->element_mode, qdct ); #else LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); #endif -- GitLab From 3eace83dd732de5fd196ec538511a2af4980bff9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 15:34:29 +0100 Subject: [PATCH 465/750] HARM_COREDECODER_FUNCTIONS --- lib_enc/enc_prm_fx.c | 23 ++++++++++++++++---- lib_enc/ivas_mdct_core_enc_fx.c | 7 +++++- lib_enc/lsf_msvq_ma_enc_fx.c | 14 ++++++------ lib_enc/prot_fx_enc.h | 12 +++++++---- lib_enc/qlpc_avq_fx.c | 38 ++++++++++++++++++++++++++++++--- 5 files changed, 74 insertions(+), 20 deletions(-) diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index d0b050ac0..89abd96da 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -1152,7 +1152,11 @@ void writeLPCparam_fx( IF( st->enableTcxLpc && st->core != ACELP_CORE ) { /* Encode the indices */ - *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr ); /* Q0 */ +#else + *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */ +#endif move16(); } ELSE @@ -1171,7 +1175,11 @@ void writeLPCparam_fx( move16(); } - *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ +#else + *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ +#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) @@ -1181,13 +1189,20 @@ void writeLPCparam_fx( IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->coder_type, VOICED ) && EQ_16( st->core, ACELP_CORE ) ) { assert( st->element_mode == EVS_MONO ); - - *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#else + *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#endif move16(); } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#else *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#endif move16(); } } diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 19f52647f..f4889bf5f 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2445,14 +2445,17 @@ void ivas_mdct_core_whitening_enc_fx( } } +#ifdef HARM_COREDECODER_FUNCTIONS + encode_lpc_avq_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); +#else encode_lpc_avq_ivas_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); +#endif st->side_bits_frame_channel = add( st->side_bits_frame_channel, sub( hBstr->nb_bits_tot, nbits_start_sns ) ); move16(); } } - /*update pitch buffer*/ FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -2474,6 +2477,8 @@ void ivas_mdct_core_whitening_enc_fx( pop_wmops(); return; } + + void ivas_mdct_quant_coder_fx( CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index b79099911..00d5b8d45 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1466,7 +1466,6 @@ excludes the waveform contributions at pos 21,22,23 to the MSE, important to kee /*mvi2i (indices[1]+c2*stages, Idx, stages);*/ Copy( indices[1] + c2 * stages, Idx, stages ); - return; } @@ -1496,7 +1495,6 @@ Word16 lsf_msvq_ma_encprm_fx( FOR( i = 0; i < no_indices; i++ ) { - push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); param_lpc++; nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); @@ -1506,7 +1504,6 @@ Word16 lsf_msvq_ma_encprm_fx( test(); IF( ( core == ACELP_CORE ) && acelp_midLpc ) { - push_next_indice( hBstr, *param_lpc, bits_midlpc ); nbits_lpc = add( nbits_lpc, bits_midlpc ); } @@ -1515,7 +1512,7 @@ Word16 lsf_msvq_ma_encprm_fx( return nbits_lpc; } - +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_msvq_ma_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, // Q0 @@ -1553,7 +1550,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( return nbits_lpc; } - +#endif /*--------------------------------------------------------------------------* * midlsf_enc_fx() @@ -1995,7 +1992,7 @@ Word16 enc_lsf_tcxlpc_fx( return NumBits; } - +#ifndef HARM_COREDECODER_FUNCTIONS Word16 enc_lsf_tcxlpc_ivas_fx( const Word16 **indices, /* i : Ptr to VQ indices */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ @@ -2029,7 +2026,7 @@ Word16 enc_lsf_tcxlpc_ivas_fx( } return NumBits; } - +#endif /*--------------------------------------------------------------------------* * lsf_bctcvq_encprm_fx() @@ -2056,7 +2053,7 @@ Word16 lsf_bctcvq_encprm_fx( return nbits_lpc; } - +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_bctcvq_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, @@ -2078,3 +2075,4 @@ Word16 lsf_bctcvq_encprm_ivas_fx( return nbits_lpc; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0b607089f..389152dac 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2808,12 +2808,13 @@ Word16 enc_lsf_tcxlpc_fx( BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); +#ifndef HARM_COREDECODER_FUNCTIONS /* Returns: number of bits written */ Word16 enc_lsf_tcxlpc_ivas_fx( const Word16 **indices, /* i : Ptr to VQ indices */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); - +#endif Word16 encode_lpc_avq_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ @@ -2822,6 +2823,7 @@ Word16 encode_lpc_avq_fx( const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 encode_lpc_avq_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ @@ -2829,19 +2831,20 @@ Word16 encode_lpc_avq_ivas_fx( const Word16 core, /* i : core Q0*/ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ ); - +#endif Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, Word16 *param_lpc, Word16 *bits_param_lpc, Word16 no_indices ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_bctcvq_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, const Word16 *bits_param_lpc, const Word16 no_indices ); - +#endif Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, Word16 *param_lpc, @@ -2851,6 +2854,7 @@ Word16 lsf_msvq_ma_encprm_fx( Word16 *bits_param_lpc, Word16 no_indices ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_msvq_ma_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, @@ -2859,7 +2863,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( const Word16 acelp_midLpc, const Word16 *bits_param_lpc, const Word16 no_indices ); - +#endif /* o: number of bits written per frame */ Word16 IGFEncWriteBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ diff --git a/lib_enc/qlpc_avq_fx.c b/lib_enc/qlpc_avq_fx.c index 67b481ea0..0b28d1b77 100644 --- a/lib_enc/qlpc_avq_fx.c +++ b/lib_enc/qlpc_avq_fx.c @@ -123,15 +123,21 @@ void qlpc_avq_fx( return; } + /*-------------------------------------------------------------------* * unary_code() * * *--------------------------------------------------------------------*/ +#ifdef HARM_COREDECODER_FUNCTIONS +static Word16 unary_code_fx( +#else static Word16 unary_code( +#endif Word16 ind, /* Q0 */ BSTR_ENC_HANDLE hBstr ) +#ifndef HARM_COREDECODER_FUNCTIONS { Word16 nb_bits; @@ -155,6 +161,7 @@ static Word16 unary_code( static Word16 unary_code_ivas_fx( Word16 ind, /* Q0 */ BSTR_ENC_HANDLE hBstr ) +#endif { Word16 nb_bits; @@ -181,12 +188,18 @@ static Word16 unary_code_ivas_fx( return ( nb_bits ); } + /*-------------------------------------------------------------------* * unpack4bits() * * *--------------------------------------------------------------------*/ + +#ifdef HARM_COREDECODER_FUNCTIONS +static Word16 unpack4bits_fx( +#else static Word16 unpack4bits( +#endif Word16 nbits, /* Q0 */ const Word16 *prm, /* Q0 */ BSTR_ENC_HANDLE hBstr ) @@ -215,6 +228,7 @@ static Word16 unpack4bits( return ( i ); } +#ifndef HARM_COREDECODER_FUNCTIONS static Word16 unpack4bits_ivas_fx( Word16 nbits, /* Q0 */ const Word16 *prm, /* Q0 */ @@ -244,6 +258,7 @@ static Word16 unpack4bits_ivas_fx( return ( i ); } +#endif /*-------------------------------------------------------------------* * encode_lpc_avq_fx() * @@ -251,6 +266,7 @@ static Word16 unpack4bits_ivas_fx( *--------------------------------------------------------------------*/ Word16 encode_lpc_avq_fx( +#ifndef HARM_COREDECODER_FUNCTIONS BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ const Word16 *param_lpc, /* i : lpc parameters Q0*/ @@ -458,7 +474,8 @@ Word16 encode_lpc_avq_fx( } Word16 encode_lpc_avq_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ +#endif + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ const Word16 *param_lpc, /* i : lpc parameters Q0*/ const Word16 core, /* i : core Q0*/ @@ -491,8 +508,6 @@ Word16 encode_lpc_avq_ivas_fx( FOR( k = 0; k < numlpc; k++ ) { /* Retrieve quantizer type */ - - move16(); q_type = 0; IF( k != 0 ) @@ -508,6 +523,7 @@ Word16 encode_lpc_avq_ivas_fx( move16(); j = add( j, 1 ); } + /* Determine number of AVQ indices */ move16(); nb_ind = 0; @@ -615,7 +631,11 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + unary_code_fx( nb, hBstr ); +#else unary_code_ivas_fx( nb, hBstr ); +#endif } nb_bits = add( nb_bits, nb ); @@ -643,17 +663,29 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + unary_code_fx( nb, hBstr ); +#else unary_code_ivas_fx( nb, hBstr ); +#endif } nb_bits = add( nb_bits, nb ); avqBits = shl( qn1, 2 ); +#ifdef HARM_COREDECODER_FUNCTIONS + unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); +#else unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); +#endif j = add( j, qn1 ); nb_bits = add( nb_bits, avqBits ); // Q0 avqBits = shl( qn2, 2 ); +#ifdef HARM_COREDECODER_FUNCTIONS + unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); +#else unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); +#endif j = add( j, qn2 ); nb_bits = add( nb_bits, avqBits ); // Q0 } -- GitLab From 5fe3418e90b619a3207c2ba2a9464ae361d5e830 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 15:52:47 +0100 Subject: [PATCH 466/750] HARM_COREDECODER_FUNCTIONS --- lib_com/parameter_bitmaping_fx.c | 14 ++++++++++++-- lib_com/prot_fx.h | 3 ++- lib_enc/tns_base_enc_fx.c | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 923872090..412ab4647 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -25,6 +25,7 @@ static Word16 PutIntoBitstream_fx( return value; } +#ifndef HARM_COREDECODER_FUNCTIONS static Word16 PutIntoBitstream_ivas_fx( const Word16 **pStream, TEncodeValue EncodeValue, @@ -43,6 +44,7 @@ static Word16 PutIntoBitstream_ivas_fx( return value; } +#endif static Word16 FixedWidthEncoding( Word16 value, Word16 index ) { @@ -252,6 +254,8 @@ void SetParameters_fx( } } } + + return; } @@ -266,13 +270,11 @@ void WriteToBitstream_fx( Word16 index; Word16 iParam, nParams; - assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( hBstr != NULL ) && ( pnBits != NULL ) ); nParams = paramsBitMap->nParams; FOR( index = 0; index < nArrayLength; index++ ) { - FOR( iParam = 0; iParam < nParams; iParam++ ) { ParamBitMap const *param; @@ -321,7 +323,11 @@ void WriteToBitstream_fx( } } } + + return; } + +#ifndef HARM_COREDECODER_FUNCTIONS void WriteToBitstream_ivas_fx( ParamsBitMap const *paramsBitMap, const Word16 nArrayLength, @@ -389,6 +395,7 @@ void WriteToBitstream_ivas_fx( } } } +#endif /** Get nBits long value from bitstream into *pStream. */ static Word16 GetFromBitstream( @@ -457,6 +464,9 @@ void ReadFromBitstream_fx( } } } + move16(); *pnSize = add( *pnSize, i_mult( nParams, nArrayLength ) ); + + return; } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 028556b88..86312b8e9 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10869,6 +10869,7 @@ void WriteToBitstream_fx( BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); +#ifndef HARM_COREDECODER_FUNCTIONS void WriteToBitstream_ivas_fx( ParamsBitMap const *paramsBitMap, const Word16 nArrayLength, @@ -10876,7 +10877,7 @@ void WriteToBitstream_ivas_fx( Word16 *pnSize, BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); - +#endif /*===========================================================================================*/ /*----------------------------------------------------------------------------------* diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index d8e5899da..08f3e5033 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -791,32 +791,53 @@ Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, Word16 const *stream, { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } } ELSE { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } } } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } return TNS_NO_ERROR; } + /*********************************************************************************************/ /* Definitions of functions used in the mapping between TNS parameters and a bitstream. */ /*********************************************************************************************/ -- GitLab From c3dcc2dcc2aadc8480f98a3a886053d398591239 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 16:06:27 +0100 Subject: [PATCH 467/750] fix build --- lib_enc/enc_prm_fx.c | 4 ---- lib_enc/lsf_msvq_ma_enc_fx.c | 22 +++++++++++----------- lib_enc/prot_fx_enc.h | 22 +++++++++++----------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 89abd96da..80d74522d 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -23,7 +23,6 @@ static void enc_prm_hm( Word8 flag; BSTR_ENC_HANDLE hBstr = st->hBstr; - /* Disable HM for non-GC,VC modes */ test(); IF( NE_16( st->hTcxCfg->coder_type, VOICED ) && NE_16( st->hTcxCfg->coder_type, GENERIC ) ) @@ -1111,15 +1110,12 @@ void enc_prm_fx( } /* k, window index */ } - /*--------------------------------------------------------------------------------* * END *--------------------------------------------------------------------------------*/ - total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */ - /* Check if total encoded bits does not exceed CBR target bits (->this must never happen) */ if ( st->bits_frame_core && ( total_nbbits > st->bits_frame_core ) ) { diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 00d5b8d45..bf2b1a704 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1478,12 +1478,12 @@ excludes the waveform contributions at pos 21,22,23 to the MSE, important to kee Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, // Q0 - Word16 core, - Word16 acelp_mode, - Word16 acelp_midLpc, - Word16 *bits_param_lpc, - Word16 no_indices ) + const Word16 *param_lpc, // Q0 + const Word16 core, + const Word16 acelp_mode, + const Word16 acelp_midLpc, + const Word16 *bits_param_lpc, + const Word16 no_indices ) { Word16 i, nbits_lpc; Word16 bits_midlpc; @@ -1959,8 +1959,8 @@ Word16 Q_lsf_tcxlpc_ivas_fx( *--------------------------------------------------------------------------*/ Word16 enc_lsf_tcxlpc_fx( - Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + const Word16 **indices, /* i : Ptr to VQ indices */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ) { Word16 i, NumBits; @@ -2036,9 +2036,9 @@ Word16 enc_lsf_tcxlpc_ivas_fx( Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, // Q0 - Word16 *bits_param_lpc, - Word16 no_indices ) + const Word16 *param_lpc, // Q0 + const Word16 *bits_param_lpc, + const Word16 no_indices ) { Word16 i, nbits_lpc; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 389152dac..6dfc26f53 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2804,8 +2804,8 @@ void enc_prm_side_Info_fx( /* Returns: number of bits written */ Word16 enc_lsf_tcxlpc_fx( - Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + const Word16 **indices, /* i : Ptr to VQ indices */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); #ifndef HARM_COREDECODER_FUNCTIONS @@ -2834,9 +2834,9 @@ Word16 encode_lpc_avq_ivas_fx( #endif Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, - Word16 *bits_param_lpc, - Word16 no_indices ); + const Word16 *param_lpc, + const Word16 *bits_param_lpc, + const Word16 no_indices ); #ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_bctcvq_encprm_ivas_fx( @@ -2847,12 +2847,12 @@ Word16 lsf_bctcvq_encprm_ivas_fx( #endif Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, - Word16 core, - Word16 acelp_mode, - Word16 acelp_midLpc, - Word16 *bits_param_lpc, - Word16 no_indices ); + const Word16 *param_lpc, + const Word16 core, + const Word16 acelp_mode, + const Word16 acelp_midLpc, + const Word16 *bits_param_lpc, + const Word16 no_indices ); #ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_msvq_ma_encprm_ivas_fx( -- GitLab From 4d29115f7f5769b99e112e604a465321ed235f86 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 10:26:26 -0500 Subject: [PATCH 468/750] CodeFileLineColumn --- lib_com/options.h | 1 - lib_com/prot_fx.h | 3 --- lib_dec/LD_music_post_filter_fx.c | 17 +---------------- lib_dec/acelp_core_dec_fx.c | 5 +---- lib_dec/amr_wb_dec_fx.c | 5 +---- 5 files changed, 3 insertions(+), 28 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6b0f753a6..0b6411001 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,6 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ -#define FIX_2338_HARM_GSC_GAIN_COMP_PART2 /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS, reducing MLD regressions */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ddf300830..249f67250 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7944,9 +7944,6 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : i scaling Q0 */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - const Word16 element_mode, /* i : IVAS element mode Q0 */ -#endif const Word16 Qdct /* i : i scaling Q0 */ ); diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 47c1fb06a..4dc9ee37b 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -48,9 +48,6 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - const Word16 element_mode, /* i : IVAS element mode Q0 */ -#endif const Word16 Qdct /* i : input scaling Q0 */ ) { @@ -72,9 +69,6 @@ void LD_music_post_filter_fx( Word16 mant, exp1, s_ave, tmp16, old_tmp16; Word16 diff_sc; Word16 old_tmp16_1; -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - Word16 previous_flag; -#endif move16(); move16(); move16(); @@ -99,17 +93,8 @@ void LD_music_post_filter_fx( /*------------------------------------------------------------------------* * Find signal classification *------------------------------------------------------------------------*/ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - previous_flag = hMusicPF->LDm_last_music_flag; -#endif music_flag2 = stab_est_fx( LG_etot, hMusicPF->LDm_lt_diff_etot_fx, &hMusicPF->LDm_mem_etot_fx, &hMusicPF->LDm_nb_thr_3, &hMusicPF->LDm_nb_thr_1, hMusicPF->LDm_thres_fx, &hMusicPF->LDm_last_music_flag, 1 ); -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - /* delay going back to 0 by one frame, prevent single frame switching during audio segment */ - if ( EQ_16( Last_coder_type, AUDIO ) && EQ_16( coder_type, AUDIO ) && EQ_16( previous_flag, 1 ) && music_flag2 == 0 && element_mode > EVS_MONO ) - { - music_flag2 = previous_flag; - } -#endif + test(); if ( LT_32( core_brate, ACELP_6k60 ) || NE_16( Last_coder_type, AUDIO ) ) { diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index f133ced32..71d8729aa 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1213,11 +1213,8 @@ ivas_error acelp_core_dec_fx( } /* LD music post-filter */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, st->element_mode, qdct ); -#else LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); -#endif + /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS { diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 7926ea137..db508ec27 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -586,11 +586,8 @@ ivas_error amr_wb_dec_fx( Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, st_fx->element_mode, pitch_buf_fx, hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &Qdct ); /* LD music post-filter */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, EVS_MONO, Qdct ); -#else LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, Qdct ); -#endif + /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ Post_music_postP_fx( dct_buffer_fx, exc2_fx, mem_tmp_fx, st_fx->mem_syn2_fx, Aq_fx, syn_fx, &st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn_clas_estim_fx, 1, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, -- GitLab From 382491812b20ed617e5480b0d6a5356f68c9a62f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 16:27:22 +0100 Subject: [PATCH 469/750] fix build --- lib_enc/enc_prm_fx.c | 14 +++++++------- lib_enc/prot_fx_enc.h | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 80d74522d..74b27351a 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -451,14 +451,14 @@ void enc_prm_rf_fx( *-----------------------------------------------------------------*/ void enc_prm_fx( - const Word16 coder_type, /* (i) : coding type */ - Word16 param[], /* (i) : parameters Q0*/ - Word16 param_lpc[], /* (i) : LPC parameters Q0*/ - Encoder_State *st, /* i/o : quantization Analysis values */ - Word16 L_frame, /* Q0 */ + const Word16 coder_type, /* (i) : coding type */ + Word16 param[], /* (i) : parameters Q0*/ + const Word16 param_lpc[], /* (i) : LPC parameters Q0*/ + Encoder_State *st, /* i/o : quantization Analysis values */ + const Word16 L_frame, /* Q0 */ CONTEXT_HM_CONFIG hm_cfg[], - Word16 *bits_param_lpc, /* Q0 */ - Word16 no_param_lpc /* Q0 */ + Word16 *bits_param_lpc, /* Q0 */ + const Word16 no_param_lpc /* Q0 */ ) { Word16 j, k, n, sfr, core, last_core, *prm, tmp; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 6dfc26f53..7d2ead3da 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2499,14 +2499,14 @@ void coder_tcx_post_ivas_fx( Word16 Q_new ); void enc_prm_fx( - const Word16 coder_type, /* i : coding type */ - Word16 param[], /* i : parameters */ - Word16 param_lpc[], /* i : LPC parameters */ - Encoder_State *st, /* i/o: quantization Analysis values */ - Word16 L_Frame, + const Word16 coder_type, /* i : coding type */ + Word16 param[], /* i : parameters */ + const Word16 param_lpc[], /* i : LPC parameters */ + Encoder_State *st, /* i/o: quantization Analysis values */ + const Word16 L_Frame, CONTEXT_HM_CONFIG hm_cfg[], Word16 *bits_param_lpc, - Word16 no_param_lpc ); + const Word16 no_param_lpc ); void IGFEncSetMode_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ @@ -3738,6 +3738,7 @@ void gain_enc_tc_fx( const Word16 Q_xn /* i : xn and y1 scaling */ ); +#ifndef HARM_COREDECODER_FUNCTIONS void gain_enc_tc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3752,7 +3753,7 @@ void gain_enc_tc_ivas_fx( Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ const Word16 Q_xn /* i : xn and y1 scaling */ ); - +#endif Word16 gaus_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -3773,6 +3774,7 @@ Word16 gaus_encode_fx( Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 gaus_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -3792,7 +3794,7 @@ Word16 gaus_encode_ivas_fx( const Word16 shift, /* i : scaling factor */ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ ); - +#endif void pre_proc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 input_frame, /* i : frame length */ -- GitLab From 2e00f1c42660ccf4fc5b0903d22bf1adeb354735 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 19 Jan 2026 19:48:20 +0100 Subject: [PATCH 470/750] do not update seed[1] when j == k in the first run --- lib_com/swb_tbe_com_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 698b34e3a..2c3c718b3 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6140,6 +6140,7 @@ void create_random_vector_fx( Word16 i, j, k; Word16 scale1, scale2; Word32 L_tmp; + /* Note: the constant 2144047674 is 0.0078f in Q38 from the float reference. It should read 0.0078125f, which is 1/128.Since 0.0078f is nor exactly @@ -6185,7 +6186,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - k = abs_s( shr( Random( &seed[1] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ + k = abs_s( shr( Random( &k ), 7 ) ); } else { -- GitLab From 536059e31ddc37f7ac2c3a947d34ab83e2083935 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 19 Jan 2026 20:29:23 +0100 Subject: [PATCH 471/750] clang format --- lib_com/swb_tbe_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 917118d36..f0229089d 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6037,7 +6037,7 @@ void create_random_vector_fx( j = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ j = extract_l( L_shr( L_tmp, 23 ) ); #endif j = s_and( j, 0xff ); @@ -6064,7 +6064,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - k = abs_s( shr( Random( &k ), 7 ) ); + k = abs_s( shr( Random( &k ), 7 ) ); } else { -- GitLab From f1044b00c6d691307574f5b86de25c166bf60f62 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 19 Jan 2026 21:10:22 +0100 Subject: [PATCH 472/750] move after variable declaration block --- lib_rend/lib_rend_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a4afac9eb..697b87fbf 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6953,13 +6953,14 @@ static ivas_error renderIsmToSba( Word16 ambiOrderOut; Word16 numOutChannels; pan_vector_fx currentPanGains_fx; -#ifdef FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE - set32_fx( currentPanGains_fx, 0, MAX_OUTPUT_CHANNELS ); -#endif ivas_error error; error = IVAS_ERR_OK; move32(); +#ifdef FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE + set32_fx( currentPanGains_fx, 0, MAX_OUTPUT_CHANNELS ); +#endif + ismInput->currentPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->currentPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 ); ismInput->currentPos.elevation_fx = L_shl( L_shr( L_add( ismInput->currentPos.elevation_fx, ONE_IN_Q21 ), Q22 ), Q22 ); ismInput->previousPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->previousPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 ); -- GitLab From 111e1f19d60e28448c2d68d6d7ce8863100a320b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 20 Jan 2026 10:10:46 +0100 Subject: [PATCH 473/750] ommit calculation of proto_frame_dec_f_q in intermidiate_ext_dirac_render() for testing purposes --- lib_rend/lib_rend_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e7534b558..f29b4ed19 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -10579,6 +10579,8 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( * memory allocation *-----------------------------------------------------------------*/ + /*TODO 2230: Should we allocate memory here for proto_frame_dec_f_fx and set proto_frame_dec_f_q? */ + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->proto_frame_f_fx = NULL; @@ -11230,8 +11232,8 @@ static void intermidiate_ext_dirac_render( move16(); } } - hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); - move16(); + //hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); + //move16(); IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { -- GitLab From a91f92c131038323dec46e7ccce063e20923d3ba Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 20 Jan 2026 10:12:26 +0100 Subject: [PATCH 474/750] try correct format --- lib_rend/lib_rend_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index f29b4ed19..a9c98aec6 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11232,8 +11232,8 @@ static void intermidiate_ext_dirac_render( move16(); } } - //hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); - //move16(); + // hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); + // move16(); IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { -- GitLab From 566ea4a613348260e47f41e5c4cdf55cd7522ddd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 20 Jan 2026 10:44:35 +0100 Subject: [PATCH 475/750] inplement macro into lib_rend_fx.c --- lib_rend/lib_rend_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a9c98aec6..8fcdc1771 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11232,8 +11232,10 @@ static void intermidiate_ext_dirac_render( move16(); } } - // hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); - // move16(); +#ifndef FIX_2330_CLANG_18_WARNINGS_REND + hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); + move16(); +#endif IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { -- GitLab From a87299cd4e27789f72465e1359100875f05c232d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 20 Jan 2026 10:34:40 +0000 Subject: [PATCH 476/750] cleanup --- lib_rend/lib_rend_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a9c98aec6..d21043981 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -10579,8 +10579,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( * memory allocation *-----------------------------------------------------------------*/ - /*TODO 2230: Should we allocate memory here for proto_frame_dec_f_fx and set proto_frame_dec_f_q? */ - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->proto_frame_f_fx = NULL; -- GitLab From 2d80f7be56a4a49754de3bb899e8ff52b5366842 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 20 Jan 2026 10:35:46 +0000 Subject: [PATCH 477/750] incorporate macro correctly --- lib_rend/lib_rend_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index d21043981..da6c59749 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11230,8 +11230,10 @@ static void intermidiate_ext_dirac_render( move16(); } } - // hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); - // move16(); +#ifndef FIX_2330_CLANG_18_WARNINGS_REND + hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); + move16(); +#endif IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { -- GitLab From ff351d0a8c2edbb851878effaffa5ab2b7144c80 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 20 Jan 2026 13:09:13 +0100 Subject: [PATCH 478/750] do not call IVAS_DEC_GetRenderNumSubfr() twice --- apps/decoder.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 399aadb44..e601d1e1a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -417,22 +417,10 @@ int main( goto cleanup; } - if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( arg.render_num_subframes != asked_num_subframes ) - { - fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" ); - } - /*------------------------------------------------------------------------------------------* * Configure Split rendering *------------------------------------------------------------------------------------------*/ - asked_num_subframes = arg.render_num_subframes; if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) @@ -440,20 +428,20 @@ int main( fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + } - if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } + if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } #ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR - if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) - { - fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); - } -#endif + if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms allowed!\n" ); } +#endif /*------------------------------------------------------------------------------------------* * Configure VoIP mode @@ -3942,6 +3930,15 @@ static ivas_error restartDecoder( goto cleanup; } + if ( arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg->render_num_subframes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); -- GitLab From d5d4ccd5c39625391e45096a34275f204246b03b Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 20 Jan 2026 13:11:47 +0100 Subject: [PATCH 479/750] remove complexity level from ISAR post-renderer --- apps/isar_post_rend.c | 32 -------------------------------- lib_isar/lib_isar_post_rend.h | 8 -------- 2 files changed, 40 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index ba0001541..cd10d9d37 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -109,7 +109,6 @@ typedef struct char inMetadataFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; char headRotationFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; char splitRendBFIFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; - ISAR_POST_REND_COMPLEXITY_LEVEL complexityLevel; bool delayCompensationEnabled; bool quietModeEnabled; IVAS_RENDER_NUM_SUBFR render_num_subframes; @@ -122,7 +121,6 @@ typedef enum CmdLnOptionId_outputFile, CmdLnOptionId_sampleRate, CmdLnOptionId_trajFile, - CmdLnOptionId_complexityLevel, CmdLnOptionId_noDelayCmp, CmdLnOptionId_quietModeEnabled, CmdLnOptionId_inputMetadata, @@ -192,13 +190,6 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "no_delay_cmp", .description = "Turn off delay compensation", }, - { - .id = CmdLnOptionId_complexityLevel, - .match = "complexity_level", - .matchShort = "level", - .placeholder = "", - .description = "Complexity level (1, 2, 3) - will be defined after characterisation", - }, { .id = CmdLnOptionId_quietModeEnabled, .match = "quiet", @@ -432,7 +423,6 @@ static CmdlnArgs defaultArgs( clearString( args.headRotationFilePath ); clearString( args.splitRendBFIFilePath ); - args.complexityLevel = ISAR_POST_REND_COMPLEXITY_LEVEL_THREE; args.delayCompensationEnabled = true; args.quietModeEnabled = false; @@ -546,28 +536,6 @@ static int16_t parseOption( } strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; - case CmdLnOptionId_complexityLevel: - if ( numOptionValues == 0 ) - { - fprintf( stderr, "Error: No complexity level has been provided!\n" ); - return -1; - } - else if ( numOptionValues > 1 ) - { - fprintf( stderr, "Error: The program expects a single complexity level, but %d have been provided!\n", numOptionValues ); - return -1; - } - args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); - if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) - { - fprintf( stderr, "Error: Invalid complexity level specified.\n" ); - return -1; - } - else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) - { - fprintf( stderr, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); - } - break; case CmdLnOptionId_noDelayCmp: if ( numOptionValues != 0 ) { diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index c7d4c2141..d7f1cce84 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -82,14 +82,6 @@ typedef struct ISAR_POST_REND const *ISAR_POST_REND_CONST_HANDLE; typedef UWord16 ISAR_POST_REND_InputId; -typedef enum _ISAR_POST_REND_COMPLEXITY_LEVEL -{ - ISAR_POST_REND_COMPLEXITY_LEVEL_ONE = 1, - ISAR_POST_REND_COMPLEXITY_LEVEL_TWO = 2, - ISAR_POST_REND_COMPLEXITY_LEVEL_THREE = 3 -} ISAR_POST_REND_COMPLEXITY_LEVEL; - - /* clang-format off */ /*----------------------------------------------------------------------------------* * ISAR post-renderer function prototypes -- GitLab From b0db2d05b0980c1ab8efa550fa0e045690e8e881 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 20 Jan 2026 13:14:07 +0100 Subject: [PATCH 480/750] modifications to cmd-line parameter descriptions --- apps/isar_post_rend.c | 8 ++++---- readme.txt | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index cd10d9d37..c3fe556c8 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -145,7 +145,7 @@ static const CmdLnParser_Option cliOptions[] = { .match = "input_format", .matchShort = "if", .placeholder = "", - .description = "Audio format of input file (e.g. BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, ... Use -l for a list)", + .description = "Audio format of input file (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM or RTPDUMP)", .isMandatory = true, }, { @@ -161,14 +161,14 @@ static const CmdLnParser_Option cliOptions[] = { .match = "input_metadata", .matchShort = "im", .placeholder = "", - .description = "Path to the input metadata file for BINAURAL_SPLIT_PCM input format", + .description = "Path to the input metadata file (mandatory for BINAURAL_SPLIT_PCM input format)", }, { .id = CmdLnOptionId_sampleRate, .match = "sample_rate", .matchShort = "fs", .placeholder = "", - .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM input files", + .description = "Input sampling rate in kHz (16, 32, 48) (mandatory for raw PCM input files)", }, { .id = CmdLnOptionId_trajFile, @@ -214,7 +214,7 @@ static const CmdLnParser_Option cliOptions[] = { .match = "sr_params", .matchShort = "s", .placeholder = "", - .description = "Path to the split rendering init params file", + .description = "Path to the split rendering SDP init params file (mandatory for RTPDUMP input format)", }, { .id = CmdLnOptionId_help, diff --git a/readme.txt b/readme.txt index a94133f20..0f4848d61 100644 --- a/readme.txt +++ b/readme.txt @@ -387,24 +387,23 @@ The usage of the "ISAR_post_rend" program is as follows: Usage: ISAR_post_rend [options] -i -if -o -Mandatory parameters: ---------------------- --i File : Path to the input file (WAV or raw PCM file with BINAURAL_SPLIT_PCM input format or ISAR bitstream file with BINAURAL_SPLIT_CODED input format) --if Format : Audio format of input file (e.g. BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, ... Use -l for a list) --o File : Path to the output file - -Options: --------- --im File : Path to the input metadata file for BINAURAL_SPLIT_PCM input format --fs : Input sampling rate in kHz (16, 32, 48) - required only with raw PCM input files +Mandatory parameters: +--------------------- +-i File : Path to the input file (WAV or raw PCM file with BINAURAL_SPLIT_PCM input format or ISAR bitstream file with BINAURAL_SPLIT_CODED input format) +-if Format : Audio format of input file (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM or RTPDUMP) +-o File : Path to the output file + +Options : +------- - +-im File : Path to the input metadata file (mandatory for BINAURAL_SPLIT_PCM input format) +-fs : Input sampling rate in kHz (16, 32, 48) (mandatory for raw PCM input files) -T File : Head rotation trajectory file for simulation of head tracking -prbfi File : Split rendering BFI (Bad Frame Indicator) file -no_delay_cmp : Turn off delay compensation --level level : Complexity level (1, 2, 3) - will be defined after characterisation -q : Quiet mode - limit printouts to terminal -l : List supported audio formats of input file -fr L : Render frame size in ms L=(5, 10, 20), default is 20 --s File : Path to the split rendering init params file +-s File : Path to the split rendering SDP init params file (mandatory for RTPDUMP input format) -h : Show this help message and exit -- GitLab From 6bb393949099b721944dbcea1219a02c54a6b963 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 20 Jan 2026 13:25:13 +0100 Subject: [PATCH 481/750] fix merge --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8390207a5..b1c205129 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,7 +104,6 @@ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ #define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ -#define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsolete CAM code from IVAS */ #define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ /* #################### End BE switches ################################## */ -- GitLab From 8dd635e2b70487b0ad7a1648be525940561fda44 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 20 Jan 2026 14:27:28 +0100 Subject: [PATCH 482/750] adopt proposal by M.Multrus --- lib_com/swb_tbe_com_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index f0229089d..c31a18fc4 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6029,7 +6029,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - j = abs_s( shr( Random( &seed[0] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ + j = shr( abs_s( Random( &seed[0] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ } else { @@ -6045,7 +6045,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - k = abs_s( shr( Random( &seed[1] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ + k = shr( abs_s( Random( &seed[1] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ } else { @@ -6064,7 +6064,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - k = abs_s( shr( Random( &k ), 7 ) ); + k = shr( abs_s( Random( &k ), 7 ) ); } else { -- GitLab From e2ef5abaf085773acc2c01d86d3ebdd0bbf70755 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 10:04:32 -0500 Subject: [PATCH 483/750] replace FEC_encode_ivas_fx with FEC_encode_fx --- lib_com/options.h | 1 + lib_com/prot_fx.h | 4 ++-- lib_enc/FEC_enc_fx.c | 3 ++- lib_enc/acelp_core_enc_fx.c | 5 ++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1b811a39f..103a2a984 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,7 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ +#define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index d141a9802..949fc05ab 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10827,7 +10827,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ); - +#ifndef FIX_2348_REPLACE_FEC_ENC void FEC_encode_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ @@ -10841,7 +10841,7 @@ void FEC_encode_ivas_fx( const Word32 total_brate, /* i : total codec bitrate Q0*/ const Word16 Q_synth /* i : input scaling */ ); - +#endif ivas_error IGF_Reconfig_fx( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index d6db81232..d5c9f8913 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -292,7 +292,7 @@ void FEC_lsf_estim_enc_fx( return; } - +#ifndef FIX_2348_REPLACE_FEC_ENC /*-------------------------------------------------------------------* * FEC_encode() * @@ -464,3 +464,4 @@ void FEC_encode_ivas_fx( return; } +#endif \ No newline at end of file diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 104e9bc96..09d6c3da6 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1402,10 +1402,13 @@ ivas_error acelp_core_enc_ivas_fx( /*-----------------------------------------------------------------* * Encode supplementary information for Frame Error Concealment *-----------------------------------------------------------------*/ - +#ifndef FIX_2348_REPLACE_FEC_ENC Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new ) Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new ) FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) ); +#else + FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1), 0 ); +#endif IF( st->hBWE_TD != NULL ) { IF( EQ_16( st->L_frame, L_FRAME ) ) -- GitLab From f6358e0a16c422a3b543d80b656f77d50d33bbdb Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 10:06:37 -0500 Subject: [PATCH 484/750] Fix clang --- lib_enc/FEC_enc_fx.c | 2 +- lib_enc/acelp_core_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index d5c9f8913..c47527f3a 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -464,4 +464,4 @@ void FEC_encode_ivas_fx( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 09d6c3da6..1c1e95437 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1407,7 +1407,7 @@ ivas_error acelp_core_enc_ivas_fx( Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new ) FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) ); #else - FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1), 0 ); + FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1 ), 0 ); #endif IF( st->hBWE_TD != NULL ) { -- GitLab From e6d8865997d2fc6d3a5908ef70b243d13c35c8af Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 20 Jan 2026 16:34:23 +0100 Subject: [PATCH 485/750] clang format --- lib_com/swb_tbe_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 41b233e24..f78a096c7 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6092,7 +6092,7 @@ void create_random_vector_fx( j = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ j = extract_l( L_shr( L_tmp, 23 ) ); #endif j = s_and( j, 0xff ); -- GitLab From 22a38d5a9e56a32ef3f11d7da2e919a9c8a0c93d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 12:09:33 -0500 Subject: [PATCH 486/750] fix clang-format --- lib_com/prot_fx.h | 2 +- lib_dec/LD_music_post_filter_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 22f5a89b8..05458b52d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7953,7 +7953,7 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ ); void Prep_music_postP_fx( diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 4dc9ee37b..fe6433768 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -48,7 +48,7 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ - const Word16 Qdct /* i : input scaling Q0 */ + const Word16 Qdct /* i : input scaling Q0 */ ) { Word32 fr_bands[MBANDS_GN_LD]; /*2*Qdct+10*/ -- GitLab From 1d29f81de7a485037e0b152bee5c484a36d5f00a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 13:19:48 -0500 Subject: [PATCH 487/750] harmonized find_uv --- lib_com/options.h | 1 + lib_enc/find_uv_fx.c | 61 +++++++++++++++++++++------ lib_enc/ivas_core_pre_proc_front_fx.c | 6 ++- lib_enc/pre_proc_fx.c | 6 ++- 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8eda542ad..0ee84c145 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +109,7 @@ #define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ #define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT /* Nokia/FhG: basop issue 2323: Use correct init size */ #define FIX_BASOP_2324_MISSING_SET_TO_ZERO /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */ +#define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349 : harmonizing find_uv function */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index a0fa4dbbd..9f2dd523e 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -82,7 +82,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum * * Decision about coder type *-------------------------------------------------------------------*/ - +#ifndef FIX_2349_HARM_FIND_UV Word16 find_uv_fx( /* o : coding type */ Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ @@ -573,6 +573,9 @@ Word16 find_uv_fx( /* o : coding type * Decision about coder type *-------------------------------------------------------------------*/ Word16 find_uv_ivas_fx( /* o : coding type */ +#else +Word16 find_uv_fx( /* o : coding type */ +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ @@ -587,6 +590,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, + const Word16 shift, const Word16 q_hp_E ) { Word16 coder_type, i; @@ -607,7 +611,16 @@ Word16 find_uv_ivas_fx( /* o : coding typ SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; Word16 Last_Resort; Word16 vadnoise; - +#ifdef FIX_2349_HARM_FIND_UV + Word16 Q_in, loc_lp_noise; + + Q_in = Q_new; + move16(); + if( st_fx->element_mode == EVS_MONO ) + { + Q_in = sub( Q_new, 1 ); + } +#endif IF( hSC_VBR != NULL ) { Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ @@ -637,7 +650,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ pt_enr_ssf = enr_ssf + 2 * NB_SSF; FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) { - emaximum_fx( Q_new, pt_speech, SSF, pt_enr_ssf ); + emaximum_fx( Q_in, pt_speech, SSF, pt_enr_ssf ); pt_speech += ( SSF / 2 ); pt_enr_ssf++; } @@ -675,7 +688,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ pt_enr_ssf1++; } - IF( hStereoClassif != NULL ) + IF( hStereoClassif != NULL ) /* IVAS only */ { IF( st_fx->idchan == 0 ) { @@ -717,7 +730,12 @@ Word16 find_uv_ivas_fx( /* o : coding typ *-----------------------------------------------------------------*/ dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ - +#ifdef FIX_2349_HARM_FIND_UV + if ( st_fx->element_mode == EVS_MONO ) /* Overwrite DE3 in case of EVS */ + { + dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ + } +#endif /*-----------------------------------------------------------------* * Energy decrease after spike (dE2) *-----------------------------------------------------------------*/ @@ -806,7 +824,12 @@ Word16 find_uv_ivas_fx( /* o : coding typ } E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); - +#ifdef FIX_2349_HARM_FIND_UV + if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ + { + E_min_th = L_shl( E_MIN_FX, Q_new ); + } +#endif test(); test(); test(); @@ -836,16 +859,22 @@ Word16 find_uv_ivas_fx( /* o : coding typ { ee1_th = 544; /*8.5f Q6*/ move16(); - + loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); +#ifdef FIX_2349_HARM_FIND_UV + if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ + { + loc_lp_noise = st_fx->lp_noise_fx; + } +#endif /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ IF( st_fx->input_bwidth != NB ) { /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, loc_lp_noise ); // Q24 IF( Last_Resort == 0 ) { /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, loc_lp_noise ); // Q24 } relE_thres = round_fx( L_tmp ); } @@ -853,7 +882,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ { /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 + L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, loc_lp_noise ); // Q24 relE_thres = round_fx( L_tmp ); } relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */ @@ -889,7 +918,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); - IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + if( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ @@ -917,7 +946,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ +#ifdef FIX_2349_HARM_FIND_UV + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) && st_fx->element_mode == EVS_MONO ) && /* normalized correlation low on look-ahead - onset detection */ +#endif ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ @@ -1037,9 +1068,13 @@ Word16 find_uv_ivas_fx( /* o : coding typ move16(); /* Current frame cannot be compressed to pack the partial redundancy;*/ - IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) + IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) /* can happen only for EVS-BE modes*/ { +#ifdef FIX_2349_HARM_FIND_UV + core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift ); +#else core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); +#endif } } } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8090f9ede..4e8846cf7 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1292,9 +1292,13 @@ ivas_error pre_proc_front_ivas_fx( find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx, corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); - +#ifdef FIX_2349_HARM_FIND_UV + st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, + &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, shift, fr_bands_fx_q ); // Q0 +#else st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 +#endif Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); /*-----------------------------------------------------------------* diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 978df321a..1c5ffc863 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -520,9 +520,13 @@ void pre_proc_fx( find_tilt_fx( fr_bands, hNoiseEst->bckr_fx, ee, st->pitch, st->voicing_fx, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); +#ifdef FIX_2349_HARM_FIND_UV + st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, NULL, corr_shift, relE, *Etot, hp_E, + &flag_spitch, last_core_orig, NULL, *Q_new, *shift, NULL ); // Q0 +#else st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); - +#endif /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ -- GitLab From 3267a954786ea875ccaec03731b0f7af2095ba75 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 13:29:55 -0500 Subject: [PATCH 488/750] fix gcc --- lib_enc/pre_proc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 1c5ffc863..f30216517 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -521,8 +521,8 @@ void pre_proc_fx( st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); #ifdef FIX_2349_HARM_FIND_UV - st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, NULL, corr_shift, relE, *Etot, hp_E, - &flag_spitch, last_core_orig, NULL, *Q_new, *shift, NULL ); // Q0 + st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0, corr_shift, relE, *Etot, hp_E, + &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 0 ); // Q0 #else st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); -- GitLab From efda00c4a361c7df35446d1a9f7c21f343e1026b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 13:39:38 -0500 Subject: [PATCH 489/750] fix gcc --- lib_enc/pre_proc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index f30216517..78f52dd37 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -521,7 +521,7 @@ void pre_proc_fx( st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); #ifdef FIX_2349_HARM_FIND_UV - st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0, corr_shift, relE, *Etot, hp_E, + st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0L, corr_shift, relE, *Etot, hp_E, &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 0 ); // Q0 #else st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, -- GitLab From 2a1dbfab84f3d3e649d17b832a54ac3ffe8cabc0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 13:41:16 -0500 Subject: [PATCH 490/750] missing modifications --- lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/prot_fx_enc.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 4e8846cf7..82d1cdcc9 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1294,7 +1294,7 @@ ivas_error pre_proc_front_ivas_fx( corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); #ifdef FIX_2349_HARM_FIND_UV st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, - &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, shift, fr_bands_fx_q ); // Q0 + &flag_spitch, last_core_orig, hStereoClassif, *Q_new, 0, fr_bands_fx_q ); // Q0 #else st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index d6caa4780..303c0b0dc 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -241,9 +241,12 @@ void find_tilt_fx( Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16*/ Word16 Opt_vbr_mode /* Q0 */ ); - +#ifndef FIX_2349_HARM_FIND_UV /* o : coding type */ Word16 find_uv_ivas_fx( +#else +Word16 find_uv_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ @@ -258,8 +261,10 @@ Word16 find_uv_ivas_fx( const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, + const Word16 shift, const Word16 q_hp_E ); +#ifndef FIX_2349_HARM_FIND_UV /* o : coding type */ Word16 find_uv_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -276,6 +281,7 @@ Word16 find_uv_fx( const Word16 shift, const Word16 last_core_orig /* i : original last core Q0*/ ); +#endif void fine_gain_quant_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ -- GitLab From 13d4e22e0a7d992b1995797cd6d0b342e0a7a7ca Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 14:04:48 -0500 Subject: [PATCH 491/750] modification to ensure build even if switch not activated --- lib_enc/find_uv_fx.c | 8 ++++++-- lib_enc/prot_fx_enc.h | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 9f2dd523e..2f64f8d5f 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -590,7 +590,9 @@ Word16 find_uv_fx( /* o : coding type const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, +#ifdef FIX_2349_HARM_FIND_UV const Word16 shift, +#endif const Word16 q_hp_E ) { Word16 coder_type, i; @@ -611,16 +613,18 @@ Word16 find_uv_fx( /* o : coding type SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; Word16 Last_Resort; Word16 vadnoise; -#ifdef FIX_2349_HARM_FIND_UV Word16 Q_in, loc_lp_noise; - + Q_in = Q_new; move16(); + +#ifdef FIX_2349_HARM_FIND_UV if( st_fx->element_mode == EVS_MONO ) { Q_in = sub( Q_new, 1 ); } #endif + IF( hSC_VBR != NULL ) { Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 303c0b0dc..0eec956d0 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -261,8 +261,11 @@ Word16 find_uv_fx( const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, +#ifdef FIX_2349_HARM_FIND_UV const Word16 shift, - const Word16 q_hp_E ); +#endif + const Word16 q_hp_E +); #ifndef FIX_2349_HARM_FIND_UV /* o : coding type */ -- GitLab From 7d747298c186ff7aecbf91a6292263eb79ebbdcd Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 14:10:53 -0500 Subject: [PATCH 492/750] fix clang format --- lib_enc/find_uv_fx.c | 40 +++++++++++++-------------- lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/prot_fx_enc.h | 3 +- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 2f64f8d5f..7f7834ff6 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -572,7 +572,7 @@ Word16 find_uv_fx( /* o : coding type * * Decision about coder type *-------------------------------------------------------------------*/ -Word16 find_uv_ivas_fx( /* o : coding type */ +Word16 find_uv_ivas_fx( /* o : coding type */ #else Word16 find_uv_fx( /* o : coding type */ #endif @@ -619,7 +619,7 @@ Word16 find_uv_fx( /* o : coding type move16(); #ifdef FIX_2349_HARM_FIND_UV - if( st_fx->element_mode == EVS_MONO ) + if ( st_fx->element_mode == EVS_MONO ) { Q_in = sub( Q_new, 1 ); } @@ -922,16 +922,16 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - if( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; @@ -953,14 +953,14 @@ Word16 find_uv_fx( /* o : coding type #ifdef FIX_2349_HARM_FIND_UV ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) && st_fx->element_mode == EVS_MONO ) && /* normalized correlation low on look-ahead - onset detection */ #endif - ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 82d1cdcc9..cddc64ad1 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1294,7 +1294,7 @@ ivas_error pre_proc_front_ivas_fx( corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); #ifdef FIX_2349_HARM_FIND_UV st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, - &flag_spitch, last_core_orig, hStereoClassif, *Q_new, 0, fr_bands_fx_q ); // Q0 + &flag_spitch, last_core_orig, hStereoClassif, *Q_new, 0, fr_bands_fx_q ); // Q0 #else st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0eec956d0..3ca145caf 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -264,8 +264,7 @@ Word16 find_uv_fx( #ifdef FIX_2349_HARM_FIND_UV const Word16 shift, #endif - const Word16 q_hp_E -); + const Word16 q_hp_E ); #ifndef FIX_2349_HARM_FIND_UV /* o : coding type */ -- GitLab From 4b38f9082d4369c0582928bd329c89db25f1d59d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 15:19:45 -0500 Subject: [PATCH 493/750] fix wrong condition --- lib_enc/find_uv_fx.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 7f7834ff6..432f3583e 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -938,6 +938,25 @@ Word16 find_uv_fx( /* o : coding type move16(); } } +#ifdef FIX_2349_HARM_FIND_UV + ELSE IF( st_fx->element_mode == EVS_MONO ) + { + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + { + coder_type = UNVOICED; + move16(); + } + } +#endif ELSE { test(); @@ -950,9 +969,7 @@ Word16 find_uv_fx( /* o : coding type test(); test(); if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ -#ifdef FIX_2349_HARM_FIND_UV - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) && st_fx->element_mode == EVS_MONO ) && /* normalized correlation low on look-ahead - onset detection */ -#endif + /* ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ -- GitLab From 757a568f7dc3818e7e7b50d806296289bb812c4e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 15:25:56 -0500 Subject: [PATCH 494/750] fix clang-format --- lib_enc/find_uv_fx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 432f3583e..1338ac5c9 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -954,7 +954,7 @@ Word16 find_uv_fx( /* o : coding type { coder_type = UNVOICED; move16(); - } + } } #endif ELSE @@ -969,15 +969,15 @@ Word16 find_uv_fx( /* o : coding type test(); test(); if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - /* ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + /* ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); -- GitLab From 63842b01fb4041c8b0b3d665cefa9d5e82fbf653 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 16:40:40 -0500 Subject: [PATCH 495/750] fix some asan errors --- lib_enc/find_uv_fx.c | 20 ++++++++++++++++---- lib_enc/pre_proc_fx.c | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 1338ac5c9..7a35b7bca 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -733,13 +733,19 @@ Word16 find_uv_fx( /* o : coding type * Total frame energy difference (dE3) *-----------------------------------------------------------------*/ - dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ #ifdef FIX_2349_HARM_FIND_UV - if ( st_fx->element_mode == EVS_MONO ) /* Overwrite DE3 in case of EVS */ + IF ( st_fx->element_mode == EVS_MONO ) /* Overwrite DE3 in case of EVS */ { dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ } + ELSE + { + dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ + } +#else + dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ #endif + /*-----------------------------------------------------------------* * Energy decrease after spike (dE2) *-----------------------------------------------------------------*/ @@ -863,13 +869,19 @@ Word16 find_uv_fx( /* o : coding type { ee1_th = 544; /*8.5f Q6*/ move16(); - loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); #ifdef FIX_2349_HARM_FIND_UV - if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ + IF ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ { loc_lp_noise = st_fx->lp_noise_fx; } + ELSE + { + loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); + } +#else + loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); #endif + /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ IF( st_fx->input_bwidth != NB ) { diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 78f52dd37..8b0b79bd9 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -522,7 +522,7 @@ void pre_proc_fx( #ifdef FIX_2349_HARM_FIND_UV st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0L, corr_shift, relE, *Etot, hp_E, - &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 0 ); // Q0 + &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 31 ); // Q0 #else st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); -- GitLab From d263f62c4b5e58745d3cf2a54e6c383608d3dcbc Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 20:10:53 -0500 Subject: [PATCH 496/750] correct clang-format --- lib_enc/find_uv_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 7a35b7bca..650d6ddc6 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -574,7 +574,7 @@ Word16 find_uv_fx( /* o : coding type *-------------------------------------------------------------------*/ Word16 find_uv_ivas_fx( /* o : coding type */ #else -Word16 find_uv_fx( /* o : coding type */ +Word16 find_uv_fx( /* o : coding type */ #endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ @@ -734,7 +734,7 @@ Word16 find_uv_fx( /* o : coding type *-----------------------------------------------------------------*/ #ifdef FIX_2349_HARM_FIND_UV - IF ( st_fx->element_mode == EVS_MONO ) /* Overwrite DE3 in case of EVS */ + IF( st_fx->element_mode == EVS_MONO ) /* Overwrite DE3 in case of EVS */ { dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ } @@ -870,7 +870,7 @@ Word16 find_uv_fx( /* o : coding type ee1_th = 544; /*8.5f Q6*/ move16(); #ifdef FIX_2349_HARM_FIND_UV - IF ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ + IF( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ { loc_lp_noise = st_fx->lp_noise_fx; } -- GitLab From 0e13b6c75499a27c81cb75728302b379336ca4b1 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 21 Jan 2026 08:18:10 +0100 Subject: [PATCH 497/750] fix wrong ) placement --- lib_com/swb_tbe_com_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index f78a096c7..9242314ce 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6084,7 +6084,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - j = shr( abs_s( Random( &seed[0] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ + j = shr( abs_s( Random( &seed[0] ) ), 7 ); /* Random( &seed[0] * 0.0078125f ) */ } else { @@ -6100,7 +6100,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - k = shr( abs_s( Random( &seed[1] ), 7 ) ); /* Random( &seed[0] * 0.0078125f ) */ + k = shr( abs_s( Random( &seed[1] ) ), 7 ); /* Random( &seed[0] * 0.0078125f ) */ } else { @@ -6119,7 +6119,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - k = shr( abs_s( Random( &k ), 7 ) ); + k = shr( abs_s( Random( &k ) ), 7 ); } else { -- GitLab From 739f8ae488e78cfb97c7107fbea42708969f452f Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 21 Jan 2026 09:30:13 +0100 Subject: [PATCH 498/750] slight modification to the wording describing ISAR output formats --- lib_rend/ivas_output_init_fx.c | 4 ++-- readme.txt | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index aa3bed7b9..ec279e168 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -615,11 +615,11 @@ ivas_error get_channel_config( } ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { - strcpy( (char *) str, "Binaural: split-rendering mode using encoded data" ); + strcpy( (char *) str, "Binaural: split-rendering mode with encoded output in an intermediate format" ); } ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - strcpy( (char *) str, "Binaural: split-rendering mode using PCM data" ); + strcpy( (char *) str, "Binaural: split-rendering mode with separate PCM binaural output and metadata bitstream output" ); } ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { diff --git a/readme.txt b/readme.txt index 0f4848d61..2eb1308b0 100644 --- a/readme.txt +++ b/readme.txt @@ -389,21 +389,21 @@ Usage: ISAR_post_rend [options] -i -if -o Mandatory parameters: --------------------- --i File : Path to the input file (WAV or raw PCM file with BINAURAL_SPLIT_PCM input format or ISAR bitstream file with BINAURAL_SPLIT_CODED input format) --if Format : Audio format of input file (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM or RTPDUMP) --o File : Path to the output file +-i File : Path to the input File (WAV or raw PCM for BINAURAL_SPLIT_PCM format, or encoded intermediate-format data for BINAURAL_SPLIT_CODED format) +-if Format : Audio format of input File (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM or RTPDUMP) +-o File : Path to the output File Options : ------- - --im File : Path to the input metadata file (mandatory for BINAURAL_SPLIT_PCM input format) --fs : Input sampling rate in kHz (16, 32, 48) (mandatory for raw PCM input files) --T File : Head rotation trajectory file for simulation of head tracking --prbfi File : Split rendering BFI (Bad Frame Indicator) file +-im File : Path to the coded metadata File (mandatory for BINAURAL_SPLIT_PCM format) +-fs : Input sampling rate in kHz (16, 32, 48) (mandatory for raw PCM input Files) +-T File : Head rotation trajectory File for simulation of head tracking +-prbfi File : Split rendering BFI (Bad Frame Indicator) File -no_delay_cmp : Turn off delay compensation -q : Quiet mode - limit printouts to terminal --l : List supported audio formats of input file +-l : List supported audio formats of input File -fr L : Render frame size in ms L=(5, 10, 20), default is 20 --s File : Path to the split rendering SDP init params file (mandatory for RTPDUMP input format) +-s File : Path to the split rendering SDP init params File (mandatory for RTPDUMP format) -h : Show this help message and exit -- GitLab From 8aa10aa200dfdd3da88fc008ff9e654a4b92e009 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 21 Jan 2026 10:01:17 +0100 Subject: [PATCH 499/750] revert the change involving using seed[1] when k==j --- lib_com/swb_tbe_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 9242314ce..9b4db81b7 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6119,7 +6119,7 @@ void create_random_vector_fx( #ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT if ( element_mode != EVS_MONO ) { - k = shr( abs_s( Random( &k ) ), 7 ); + k = shr( abs_s( Random( &seed[1] ) ), 7 ); } else { -- GitLab From c444ec22173c1c009b252c47a0d5e1f53c6ac177 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 14:49:47 +0100 Subject: [PATCH 500/750] replace erroneous division by if-else-statemment --- lib_com/options.h | 1 + lib_enc/ivas_cpe_enc_fx.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..0ee88e0ec 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,6 +133,7 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ +#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index ef7e3f83e..5179b10e8 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -632,7 +632,20 @@ ivas_error ivas_cpe_enc_fx( { sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */ sts[n]->bits_frame_channel = idiv1616( extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), n_CoreChannels ); /* Q0 */ - sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */ +#ifdef FIX_2362_TOTAL_BRATE_CALCULATION + /* sts[n]->total_brate = hCPE->element_brate / n_CoreChannels; */ + assert( n_CoreChannels == 1 || n_CoreChannels == 2 ); + IF( n_CoreChannels == 1 ) + { + sts[n]->total_brate = hCPE->element_brate; + } + ELSE IF( n_CoreChannels == 2 ) + { + sts[n]->total_brate = L_shr( hCPE->element_brate, 1 ); + } +#else + sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */ +#endif move32(); move16(); move16(); -- GitLab From b4057c0d7d43338f2581a3e25e13986410c9588a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 21 Jan 2026 15:16:37 +0100 Subject: [PATCH 501/750] FIX_1500_ISM_MD_DTX --- lib_com/options.h | 1 + lib_dec/ivas_ism_metadata_dec_fx.c | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..2b60cb6a3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,6 +133,7 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ +#define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 4fe9e5767..993117abe 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -54,8 +54,8 @@ static Word16 decode_radius_fx( DEC_CORE_HANDLE st0, Word16 *last_radius_idx, Wo #define IVAS_ISM_DTX_HO_MAX 5 -#define CNG_MD_MAX_DIFF_AZIMUTH 5 -#define CNG_MD_MAX_DIFF_ELEVATION 5 +#define CNG_MD_MAX_DIFF_AZIMUTH_FX ( 5 << Q22 ) +#define CNG_MD_MAX_DIFF_ELEVATION_FX ( 5 << Q22 ) #define MAX_BITS_ISM_METADATA ( 2 * ISM_EXTENDED_METADATA_BITS + MAX_NUM_OBJECTS * ( 1 /*number of objects*/ + ISM_METADATA_MD_FLAG_BITS + 2 * ISM_METADATA_FLAG_BITS + ISM_METADATA_IS_NDP_BITS + 1 /*abs.flag*/ + ISM_AZIMUTH_NBITS + ISM_ELEVATION_NBITS + 1 /*abs.flag*/ + ISM_RADIUS_NBITS + 1 /*abs.flag*/ + ISM_AZIMUTH_NBITS + ISM_ELEVATION_NBITS ) + 10 /* margin */ ) /* max. bit-budget of ISM metadata */ @@ -95,20 +95,20 @@ static void ism_metadata_smooth_fx( } test(); - IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), L_shl( IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) ) ) + IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_AZIMUTH_FX ) ) { /* skip the smoothing */ } - ELSE IF( GT_32( L_abs( diff_fx ), L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) ) ) + ELSE IF( GT_32( L_abs( diff_fx ), CNG_MD_MAX_DIFF_AZIMUTH_FX ) ) { Word32 temp; IF( ( diff_fx > 0 ) ) { - temp = L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ); + temp = CNG_MD_MAX_DIFF_AZIMUTH_FX; } ELSE { - temp = L_negate( L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) ); + temp = CNG_MD_MAX_DIFF_AZIMUTH_FX; } hIsmMetaData->azimuth_fx = L_add( hIsmMetaData->last_azimuth_fx, temp ); move32(); @@ -129,20 +129,24 @@ static void ism_metadata_smooth_fx( diff_fx = L_sub( hIsmMetaData->last_true_elevation_fx, hIsmMetaData->last_elevation_fx ); test(); - IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( diff_fx, L_shl( IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION, Q22 ) ) ) +#ifdef FIX_1500_ISM_MD_DTX + IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION_FX ) ) +#else + IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( diff_fx, IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION_FX ) ) +#endif { /* skip the smoothing */ } - ELSE IF( GT_32( L_abs( diff_fx ), L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ) ) ) + ELSE IF( GT_32( L_abs( diff_fx ), CNG_MD_MAX_DIFF_ELEVATION_FX ) ) { Word32 temp; IF( ( diff_fx > 0 ) ) { - temp = L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ); + temp = CNG_MD_MAX_DIFF_ELEVATION_FX; } ELSE { - temp = L_negate( L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ) ); + temp = L_negate( CNG_MD_MAX_DIFF_ELEVATION_FX ); } hIsmMetaData->elevation_fx = L_add( hIsmMetaData->last_elevation_fx, temp ); move32(); -- GitLab From f15a0e6814acd5ab707bdcac48c40124dbb1300c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 15:18:42 +0100 Subject: [PATCH 502/750] small optimization of patch --- lib_enc/ivas_cpe_enc_fx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 5179b10e8..46e21a087 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -635,11 +635,8 @@ ivas_error ivas_cpe_enc_fx( #ifdef FIX_2362_TOTAL_BRATE_CALCULATION /* sts[n]->total_brate = hCPE->element_brate / n_CoreChannels; */ assert( n_CoreChannels == 1 || n_CoreChannels == 2 ); - IF( n_CoreChannels == 1 ) - { - sts[n]->total_brate = hCPE->element_brate; - } - ELSE IF( n_CoreChannels == 2 ) + sts[n]->total_brate = hCPE->element_brate; + if ( n_CoreChannels == 2 ) { sts[n]->total_brate = L_shr( hCPE->element_brate, 1 ); } -- GitLab From 16f15d619ac3f46e4b0f4dea78062c193ee4997b Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 21 Jan 2026 15:54:09 +0100 Subject: [PATCH 503/750] increase length of config str --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4a99ce5f2..8eded2fa9 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5358,7 +5358,7 @@ static ivas_error printConfigInfo_dec( const bool quietModeEnabled ) { ivas_error error; - Word8 config_str[50]; + Word8 config_str[200]; AUDIO_CONFIG output_config; /*-----------------------------------------------------------------* -- GitLab From 2ae09e853b8292d642a7b8302163773586e80dae Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 21 Jan 2026 15:58:07 +0100 Subject: [PATCH 504/750] comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2b60cb6a3..180b43c40 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,7 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ -#define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ +#define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ /* ##################### End NON-BE switches ########################### */ -- GitLab From a9c3fc13751addffb5b8d1159481c25065335a59 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 21 Jan 2026 15:59:47 +0100 Subject: [PATCH 505/750] fix accidentally removed operation --- lib_dec/ivas_ism_metadata_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 993117abe..063f089d0 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -108,7 +108,7 @@ static void ism_metadata_smooth_fx( } ELSE { - temp = CNG_MD_MAX_DIFF_AZIMUTH_FX; + temp = L_negate( CNG_MD_MAX_DIFF_AZIMUTH_FX ); } hIsmMetaData->azimuth_fx = L_add( hIsmMetaData->last_azimuth_fx, temp ); move32(); -- GitLab From 52a5892faf0c389dc8bc0592bb11a7a1c4d0fa76 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 21 Jan 2026 16:49:42 +0100 Subject: [PATCH 506/750] scale only relevant samples in external renderer temporary buffers --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..06551d04f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,6 +116,7 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5d5179c53..77277cb9a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6516,9 +6516,17 @@ static ivas_error renderIsmToBinaural( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpTDRendBuffer[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, @@ -6528,9 +6536,17 @@ static ivas_error renderIsmToBinaural( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpTDRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } IF( ismInput->hReverb != NULL ) @@ -6793,9 +6809,17 @@ static ivas_error renderIsmToBinauralReverb( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), IVAS_ERR_OK ) ) @@ -6803,9 +6827,17 @@ static ivas_error renderIsmToBinauralReverb( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( 11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( 11, exp ) ) ); /* Q(exp) */ +#endif } IF( ismInput->hReverb != NULL ) @@ -7104,9 +7136,17 @@ static ivas_error renderIsmToSplitBinaural( } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_NUM_OBJECTS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } /* Render */ @@ -7118,7 +7158,11 @@ static ivas_error renderIsmToSplitBinaural( FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpProcessing[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } IF( ismInput->hReverb != NULL ) @@ -7521,9 +7565,17 @@ static ivas_error renderMcToBinaural( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer_fx ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), @@ -7532,9 +7584,17 @@ static ivas_error renderMcToBinaural( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } } ELSE @@ -7644,9 +7704,17 @@ static ivas_error renderMcToBinauralRoom( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numChannels, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, @@ -7656,9 +7724,17 @@ static ivas_error renderMcToBinauralRoom( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } } ELSE @@ -8001,9 +8077,17 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } /* Render */ IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer, &exp ) ) != IVAS_ERR_OK ) @@ -8012,7 +8096,11 @@ static ivas_error renderMcToSplitBinaural( } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } /* Copy rendered audio to tmp storage buffer. Copying directly to output would -- GitLab From 9321a51d2f2730b5ed89632c7d041782eedcfcab Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 21 Jan 2026 17:24:09 +0100 Subject: [PATCH 507/750] clang-format --- lib_rend/lib_rend_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 77277cb9a..c6547b58a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7145,7 +7145,7 @@ static ivas_error renderIsmToSplitBinaural( #ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ #else - Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ + Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ #endif } @@ -8086,7 +8086,7 @@ static ivas_error renderMcToSplitBinaural( #ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ #else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ + Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ #endif } /* Render */ @@ -8099,7 +8099,7 @@ static ivas_error renderMcToSplitBinaural( #ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ + Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #endif } -- GitLab From 674db435169d52c6696e8a6a881d81e3e73852ce Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 21 Jan 2026 13:19:50 -0500 Subject: [PATCH 508/750] merging IVAS and ESV 0b BWE --- lib_com/options.h | 1 + lib_com/prot_fx.h | 18 ++- lib_dec/acelp_core_dec_fx.c | 8 ++ lib_dec/hf_synth_fx.c | 221 ++++++++++++++++++++++++++---------- 4 files changed, 185 insertions(+), 63 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..b1ca3e5a7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,6 +116,7 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index fac7485fb..08da961c1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6492,6 +6492,7 @@ void hf_synth_reset_fx( ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ ); +#ifndef FIX_BASOP_2350_HARM_0B_BWE void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ const Word32 core_brate, /* i : core bitrate Q0*/ @@ -6503,7 +6504,6 @@ void hf_synth_fx( const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2 /* i : synthesis scaling */ ); - void hf_synth_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ const Word32 core_brate, /* i : core bitrate Q0*/ @@ -6515,7 +6515,23 @@ void hf_synth_ivas_fx( const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2 /* i : synthesis scaling */ ); +#else +void hf_synth_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ +#ifdef FIX_BASOP_2350_HARM_0B_BWE + const Word16 element_mode, /* i : element mode Q0*/ +#endif + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ +); +#endif void hf_synth_amr_wb_init_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index b65b49a42..bd5cbf5ad 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2223,12 +2223,20 @@ ivas_error acelp_core_dec_fx( { IF( EQ_16( st->element_mode, EVS_MONO ) ) { +#ifndef FIX_BASOP_2350_HARM_0B_BWE hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); +#else + hf_synth_fx( st->hBWE_zero, EVS_MONO, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); +#endif } ELSE { Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 +#ifndef FIX_BASOP_2350_HARM_0B_BWE hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); +#else + hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); +#endif Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); } } diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 87e8b1fd7..dde0d717a 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -20,8 +20,12 @@ *---------------------------------------------------------------------*/ static void filt_6k_7k_scale_fx( Word16 signal[], Word16 lg, Word16 mem[], Word16 fact, Word16 exp ); +#ifdef FIX_BASOP_2350_HARM_0B_BWE +static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word16 element_mode, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); +#else static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); static void hf_synthesis_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); +#endif static void hf_synthesis_amr_wb_fx( const Word32 core_brate, const Word16 output_subfr, const Word16 Ap[], Word16 exc16k[], Word16 synth_out[], Word16 *mem_syn_hf, Word16 *delay_syn_hf, Word16 *mem_hp_interp, Word16 p_r, Word16 HF_corr_gain, Word16 til, Word16 voice_factors, const Word16 exc[], const Word16 Q_exc, const Word16 Q_out, Word16 qhf ); static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, const Word32 core_brate, const Word16 Aq[], Word16 Ap[], Word16 *r, Word16 tilt0, Word16 tilt, Word16 voice_factor ); static void AdaptiveStartBand_fx( Word16 *start_band, const Word32 rate, const Word16 *lsf, const Word16 voicing_fac, const Word16 clas, Word16 *voicing_flag, Word16 *start_band_old, Word32 *OptCrit_old ); @@ -80,7 +84,10 @@ void hf_synth_reset_fx( void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ +#ifdef FIX_BASOP_2350_HARM_0B_BWE + const Word16 element_mode, /* i : element mode Q0*/ +#endif + const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ const Word16 *Aq, /* i : quantized Az Q12*/ const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ @@ -99,8 +106,11 @@ void hf_synth_fx( p_Aq = Aq; /* Q12 */ FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { - hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[imult3216( (Word32) i_subfr, output_subfr ) / L_SUBFR], Q_syn2 ); - +#ifdef FIX_BASOP_2350_HARM_0B_BWE + hf_synthesis_fx( hBWE_zero, element_mode, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); +#else + hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); +#endif p_Aq += ( M + 1 ); /* Q12 */ } @@ -120,6 +130,9 @@ void hf_synth_fx( static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, +#ifdef FIX_BASOP_2350_HARM_0B_BWE + const Word16 element_mode, /* i : element mode Q0*/ +#endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_subfr, /* i : output sub-frame length Q0*/ const Word16 Aq[], /* i : quantized Az Q12*/ @@ -135,6 +148,11 @@ static void hf_synthesis_fx( Word16 HF_exc[L_SUBFR16k]; Word16 tmp, ener, exp1, exp2, scale; Word32 L_tmp; +#ifdef FIX_BASOP_2350_HARM_0B_BWE + Word16 Q_tmp, Q_ener, sft; + Word32 ONE, P_ONE; + Word64 prod; +#endif Word16 Ap[M16k + 1]; /*-----------------------------------------------------------------* @@ -157,75 +175,154 @@ static void hf_synthesis_fx( /*tmp = round_fx(Dot_product12(HF_exc, HF_exc, output_subfr, &exp1)); */ L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 ); tmp = round_fx( L_tmp ); /* Q15 */ - /* tmp = (float)(sqrt(ener/tmp)) */ - /* scale is -1 if tmp > ener */ - scale = shr( sub( ener, tmp ), 15 ); /* Q0 */ - tmp = shl( tmp, scale ); /* Q15 + scale*/ - exp1 = sub( exp1, scale ); - tmp = div_s( tmp, ener ); /* Q15 */ - exp1 = sub( exp1, exp2 ); + IF( element_mode == EVS_MONO ) + { - L_tmp = L_deposit_h( tmp ); /* Q31 */ + /* tmp = (float)(sqrt(ener/tmp)) */ + /* scale is -1 if tmp > ener */ + scale = shr( sub( ener, tmp ), 15 ); /* Q0 */ + tmp = shl( tmp, scale ); /* Q15 + scale*/ + exp1 = sub( exp1, scale ); - L_tmp = Isqrt_lc( L_tmp, &exp1 ); - scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */ + tmp = div_s( tmp, ener ); /* Q15 */ + exp1 = sub( exp1, exp2 ); - exp2 = sub( hBWE_zero->memExp1, exp1 ); - hBWE_zero->memExp1 = exp1; - move16(); + L_tmp = L_deposit_h( tmp ); /* Q31 */ - /*-----------------------------------------------------------------* - * calculate energy scaling factor to respect tilt of synth12k8 - * (tilt: 1=voiced, -1=unvoiced) - *-----------------------------------------------------------------*/ - hp400_12k8_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx ); - /* i: mem_hp400 in Q_syn */ - /* i: synth in Q_syn */ - /* o: synth in Q_syn-3 */ + L_tmp = Isqrt_lc( L_tmp, &exp1 ); + scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */ - L_tmp = L_mac( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3)+1 */ - FOR( i = 1; i < L_SUBFR; i++ ) - { - L_tmp = L_mac_sat( L_tmp, synth[i], synth[i] ); /* 2*(Q_syn-3)+1 */ - } - tmp = norm_l( L_tmp ); - ener = extract_h( L_shl( L_tmp, tmp ) ); /* ener = r[0] */ - /*ener in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0*/ + exp2 = sub( hBWE_zero->memExp1, exp1 ); + hBWE_zero->memExp1 = exp1; + move16(); - L_tmp = L_mac( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3)+1 */ - FOR( i = 2; i < L_SUBFR; i++ ) - { - L_tmp = L_mac_sat( L_tmp, synth[i], synth[i - 1] ); /* 2*(Q_syn-3)+1 */ - } - tmp = extract_h( L_shl( L_tmp, tmp ) ); /* tmp = r[1] */ - /*tmp in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0 */ - /*we use the same normalization factor for both ener and tmp, */ - /*if the headroom in "tmp" is less than "ener", tmp can saturate */ - /*but this is ok since below we apply some thresholds to tmp */ + /*-----------------------------------------------------------------* + * calculate energy scaling factor to respect tilt of synth12k8 + * (tilt: 1=voiced, -1=unvoiced) + *-----------------------------------------------------------------*/ + hp400_12k8_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx ); + /* i: mem_hp400 in Q_syn */ + /* i: synth in Q_syn */ + /* o: synth in Q_syn-3 */ + + L_tmp = L_mac( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3)+1 */ + FOR( i = 1; i < L_SUBFR; i++ ) + { + L_tmp = L_mac_sat( L_tmp, synth[i], synth[i] ); /* 2*(Q_syn-3)+1 */ + } + tmp = norm_l( L_tmp ); + ener = extract_h( L_shl( L_tmp, tmp ) ); /* ener = r[0] */ + /*ener in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0*/ - tmp = s_max( 0, tmp ); - if ( tmp > 0 ) - { - tmp = div_s( tmp, ener ); /* Q15 */ - } + L_tmp = L_mac( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3)+1 */ + FOR( i = 2; i < L_SUBFR; i++ ) + { + L_tmp = L_mac_sat( L_tmp, synth[i], synth[i - 1] ); /* 2*(Q_syn-3)+1 */ + } + tmp = extract_h( L_shl( L_tmp, tmp ) ); /* tmp = r[1] */ + /*tmp in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0 */ + /*we use the same normalization factor for both ener and tmp, */ + /*if the headroom in "tmp" is less than "ener", tmp can saturate */ + /*but this is ok since below we apply some thresholds to tmp */ + tmp = s_max( 0, tmp ); + if ( tmp > 0 ) + { + tmp = div_s( tmp, ener ); /* Q15 */ + } - /*-----------------------------------------------------------------* - * modify energy of white noise according to synthesis tilt - *-----------------------------------------------------------------*/ - /* tmp = 1.0 - fac */ - tmp = add_sat( 1, sub( 32767 /* 1 in Q15 */, tmp ) ); - test(); - if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) ) + /*-----------------------------------------------------------------* + * modify energy of white noise according to synthesis tilt + *-----------------------------------------------------------------*/ + /* tmp = 1.0 - fac */ + tmp = add_sat( 1, sub( 32767 /* 1 in Q15 */, tmp ) ); + test(); + if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) ) + { + /* emphasize HF noise in CNG */ + /*fac *= 2.0f;*/ + tmp = add_sat( tmp, tmp ); /* Q15 */ + } + tmp = s_max( tmp, 3277 ); /* 0.1 in Q15 */ + + /*scale *= fac;*/ + tmp = mult_r( scale, tmp ); + } + ELSE { - /* emphasize HF noise in CNG */ - /*fac *= 2.0f;*/ - tmp = add_sat( tmp, tmp ); /* Q15 */ + exp1 = add( exp1, 6 ); /* tmp exponent */ + + ener = shr( ener, 1 ); /* to avoid the assertion in div_s() further*/ + exp2 = add( exp2, 1 ); + + tmp = div_s( ener, tmp ); + exp1 = sub( exp2, exp1 ); + + scale = Sqrt16( tmp, &exp1 ); /* scale exponent = exp1 */ + + /*-----------------------------------------------------------------* + * calculate energy scaling factor to respect tilt of synth12k8 + * (tilt: 1=voiced, -1=unvoiced) + *-----------------------------------------------------------------*/ + + hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx ); + + /* i: mem_hp400 in Q_syn */ + /* i: synth in Q_syn */ + /* o: synth in Q_syn-3 */ + prod = W_mac0_16_16( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3) */ + FOR( i = 1; i < L_SUBFR; i++ ) + { + prod = W_mac0_16_16( prod, synth[i], synth[i] ); /* 2*(Q_syn-3) */ + } + sft = W_norm( prod ); + ener = extract_h( W_extract_h( W_shl( prod, sft ) ) ); + Q_ener = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 ); + + prod = W_mac0_16_16( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3) */ + FOR( i = 2; i < L_SUBFR; i++ ) + { + prod = W_mac0_16_16( prod, synth[i], synth[i - 1] ); /* 2*(Q_syn-3) */ + } + sft = sub( W_norm( prod ), 1 ); + tmp = extract_h( W_extract_h( W_shl( prod, sft ) ) ); + Q_tmp = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 ); + + tmp = s_max( 0, tmp ); + IF( tmp > 0 ) + { + tmp = div_s( tmp, ener ); + Q_tmp = add( 15, sub( Q_tmp, Q_ener ) ); + } + + /*-----------------------------------------------------------------* + * modify energy of white noise according to synthesis tilt + *-----------------------------------------------------------------*/ + /* tmp = 1.0 - fac */ + ONE = L_shl( 1, Q_tmp ); + P_ONE = L_shl( 3277 /* 0.1 in Q15 */, sub( Q_tmp, 15 ) ); + L_tmp = L_msu0( ONE, tmp, 1 ); + test(); + if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) ) + { + /* emphasize HF noise in CNG */ + /*fac *= 2.0f;*/ + L_tmp = L_add( L_tmp, L_tmp ); + } + L_tmp = L_max( L_tmp, P_ONE ); + L_tmp = L_min( L_tmp, ONE ); + + sft = norm_l( L_tmp ); + L_tmp = L_shl( L_tmp, sft ); + + tmp = round_fx( L_tmp ); + Q_tmp = sub( add( Q_tmp, sft ), 16 ); + + /*scale *= fac;*/ + tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */ + Q_tmp = sub( Q_tmp, exp1 ); } - tmp = s_max( tmp, 3277 ); /* 0.1 in Q15 */ - /*scale *= fac;*/ - tmp = mult_r( scale, tmp ); /*-----------------------------------------------------------------* * modify HF excitation according to both calculated scaling factors * high pass filtering (0.94ms of delay) @@ -291,7 +388,7 @@ static void hf_synthesis_fx( return; } - +#ifndef FIX_BASOP_2350_HARM_0B_BWE void hf_synth_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ const Word32 core_brate, /* i : core bitrate Q0*/ @@ -319,7 +416,6 @@ void hf_synth_ivas_fx( return; } - static void hf_synthesis_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, /* i : core bitrate Q0*/ @@ -498,6 +594,7 @@ static void hf_synthesis_ivas_fx( return; } +#endif /*-------------------------------------------------------------------* * filt_6k_7k: -- GitLab From 3caa68324f4136bbc5641d026c7f40af6fcc119a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 21 Jan 2026 13:56:18 -0500 Subject: [PATCH 509/750] fix --- lib_dec/hf_synth_fx.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index dde0d717a..20a3d6323 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -176,9 +176,10 @@ static void hf_synthesis_fx( L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 ); tmp = round_fx( L_tmp ); /* Q15 */ +#ifdef FIX_BASOP_2350_HARM_0B_BWE IF( element_mode == EVS_MONO ) { - +#endif /* tmp = (float)(sqrt(ener/tmp)) */ /* scale is -1 if tmp > ener */ scale = shr( sub( ener, tmp ), 15 ); /* Q0 */ @@ -193,10 +194,10 @@ static void hf_synthesis_fx( L_tmp = Isqrt_lc( L_tmp, &exp1 ); scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */ - exp2 = sub( hBWE_zero->memExp1, exp1 ); - hBWE_zero->memExp1 = exp1; - move16(); - + /* moved after the else */ + /* exp2 = sub( hBWE_zero->memExp1, exp1 ); + hBWE_zero->memExp1 = exp1; + move16(); */ /*-----------------------------------------------------------------* * calculate energy scaling factor to respect tilt of synth12k8 * (tilt: 1=voiced, -1=unvoiced) @@ -247,6 +248,7 @@ static void hf_synthesis_fx( /*scale *= fac;*/ tmp = mult_r( scale, tmp ); +#ifdef FIX_BASOP_2350_HARM_0B_BWE } ELSE { @@ -321,12 +323,17 @@ static void hf_synthesis_fx( /*scale *= fac;*/ tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */ Q_tmp = sub( Q_tmp, exp1 ); - } + + } +#endif /*-----------------------------------------------------------------* * modify HF excitation according to both calculated scaling factors * high pass filtering (0.94ms of delay) *-----------------------------------------------------------------*/ + exp2 = sub( hBWE_zero->memExp1, exp1 ); + hBWE_zero->memExp1 = exp1; + move16(); filt_6k_7k_scale_fx( HF_exc, L_SUBFR16k, hBWE_zero->mem_hf_fx, tmp, exp2 ); /* i: input HF_exc is scaled in float, here scaling is done inside this filter */ -- GitLab From fc9cc6b74a97c77e8fb68af149c7fe9e0da060e8 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 21 Jan 2026 14:19:21 -0500 Subject: [PATCH 510/750] fix clang-format --- lib_dec/hf_synth_fx.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 20a3d6323..8466a5f43 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -88,13 +88,13 @@ void hf_synth_fx( const Word16 element_mode, /* i : element mode Q0*/ #endif const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ ) { const Word16 *p_Aq; @@ -131,7 +131,7 @@ void hf_synth_fx( static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, #ifdef FIX_BASOP_2350_HARM_0B_BWE - const Word16 element_mode, /* i : element mode Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ #endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_subfr, /* i : output sub-frame length Q0*/ @@ -322,9 +322,7 @@ static void hf_synthesis_fx( /*scale *= fac;*/ tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */ - Q_tmp = sub( Q_tmp, exp1 ); - - + Q_tmp = sub( Q_tmp, exp1 ); } #endif /*-----------------------------------------------------------------* -- GitLab From cc206a23b2943dd2b5cb96d12639c910e7f1797a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:04:24 +0100 Subject: [PATCH 511/750] [cleanup] accept FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR --- apps/decoder.c | 2 -- lib_com/options.h | 1 - lib_dec/lib_dec_fx.c | 26 -------------------------- 3 files changed, 29 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 35d7e6c3e..12f6b1786 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -448,12 +448,10 @@ int main( goto cleanup; } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) { fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } -#endif } /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..445c53844 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1495_INCORRECT_FREAD_CALL /* Eri: Switched size and number of elements in fread call. */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4a99ce5f2..ff3d435c2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1582,22 +1582,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); #endif -#else - IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) - { -#ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); -#endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); - } -#endif ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, pcmBuf_out ); } @@ -4928,22 +4915,9 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif -#else - IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) - { -#ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); -#endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); - } -#endif ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } -- GitLab From eedccddd717b7c05c46d5a6e848a3b7dbd9bdd00 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:05:06 +0100 Subject: [PATCH 512/750] [cleanup] accept FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR --- lib_com/options.h | 1 - lib_isar/isar_lcld_decoder.c | 37 ------------------------------------ lib_isar/isar_lcld_prot.h | 29 ---------------------------- 3 files changed, 67 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 445c53844..c08c717ee 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1495_INCORRECT_FREAD_CALL /* Eri: Switched size and number of elements in fread call. */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index e296a2e0d..d34c56dac 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -106,9 +106,6 @@ struct LCLD_DECODER PredictionDecoder *psPredictionDecoder; -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - NoiseGen *psNoiseGen; -#endif }; static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables ); @@ -605,9 +602,6 @@ ivas_error CreateLCLDDecoder( { return error; } -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - psLCLDDecoder->psNoiseGen = NULL; /* CreateNoiseGen(); No noise fill for now*/ -#endif *psLCLDDecoder_out = psLCLDDecoder; return IVAS_ERR_OK; @@ -769,12 +763,6 @@ void DeleteLCLDDecoder( psLCLDDecoder->psPredictionDecoder = NULL; } -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - IF( psLCLDDecoder->psNoiseGen != NULL ) - { - DeleteNoiseGen( psLCLDDecoder->psNoiseGen ); - } -#endif free( psLCLDDecoder ); } @@ -794,10 +782,6 @@ static void ApplyRMSEnvelope_fx( const Word32 iNumBands, const Word32 *piBandwid static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, Word32 **ppiSignReal, Word32 **ppiSignImag, Word32 **ppfReal, Word32 **ppfImag, const Word32 *piBandwidths ); static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - , - NoiseGen *psNoiseGen -#endif ); static void InvMSCoding_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiffs, const Word32 *piMSPredCoefs, Word32 ***pppfReal, Word32 ***pppfImag ); @@ -1021,10 +1005,6 @@ Word32 DecodeLCLDFrame( psLCLDDecoder->pppiQLCLDReal[n], psLCLDDecoder->pppiQLCLDImag[n], pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - , - psLCLDDecoder->psNoiseGen -#endif ); ReplaceSign_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, @@ -1296,10 +1276,6 @@ static void InvQuantizeSpectrum_fx( Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - , - NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ -#endif ) { Word32 b, k, n; @@ -1339,19 +1315,6 @@ static void InvQuantizeSpectrum_fx( iFBOffset++; } } -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - ELSE IF( psNoiseGen != NULL ) - { - FOR( m = 0; m < piBandwidths[b]; m++ ) - { - ppfReal[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14 + 15 -15 )=Q14 - move32(); - ppfImag[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14+ 15 -15 )=Q14 - move32(); - iFBOffset++; - } - } -#endif ELSE { iFBOffset = L_add( iFBOffset, piBandwidths[b] ); diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index d16d32326..56dd08f6b 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -170,35 +170,6 @@ Word32 CountMSBits( ); -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - -/*----------------------------------------------------------------------------------* - * NoiseGen prototypes - *----------------------------------------------------------------------------------*/ - -typedef struct NOISE_GEN -{ - Word32 iNoiseBufferLength; - Word32 iNoiseBufferMask; - Word32 iNoiseBufferIndex; - float *pfNoiseBuffer; -} NoiseGen; - -void DeleteNoiseGen( - NoiseGen *psNoiseGen -); - -inline Word32 GetNoise_fx( NoiseGen *psNoiseGen ) -{ - Word32 fNoiseSample; - - fNoiseSample = (Word32) (psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex] * (1<<14)); - psNoiseGen->iNoiseBufferIndex++; - psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask; - - return fNoiseSample; -} -#endif /*----------------------------------------------------------------------------------* * PereptualModel prototypes -- GitLab From 74331d14c2e98ddcb6225b98f65306805faa8798 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:05:52 +0100 Subject: [PATCH 513/750] [cleanup] accept FIX_1495_INCORRECT_FREAD_CALL --- lib_com/options.h | 1 - lib_util/hrtf_file_reader.c | 60 ------------------------------------- 2 files changed, 61 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c08c717ee..f65927487 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1495_INCORRECT_FREAD_CALL /* Eri: Switched size and number of elements in fread call. */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ #define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 9ece3ecb3..3742459f8 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -302,11 +302,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), modelITD->elevDim3 - 2, f_hrtf ); for ( j = 0; j < modelITD->elevDim3 - 2; j++ ) { @@ -321,11 +317,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); for ( j = 0; j < ( modelITD->azimDim3 + 1 ) / 2 - 2; j++ ) { @@ -340,11 +332,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -380,11 +368,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -420,11 +404,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -469,17 +449,9 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif HrFiltSet_p->latency_s_Q_fx = Q31 - factor_Q; -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &HrFiltSet_p->latency_s_fx, sizeof( Word32 ), 1, f_hrtf ); -#else - fread( &HrFiltSet_p->latency_s_fx, 1, sizeof( Word32 ), f_hrtf ); -#endif model = &( HrFiltSet_p->ModelParams ); /* Set ROM flag for correct deallocation */ @@ -524,11 +496,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), model->elevDim3 - 2, f_hrtf ); for ( j = 0; j < model->elevDim3 - 2; j++ ) { @@ -554,11 +522,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); for ( j = 0; j < model->azimDim3_dyn[i] + 1; j++ ) { @@ -574,11 +538,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif model->AlphaL_e = Q15 - factor_Q; // model->AlphaL_dyn_e = 1; /* force to 6 to be corrected */ @@ -621,11 +581,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -675,11 +631,7 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -694,11 +646,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif model->EL_e = Q31 - factor_Q; model->ER_e = model->EL_e; @@ -943,11 +891,7 @@ static ivas_error TDREND_MIX_LoadHRTF( /* try if it is old format for BE tests*/ fseek( f_hrtf, 0, SEEK_SET ); -#ifdef FIX_1495_INCORRECT_FREAD_CALL if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 ) -#else - if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) -#endif { header_check_result = IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -1019,11 +963,7 @@ static ivas_error TDREND_MIX_LoadHRTF( if ( is_tdrend ) { -#ifdef FIX_1495_INCORRECT_FREAD_CALL if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 ) -#else - if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) -#endif { return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } -- GitLab From ead89d582281b3180c377710c7257f9577831d54 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:06:48 +0100 Subject: [PATCH 514/750] [cleanup] accept FIX_1486_INIT_OUTPUT_POINTERS --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f65927487..7e9f29bd1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ #define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ #define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index dd0ca93f3..d703a4104 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2553,9 +2553,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS]; Word16 nchan_in, nchan_out; -#ifdef FIX_1486_INIT_OUTPUT_POINTERS Word16 ch_idx; -#endif IF( !st_ivas->hDecoderConfig->Opt_tsm ) @@ -2563,12 +2561,10 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( return IVAS_ERR_OK; } -#ifdef FIX_1486_INIT_OUTPUT_POINTERS FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) { p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; } -#endif *nSamplesRendered = 0; move16(); @@ -2595,9 +2591,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( n_slots_still_available ) { -#ifndef FIX_1486_INIT_OUTPUT_POINTERS - Word16 ch_idx; -#endif /* render available full slots (with new lower granularity) */ FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) @@ -2627,12 +2620,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); -#ifndef FIX_1486_INIT_OUTPUT_POINTERS - FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) - { - p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; - } -#endif test(); IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) @@ -2883,11 +2870,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) { #ifndef DISABLE_LIMITER -#ifndef FIX_1486_INIT_OUTPUT_POINTERS - Word16 ch_idx, exp = 11; -#else Word16 exp = 11; -#endif move16(); FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { -- GitLab From 1153441fb4f3cdbe744c3dd17880883bd877d825 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:07:39 +0100 Subject: [PATCH 515/750] [cleanup] accept FIX_1494_SET_SPLITBFI_UNUSED --- apps/renderer.c | 36 ------------------------------------ lib_com/options.h | 1 - lib_rend/lib_rend.h | 5 ----- lib_rend/lib_rend_fx.c | 28 ---------------------------- 4 files changed, 70 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 80a37b2a6..c8d14a347 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -167,9 +167,6 @@ typedef struct int16_t numInMetadataFiles; char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; -#endif char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -220,9 +217,6 @@ typedef enum CmdLnOptionId_listFormats, CmdLnOptionId_inputGain, CmdLnOptionId_outputMetadata, -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - CmdLnOptionId_SplitRendBFIFile, -#endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, CmdLnOptionId_framing, @@ -281,14 +275,6 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "om", .description = "coded metadata file for BINAURAL_SPLIT_PCM output mode", }, -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - { - .id = CmdLnOptionId_SplitRendBFIFile, - .match = "post_rend_bfi_file", - .matchShort = "prbfi", - .description = "Split rendering option: bfi file", - }, -#endif { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", @@ -764,9 +750,6 @@ int main( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[RENDERER_MAX_INPUT_CHANNELS]; IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[RENDERER_MAX_INPUT_CHANNELS]; int16_t cldfb_in_flag, CLDFBframeSize_smpls; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - SplitRendBFIFileReader *splitRendBFIReader = NULL; -#endif Vector3PairFileReader *referenceVectorReader = NULL; hrtfFileReader *hrtfFileReader = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL; @@ -896,13 +879,6 @@ int main( } } -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - if ( !isEmptyString( args.splitRendBFIFilePath ) ) - { - convert_backslash( args.splitRendBFIFilePath ); - SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); - } -#endif if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -2184,9 +2160,6 @@ cleanup: } split_rend_reader_writer_close( &hSplitRendFileReadWrite ); -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - SplitRendBFIFileReader_close( &splitRendBFIReader ); -#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { @@ -2798,9 +2771,6 @@ static CmdlnArgs defaultArgs( clearString( args.headRotationFilePath ); clearString( args.outMetadataFilePath ); -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - clearString( args.splitRendBFIFilePath ); -#endif clearString( args.referenceVectorFilePath ); clearString( args.referenceRotationFilePath ); clearString( args.customHrtfFilePath ); @@ -2907,12 +2877,6 @@ static void parseOption( assert( numOptionValues == 1 ); strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - case CmdLnOptionId_SplitRendBFIFile: - assert( numOptionValues == 1 ); - strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); - break; -#endif case CmdLnOptionId_referenceVectorFile: assert( numOptionValues == 1 ); strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index 7e9f29bd1..b36bdfd0a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ #define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 3ce6d0bb3..1cb307790 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -344,11 +344,6 @@ ivas_error IVAS_REND_SetReferenceVector( const IVAS_VECTOR3 refPos /* i : Reference position */ ); -#ifndef FIX_1494_SET_SPLITBFI_UNUSED -ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const Word16 bfi); -#endif ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5d5179c53..232c38ee5 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -94,9 +94,6 @@ typedef struct const EFAP_WRAPPER *pEfapOutWrapper; IVAS_REND_HeadRotData *pHeadRotData; // for now removing the const qualifier TODO: will modify later const RENDER_CONFIG_HANDLE *hhRendererConfig; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - const Word16 *pSplitRendBFI; -#endif const SPLIT_REND_WRAPPER *pSplitRendWrapper; const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData; const IVAS_DefaultReverbSize *pSelectedRoomReverbSize; @@ -218,9 +215,6 @@ struct IVAS_REND EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - Word16 splitRendBFI; -#endif SPLIT_REND_WRAPPER *splitRendWrapper; IVAS_REND_AudioBuffer splitRendEncBuffer; IVAS_REND_HeadRotData headRotData; @@ -1369,9 +1363,6 @@ static rendering_context getRendCtx( ctx.pEfapOutWrapper = &hIvasRend->efapOutWrapper; ctx.pHeadRotData = &hIvasRend->headRotData; ctx.hhRendererConfig = &hIvasRend->hRendererConfig; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; -#endif ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper; ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; ctx.pSelectedRoomReverbSize = &hIvasRend->selectedRoomReverbSize; @@ -5729,25 +5720,6 @@ ivas_error IVAS_REND_DisableHeadRotation( return IVAS_ERR_OK; } -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - -/*-------------------------------------------------------------------* - * IVAS_REND_SetSplitRendBFI() - * - * - *-------------------------------------------------------------------*/ - -ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const Word16 bfi /* i : Bad Frame Indicator */ -) -{ - hIvasRend->splitRendBFI = bfi; - - return IVAS_ERR_OK; -} - -#endif /*-------------------------------------------------------------------* -- GitLab From f2a77cbe828a1391a118dc7350f900be8dc52200 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:08:21 +0100 Subject: [PATCH 516/750] [cleanup] accept FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE --- lib_com/options.h | 1 - lib_dec/ivas_spar_md_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b36bdfd0a..46bde94f8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ #define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 15e156557..9bce073cd 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -631,12 +631,10 @@ ivas_error ivas_spar_md_dec_init( hMdDec->first_valid_frame = 1; move16(); -#ifdef FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE hMdDec->spar_md.res_ind = 0; hMdDec->spar_md.prior_dyn_active_w_flag = 0; move16(); move16(); -#endif return IVAS_ERR_OK; } -- GitLab From 0c5409600fb8cfadc5bbb92baca5490e1d4f46a8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:09:39 +0100 Subject: [PATCH 517/750] [cleanup] accept HARM_LSF_ENC --- lib_com/int_lsp_fx.c | 84 -- lib_com/options.h | 1 - lib_com/prot_fx.h | 11 - lib_com/stat_noise_uv_mod_fx.c | 4 - lib_dec/acelp_core_dec_fx.c | 4 - lib_dec/dec_LPD_fx.c | 4 - lib_dec/lsf_dec_fx.c | 8 - lib_enc/acelp_core_enc_fx.c | 20 - lib_enc/analy_lp_fx.c | 8 - lib_enc/cng_enc_fx.c | 8 - lib_enc/ivas_tcx_core_enc_fx.c | 5 - lib_enc/lsf_enc_fx.c | 1303 ++------------------------------ lib_enc/prot_fx_enc.h | 51 -- lib_enc/qlpc_stoch_fx.c | 183 ----- 14 files changed, 77 insertions(+), 1617 deletions(-) diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c index d591389c0..ab84c76bb 100644 --- a/lib_com/int_lsp_fx.c +++ b/lib_com/int_lsp_fx.c @@ -132,12 +132,10 @@ void int_lsp4_fx( { pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/ } -#ifdef HARM_LSF_ENC ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) ) { pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/ } -#endif ELSE { pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/ @@ -183,85 +181,3 @@ void int_lsp4_fx( return; } -#ifndef HARM_LSF_ENC - -void int_lsp4_ivas_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ - const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ - Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ - const Word16 m, /* i : order of LP filter */ - Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ -) -{ - Word16 lsp[M16k]; - Word16 i, j, k; - Word32 L_tmp; - const Word16 *pt_int_coeffs; - - IF( EQ_16( L_frame, L_FRAME ) ) - { - IF( EQ_16( relax_prev_lsf_interp, 1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) - { - pt_int_coeffs = interpol_frac_mid_FEC_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) ) - { - // This condition not present in int_lsp4_fx - pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/ - } - ELSE - { - pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/ - } - } - ELSE /* L_frame == L_FRAME16k */ - { - IF( EQ_16( relax_prev_lsf_interp, 1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) - { - pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; /*Q15*/ - } - ELSE - { - pt_int_coeffs = interpol_frac_mid_16k_fx; /*Q15*/ - } - } - k = sub( shr( L_frame, 6 ), 1 ); - FOR( j = 0; j < k; j++ ) - { - FOR( i = 0; i < m; i++ ) - { - L_tmp = L_mult( lsp_old[i], *pt_int_coeffs ); /*Q31 */ - L_tmp = L_mac( L_tmp, lsp_mid[i], *( pt_int_coeffs + 1 ) ); /*Q31 */ - lsp[i] = mac_r( L_tmp, lsp_new[i], *( pt_int_coeffs + 2 ) ); - move16(); - } - pt_int_coeffs += 3; - - E_LPC_f_lsp_a_conversion( lsp, Aq, m ); - Aq += add( m, 1 ); - } - - /* Last subframe */ - E_LPC_f_lsp_a_conversion( lsp_new, Aq, m ); - - return; -} -#endif diff --git a/lib_com/options.h b/lib_com/options.h index 46bde94f8..4a44696c0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index fac7485fb..2c9412b24 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1644,17 +1644,6 @@ void int_lsp4_fx( Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ ); -#ifndef HARM_LSF_ENC -void int_lsp4_ivas_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ - const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ - Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ - const Word16 m, /* i : order of LP filter */ - Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ -); -#endif void de_interleave_spectrum_fx( Word32 *coefs, /* i/o: i and output coefficients Q? */ const Word16 length /* i : length of spectrum Q0 */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 6f364ce99..33c5545ce 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -614,11 +614,7 @@ void stat_noise_uv_mod_ivas_fx( mult( sub( 32767, beta ), lspnew_s[i] ) ); } -#ifdef HARM_LSF_ENC int_lsp4_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 ); -#else - int_lsp4_ivas_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 ); -#endif Copy( lspnew_s, lspold_s, M ); } ELSE /* (unvoiced_vad != 0) */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index b65b49a42..c893ca4d2 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1035,11 +1035,7 @@ ivas_error acelp_core_dec_fx( test(); IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) ) { -#ifdef HARM_LSF_ENC int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); -#endif } /*---------------------------------------------------------------* diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index 07372eae0..c24d338cb 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -556,11 +556,7 @@ void decoder_LPD_fx( move16(); } -#ifdef HARM_LSF_ENC int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); -#else - int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); -#endif } ELSE { diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index bfb92005a..32c8c9958 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -300,20 +300,12 @@ void lsf_dec_fx( } /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ -#ifdef HARM_LSF_ENC int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#else - int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#endif } ELSE { /* LSP interpolation and conversion of LSPs to A(z) */ -#ifdef HARM_LSF_ENC int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp ); -#else - int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp ); -#endif } /*------------------------------------------------------------------* diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 104e9bc96..1aa59f93f 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -431,11 +431,7 @@ ivas_error acelp_core_enc_fx( if ( !tdm_lp_reuse_flag ) { -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, NULL, Q_new ); -#else - lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); -#endif } /*---------------------------------------------------------------* @@ -509,11 +505,7 @@ ivas_error acelp_core_enc_fx( config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, st_fx->idchan, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, 0, -1, NULL, Q_new ); -#else - lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); -#endif /* recalculation of LP residual (filtering through A[z] filter) */ calc_residu_fx( st_fx, inp_fx, res_fx, Aq_fx ); @@ -943,19 +935,11 @@ ivas_error acelp_core_enc_ivas_fx( IF( st->rate_switching_reset ) { /*extrapolation in case of unstable LSP*/ -#ifdef HARM_LSF_ENC int_lsp4_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 ); -#else - int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 ); -#endif } ELSE { -#ifdef HARM_LSF_ENC int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 ); -#endif } /* Reset LPC mem */ @@ -1188,11 +1172,7 @@ ivas_error acelp_core_enc_ivas_fx( IF( !tdm_lp_reuse_flag ) { -#ifdef HARM_LSF_ENC lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#else - lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#endif } ELSE { diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index e61f7f76b..162b87ea4 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -115,20 +115,12 @@ void analy_lp_fx( IF( EQ_16( sec_chan_low_rate, 1 ) ) { /* LSP interpolation */ -#ifdef HARM_LSF_ENC int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); -#else - int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); -#endif } ELSE { /* LSP interpolation */ -#ifdef HARM_LSF_ENC int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); -#else - int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); -#endif } Copy( lsp_new, lsp_old, M ); /* Q15 */ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */ diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 1bc7cab41..2903c2d09 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -340,11 +340,7 @@ void CNG_enc_fx( } ELSE { -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); -#else - lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, Q_new ); -#endif } /* Reset CNG history if CNG frame length is changed */ @@ -1561,11 +1557,7 @@ void CNG_enc_fx( } ELSE { -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); -#else - lsf_enc_ivas_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); -#endif } /* Reset CNG history if CNG frame length is changed */ diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 1b2833473..6bd3aca8c 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -420,13 +420,8 @@ void stereo_tcx_core_enc( move16(); } -#ifdef HARM_LSF_ENC lpc_quantization_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, NULL, st->clip_var_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/ param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener ); -#else - lpc_quantization_ivas_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/ - param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener ); -#endif /*--------------------------------------------------------------* * Rate switching diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 946330614..3995f1ab7 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -24,23 +24,13 @@ * Local function prototypes *---------------------------------------------------------------------*/ -#ifdef HARM_LSF_ENC static void lsfq_CNG_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ); -#else -static void lsfq_CNG_fx( BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ); -#endif static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word32 p_offset_scale1[][MAX_NO_SCALES + 1], Word32 p_offset_scale2[][MAX_NO_SCALES + 1], Word16 p_no_scales[][2], Word16 *resq, Word16 *lsfq ); static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word16 *resq, Word16 *lsfq ); -#ifdef HARM_LSF_ENC static void lsf_mid_enc_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); -#else -static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); - -static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); -#endif /*===========================================================================*/ @@ -77,14 +67,9 @@ void lsf_enc_fx( Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ Word16 *Aq, /* o : quantized A(z) for 4 subframes */ -#ifndef HARM_LSF_ENC - const Word16 Nb_ACELP_frames, -#endif const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef HARM_LSF_ENC const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ) { Word16 nBits = 0; @@ -92,10 +77,8 @@ void lsf_enc_fx( Word16 int_fs; Word16 force_sf = 0; move16(); -#ifdef HARM_LSF_ENC Word16 no_param_lpc; Word16 param_lpc[NPRM_LPC_NEW]; -#endif Word16 fec_lsf[M], stab, i; Word32 L_tmp; Word16 coder_type, ppp_mode, nelp_mode; @@ -119,9 +102,7 @@ void lsf_enc_fx( move16(); } -#ifdef HARM_LSF_ENC no_param_lpc = 0; -#endif move16(); IF( st_fx->Opt_SC_VBR ) @@ -148,7 +129,6 @@ void lsf_enc_fx( lsp2lsf_fx( lsp_new, lsf_new, M, int_fs ); /* check resonance for pitch clipping algorithm */ -#ifdef HARM_LSF_ENC IF( st_fx->element_mode == EVS_MONO ) { gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 ); @@ -157,9 +137,6 @@ void lsf_enc_fx( { gp_clip_test_lsf_ivas_fx( st_fx->element_mode, st_fx->core_brate, lsf_new, st_fx->clip_var_fx, 0 ); } -#else - gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 ); -#endif /* Find the number of bits for LSF quantization */ @@ -199,11 +176,7 @@ void lsf_enc_fx( force_sf = 0; move16(); test(); -#ifdef HARM_LSF_ENC if ( LT_16( st_fx->Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) ) -#else - if ( LT_16( Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) ) -#endif { /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */ force_sf = 1; @@ -223,13 +196,8 @@ void lsf_enc_fx( * Frame end LSF quantization *-------------------------------------------------------------------------------------*/ -#ifdef HARM_LSF_ENC lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, force_sf, param_lpc, &no_param_lpc, NULL, st_fx->coder_type_raw, tdm_lsfQ_PCh ); -#else - lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, - force_sf, NULL, NULL, NULL, st_fx->coder_type_raw ); -#endif /* convert quantized LSFs back to LSPs */ lsf2lsp_fx( lsf_new, lsp_new, M, int_fs ); @@ -242,7 +210,6 @@ void lsf_enc_fx( } /* set seed_acelp used in UC mode */ -#ifdef HARM_LSF_ENC test(); IF( EQ_16( coder_type, UNVOICED ) && ( st_fx->element_mode > EVS_MONO ) ) { @@ -255,7 +222,6 @@ void lsf_enc_fx( move16(); } } -#endif IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) { @@ -278,7 +244,6 @@ void lsf_enc_fx( FEC_lsf_estim_enc_fx( st_fx, fec_lsf ); /* in case of FEC in decoder - calculate LSF stability */ -#ifdef HARM_LSF_ENC IF( st_fx->element_mode == EVS_MONO ) { stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 @@ -287,9 +252,6 @@ void lsf_enc_fx( { stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 } -#else - stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 -#endif test(); test(); @@ -333,11 +295,7 @@ void lsf_enc_fx( } /* Mid-frame LSF encoding */ -#ifdef HARM_LSF_ENC lsf_mid_enc_fx( st_fx->element_mode, st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); -#else - lsf_mid_enc_fx( st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); -#endif test(); IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) @@ -372,7 +330,6 @@ void lsf_enc_fx( IF( NE_32( st_fx->core_brate, SID_2k40 ) ) { -#ifdef HARM_LSF_ENC IF( st_fx->element_mode == EVS_MONO ) { st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); @@ -381,280 +338,11 @@ void lsf_enc_fx( { st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); // Q15 } -#else - st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); -#endif } return; } -#ifndef HARM_LSF_ENC -void lsf_enc_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized Q15*/ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector Q15*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const Word16 Q_new ) -{ - Word16 nBits; - Word16 force_sf; - Word16 fec_lsf[M], stab, i; - Word16 no_param_lpc; - - Word16 param_lpc[NPRM_LPC_NEW]; - Word32 L_tmp; - Word16 coder_type, ppp_mode, nelp_mode; - - nBits = 0; - force_sf = 0; - move16(); - move16(); - - test(); - IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) ) - { - coder_type = INACTIVE; - move16(); - } - ELSE - { - coder_type = st->coder_type; - move16(); - } - - test(); - if ( EQ_16( coder_type, AUDIO ) && GSC_IVAS_mode > 0 ) - { - coder_type = GENERIC; - move16(); - } - - no_param_lpc = 0; - move16(); - - IF( st->Opt_SC_VBR ) - { - ppp_mode = st->hSC_VBR->ppp_mode; - nelp_mode = st->hSC_VBR->nelp_mode; - move16(); - move16(); - } - ELSE - { - ppp_mode = 0; - nelp_mode = 0; - move16(); - move16(); - } - - /* convert LSPs to LSFs */ - lsp2lsf_fx( lsp_new, lsf_new, M, st->sr_core ); - - /* check resonance for pitch clipping algorithm */ - gp_clip_test_lsf_ivas_fx( st->element_mode, st->core_brate, lsf_new, st->clip_var_fx, 0 ); - - /* Find the number of bits for LSF quantization */ - nBits = 0; - move16(); - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - nBits = LSF_BITS_CNG; - move16(); - } - ELSE - { - test(); - IF( ( nelp_mode == 0 ) && ( ppp_mode == 0 ) ) - { - nBits = st->acelp_cfg.lsf_bits; - move16(); - } - ELSE IF( EQ_16( nelp_mode, 1 ) ) - { - IF( st->bwidth == NB ) - { - nBits = 32; - move16(); - } - ELSE IF( EQ_16( st->bwidth, WB ) ) - { - nBits = 30; - move16(); - } - } - ELSE IF( EQ_16( ppp_mode, 1 ) ) - { - nBits = 26; - move16(); - } - } - force_sf = 0; - move16(); - /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */ - test(); - if ( LT_16( st->Nb_ACELP_frames, 3 ) && NE_32( st->core_brate, SID_2k40 ) ) - { - force_sf = 1; - move16(); - } - - /* in case of unstable filter in decoder FEC, choose safety-net to help FEC */ - IF( EQ_16( st->next_force_safety_net, 1 ) ) - { - force_sf = 1; - move16(); - st->next_force_safety_net = 0; - move16(); - } - - /*-------------------------------------------------------------------------------------* - * Frame end LSF quantization - *-------------------------------------------------------------------------------------*/ - lsf_end_enc_ivas_fx( st, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, - force_sf, param_lpc, &no_param_lpc, NULL, st->coder_type_raw, tdm_lsfQ_PCh ); - - /* convert quantized LSFs back to LSPs */ - lsf2lsp_fx( lsf_new, lsp_new, M, st->sr_core ); - - test(); - IF( EQ_16( st->last_core, HQ_CORE ) && ( st->core == ACELP_CORE ) ) - { - /* don't use old LSF values if this is the first ACELP frame after HQ frames */ - Copy( lsf_new, st->lsf_old_fx, M ); - } - - /* set seed_acelp used in UC mode */ - test(); - IF( EQ_16( coder_type, UNVOICED ) && ( st->element_mode > EVS_MONO ) ) - { - st->seed_acelp = 0; - move16(); - FOR( i = no_param_lpc - 1; i >= 0; i-- ) - { - /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ - st->seed_acelp = add( i_mult( add( shr( st->seed_acelp, 1 ), param_lpc[i] ), 31821 ), 13849 ); - move16(); - } - } - - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - /* return if SID frame (conversion to A(z) done in the calling function) */ - return; - } - - /*-------------------------------------------------------------------------------------* - * FEC - enforce safety-net in the next frame in case of unstable filter - *-------------------------------------------------------------------------------------*/ - - IF( NE_16( st->last_L_frame, st->L_frame ) ) - { - /* FEC - in case of core switching, use old LSFs */ - Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); // Q15 - Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); // Q15 - Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); // Q15 - } - - FEC_lsf_estim_enc_fx( st, fec_lsf ); - - /* in case of FEC in decoder - calculate LSF stability */ - stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st->L_frame ); // Q15 - - test(); - test(); - test(); - /* If decoder FEC frame may be unstable force safety-net usage */ - IF( ( EQ_16( st->L_frame, L_FRAME16k ) ) && ( LT_16( stab, STAB_FAC_LIMIT_FX ) ) && ( EQ_16( coder_type, GENERIC ) ) ) - { - st->next_force_safety_net = 1; - move16(); - } - ELSE IF( ( LT_16( stab, STAB_FAC_LIMIT_FX ) ) && ( EQ_16( st->clas, VOICED_CLAS ) || ( LT_16( st->clas, VOICED_CLAS ) && EQ_16( coder_type, AUDIO ) ) ) ) - { - st->next_force_safety_net = 1; - move16(); - } - - - /* FEC - update adaptive LSF mean vector */ - FOR( i = 0; i < M; i++ ) - { - L_tmp = L_mult( lsf_new[i], 10922 ); /*Q(x2.56+16)*/ - L_tmp = L_mac( L_tmp, st->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/ - L_tmp = L_mac( L_tmp, st->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/ - st->lsf_adaptive_mean_fx[i] = extract_h( L_tmp ); /*Q(x2.56)*/ - } - - /* FEC - update LSF memories */ - Copy( st->lsfoldbfi0_fx, st->lsfoldbfi1_fx, M ); - Copy( lsf_new, st->lsfoldbfi0_fx, M ); - - - /*-------------------------------------------------------------------------------------* - * Mid-frame LSF encoding - * LSP interpolation and conversion of LSPs to A(z) - *-------------------------------------------------------------------------------------*/ - IF( st->rate_switching_reset ) - { - /*extrapolation in case of unstable LSF convert*/ - Copy( lsp_new, st->lsp_old_fx, M ); // Q15 - Copy( lsf_new, st->lsf_old_fx, M ); // Q15 - } - /* Mid-frame LSF encoding */ - lsf_mid_enc_ivas_fx( st->hBstr, st->acelp_cfg.mid_lsf_bits, st->sr_core, st->lsp_old_fx, lsp_new, lsp_mid, coder_type, st->bwidth, st->Bin_E_old_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); - - test(); - IF( EQ_16( st->last_core, HQ_CORE ) && EQ_16( st->core, ACELP_CORE ) ) - { - /* don't use old LSP/LSF values if this is the first ACELP frame after HQ frames */ - Copy( lsp_mid, st->lsp_old_fx, M ); - lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core ); - } - - /* LSP interpolation and conversion of LSPs to A(z) */ - test(); - IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) ) - { - IF( EQ_16( st->active_cnt, 1 ) ) - { - Copy( lsp_mid, st->lsp_old_fx, M ); // Q15 - lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core ); - Copy( lsp_new, lsp_mid, M ); // Q15 - } - - /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ -#ifdef HARM_LSF_ENC - int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#endif - } - ELSE - { -#ifdef HARM_LSF_ENC - int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); -#endif - } - - /*------------------------------------------------------------------* - * Check LSF stability (distance between old LSFs and current LSFs) - *------------------------------------------------------------------*/ - - IF( NE_32( st->core_brate, SID_2k40 ) ) - { - st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); // Q15 - } - - return; -} -#endif /*-------------------------------------------------------------------* * lsfq_CNG_fx() @@ -668,9 +356,7 @@ void lsf_enc_ivas_fx( *-------------------------------------------------------------------*/ static void lsfq_CNG_fx( -#ifdef HARM_LSF_ENC const Word16 element_mode, /* i : element mode */ -#endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/ const Word16 *lsf, /*x2.56 unquantized LSF vector */ const Word16 *wghts, /*Q10 LSF weights */ @@ -746,7 +432,6 @@ static void lsfq_CNG_fx( /* quantize the difference with LVQ */ /* MSVQ_ROM to be updated */ -#ifdef HARM_LSF_ENC IF( element_mode == EVS_MONO ) { mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales ); @@ -760,12 +445,6 @@ static void lsfq_CNG_fx( index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 ); } -#else - mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales ); - - index_lvq_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG + idx_cv, idx_lvq, - p_offset_scale1, p_offset_scale2, p_no_scales ); -#endif Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M ); @@ -779,118 +458,27 @@ static void lsfq_CNG_fx( return; } -#ifndef HARM_LSF_ENC -static void lsfq_CNG_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *lsf, /*x2.56 unquantized LSF vector */ - const Word16 *wghts, /*Q10 LSF weights */ - Word16 *qlsf /*x2.56 quantized LSF vecotor */ + +/*-------------------------------------------------------------------* + * qlsf_Mode_Select_fx() + * + * Mode selection for LSF quantizer + *-------------------------------------------------------------------*/ + +static Word16 qlsf_Mode_Select_fx( + const Word16 *w, /* i : weighting vector Q8 */ + const Word16 *pred1, /* i : prediction vector x2.56 */ + const Word16 streaklimit, /* i : predictive streak limit Q15 */ + const Word32 op_loop_thr /* i : Open-loop Threshold */ ) { - Word16 i, j, idx_cv, idx_lvq[3]; - Word32 min_dist, dist; - Word16 dd[M], ddq[M]; - const Word16 *p_cb; - Word16 first_cb, last_cb; - Word16 idx_lead_cng[2], idx_scale_cng[2]; - Word16 tmp; + Word16 pred_pow2[M]; + Word32 temp32, En = 0; + Word16 safety_net; + Word16 i, cs, cl; - idx_cv = 0; - move16(); - - /* quantize first stage with 4 bits - The sampling frequency of the LP-CNG frame can be determined by checking the value of the highest order LSF - coefficient (last coefficient of lsf). If the last LSF coefficient (lsf[M-1]) is larger than 6350 - the decoded frame is WB2 with sampling rate of 16 kHz, otherwise it is sampled at 12.8kHz and contains - either NB or WB LSF data. */ - IF( GT_16( lsf[M - 1], WB_LIMIT_LSF_FX ) ) /* 16kHz sampled LSF vector*/ - { - p_cb = &CNG_SN1_fx[0]; - move16(); - first_cb = 0; - move16(); - last_cb = 6; - move16(); - } - ELSE /* 12.8kHz sampled LSF vector*/ - { - p_cb = &CNG_SN1_fx[6 * M]; - move16(); - first_cb = 6; - move16(); - last_cb = M; - move16(); - } - - - min_dist = L_add( MAXINT32, 0 ); - FOR( i = first_cb; i < last_cb; i++ ) - { - tmp = sub( *p_cb, shl( lsf[0], 1 ) ); /*x2.56 */ - dist = Mult_32_16( L_mult0( wghts[0], *p_cb ), tmp ); /*Q8 + x2.56 -Q15 + x2.56 = Q-7 + x2.56+x.256 */ - p_cb++; - FOR( j = 1; j < M; j++ ) - { - tmp = sub( *p_cb, lsf[j] ); - tmp = sub( tmp, lsf[j] ); - - dist = L_add( dist, Mult_32_16( L_mult0( wghts[j], *p_cb ), tmp ) ); - p_cb++; - } - IF( LT_32( dist, min_dist ) ) - { - min_dist = dist; - move16(); /*Q-4 */ - idx_cv = i; - move16(); - } - } - - /* calculate difference */ - FOR( i = 0; i < M; i++ ) - { - dd[i] = sub( lsf[i], CNG_SN1_fx[idx_cv * M + i] ); /*x2.56 */ - move16(); - } - - /* quantize the difference with LVQ */ - /* MSVQ_ROM to be updated */ - mslvq_cng_ivas_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts ); - - index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 ); - Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M ); - - /* write the VQ index to the bitstream */ - push_indice( hBstr, IND_ISF_0_0, idx_cv, 4 ); - - /* write the LVQ index to the bitstream */ - push_indice( hBstr, IND_ISF_0_1, idx_lvq[0], LEN_INDICE ); - push_indice( hBstr, IND_ISF_0_1, idx_lvq[1], LSF_BITS_CNG - 4 - LEN_INDICE ); - - return; -} -#endif - -/*-------------------------------------------------------------------* - * qlsf_Mode_Select_fx() - * - * Mode selection for LSF quantizer - *-------------------------------------------------------------------*/ - -static Word16 qlsf_Mode_Select_fx( - const Word16 *w, /* i : weighting vector Q8 */ - const Word16 *pred1, /* i : prediction vector x2.56 */ - const Word16 streaklimit, /* i : predictive streak limit Q15 */ - const Word32 op_loop_thr /* i : Open-loop Threshold */ -) -{ - Word16 pred_pow2[M]; - Word32 temp32, En = 0; - Word16 safety_net; - Word16 i, cs, cl; - - /* calculate the prediction residual */ - cl = 0; + /* calculate the prediction residual */ + cl = 0; move16(); FOR( i = 0; i < M; i++ ) { @@ -906,582 +494,71 @@ static Word16 qlsf_Mode_Select_fx( En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ } - cs = shl( cs, 1 ); - En = L_shr( En, cs ); - temp32 = Mult_32_16( op_loop_thr, streaklimit ); - - /* choose the mode */ - IF( GT_32( En, temp32 ) ) - { - /* Safety-net */ - safety_net = 1; - move16(); - } - ELSE - { - /* Predictive */ - safety_net = 0; - move16(); - } - return safety_net; -} - - -/*========================================================================*/ -/* FUNCTION : lsf_end_enc_fx() */ -/*------------------------------------------------------------------------*/ -/* PURPOSE : Quantization of LSF parameters */ -/*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16*) lsf : LSF in the frequency domain (0..6400) x2.56 */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) bwidth : input signal bandwidth */ -/* _ (Word16) nBits : number of bits used for ISF quantization */ -/* _ (Word16*) stable_isp : most recent stable ISP (can be */ -/* removed after passing to LSF) Q15 */ -/* _ (Word16*) stable_lsp : most recent stable LSP Q15 */ -/* _ (Word32*) grid : Table of 100 grid points for evaluating */ -/* Chebyshev polynomials Q31 */ -/* _ (Word16) int_fs : sampling frequency */ -/* _ (Word32) core_brate : Coding Bit Rate */ -/* _ (Word16) force_sf : Force safety-net usage if possible */ -/* _ (Word32*) Bin_Ener : FFT Bin energy 128 *2 sets Q_ener */ -/* _ (Word16) Q_ener : Q format of Bin_Ener */ -/* _ (Word32*) offset_scale1: offsets for LSF LVQ structure 1st */ -/* 8-dim subvector Q0 */ -/* _ (Word32*) offset_scale2: offsets for LSF LVQ structure 2nd */ -/* 8-dim subvector Q0 */ -/* _ (Word32*) offset_scale1_p: offsets for LSF LVQ structure, pred. */ -/* case, 1st 8-dim subvector Q0 */ -/* _ (Word32*) offset_scale2_p: offsets for LSF LVQ structure, */ -/* pred. case, 2nd 8-dim subvector Q0 */ -/* _ (Word16*) no_scales : LSF LVQ structure Q0 */ -/* _ (Word16*) no_scales_p : LSF LVQ structure Q0 */ -/*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16*) mem_AR : quantizer memory for AR model x2.56 */ -/*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) qlsf : quantized LSFs in the cosine domain x2.56 */ -/*------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*========================================================================*/ -#ifndef HARM_LSF_ENC -void lsf_end_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ - Word16 *qlsf, /* o : quantized LSF x2.56*/ - const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ - const Word16 coder_type_org, /* i : coding type */ - Word16 Q_ener, /* i : Q valuen for Bin_Ener */ - Word16 force_sf, /* i : Force safety-net usage if coding type supports */ - Word16 *lpc_param, - Word16 *no_indices, - Word16 *bits_param_lpc, - Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -) -{ - Word16 i; - Word16 Idx0[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for safety-net quantizer */ - Word16 Idx1[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for predictive quantizer */ - Word16 indice[MAX_VQ_STAGES + 3]; /* Temp. array of indice for vector de-quantizer */ - Word16 mode_lvq = 0, mode_lvq_p = 0; /* LVQ mode and predictive LVQ mode */ - Word16 bits0[MAX_VQ_STAGES], bits1[MAX_VQ_STAGES]; - const Word16 *Bit_alloc1 = NULL; - Word32 Err[2]; /* Quantization error for safety-net(0) and predictive(1) quantizers */ - Word16 Tmp[M]; /* Temporary target vector (mean and prediction removed) */ - Word16 pred0[M]; /* Prediction for the safety-net quantizer (usually mean) */ - Word16 pred1[M]; /* Prediction for the predictive quantizer */ - Word16 pred2[M]; /* Prediction for the predictive quantizer */ - Word16 wghts[M]; /* Weighting used for quantizer (currently GSM based) */ - Word16 stages0; /* Amount of stages used by safety-net quantizer */ - Word16 stages1; /* Amount of stages used by predictive quantizer */ - Word16 levels0[MAX_VQ_STAGES]; /* Sizes of different codebook stages for safety-net quantizer */ - Word16 levels1[MAX_VQ_STAGES]; /* Sizes of different codebook stages for predictive quantizer */ - Word16 predmode; /* 0: safety-net only, 1: predictive only, 2: best of the two */ - Word16 safety_net, cumleft, num_bits; - Word16 *Idx, stages, *bits; - Word16 Tmp2[M], Tmp1[M]; - Word32 abs_threshold; /* Absolute threshold depending on signal bandwidth, that indicates - very good perceptual LSF quantization performance */ - Word16 lsfq[M * 2], resq[M * 2]; - Word16 coder_type; /* coder type (from LSF quantizer point of view) */ - Word16 nBits; /* Number of bits */ - Word16 TCQIdx0[M + 2]; /* Optimal codebook indices for VQ-TCQ quantizer */ - Word16 *TCQIdx; - Word16 tmp; - Word16 flag_1bit_gran; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO ); - - nBits = nBits_in; - move16(); - /* Update LSF coder_type for LSF quantizer for some special cases */ - test(); - test(); - test(); - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) ) - { - IF( EQ_16( coder_type_raw, VOICED ) ) - { - coder_type = VOICED; - move16(); /* Reflect Inactive mode */ - if ( EQ_16( flag_1bit_gran, 1 ) ) - { - nBits = sub( nBits, 1 ); /* This is for real Generic*/ - } - } - ELSE - { - nBits = sub( nBits, 1 ); /* This is for real Generic*/ - coder_type = coder_type_org; - move16(); - } - } - ELSE - { - coder_type = coder_type_org; - move16(); - } - - /*----------------------------------------------------------------------------------- -* - * Calculate the number of stages and levels for each stage based on allowed bit budget - * Set absolute threshold for codebook-type decision logic depending on signal bandwidth - *------------------------------------------------------------------------------------ -*/ - IF( EQ_16( st->bwidth, NB ) ) - { - abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); - } - ELSE - { - abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); - } - /* Calculate LSF weighting coefficients */ - Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], Q_ener, lsf, wghts, (Word16) EQ_16( st->bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), st->sr_core, M ); - - /*--------------------------------------------------------------------------------* - * LSF quantization of SID frames - *--------------------------------------------------------------------------------*/ - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - lsfq_CNG_fx( hBstr, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] ); - sort_fx( qlsf, 0, M - 1 ); - reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core ); - - return; - } - /* Find allowed predictor mode for current coder_type. (SN only (0), SN/AR switched (2) or MA predictive (1) */ - find_pred_mode( &predmode, coder_type, st->bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); - - /*----------------------------------------------------------------* - * Calculate number of stages and levels for each stage based on the allowed bit allocation - * (subtract one bit for LSF predictor selection) - *----------------------------------------------------------------*/ - lsf_allocate_fx( sub( nBits, shr( predmode, 1 ) ), mode_lvq, mode_lvq_p, &stages0, &stages1, levels0, levels1, bits0, bits1 ); - - - /*--------------------------------------------------------------------------------* - * LSF quantization of all other frames but SID frames - * Select safety-net or predictive mode - *--------------------------------------------------------------------------------*/ - - Err[0] = MAXINT32; - move32(); - Err[1] = MAXINT32; - move32(); - /* for mem_MA update */ - FOR( i = 0; i < M; i++ ) - { - pred1[i] = add( ModeMeans_fx[mode_lvq][i], mult_r( MU_MA_FX, st->mem_MA_fx[i] ) ); - move16(); - } - - IF( predmode == 0 ) - { - /* Subtract only mean */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - Vr_subt( lsf, pred0, Tmp, M ); - - /* LVQ quantization (safety-net only) */ - Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, - st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); - safety_net = 1; - move16(); - st->pstreaklen = 0; - move16(); /* predictive LSF quantizer streak is ended with safety-net */ - } - ELSE IF( EQ_16( predmode, 1 ) ) /* only MA prediction */ - { - Vr_subt( lsf, pred1, Tmp1, M ); - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, - st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, resq, lsfq ); - - safety_net = 0; - move16(); - } - ELSE - { - /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in - case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */ - test(); - test(); - test(); - IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) - { - /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); // Q15 - move16(); - } - - IF( st->pstreaklen == 0 ) - { - /* reset the consecutive AR-predictor multiplier */ - st->streaklimit_fx = 32767; /*1.0 in Q15 */ - move16(); - } - - /* VOICED_WB@16kHz */ - test(); - IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 ) - { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ); - Tmp2[i] = sub( Tmp[i], pred2[i] ); - pred2[i] = add( pred2[i], pred0[i] ); - } - - /* select safety_net or predictive */ - safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, st->streaklimit_fx, OP_LOOP_THR_HVO ); - IF( EQ_16( force_sf, 1 ) ) - { - safety_net = 1; - move16(); - } - - IF( safety_net ) - { - /* Safety-net - BC-TCQ quantization : SN */ - Err[0] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = 0; - move16(); - } - ELSE - { - /* predictive - BC-TCQ quantization : AR */ - Err[1] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp2, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = add( st->pstreaklen, 1 ); - } - } - /* all other frames (not VOICED@16kHz) */ - ELSE - { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); - Tmp2[i] = sub( lsf[i], pred2[i] ); - } - - /* safety-net */ - Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); - /* Predictive quantizer is calculated only if it can be selected */ - test(); - IF( !force_sf || GT_32( Err[0], abs_threshold ) ) - { - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, - st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); - } - test(); - test(); - /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following: - if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected - or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer. - or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */ - IF( force_sf || LT_32( Mult_32_16( Err[0], ( st->streaklimit_fx ) ), L_add( Err[1], Mult_32_16( Err[1], PREFERSFNET_FX ) ) ) || LT_32( Err[0], abs_threshold ) ) - { - safety_net = 1; - move16(); - st->pstreaklen = 0; - move16(); /* Reset the consecutive predictive frame counter */ - } - ELSE - { - safety_net = 0; - move16(); /* Increase the consecutive predictive frame counter by one */ - st->pstreaklen = add( st->pstreaklen, 1 ); - } - } - } - - /*--------------------------------------------------------------------------* \ - * Write indices to array \ - *--------------------------------------------------------------------------*/ - - IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->core, ACELP_CORE ) ) - { - /* write coder_type bit for VOICED@16kHz or GENERIC@16kHz */ - test(); - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) ) - { - /* VOICED =2 and GENERIC=3, so "coder_type-2" means VOICED =0 and GENERIC=1*/ - push_indice( hBstr, IND_LSF_PREDICTOR_SELECT_BIT, sub( coder_type, 2 ), 1 ); - } - - /* write predictor selection bit */ - IF( EQ_16( predmode, 2 ) ) - { - push_indice( st->hBstr, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 ); - } - - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 ) - { - /* BC-TCVQ (only for VOICED@16kHz) */ - TCQIdx = &TCQIdx0[1]; - Bit_alloc1 = &BC_TCVQ_BIT_ALLOC_40B[1]; - FOR( i = 0; i < ( M / 2 ) + 3; i++ ) - { - push_indice( hBstr, IND_LSF, TCQIdx[i], Bit_alloc1[i] ); - } - } - ELSE - { - cumleft = nBits; - move16(); - IF( EQ_16( predmode, 2 ) ) - { - /* subtract predictor selection bit */ - cumleft = sub( nBits, 1 ); - } - - IF( safety_net ) - { - stages = stages0; - move16(); - Idx = Idx0; - move16(); - bits = bits0; - move16(); - } - ELSE - { - stages = stages1; - move16(); - Idx = Idx1; - move16(); - bits = bits1; - move16(); - } - - tmp = sub( stages, 1 ); - FOR( i = 0; i < tmp; i++ ) - { - indice[i] = Idx[i]; - move16(); - num_bits = bits[i]; - move16(); - cumleft -= num_bits; - move16(); - push_indice( hBstr, IND_LSF, indice[i], num_bits ); - } - - WHILE( cumleft > 0 ) - { - indice[i] = Idx[i]; - move16(); - - IF( GT_16( cumleft, LEN_INDICE ) ) - { - num_bits = LEN_INDICE; - move16(); - } - ELSE - { - num_bits = cumleft; - move16(); - } - - cumleft = sub( cumleft, num_bits ); - push_indice( hBstr, IND_LSF, indice[i], num_bits ); - i = add( i, 1 ); - } - } - } - ELSE - { - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) ) - { - /* BC-TCVQ (only for VOICED@16kHz) */ - /* Number of quantization indices */ - *no_indices = 10; - move16(); - FOR( i = 0; i < *no_indices; i++ ) - { - lpc_param[i] = TCQIdx0[i]; - move16(); - bits_param_lpc[i] = BC_TCVQ_BIT_ALLOC_40B[i]; // Q0 - move16(); - } - } - ELSE - { - /* Number of quantization indices */ - - /* there are 31 bits */ - IF( EQ_16( safety_net, 1 ) ) - { - Idx = Idx0; - move16(); - *no_indices = add( stages0, 1 ); - FOR( i = 0; i < stages0; i++ ) - { - lpc_param[i] = Idx[i]; - move16(); - indice[i] = Idx[i]; - move16(); - bits_param_lpc[i] = bits0[i]; - move16(); - } - lpc_param[stages0] = Idx[stages0]; - move16(); - indice[stages0] = Idx[stages0]; - move16(); - tmp = sub( stages0, 1 ); - bits_param_lpc[tmp] = LEN_INDICE; - move16(); - bits_param_lpc[stages0] = sub( bits0[tmp], LEN_INDICE ); - } - ELSE - { - *no_indices = add( stages1, 1 ); - Idx = Idx1; - move16(); - FOR( i = 0; i < stages1; i++ ) - { - lpc_param[i] = ( Idx[i] ); - move16(); - indice[i] = Idx[i]; - move16(); - bits_param_lpc[i] = bits1[i]; - move16(); - } - lpc_param[stages1] = ( Idx[stages1] ); - move16(); - indice[stages1] = Idx[stages1]; - move16(); - tmp = sub( stages1, 1 ); - bits_param_lpc[tmp] = LEN_INDICE; - move16(); - bits_param_lpc[stages1] = sub( bits1[tmp], LEN_INDICE ); - } - IF( EQ_16( predmode, 2 ) ) - { - FOR( i = *no_indices; i > 0; i-- ) - { - tmp = sub( i, 1 ); - lpc_param[i] = lpc_param[tmp]; - move16(); - bits_param_lpc[i] = bits_param_lpc[tmp]; - move16(); - } - lpc_param[0] = safety_net; - move16(); /* put the safety net info on the last param */ - bits_param_lpc[0] = 1; - move16(); - *no_indices = add( *no_indices, 1 ); - } - } - } - - - /*--------------------------------------------------------------------------* - * De-quantize encoded LSF vector - *--------------------------------------------------------------------------*/ - - IF( safety_net ) - { - /* Safety-net */ - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 ) - { - /* BC-TCQ */ - Copy( lsfq, st->mem_MA_fx, M ); - Vr_add( lsfq, pred0, qlsf, M ); - } - ELSE - { - { - vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1], - &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], - &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); - Vr_add( qlsf, pred0, qlsf, M ); - Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); - } - } - } - ELSE - { - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 ) - { - /* BC-TCVQ */ - Copy( lsfq, st->mem_MA_fx, M ); - Vr_add( lsfq, pred2, qlsf, M ); - } - ELSE - { - /* LVQ */ - vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1], - &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], - &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); - IF( EQ_16( predmode, 1 ) ) - { - Copy( qlsf, st->mem_MA_fx, M ); - Vr_add( qlsf, pred1, qlsf, M ); - } - ELSE - { - Vr_add( qlsf, pred2, qlsf, M ); - Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); - } - } - } + cs = shl( cs, 1 ); + En = L_shr( En, cs ); + temp32 = Mult_32_16( op_loop_thr, streaklimit ); - /* Sort the quantized vector to ascending order */ - sort_fx( qlsf, 0, M - 1 ); + /* choose the mode */ + IF( GT_32( En, temp32 ) ) + { + /* Safety-net */ + safety_net = 1; + move16(); + } + ELSE + { + /* Predictive */ + safety_net = 0; + move16(); + } + return safety_net; +} - /* Verify stability by adding minimum separation */ - reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core ); - /* Update AR-predictor memories */ - Copy( qlsf, st->mem_AR_fx, M ); +/*========================================================================*/ +/* FUNCTION : lsf_end_enc_fx() */ +/*------------------------------------------------------------------------*/ +/* PURPOSE : Quantization of LSF parameters */ +/*------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16*) lsf : LSF in the frequency domain (0..6400) x2.56 */ +/* _ (Word16) coder_type : coding type */ +/* _ (Word16) bwidth : input signal bandwidth */ +/* _ (Word16) nBits : number of bits used for ISF quantization */ +/* _ (Word16*) stable_isp : most recent stable ISP (can be */ +/* removed after passing to LSF) Q15 */ +/* _ (Word16*) stable_lsp : most recent stable LSP Q15 */ +/* _ (Word32*) grid : Table of 100 grid points for evaluating */ +/* Chebyshev polynomials Q31 */ +/* _ (Word16) int_fs : sampling frequency */ +/* _ (Word32) core_brate : Coding Bit Rate */ +/* _ (Word16) force_sf : Force safety-net usage if possible */ +/* _ (Word32*) Bin_Ener : FFT Bin energy 128 *2 sets Q_ener */ +/* _ (Word16) Q_ener : Q format of Bin_Ener */ +/* _ (Word32*) offset_scale1: offsets for LSF LVQ structure 1st */ +/* 8-dim subvector Q0 */ +/* _ (Word32*) offset_scale2: offsets for LSF LVQ structure 2nd */ +/* 8-dim subvector Q0 */ +/* _ (Word32*) offset_scale1_p: offsets for LSF LVQ structure, pred. */ +/* case, 1st 8-dim subvector Q0 */ +/* _ (Word32*) offset_scale2_p: offsets for LSF LVQ structure, */ +/* pred. case, 2nd 8-dim subvector Q0 */ +/* _ (Word16*) no_scales : LSF LVQ structure Q0 */ +/* _ (Word16*) no_scales_p : LSF LVQ structure Q0 */ +/*------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16*) mem_AR : quantizer memory for AR model x2.56 */ +/*------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) qlsf : quantized LSFs in the cosine domain x2.56 */ +/*------------------------------------------------------------------------*/ - return; -} -#endif +/*------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*========================================================================*/ -#ifdef HARM_LSF_ENC void lsf_end_enc_fx( -#else -void lsf_end_enc_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ Word16 *qlsf, /* o : quantized LSF x2.56*/ @@ -1530,7 +607,6 @@ void lsf_end_enc_ivas_fx( Word16 pred3[M]; Word16 dummy, dummy_v[5]; -#ifdef HARM_LSF_ENC flag_1bit_gran = 0; move16(); if ( GT_16( st->element_mode, EVS_MONO ) ) @@ -1538,9 +614,6 @@ void lsf_end_enc_ivas_fx( flag_1bit_gran = 1; move16(); } -#else - flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO ); -#endif nBits = nBits_in; move16(); @@ -1583,11 +656,7 @@ void lsf_end_enc_ivas_fx( #ifdef FIX_2302_LSF_CDBK_THRESHOLD abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); #else -#ifdef HARM_LSF_ENC abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); -#else - abs_threshold = SFNETLOWLIMIT_NB / 2; -#endif #endif } ELSE @@ -1597,12 +666,10 @@ void lsf_end_enc_ivas_fx( #else abs_threshold = SFNETLOWLIMIT_WB / 2; move32(); -#ifdef HARM_LSF_ENC if ( flag_1bit_gran == 0 ) { abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); } -#endif #endif } @@ -1615,11 +682,7 @@ void lsf_end_enc_ivas_fx( IF( EQ_32( st->core_brate, SID_2k40 ) ) { -#ifdef HARM_LSF_ENC lsfq_CNG_fx( st->element_mode, hBstr, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] ); -#else - lsfq_CNG_ivas_fx( hBstr, lsf, wghts, qlsf ); -#endif sort_fx( qlsf, 0, M - 1 ); reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core ); @@ -1670,14 +733,12 @@ void lsf_end_enc_ivas_fx( Vr_subt( lsf, pred0, Tmp, M ); /* LVQ quantization (safety-net only) */ -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); } ELSE -#endif { Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); } @@ -1691,14 +752,12 @@ void lsf_end_enc_ivas_fx( { Vr_subt( lsf, pred1, Tmp1, M ); -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, resq, lsfq ); } ELSE -#endif { Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, resq, lsfq ); } @@ -1773,13 +832,11 @@ void lsf_end_enc_ivas_fx( ELSE { /* Switched Safety-Net/AR prediction */ -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); } ELSE -#endif { Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); } @@ -1788,14 +845,12 @@ void lsf_end_enc_ivas_fx( test(); IF( !force_sf || GT_32( Err[0], abs_threshold ) ) { -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); } ELSE -#endif { Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, &resq[M], &lsfq[M] ); } @@ -2101,7 +1156,6 @@ void lsf_end_enc_ivas_fx( } ELSE { -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1], @@ -2109,7 +1163,6 @@ void lsf_end_enc_ivas_fx( &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); } ELSE -#endif { vq_dec_lvq_ivas_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1] ); } @@ -2131,7 +1184,6 @@ void lsf_end_enc_ivas_fx( ELSE { /* LVQ */ -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1], @@ -2139,7 +1191,6 @@ void lsf_end_enc_ivas_fx( &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); } ELSE -#endif { vq_dec_lvq_ivas_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1] ); } @@ -3685,9 +2736,7 @@ static void FFT_Mid_Interpol_16k_fx( static void lsf_mid_enc_fx( -#ifdef HARM_LSF_ENC const Word16 element_mode, /* i : element mode */ -#endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 nb_bits, /* i : number of bits */ const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/ @@ -3715,7 +2764,6 @@ static void lsf_mid_enc_fx( lsp2lsf_fx( qlsp0, qlsf0, M, int_fs ); lsp2lsf_fx( qlsp1, qlsf1, M, int_fs ); -#ifdef HARM_LSF_ENC IF( element_mode == EVS_MONO ) { /* calculate weights */ @@ -3730,14 +2778,6 @@ static void lsf_mid_enc_fx( Unified_weighting_fx( Bin_Ener_old, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); move16(); } -#else - /* calculate weights */ - FFT_Mid_Interpol_16k_fx( Bin_Ener_old, &Bin_Ener[L_FFT / 2], Bin_Ener_mid ); - - /* LSF weighting */ - Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); - move16(); -#endif /* codebook selection, number of bits, size of the codebook */ test(); @@ -3760,14 +2800,12 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef HARM_LSF_ENC case 1: { ratio = tbl_mid_voi_wb_1b_fx; // Q13 move16(); BREAK; } -#endif } } ELSE IF( EQ_16( coder_type, UNVOICED ) ) @@ -3785,14 +2823,12 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef HARM_LSF_ENC case 4: { ratio = tbl_mid_gen_wb_4b_fx; // Q13 move16(); BREAK; } -#endif case 2: { ratio = tbl_mid_gen_wb_2b_fx; @@ -3896,188 +2932,3 @@ static void lsf_mid_enc_fx( return; } -#ifndef HARM_LSF_ENC - -static void lsf_mid_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 nb_bits, /* i : number of bits */ - const Word32 int_fs, /* i : internal (ACELP) sampling frequency*/ - const Word16 qlsp0[], /* i : quantized LSPs from frame beginning Q15*/ - const Word16 qlsp1[], /* i : quantized LSPs from frame end Q15*/ - Word16 lsp[], /* i/o: mid-frame LSP Q15*/ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - Word32 Bin_Ener[], /* i : per bin log energy spectrum Q_ener*/ - Word16 Q_ener, /* i : Q value of Bin_ener */ - Word16 ppp_mode, - Word16 nelp_mode ) -{ - Word16 lsf[M], qlsf[M], qlsf1[M], qlsf0[M], wghts[M]; - Word32 err, err_min; - Word16 j, k, idx, size = 0; - Word32 L_tmp; - Word16 tmp, k1; - const Word16 *ratio = NULL; - - /* convert LSPs to LSFs */ - lsp2lsf_fx( lsp, lsf, M, int_fs ); - lsp2lsf_fx( qlsp0, qlsf0, M, int_fs ); - lsp2lsf_fx( qlsp1, qlsf1, M, int_fs ); - - /* LSF weighting */ - Unified_weighting_fx( Bin_Ener, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); - move16(); - /* codebook selection, number of bits, size of the codebook */ - test(); - IF( ppp_mode == 0 && nelp_mode == 0 ) - { - /* codebook selection */ - IF( EQ_16( coder_type, VOICED ) ) - { - SWITCH( nb_bits ) - { - case 5: - { - ratio = tbl_mid_voi_wb_5b_fx; // Q13 - move16(); - BREAK; - } - case 4: - { - ratio = tbl_mid_voi_wb_4b_fx; // Q13 - move16(); - BREAK; - } - case 1: - { - ratio = tbl_mid_voi_wb_1b_fx; // Q13 - move16(); - BREAK; - } - } - } - ELSE IF( EQ_16( coder_type, UNVOICED ) ) - { - ratio = tbl_mid_unv_wb_5b_fx; // Q13 - } - ELSE - { - /* GENERIC, TRANSITION, AUDIO and INACTIVE */ - SWITCH( nb_bits ) - { - case 5: - { - ratio = tbl_mid_gen_wb_5b_fx; // Q13 - move16(); - BREAK; - } - case 4: - { - ratio = tbl_mid_gen_wb_4b_fx; // Q13 - move16(); - BREAK; - } - case 2: - { - ratio = tbl_mid_gen_wb_2b_fx; // Q13 - move16(); - BREAK; - } - } - } - - size = (Word16) pow2[nb_bits]; - move16(); - } - ELSE IF( EQ_16( ppp_mode, 1 ) ) - { - ratio = tbl_mid_voi_wb_1b_fx; // Q13 - move16(); - nb_bits = 1; - move16(); - size = 2; - move16(); - } - ELSE IF( EQ_16( nelp_mode, 1 ) ) - { - ratio = tbl_mid_unv_wb_4b_fx; // Q13 - move16(); - nb_bits = 4; - move16(); - size = 16; - move16(); - } - - /* loop over codevectors */ - err_min = MAXINT32; - move16(); - idx = 0; - move16(); - k1 = 0; - move16(); - FOR( k = 0; k < size; k++ ) - { - err = L_deposit_l( 0 ); - - FOR( j = 0; j < M; j++ ) - { - /* qlsf[j] = (1.0f - ratio[k*M+j]) * qlsf0[j] + ratio[k*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[k1 + j] ), qlsf0[j] ); - L_tmp = L_mac( L_tmp, ratio[k1 + j], qlsf1[j] ); - qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); - - test(); - test(); - IF( j > 0 && LT_16( j, M ) && LT_16( qlsf[j], add( qlsf[j - 1], LSF_GAP_MID_FX ) ) ) - { - qlsf[j] = add( qlsf[j - 1], LSF_GAP_MID_FX ); - move16(); - } - - tmp = sub( lsf[j], qlsf[j] ); - /* err += wghts[j] * ftemp * ftemp; */ - /* tmp is usually very small, we can have some extra precision with very rare saturation */ - tmp = shl_sat( tmp, 4 ); - tmp = mult_r_sat( tmp, tmp ); - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); - } - /* err = L_shl(err,Wscale); */ - err = Mult_32_16( err, LSF_1_OVER_256SQ ); - /* err = Mult_32_16(err,Wmult); */ - - IF( LT_32( err, err_min ) ) - { - err_min = L_add( err, 0 ); - idx = k; - move16(); - } - k1 += M; - move16(); - } - - /* calculate the quantized LSF vector */ - FOR( j = 0; j < M; j++ ) - { - /* qlsf[j] = (1.0f - ratio[idx*M+j]) * qlsf0[j] + ratio[idx*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[idx * M + j] ), qlsf0[j] ); - L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); - qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); - - test(); - test(); - IF( j > 0 && LT_16( j, M ) && LT_16( qlsf[j], add( qlsf[j - 1], LSF_GAP_MID_FX ) ) ) - { - qlsf[j] = add( qlsf[j - 1], LSF_GAP_MID_FX ); - move16(); - } - } - - reorder_lsf_fx( qlsf, LSF_GAP_MID_FX, M, int_fs ); - - /* convert LSFs back to LSPs */ - lsf2lsp_fx( qlsf, lsp, M, int_fs ); - push_indice( hBstr, IND_MID_FRAME_LSF_INDEX, idx, nb_bits ); - - return; -} -#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 7e172b31d..969649190 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -908,25 +908,7 @@ void LPDmem_enc_init_fx( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); -#ifndef HARM_LSF_ENC void lsf_end_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ - Word16 *qlsf, /* o : quantized LSF */ - const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ - const Word16 coder_type_org, /* i : coding type */ - Word16 Q_ener, /* i : Q valuen for Bin_Ener */ - Word16 force_sf, /* i : Force safety-net usage if coding type supports */ - Word16 *lpc_param, - Word16 *no_indices, - Word16 *bits_param_lpc, - Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -); - -void lsf_end_enc_ivas_fx( -#else -void lsf_end_enc_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ Word16 *qlsf, /* o : quantized LSF */ @@ -1554,22 +1536,6 @@ void lpc_quantization_fx( Word16 *no_param_lpc, /* Q0 */ const Word16 Q_ener ); -#ifndef HARM_LSF_ENC -void lpc_quantization_ivas_fx( - Encoder_State *st, - const Word16 lsp[], /* Q15 */ - const Word16 lspmid[], /* Q15 */ - Word16 lsp_q[], /* Q15 */ - Word16 lsf_q[], /* 14Q1*1.28 */ - Word16 lspmid_q[], /* Q15 */ - const Word16 coder_type, /* Q0 */ - const Word16 acelp_midLpc, /* Q0 */ - Word16 param_lpc[], /* Q0 */ - Word16 nbits_lpc[], /* Q0 */ - Word16 *bits_param_lpc, /* Q0 */ - Word16 *no_param_lpc, /* Q0 */ - const Word16 Q_ener ); -#endif void Mode2_pit_encode_fx( const Word16 coder_type, /* i : coding model */ const Word16 i_subfr, /* i : subframe index */ @@ -1846,28 +1812,11 @@ void lsf_enc_fx( Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ Word16 *Aq, /* o : quantized A(z) for 4 subframes */ -#ifndef HARM_LSF_ENC - const Word16 Nb_ACELP_frames, -#endif const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef HARM_LSF_ENC const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ); -#ifndef HARM_LSF_ENC -void lsf_enc_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const Word16 Q_new ); -#endif void Es_pred_enc_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ Word16 *indice, /* o : indice of quantization Q0*/ diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 0e0672abd..0d02d4742 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -117,26 +117,16 @@ void lpc_quantization_fx( test(); IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) ) { -#ifdef HARM_LSF_ENC lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); -#else - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC ); -#endif nb_indices = *no_param_lpc; // Q0 move16(); } ELSE { -#ifdef HARM_LSF_ENC lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); -#else - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type ); -#endif nb_indices = *no_param_lpc; // Q0 move16(); @@ -206,179 +196,6 @@ void lpc_quantization_fx( return; } -#ifndef HARM_LSF_ENC -void lpc_quantization_ivas_fx( - Encoder_State *st, - const Word16 lsp[], /* Q15 */ - const Word16 lspmid[], /* Q15 */ - Word16 lsp_q[], /* Q15 */ - Word16 lsf_q[], /* 14Q1*1.28 */ - Word16 lspmid_q[], /* Q15 */ - const Word16 coder_type, /* Q0 */ - const Word16 acelp_midLpc, /* Q0 */ - Word16 param_lpc[], /* Q0 */ - Word16 nbits_lpc[], /* Q0 */ - Word16 *bits_param_lpc, /* Q0 */ - Word16 *no_param_lpc, /* Q0 */ - const Word16 Q_ener ) -{ - Word16 nb_indices; - Word16 lsfmid_q[M]; /* 14Q1*1.28 */ - Word16 lsfmid_idx; - Word16 i, force_sf; - Word16 lsf[M], lsfmid[M]; - Word16 fec_lsf[M], stab; - - nb_indices = 0; - move16(); - - /****** High-rate LPC quantizer *******/ - - IF( st->lpcQuantization == 0 ) - { - E_LPC_lsp_lsf_conversion( lsp, lsf, M ); - - IF( ( EQ_16( st->core, TCX_10_CORE ) ) ) - { - E_LPC_lsp_lsf_conversion( lspmid, lsfmid, M ); - } - - /* LPC quantizer */ - qlpc_avq_fx( lsf, lsfmid, lsf_q, lsfmid_q, param_lpc, &nb_indices, nbits_lpc, st->core, st->sr_core ); - - E_LPC_lsf_lsp_conversion( lsf_q, lsp_q, M ); - - IF( EQ_16( st->core, TCX_10_CORE ) ) - { - E_LPC_lsf_lsp_conversion( lsfmid_q, lspmid_q, M ); - } - - assert( nb_indices <= NPRM_LPC_NEW ); - } - - /****** Low-rate LPC quantizer *******/ - - ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) - { - - lsp2lsf_fx( lsp, lsf, M, extract_l( st->sr_core ) ); - - force_sf = 0; - move16(); - /*Force safety net when possible in case of transitions*/ - test(); - test(); - IF( GE_32( st->tc_cnt, 1 ) || LE_32( st->last_core_brate, SID_2k40 ) || ( EQ_16( st->next_force_safety_net, 1 ) ) ) - { - force_sf = 1; - move16(); - st->next_force_safety_net = 0; - move16(); - } - - test(); - IF( EQ_16( st->next_force_safety_net, 1 ) && EQ_16( st->Opt_RF_ON, 1 ) ) - { - force_sf = 1; - st->next_force_safety_net = 0; - move16(); - move16(); - } - - test(); - IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) ) - { -#ifdef HARM_LSF_ENC - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); -#else - lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); -#endif - - nb_indices = *no_param_lpc; // Q0 - move16(); - } - ELSE - { -#ifdef HARM_LSF_ENC - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); -#else - lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); -#endif - - nb_indices = *no_param_lpc; // Q0 - move16(); - } - - - FEC_lsf_estim_enc_fx( st, fec_lsf ); - - /* FEC - calculate LSF stability */ - stab = lsf_stab_fx( lsf_q, fec_lsf, 0, st->L_frame ); /*Q15*/ - - - test(); - test(); - test(); - IF( LT_16( stab, add( STAB_FAC_LIMIT_FX, 6553 /* =0.2 in Q15*/ ) ) && - ( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) ) && EQ_16( st->Opt_RF_ON, 1 ) ) - { - st->next_force_safety_net = 1; - move16(); - } - - lsf2lsp_fx( lsf_q, lsp_q, M, st->sr_core ); - - *nbits_lpc = ENDLSF_NBITS; - move16(); - } - ELSE - { - assert( 0 ); - } - - st->seed_acelp = 0; - move16(); - FOR( i = nb_indices - 1; i >= 0; i-- ) - { - st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) ); // Q0 - move16(); - } - - /* Mid-frame LPC quantization */ - - test(); - IF( st->lpcQuantization && acelp_midLpc ) - { - - IF( st->rate_switching_reset == 0 ) - { - lsp2lsf_fx( lspmid, lsfmid, M, extract_l( st->sr_core ) ); - - midlsf_enc_fx( st->lsf_old_fx, lsf_q, lsfmid, &lsfmid_idx, M, st->Bin_E_old_fx, Q_ener, (Word8) st->narrowBand, st->sr_core, coder_type ); - param_lpc[nb_indices] = lsfmid_idx; // Q0 - move16(); - nb_indices = add( nb_indices, 1 ); - midlsf_dec( st->lsf_old_fx, lsf_q, lsfmid_idx, lsfmid_q, coder_type, NULL, 0, 1 ); - - reorder_lsf_fx( lsfmid_q, LSF_GAP_MID_FX, M, st->sr_core ); - lsf2lsp_fx( lsfmid_q, lspmid_q, M, st->sr_core ); - } - ELSE - { - param_lpc[nb_indices] = 0; - move16(); - nb_indices = add( nb_indices, 1 ); // Q0 - } - } - - - return; -} -#endif /*-------------------------------------------------------------------* * Unified_weighting() -- GitLab From 3ea265be89cd299f4b9bb1ce2d256ac48878fd38 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:11:00 +0100 Subject: [PATCH 518/750] [cleanup] accept CLEANUP_HQ_CORE --- lib_com/hq2_core_com_fx.c | 166 --- lib_com/ivas_prot_fx.h | 2 - lib_com/options.h | 1 - lib_com/prot_fx.h | 40 - lib_dec/FEC_HQ_core_fx.c | 280 ---- lib_dec/hq_core_dec_fx.c | 124 -- lib_enc/hq_core_enc_fx.c | 4 - lib_enc/hq_lr_enc_fx.c | 2473 ++++------------------------------- lib_enc/prot_fx_enc.h | 30 - lib_enc/swb_bwe_enc_lr_fx.c | 285 ---- lib_enc/tcq_core_enc_fx.c | 486 ------- 11 files changed, 256 insertions(+), 3635 deletions(-) diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index db2397897..1331b31a1 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -208,172 +208,6 @@ void mdct_spectrum_denorm_fx( return; } -#ifndef CLEANUP_HQ_CORE -void mdct_spectrum_denorm_ivas_fx( - const Word32 inp_vector[], /* i : Q0 : */ - Word32 L_y2[], /* i/o : Qs : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */ - const Word32 L_band_energy[], /* i : Qbe : band energy */ - const Word16 npulses[], /* i : Q0 : number of coded spectrum */ - const Word16 bands, /* i : Q0 : number of subbands */ - const Word16 ld_slope_fx, /* i : Q15 : */ - const Word16 pd_thresh_fx /* i : Q15 : */ -) -{ - Word16 i, k; - Word32 L_Eyy; - Word32 L_tmp, L_temp; - Word16 temp_fx, temp_lo_fx, temp_hi_fx; - Word32 L_inp_tmp[L_FRAME48k]; - Word16 exp_norm; - Word16 exp_safe; - Word16 exp_normn, exp_normd; - - Word16 pd_fx; - Word16 Qpd; - - Word16 div_pd_fx; - Word16 Qdivpd; - Word32 L_div_pd; - - Word16 frac, exp; - - Word16 gain_tweak_fx; - Word16 Qtweak; - - Word16 exp_shift; - - Word16 QEyy; - Word16 pow_fx; - Word16 Qpow; - Word16 Qdiv; - Word16 Qgamma; - Word16 gamma_fx; - - Word16 cond_fx; - - exp_safe = 4; /* safe bit for overflow */ - move16(); - - FOR( k = 0; k < bands; k++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - L_inp_tmp[i] = L_mult( extract_l( inp_vector[i] ), extract_l( inp_vector[i] ) ); - move32(); /* Q0+Q0+1 */ - L_tmp = L_or( L_tmp, L_inp_tmp[i] ); - } - exp_norm = norm_l( L_tmp ); - exp_norm = sub( exp_norm, exp_safe ); - - L_Eyy = L_deposit_l( 0 ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - /*Eyy += (float) inp_vector[i] * inp_vector[i]; */ - L_Eyy = L_add( L_Eyy, L_shl( L_inp_tmp[i], exp_norm ) ); /* Q1+exp_norm */ - } - QEyy = add( 1, exp_norm ); - - IF( L_Eyy > 0x0L ) - { - /* Set gamma to be pulse gain which results in perfect quantized subband energy */ - /*gamma = (float) sqrt (pow (2.0f, band_energy[k]) / Eyy); */ - - /* Pow part (pow(2.0f, band_energy) ) */ - L_temp = L_shr( L_band_energy[k], sub( SWB_BWE_LR_Qbe, 16 ) ); - temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); - Qpow = sub( 14, temp_hi_fx ); - pow_fx = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qpow */ - - /* Div part ( pow (2.0f, band_energy[i])/Eyy ) */ - exp_normn = norm_s( pow_fx ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_l( L_Eyy ); - temp_fx = div_s( shl( pow_fx, exp_normn ), extract_h( L_shl( L_Eyy, exp_normd ) ) ); /* ((Qpow + exp_norm) - (QEyy + exp_normd)) + 31 */ - Qdiv = add( sub( add( Qpow, exp_normn ), add( QEyy, exp_normd ) ), 31 ); - - exp_norm = norm_s( temp_fx ); - temp_fx = shl( temp_fx, exp_norm ); /* Qdiv + exp_norm */ - Qdiv = add( Qdiv, exp_norm ); - - /* Sqrt part sqrt(pow (2.0f, band_energy[i])/Eyy) */ - Qgamma = add( Qdiv, 16 ); - IF( s_and( Qdiv, 1 ) == 0 ) /* Qdiv % 2 == 0 */ - { - L_temp = Sqrt_l( L_shr( L_deposit_h( temp_fx ), 1 ), &exp_norm ); - L_temp = L_shr( L_temp, exp_norm ); - Qgamma = sub( shr( Qgamma, 1 ), 1 ); - gamma_fx = round_fx( L_temp ); - } - ELSE - { - L_temp = Sqrt_l( L_deposit_h( temp_fx ), &exp_norm ); - L_temp = L_shr( L_temp, exp_norm ); - Qgamma = shr( Qgamma, 1 ); - gamma_fx = round_fx( L_temp ); - } - - /* Adjust gamma based on pulse density (0 bit MSE gain estimator) */ - /*pd = (float) npulses[k] / band_width[k]; */ - exp_normn = norm_s( npulses[k] ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( band_width[k] ); - pd_fx = div_s( shl( npulses[k], exp_normn ), shl( band_width[k], exp_normd ) ); /* 15 + (exp_normn + exp_normd) */ - Qpd = add( sub( exp_normn, exp_normd ), 15 ); - - cond_fx = sub( shl_sat( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); /* Q15 */ - move16(); /* allow overflow happen. */ - IF( cond_fx < 0 ) - { - /*gain_tweak = (float) pow (2.0f, (ld_slope * log2_f (pd / pd_thresh))); */ - /* Div part */ - exp_normn = norm_s( pd_fx ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( pd_thresh_fx ); - div_pd_fx = div_s( shl( pd_fx, exp_normn ), shl( pd_thresh_fx, exp_normd ) ); /* Qpd+exp_normn - (15 + exp_normd) + 15 */ - Qdivpd = add( sub( add( Qpd, exp_normn ), add( 15, exp_normd ) ), 15 ); - - /* Log2 part */ - exp_norm = norm_s( div_pd_fx ); - L_div_pd = L_deposit_h( shl( div_pd_fx, exp_norm ) ); /* Qdivpd + exp_norm + 16 */ - Qdivpd = add( add( Qdivpd, exp_norm ), 16 ); - - frac = Log2_norm_lc( L_div_pd ); - exp = sub( 30, Qdivpd ); - L_tmp = L_Comp( exp, frac ); /* Q16 */ - - /* Mult part */ - L_tmp = Mpy_32_16_1( L_tmp, ld_slope_fx ); - - /* Pow part */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - Qtweak = sub( 14, temp_hi_fx ); - gain_tweak_fx = extract_l( Pow2( 14, temp_lo_fx ) ); - - /*gamma *= gain_tweak; */ - L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */ - exp_norm = norm_l( L_tmp ); - gamma_fx = round_fx_sat( L_shl( L_tmp, exp_norm ) ); - Qgamma = sub( add( add( Qgamma, Qtweak ), exp_norm ), 15 ); /*Qgamma+Qtweak+1+exp_norm-16; */ - } - - exp_shift = sub( SWB_BWE_LR_Qs - 1, Qgamma ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - /*y2[i] = gamma * inp_vector[i]; */ - L_tmp = L_mult( gamma_fx, extract_l( inp_vector[i] ) ); /* Qgamma+0+1=Qgamma+1 */ - L_y2[i] = L_shl( L_tmp, exp_shift ); /* SWB_BWE_LR_Qs */ - move32(); - } - } - } - - return; -} -#endif /*==========================================================================*/ /* FUNCTION : void hq2_core_configure_fx() */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0fb526b41..7ffa702b9 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1596,7 +1596,6 @@ void ivas_hq_core_dec_fx( Word16 *Q_output ); -#ifdef CLEANUP_HQ_CORE void ivas_HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ @@ -1612,7 +1611,6 @@ void ivas_HQ_FEC_Mem_update_fx( Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ Word16 output_frame ); -#endif /* o : Consumed bits Q0 */ Word16 ivas_hq_classifier_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_com/options.h b/lib_com/options.h index 4a44696c0..02b867f60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2c9412b24..1637d7baa 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2242,20 +2242,6 @@ void mdct_spectrum_denorm_fx( const Word16 pd_thresh_fx /* i : Q15 : */ ); -#ifndef CLEANUP_HQ_CORE -void mdct_spectrum_denorm_ivas_fx( - const Word32 inp_vector[], /* i : Q0 : */ - Word32 L_y2[], /* i/o : Qs : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */ - const Word32 L_band_energy[], /* i : Qbe : band energy */ - const Word16 npulses[], /* i : Q0 : number of coded spectrum */ - const Word16 bands, /* i : Q0 : numbers of subbands */ - const Word16 ld_slope_fx, /* i : Q15 : */ - const Word16 pd_thresh_fx /* i : Q15 : */ -); -#endif void hq2_core_configure_fx( const Word16 frame_length, /* Q0 */ const Word16 num_bits, /* Q0 */ @@ -3837,32 +3823,6 @@ void swb_bwe_enc_lr_fx( Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ ); -#ifndef CLEANUP_HQ_CORE -void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -); -#endif void isf_enc_amr_wb_fx( Encoder_State *st, /* i/o: state structure */ Word16 *isf_new, /* i/o: quantized ISF vector */ diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 3eeffcdd4..641f60059 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -399,286 +399,6 @@ void HQ_FEC_processing_fx( return; } -#ifndef CLEANUP_HQ_CORE -void ivas_HQ_FEC_Mem_update_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /*Q12*/ - Word32 *normq_fx, /*Q14*/ - Word16 *ynrm, - Word16 *Num_bands_p, - Word16 is_transient, - Word16 hqswb_clas, - Word16 c_switching_flag, - Word16 nb_sfm, - Word16 num_Sb, - Word16 *mean_en_high_fx, /*Q5*/ - Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - Word16 output_frame ) -{ - Word16 Min_ind; - Word32 Min_value; - Word16 Max_ind; - Word16 stat_mode_curr; - - Word16 i, j, k; - Word16 offset; - Word16 exp, exp1, exp2, tmp_fx; - Word32 *norm_values_fx; // Q12 - Word32 L_tmp, tmp_energy_fx = 0 /*Q8*/, Max_coeff_fx /*Q12*/; - Word32 en_high_fx[MAX_SB_NB]; // Q12 - HQ_NBFEC_HANDLE hHQ_nbfec; - HQ_DEC_HANDLE hHQ_core; - hHQ_nbfec = st_fx->hHQ_nbfec; - hHQ_core = st_fx->hHQ_core; - move32(); // for tmp_energy_fx - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - - IF( is_transient ) - { - set16_fx( hHQ_nbfec->prev_sign_switch_2, 0, HQ_FEC_SIGN_SFM ); - set16_fx( hHQ_nbfec->prev_sign_switch, 0, HQ_FEC_SIGN_SFM ); - } - ELSE - { - FOR( j = 0; j < HQ_FEC_SIGN_SFM; j++ ) - { - hHQ_nbfec->prev_sign_switch[j] = hHQ_nbfec->prev_sign_switch_2[j]; - move16(); - hHQ_nbfec->prev_sign_switch_2[j] = 0; - move16(); - - FOR( i = 0; i < HQ_FEC_BAND_SIZE; i++ ) - { - test(); - test(); - test(); - IF( ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] > 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] < 0 ) || ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] < 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] > 0 ) ) - { - hHQ_nbfec->prev_sign_switch[j] = add( hHQ_nbfec->prev_sign_switch[j], 1 ); - move16(); - hHQ_nbfec->prev_sign_switch_2[j] = add( hHQ_nbfec->prev_sign_switch_2[j], 1 ); - move16(); - } - } - } - } - /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */ - test(); - IF( ( EQ_16( hqswb_clas, HQ_HVQ ) ) || ( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) ) - { - /* First group */ - logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) ); - j = ynrm[0]; - move16(); - offset = WID_G1; - move16(); - - FOR( i = 1; i < SFM_G1; i++ ) - { - logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) ); - offset = add( offset, WID_G1 ); - } - - /* Second group */ - FOR( i = SFM_G1; i < SFM_G1 + 2; i++ ) - { - logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) ); - offset = add( offset, WID_G2 ); - } - } - - /* Memory update for the LGF log2 Norm */ - FOR( i = 0; i < nb_sfm; i++ ) - { - normq_fx[i] = dicn_fx[ynrm[i]]; - move32(); - } - k = 0; - move16(); - FOR( i = 0; i < num_Sb; i++ ) - { - norm_values_fx = &hHQ_nbfec->ynrm_values_fx[i][0]; - Copy32( norm_values_fx, &norm_values_fx[1], MAX_PGF - 1 ); - - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < Num_bands_p[i]; j++ ) - { - L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/ - k = add( k, 1 ); - } - tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ - norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/ - move32(); - tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/ - } - test(); - test(); - IF( ( c_switching_flag ) || ( ( st_fx->last_core == ACELP_CORE ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) ) - { - FOR( i = 0; i < MAX_SB_NB; i++ ) - { - FOR( j = 1; j < MAX_PGF; j++ ) - { - hHQ_nbfec->ynrm_values_fx[i][j] = hHQ_nbfec->ynrm_values_fx[i][0]; - move32(); - } - } - } - set16_fx( hHQ_nbfec->Norm_gain_fx, 32767, SFM_N_NB ); /*15*/ - /* st->energy_MA_Curr[1]=Energy of the current frame */ - tmp_fx = inv_tbl_fx[nb_sfm]; - move16(); /*15*/ - L_tmp = Mult_32_16( tmp_energy_fx, tmp_fx ); /*8 + 15 - 15*/ - - hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl( L_tmp, 16 - 8 ) ); - move16(); - /* Moving Average */ - hHQ_nbfec->energy_MA_Curr_fx[0] = s_max( 1, add( mult_r( 26214, hHQ_nbfec->energy_MA_Curr_fx[0] ), mult_r( 6554, hHQ_nbfec->energy_MA_Curr_fx[1] ) ) ); - move16(); - - /*st->diff_energy = (float)fabs((st->energy_MA_Curr[1] - st->energy_MA_Curr[0])/st->energy_MA_Curr[0]); */ - hHQ_nbfec->diff_energy_fx = abs_s( sub( hHQ_nbfec->energy_MA_Curr_fx[1], hHQ_nbfec->energy_MA_Curr_fx[0] ) ); - move16(); - exp1 = sub( norm_l( hHQ_nbfec->diff_energy_fx ), 1 ); - exp2 = norm_l( hHQ_nbfec->energy_MA_Curr_fx[0] ); - hHQ_nbfec->diff_energy_fx = div_s( extract_h( L_shl( hHQ_nbfec->diff_energy_fx, exp1 ) ), extract_h( L_shl( hHQ_nbfec->energy_MA_Curr_fx[0], exp2 ) ) ); - move16(); - exp = add( 15, sub( exp1, exp2 ) ); - hHQ_nbfec->diff_energy_fx = shl( hHQ_nbfec->diff_energy_fx, sub( 11, exp ) ); /*11*/ - move16(); - - /* Classify the stationary mode : 12% */ - IF( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_12P_fx ) ) - { - stat_mode_curr = 1; - move16(); - } - ELSE - { - stat_mode_curr = 0; - move16(); - } - - /* Apply Hysteresis to prevent frequent mode changing */ - if ( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) ) - { - hHQ_nbfec->stat_mode_out = stat_mode_curr; - move16(); - } - - hHQ_nbfec->stat_mode_old = stat_mode_curr; - move16(); - - /* Find max. band index (Minimum value means maximum energy) */ - Min_ind = 0; - move16(); - Min_value = L_deposit_l( 100 ); - FOR( i = 0; i < num_Sb; i++ ) - { - IF( GT_32( Min_value, ynrm[i] ) ) - { - Min_value = ynrm[i]; - move16(); - Min_ind = i; - move16(); - } - } - - /* Find max. coeff in band 0 */ - Max_ind = 0; - move16(); - IF( Min_ind == 0 ) - { - Max_coeff_fx = L_deposit_l( 0 ); - FOR( i = 0; i < 8; i++ ) - { - L_tmp = L_abs( t_audio_q_fx[i] ); // Q12 - IF( LT_32( Max_coeff_fx, L_tmp ) ) - { - Max_coeff_fx = L_add( L_tmp, 0 ); - Max_ind = i; - move16(); - } - } - } - - /* Find energy difference from band 16 */ - k = 1; - move16(); - - FOR( i = k; i < num_Sb; i++ ) - { - en_high_fx[i] = L_deposit_l( 0 ); - FOR( j = 0; j < 2; j++ ) - { - /*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/ - en_high_fx[i] = L_add( en_high_fx[i], L_shr( hHQ_nbfec->ynrm_values_fx[i][j + 1], 1 ) ); /*Q12*/ - move32(); - } - } - - *mean_en_high_fx = 0; - move16(); - FOR( i = k; i < num_Sb; i++ ) - { - /* *mean_en_high += (float)(en_high[i]/st->ynrm_values[i][0]);*/ - exp1 = sub( norm_l( en_high_fx[i] ), 1 ); - exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); - tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); - exp = add( 15, sub( exp1, exp2 ) ); - *mean_en_high_fx = add_sat( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ) ); - move16(); - } - *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); - move16(); - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient[1] ) && ( EQ_16( hHQ_nbfec->prev_last_core, HQ_CORE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) ) ) - { - hHQ_nbfec->phase_mat_flag = 1; - move16(); - test(); - if ( ( Min_ind == 0 ) && ( LT_16( Max_ind, 3 ) ) ) - { - hHQ_nbfec->phase_mat_flag = 0; - move16(); - } - } - ELSE - { - hHQ_nbfec->phase_mat_flag = 0; - move16(); - } - - hHQ_nbfec->old_Min_ind = Min_ind; - move16(); - - FOR( i = 0; i < L_FRAME8k; i++ ) - { - hHQ_nbfec->old_coeffs_fx[i] = t_audio_q_fx[i]; - move32(); - } - } - - hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1]; - move16(); - hHQ_core->old_is_transient[1] = hHQ_core->old_is_transient[0]; - move16(); - hHQ_core->old_is_transient[0] = is_transient; - move16(); - - return; -} -#endif void HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 50dd36f09..e34527da0 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -484,22 +484,13 @@ void ivas_hq_core_dec_fx( Word32 normq_fx[NB_SFM]; Word16 mean_en_high_fx; Word16 SWB_fenv_fx[SWB_FENV + DIM_FB]; -#ifndef CLEANUP_HQ_CORE - const Word16 *sfmsize, *sfm_start, *sfm_end; -#endif Word16 gapsynth_fx[L_FRAME48k]; Word16 tmp, tmp_loop; Word32 L_tmp; UWord16 lsb; Word16 L_spec; -#ifndef CLEANUP_HQ_CORE - HQ_NBFEC_HANDLE hHQ_nbfec; -#endif HQ_DEC_HANDLE hHQ_core; -#ifndef CLEANUP_HQ_CORE - hHQ_nbfec = st_fx->hHQ_nbfec; -#endif hHQ_core = st_fx->hHQ_core; TCX_DEC_HANDLE hTcxDec; @@ -530,9 +521,6 @@ void ivas_hq_core_dec_fx( move16(); Q_G_audio = Q12; move16(); -#ifndef CLEANUP_HQ_CORE - sfm_start = sfm_end = NULL; -#endif num_Sb = nb_sfm = 0; move16(); move16(); @@ -574,18 +562,7 @@ void ivas_hq_core_dec_fx( } ELSE { -#ifdef CLEANUP_HQ_CORE /* this cannot happen in IVAS */ -#else - core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame ); - - /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ - if ( GT_16( num_bits, HQ_48k / 50 ) ) - { - num_bits = (Word16) ( HQ_48k / 50 ); - move16(); - } -#endif } } IF( hq_recovery_flag ) @@ -638,12 +615,6 @@ void ivas_hq_core_dec_fx( } } -#ifndef CLEANUP_HQ_CORE - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - hq_configure_bfi_fx( &nb_sfm, &num_Sb, num_bands_p, &sfmsize, &sfm_start, &sfm_end ); - } -#endif /*-------------------------------------------------------------------------- * transform-domain decoding *--------------------------------------------------------------------------*/ @@ -659,13 +630,6 @@ void ivas_hq_core_dec_fx( &hHQ_core->last_fec, hHQ_core->ph_ecu_HqVoicing, &hHQ_core->ph_ecu_active, gapsynth_fx, st_fx->prev_bfi, hHQ_core->old_is_transient, hHQ_core->mag_chg_1st_fx, hHQ_core->Xavg_fx, &hHQ_core->beta_mute_fx, output_frame, st_fx ); } -#ifndef CLEANUP_HQ_CORE - ELSE - { - HQ_FEC_processing_fx( st_fx, t_audio_q, is_transient, hHQ_nbfec->ynrm_values_fx, hHQ_nbfec->r_p_values_fx, num_Sb, nb_sfm, num_bands_p, - output_frame, sfm_start, sfm_end ); - } -#endif hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1]; /* Q0 */ move16(); @@ -691,21 +655,8 @@ void ivas_hq_core_dec_fx( { IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) { -#ifdef CLEANUP_HQ_CORE /* this cannot happen in IVAS */ -#else - IF( EQ_16( st_fx->prev_bfi, 1 ) ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - } - - /* HQ low rate decoder */ - hq_lr_dec_fx( st_fx, t_audio_q, inner_frame, num_bits, &is_transient ); -#endif is_transient = 0; move16(); hqswb_clas = is_transient; /* Q0 */ @@ -754,13 +705,8 @@ void ivas_hq_core_dec_fx( } } -#ifdef CLEANUP_HQ_CORE HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); -#else - ivas_HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, - core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); -#endif } /*-------------------------------------------------------------------------- @@ -944,45 +890,6 @@ void ivas_hq_core_dec_fx( move16(); } -#ifndef CLEANUP_HQ_CORE - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - test(); - IF( EQ_16( st_fx->bfi, 0 ) && st_fx->prev_bfi == 0 ) - { - Copy_Scale_sig( hHQ_core->old_out_fx + N_ZERO_NB, hHQ_nbfec->prev_oldauOut_fx, output_frame - N_ZERO_NB, negate( hHQ_core->Q_old_wtda ) ); /* 31 - exp_old_out - Q_old_wtda */ - } - ELSE IF( EQ_16( st_fx->prev_bfi, 1 ) ) - { - set16_fx( hHQ_nbfec->prev_oldauOut_fx, 0, output_frame ); - } - - test(); - test(); - test(); - test(); - IF( ( EQ_16( st_fx->prev_bfi, 1 ) || EQ_16( st_fx->bfi, 1 ) ) && EQ_16( hHQ_core->old_is_transient[2], 0 ) && EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->last_codec_mode, MODE1 ) ) - { - time_domain_FEC_HQ_fx( st_fx, wtda_audio, synth, mean_en_high_fx, output_frame, Q_synth ); - } - ELSE - { - window_ola_fx( wtda_audio, synth, Q_synth, hHQ_core->old_out_fx, &hHQ_core->Q_old_wtda, output_frame, - st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx ); - hHQ_nbfec->phase_mat_next = 0; - move16(); - } - - test(); - test(); - IF( ( EQ_16( st_fx->bfi, 0 ) && EQ_16( st_fx->prev_bfi, 0 ) ) || !( GE_16( output_frame, L_FRAME16k ) ) ) - { - preecho_sb_fx( st_fx->core_brate, wtda_audio, Q_audio, synth, *Q_synth, output_frame, &hHQ_core->memfilt_lb_fx, - &hHQ_core->mean_prev_hb_fx, &hHQ_core->smoothmem_fx, &hHQ_core->mean_prev_fx, &hHQ_core->mean_prev_nc_fx, &hHQ_core->wmold_hb_fx, &hHQ_core->prevflag, &hHQ_core->pastpre, st_fx->bwidth ); - } - } - ELSE -#endif { test(); IF( EQ_16( st_fx->bfi, 1 ) && GE_16( output_frame, L_FRAME16k ) ) @@ -1018,29 +925,6 @@ void ivas_hq_core_dec_fx( } } -#ifndef CLEANUP_HQ_CORE - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->hPlcInfo->concealment_method, TCX_NONTONAL ) && LT_32( st_fx->hPlcInfo->nbLostCmpt, 4 ) ) - { - st_fx->hPlcInfo->recovery_gain = shl_sat( st_fx->hPlcInfo->recovery_gain, *Q_synth ); /* Q15 */ - move16(); - IF( st_fx->hTonalMDCTConc->q_lastPcmOut != 0 ) - { - Scale_sig( st_fx->hTonalMDCTConc->secondLastPcmOut, shr( st_fx->hPlcInfo->L_frameTCX, 1 ), negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) ); - Scale_sig( st_fx->hTonalMDCTConc->lastPcmOut, st_fx->hPlcInfo->L_frameTCX, negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) ); - st_fx->hTonalMDCTConc->q_lastPcmOut = 0; - move16(); - } - waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth, 0, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi ); - } -#endif IF( GE_16( output_frame, L_FRAME16k ) ) { IF( EQ_16( hHQ_core->ph_ecu_HqVoicing, 1 ) ) @@ -1067,14 +951,6 @@ void ivas_hq_core_dec_fx( move16(); } -#ifndef CLEANUP_HQ_CORE - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - Copy32( wtda_audio, hHQ_nbfec->oldIMDCTout_fx, L_FRAME8k / 2 ); /* q_wtda */ - Copy( &hHQ_nbfec->old_auOut_2fr_fx[output_frame], hHQ_nbfec->old_auOut_2fr_fx, output_frame ); /* Q_old_auOut */ - Copy_Scale_sig( synth, &hHQ_nbfec->old_auOut_2fr_fx[output_frame], output_frame, negate( *Q_synth ) ); /* Q0 */ - } -#endif /* prepare synthesis output buffer (as recent as possible) for HQ FEC */ { diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index 46f8546fd..6c4aa6bf4 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -505,11 +505,7 @@ void hq_core_enc_ivas_fx( move16(); IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) { -#ifdef CLEANUP_HQ_CORE /* this cannot happen in IVAS */ -#else - hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient ); -#endif } ELSE { diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 8111d21c3..b2b7ac9cb 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -22,33 +22,6 @@ static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_a static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[] /*Q12*/, Word32 L_y2[] /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint /*Q29*/, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits ); -#ifndef CLEANUP_HQ_CORE -static Word16 p2a_threshold_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th /*Q11*/, Word16 *p2a_flags ); -static void mdct_spectrum_fine_gain_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_ybuf[], /* i : Q12 : input spectrum */ - Word32 L_y2[], /* i/o: Q12 : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 k_sort[], /* i : Q0 : sort table by band_energy */ - const Word16 bands, /* i : Q0 : nubmber of subbands */ - const Word32 L_qint, /* i : Q29 : */ - const Word16 Ngq, /* i : Q0 : */ - const Word16 gqlevs, /* i : Q0 : quantized level */ - const Word16 gqbits /* i : Q0 : quantized bits */ -); - -static Word16 band_energy_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word32 *L_t_audio, /* Q12 */ - const Word16 band_start[], /* Q0 */ - const Word16 band_end[], /* Q0 */ - Word32 L_band_energy[], /* Q14 */ - const Word16 bands_fx, /* Q0 */ - const Word32 L_qint, /* Q29 */ - const Word16 eref_fx, /* Q10 */ - const Word16 is_transient /* Q0 */ ); -#endif /*--------------------------------------------------------------------------* @@ -128,78 +101,6 @@ static void spt_shorten_domain_set_fx( return; } -#ifndef CLEANUP_HQ_CORE -static void spt_shorten_domain_set_ivas_fx( - Encoder_State *st_fx, /* i: encoder state structure */ - const Word32 L_t_audio[], /* i: input spectrum Q12*/ - const Word16 p2a_flags[], /* i: p2a anlysis information Q0*/ - const Word16 new_band_start[], /* i: new band start position Q0*/ - const Word16 new_band_end[], /* i: new band end position Q0*/ - const Word16 new_band_width[], /* i: new subband band width Q0*/ - const Word16 bands, /* i: total number of subbands Q0*/ - Word16 band_start[], /* i/o: band start position Q0*/ - Word16 band_end[], /* i/o: band end position Q0*/ - Word16 band_width[], /* i: sub band band width Q0*/ - Word16 *bit_budget /* i/o: bit budget Q0*/ -) -{ - Word16 i, j, k; - Word16 kpos; - Word32 L_max_y2; - Word16 max_y2_pos; - Word16 spt_shorten_flag[SPT_SHORTEN_SBNUM]; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - - kpos = 0; - j = 0; - move16(); - move16(); - FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ ) - { - IF( EQ_16( p2a_flags[k], 1 ) ) - { - spt_shorten_flag[j] = 0; - move16(); - IF( hHQ_core->prev_SWB_peak_pos[kpos] != 0 ) - { - L_max_y2 = L_deposit_l( 0 ); - max_y2_pos = 0; - move16(); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - IF( LT_32( L_max_y2, L_abs( L_t_audio[i] ) ) ) - { - L_max_y2 = L_abs( L_t_audio[i] ); /* Q12 */ - move32(); - max_y2_pos = i; - move16(); - } - } - test(); - IF( GE_16( max_y2_pos, new_band_start[j] ) && LE_16( max_y2_pos, new_band_end[j] ) ) - { - band_start[k] = new_band_start[j]; /* Q0 */ - move16(); - band_end[k] = new_band_end[j]; /* Q0 */ - move16(); - band_width[k] = new_band_width[j]; /* Q0 */ - move16(); - spt_shorten_flag[j] = 1; - move16(); - } - } - push_indice( st_fx->hBstr, IND_HQ2_SPT_SHORTEN, spt_shorten_flag[j], 1 ); - *bit_budget = sub( *bit_budget, 1 ); /* Q0 */ - move16(); - } - - kpos += 1; - j += 1; - } - - return; -} -#endif /*--------------------------------------------------------------------------* * hq_lr_enc_fx() @@ -1100,1400 +1001,107 @@ void hq_lr_enc_fx( return; } -#ifndef CLEANUP_HQ_CORE -void hq_lr_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 L_t_audio[], /* i/o: transform-domain coefs. Q12*/ - const Word16 inner_frame, /* i : inner frame length Q0*/ - Word16 *num_bits, /* i/o: number of available bits Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ -) -{ - Word16 i; - Word16 bit_budget, pbits; - Word16 bands, length, ni_seed, gqlevs, gqbits, Ngq, p2a_bands; - Word16 p2a_flags[BANDS_MAX]; - Word16 band_start[BANDS_MAX], band_end[BANDS_MAX], band_width[BANDS_MAX]; - Word32 L_band_energy[BANDS_MAX]; - Word16 ebits_fx; - - Word32 Rk_fx[BANDS_MAX]; - Word16 k1_step_fx, k2_step_fx; - Word16 k1_fx, k2_fx; - - Word32 L_qint; /* Q29 */ - Word16 eref_fx; /* Q10 */ - Word16 bit_alloc_weight_fx; /* Q13 */ - Word16 k_sort[BANDS_MAX]; - Word16 npulses[BANDS_MAX]; - Word32 inp_vector[L_FRAME48k]; - - Word16 ld_slope_fx /*, Qldslope=15*/; - Word16 p2a_th_fx /*, Qp2ath=11*/; - Word16 pd_thresh_fx /*, Qpdth=15*/; - Word16 ni_coef_fx /*, Qnicoef=14*/; - - Word32 L_y2[L_FRAME48k]; - Word32 L_y2_ni[L_FRAME48k]; - - Word16 hqswb_clas; - Word16 lowlength; - Word16 highlength; - Word16 exp_norm; - Word32 L_m[L_FRAME32k]; - - Word16 har_bands; - - Word16 lowband, highband, bw_low = 0, bw_high = 20; - move16(); - move16(); - - Word32 bwe_br; - Word16 trans_bit, p2a_flags_tmp[BANDS_MAX]; - Word16 adjustFlag = 0; - move16(); - Word16 prev_SWB_peak_pos_tmp[SPT_SHORTEN_SBNUM]; - Word16 k, j; - Word16 flag_spt; - Word16 org_band_start[SPT_SHORTEN_SBNUM]; - Word16 org_band_end[SPT_SHORTEN_SBNUM]; - Word16 org_band_width[SPT_SHORTEN_SBNUM]; - Word16 new_band_start[SPT_SHORTEN_SBNUM]; - Word16 new_band_end[SPT_SHORTEN_SBNUM]; - Word16 new_band_width[SPT_SHORTEN_SBNUM]; - Word16 bws_cnt = 0; - move16(); - Word32 L_tmp, L_tmp2, L_tmp3; - Word16 exp, tmp, exp2, tmp1, tmp2, tmp3, alpha_fx, frac1; - Word32 enerH_fx; - Word32 enerL_fx; - Word32 Ep_fx[BANDS_MAX]; - Word32 Ep_avrg_fx, Ep_vari_fx; - Word32 Ep_avrgL_fx; - Word32 Ep_peak_fx; - Word32 Ep_tmp_fx[BANDS_MAX]; - Word16 gama_fx; /*Q15 0.85f; */ - Word16 beta_fx; /*Q14 1.05f; */ - Word32 L_band_energy_tmp[BANDS_MAX]; - UWord16 lo; - Word16 Q_band_energy; - BSTR_ENC_HANDLE hBstr = st->hBstr; - HQ_ENC_HANDLE hHQ_core = st->hHQ_core; - set32_fx( L_y2, 0x0L, L_FRAME48k ); - set32_fx( inp_vector, 0, inner_frame ); - flag_spt = 0; - move16(); - set16_fx( prev_SWB_peak_pos_tmp, 0, SPT_SHORTEN_SBNUM ); - adjustFlag = 0; - move16(); - bw_low = 0; - move16(); - bw_high = 20; - move16(); - enerL_fx = L_deposit_l( 0 ); - enerH_fx = L_deposit_l( 0 ); +/*--------------------------------------------------------------------------* + * small_symbol_enc_tran() + * + * Huffman encoding of differential energies, estimating or packing bits + * if flag_pack = 0, LC mode info. is output else LC mode info. is input + * if flag_pack = 0, estimatng else packing bits + *--------------------------------------------------------------------------*/ +static Word16 small_symbol_enc_tran_fx( /* o : bits */ + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode, /* i/o: LC mode info Q0*/ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ + const Word16 is_transient /* Q0 */ ) +{ + Word16 i, bits; + Word16 difidx[BANDS_MAX]; - bwe_br = st->core_brate; - hqswb_clas = HQ_NORMAL; - move16(); + FOR( i = 0; i < BANDS; i++ ) + { + difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */ + move16(); + } - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) + FOR( i = 0; i < BANDS; ++i ) { - IF( EQ_16( is_transient, 1 ) ) - { - hqswb_clas = HQ_TRANSIENT; /* Q0 */ - move16(); - } - ELSE + test(); + IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 ) { - hqswb_clas = peak_avrg_ratio_fx( st->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */ + /* Huffman cannot encode this vector */ + return -1; } + } - /* write the classification information into the bitstream */ - push_indice( hBstr, IND_HQ2_SWB_CLAS, hqswb_clas, 2 ); - ( *num_bits ) = sub( *num_bits, 2 ); - move16(); - IF( EQ_16( hqswb_clas, HQ_NORMAL ) ) - { - flag_spt = 1; - move16(); - } + /* Preparing lossless coding input */ + IF( flag_pack == 0 ) + { + /* estimating # of bits */ + bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */ + bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ } ELSE { - /* write the transient bit into the bitstream */ - push_indice( st->hBstr, IND_HQ2_SWB_CLAS, is_transient, 1 ); - - /* subtract one bit for the transient flag */ - ( *num_bits ) = sub( *num_bits, 1 ); + bits = 0; move16(); + encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); } - /* Configure encoder for different bandwidths, bitrates, etc. */ + return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ +} - hq2_core_configure_fx( inner_frame, *num_bits, is_transient, &bands, &length, band_width, band_start, band_end, - &L_qint, &eref_fx, &bit_alloc_weight_fx, &gqlevs, &Ngq, &p2a_bands, &p2a_th_fx, &pd_thresh_fx, &ld_slope_fx, &ni_coef_fx, bwe_br ); +/*--------------------------------------------------------------------------* + * small_symbol_enc() + * + * Huffman encoding of differential energies, estimating or packing bits + * if flag_pack = 0, LC mode info. is output else LC mode info. is input + * if flag_pack = 0, estimatng else packing bits + *--------------------------------------------------------------------------*/ + +/* o : bits */ +static Word16 small_symbol_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode, /* i/o: LC mode info Q0*/ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ + const Word16 is_transient /* Q0 */ ) +{ + Word16 i, bits; + Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; - highlength = band_end[( bands - 1 )]; /* Q0 */ - move16(); - har_bands = bands; /* Q0 */ + /* Preparing lossless coding input */ + difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */ move16(); - - test(); - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && is_transient == 0 && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) + FOR( i = 1; i < BANDS; ++i ) { - /* reserve bits for HQ_NORMAL2 and HQ_HARMONIC modes */ - test(); - IF( EQ_16( hqswb_clas, HQ_NORMAL ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - ( *num_bits ) = sub( *num_bits, get_usebit_npswb_fx( hqswb_clas ) ); - move16(); - } + difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */ + move16(); } - test(); - test(); - IF( ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( st->bwidth, SWB ) ) + FOR( i = 0; i < BANDS; ++i ) { - IF( NE_16( hHQ_core->prev_hqswb_clas, HQ_NORMAL ) ) + test(); + IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 ) { - j = 0; - move16(); - FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ ) - { - hHQ_core->prev_SWB_peak_pos[j] = 0; - move16(); - j += 1; - } + /* Huffman cannot encode this vector */ + return -1; } } - test(); - IF( GT_16( inner_frame, length ) && is_transient ) + /* splitting MSB and LSB */ + FOR( i = 0; i < BANDS; ++i ) { - /* If so, collapse transient frame (4 short transforms) to remove uncoded coefficients */ - - k1_step_fx = shr( length, 2 ); /* k1 = length/NUM_TIME_SWITCHING_BLOCKS Q0*/ - k2_step_fx = shr( inner_frame, 2 ); /* k2 = inner_frame/NUM_TIME_SWITCHING_BLOCKS Q0*/ - k1_fx = k1_step_fx; /* Q0 */ - k2_fx = k2_step_fx; /* Q0 */ + LSB[i] = s_and( difidx[i], 1 ); /* Q0 */ move16(); + difidx[i] = shr( difidx[i], 1 ); /* Q0 */ move16(); - FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) - { - /*k1 = i*length/NUM_TIME_SWITCHING_BLOCKS; */ - /*k2 = i*inner_frame/NUM_TIME_SWITCHING_BLOCKS; */ - - Copy32( &L_t_audio[k2_fx], &L_t_audio[k1_fx], k1_step_fx ); /* Q12 */ - - k1_fx = add( k1_fx, k1_step_fx ); - k2_fx = add( k2_fx, k2_step_fx ); - } - } - - /* Spectral energy calculation/quantization */ - - ebits_fx = band_energy_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, L_band_energy, bands, - L_qint, eref_fx, is_transient ); /* Q0 */ - - /* First pass bit budget for TCQ of spectral band information */ - exp_norm = norm_s( gqlevs ); /* gqbits_fx = (short int) log2_f ((float) gqlevs_fx); */ - gqbits = sub( 14, exp_norm ); - - bit_budget = sub( sub( *num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq, gqbits ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/ - - - pbits = 0; - move16(); - - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) - { - IF( EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - set16_fx( p2a_flags, 1, har_bands ); - } - ELSE - { - /* High band tonality detector based on per band peak-to-average ratio */ - pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */ - bit_budget = sub( bit_budget, pbits ); - - IF( EQ_16( hqswb_clas, HQ_NORMAL ) ) - { - return_bits_normal2_fx( &bit_budget, p2a_flags, bands, bits_lagIndices_modeNormal ); - } - } - } - ELSE - { - /* High band tonality detector based on per band peak-to-average ratio */ - pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */ - bit_budget = sub( bit_budget, pbits ); - } - - IF( EQ_16( flag_spt, 1 ) ) - { - /* initialize the desired parameters for SPT */ - spt_shorten_domain_band_save_fx( bands, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width ); - spt_shorten_domain_pre_fx( band_start, band_end, hHQ_core->prev_SWB_peak_pos, bands, bwe_br, new_band_start, new_band_end, new_band_width ); - spt_shorten_domain_set_ivas_fx( st, L_t_audio, p2a_flags, new_band_start, new_band_end, new_band_width, bands, band_start, band_end, band_width, &bit_budget ); - } - -#define WMC_TOOL_SKIP - /* Estimate number of bits per band */ - Q_band_energy = SWB_BWE_LR_Qbe; - move16(); - FOR( i = 0; i < bands; i++ ) - { - L_tmp = L_shl( L_band_energy[i], sub( 16, Q_band_energy ) ); /*Q16 */ - - frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ - L_tmp = Pow2( 30, frac1 ); - exp = sub( exp, 30 ); - Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ - move32(); - } - - FOR( i = 0; i < bands; i++ ) - { - L_tmp2 = Ep_fx[i]; /* Q -6 */ - L_tmp = L_max( 1, L_tmp2 ); - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); /* Q -6 + exp - 16 */ - - L_tmp3 = L_deposit_l( band_width[i] ); /* Q0 */ - exp2 = norm_l( L_tmp3 ); - tmp2 = extract_h( L_shl( L_tmp3, exp2 ) ); /* exp2 - 16 */ - - exp2 = sub( exp, exp2 ); /* Denormalize and substract */ - - tmp3 = sub( tmp2, tmp ); - IF( tmp3 > 0 ) - { - tmp2 = shr( tmp2, 1 ); - } - IF( tmp3 > 0 ) - { - exp2 = add( exp2, 1 ); - } - tmp = div_s( tmp2, tmp ); /* Q15 */ - L_tmp = L_deposit_h( tmp ); /* Q31 */ - L_tmp = Isqrt_lc1( L_tmp, &exp2 ); /*Q(31-exp2) */ - move32(); - Ep_tmp_fx[i] = L_shr( L_tmp, sub( 15, exp2 ) ); /*Q16 */ - move32(); - } -#undef WMC_TOOL_SKIP - - test(); - test(); - test(); - test(); - test(); - test(); - IF( is_transient == 0 && EQ_16( inner_frame, L_FRAME8k ) && LE_32( st->core_brate, ACELP_13k20 ) ) - { -#define WMC_TOOL_SKIP - lowband = 6; - move16(); - trans_bit = 2; - move16(); - bit_budget = sub( bit_budget, trans_bit ); - gama_fx = 27852; /*Q15 0.85f */ - beta_fx = 17203; /*Q14 1.05f */ - move16(); - move16(); - set_s( &p2a_flags_tmp[bands - trans_bit], 0, 2 ); - - IF( EQ_32( st->core_brate, ACELP_13k20 ) ) - { - beta_fx = 13107; /* Q14 1.25f */ - move16(); - gama_fx = 31130; /* 0.95f Q15 */ - move16(); - mvs2s( &p2a_flags[( bands - trans_bit )], &p2a_flags_tmp[( bands - trans_bit )], trans_bit ); - } - - /* calculate the the low band/high band energy and the variance/avrage of the envelopes */ - Ep_vari_fx = 0; - move32(); - Ep_avrg_fx = 0; - move32(); - Ep_avrgL_fx = 0; - move32(); - Ep_peak_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - IF( sub( i, lowband ) >= 0 ) - { - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - ELSE - { - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ - IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) - { - Ep_peak_fx = Ep_tmp_fx[i]; /*Q15 */ - move32(); - } - } - } - /* modify the last p2a_bands subbands band_energies */ - k = bands; - move16(); - mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */ - Mpy_32_16_ss( Ep_peak_fx, 24576, &L_tmp, &lo ); - Mpy_32_16_ss( Ep_peak_fx, shl( sub( bands, lowband ), 9 ), &L_tmp2, &lo ); - Mpy_32_16_ss( Ep_avrg_fx, 1126, &L_tmp3, &lo ); - - test(); - test(); - test(); - IF( ( ( L_sub( L_tmp, L_shr( Ep_avrgL_fx, 1 ) ) < 0 && EQ_32( st->core_brate, ACELP_13k20 ) ) || LT_32( st->core_brate, ACELP_13k20 ) ) && - L_sub( L_tmp2, L_tmp3 ) < 0 && L_sub( L_tmp2, L_shr( Ep_avrg_fx, 7 ) ) > 0 ) - { - FOR( i = lowband; i < bands; i++ ) - { - Mpy_32_16_ss( Ep_avrg_fx, 24576, &L_tmp, &lo ); - IF( L_sub( L_shr( Ep_tmp_fx[i], 1 ), L_tmp ) < 0 ) - { - Mpy_32_16_ss( Ep_peak_fx, sub( bands, lowband ), &L_tmp, &lo ); - tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-4 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +4 = 15) */ - L_tmp2 = L_add( L_tmp, 13107 ); /*15 */ - tmp2 = extract_l( L_min( L_max( L_tmp2, 16384 ), gama_fx ) ); /*15 = 15 */ - Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_band_energy_tmp[i], &lo ); - } - } - } - ELSE - { - j = 0; - move16(); - FOR( i = ( bands - trans_bit ); i < bands; i++ ) - { - alpha_fx = 16384; /*Q14 */ - move16(); - IF( sub( p2a_flags_tmp[i], 1 ) == 0 ) - { - Mpy_32_16_ss( Ep_tmp_fx[i], sub( bands, lowband ), &L_tmp, &lo ); - tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-4 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_vari_fx, 3277, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ - - tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */ - IF( tmp2 != 0 ) - { - exp = norm_s( tmp2 ); - tmp2 = shl( tmp2, exp ); /*Q(exp) */ - tmp2 = div_s( 16384, tmp2 ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp2 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_vari_fx, 6554, &L_tmp2, &lo ); - Mpy_32_16_ss( L_tmp2, tmp2, &L_tmp2, &lo ); - L_tmp2 = L_shl( L_tmp2, sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ - L_tmp = L_min( L_tmp, L_tmp2 ); /*14 */ - tmp = extract_l( L_min( L_tmp, 13107 ) ); /*14 */ - alpha_fx = add( 16384, tmp ); /* Q14 */ - } - IF( sub( hHQ_core->last_bitalloc_max_band[j++], 1 ) == 0 ) - { - Mpy_32_16_ss( Ep_tmp_fx[i], sub( bands, lowband ), &L_tmp, &lo ); - tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-2 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); - L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ - L_tmp = L_max( L_tmp, 16384 ); /*14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ - } - ELSE - { - tmp2 = extract_h( Ep_avrg_fx ); /*13 -16 =-3 */ - IF( tmp2 != 0 ) - { - exp = norm_s( tmp2 ); - tmp2 = shl( tmp2, exp ); /*Q(exp) */ - tmp2 = div_s( 16384, tmp2 ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp2 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_tmp_fx[i], tmp2, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ - Mpy_32_16_ss( L_tmp, shl( sub( bands, lowband ), 9 ), &L_tmp, &lo ); - L_tmp = L_max( L_tmp, 13926 ); /*14 */ - tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =14 */ - } - Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q(Q_band_energy+14-15 +1= Q_band_energy) */ - move32(); - } - } - lowband = 3; - move16(); - Ep_avrg_fx = 0; - move32(); - Ep_avrgL_fx = 0; - move32(); - Ep_peak_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - IF( sub( i, lowband ) >= 0 ) - { - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - ELSE - { - Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */ - IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) - { - Ep_peak_fx = Ep_tmp_fx[i]; /*Q13 */ - move32(); - } - } - } - Mpy_32_16_ss( Ep_peak_fx, 28262, &L_tmp, &lo ); - Mpy_32_16_ss( Ep_avrgL_fx, 24576, &L_tmp2, &lo ); - - test(); - test(); - IF( L_sub( L_shr( Ep_avrg_fx, 2 ), L_tmp2 ) > 0 && L_sub( L_shr( Ep_avrg_fx, 4 ), L_tmp2 ) < 0 && L_sub( L_tmp, Ep_avrgL_fx ) > 0 ) - { - adjustFlag = 1; - move16(); - FOR( i = 0; i < lowband; i++ ) - { - tmp = extract_h( Ep_avrgL_fx ); /*Q-4 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); - L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ - tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ - Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ - move32(); - } - } -#undef WMC_TOOL_SKIP - - - hq2_bit_alloc_fx( L_band_energy_tmp, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient ); - - /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ - FOR( i = 0; i < 2; i++ ) - { - push_indice( hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); - } - } - ELSE IF( is_transient == 0 && EQ_16( inner_frame, L_FRAME16k ) ) - { -#define WMC_TOOL_SKIP - bit_budget = sub( bit_budget, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not */ - FOR( i = 0; i < bands; i++ ) - { - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ - move32(); - } - IF( EQ_32( st->core_brate, ACELP_13k20 ) ) - { - lowband = 8; - move16(); - highband = 15; - move16(); - bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */ - bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */ - } - ELSE - { - lowband = 8; - move16(); - highband = 16; - move16(); - bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */ - bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */ - } - /* calculate the the low band/high band energy and the variance/avrage of the envelopes */ - enerL_fx = 0; - move32(); - enerH_fx = 0; - move32(); - Ep_vari_fx = 0; - move32(); - Ep_avrg_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - test(); - IF( sub( i, lowband ) >= 0 && add( sub( i, bands ), p2a_bands ) < 0 ) - { - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - - IF( sub( i, highband ) >= 0 ) - { - enerH_fx = L_add( enerH_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ - } - ELSE IF( sub( i, lowband ) >= 0 ) - { - enerL_fx = L_add( enerL_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ - } - } - /* modify the last p2a_bands subbands band_energies */ - k = bands; - move16(); - mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */ - - L_tmp = L_max( enerH_fx, enerL_fx ); - tmp = s_max( bw_low, bw_high ); - i = norm_l( L_tmp ); - j = norm_s( tmp ); - Mpy_32_16_ss( L_shl( enerH_fx, i ), shl( bw_low, j ), &L_tmp, &lo ); - Mpy_32_16_ss( L_shl( enerL_fx, i ), shl( bw_high, j ), &L_tmp2, &lo ); - L_tmp2 = L_sub( L_tmp, L_tmp2 ); - - FOR( i = ( bands - p2a_bands ); i < bands; i++ ) - { - test(); - IF( sub( p2a_flags[i], 1 ) == 0 || L_tmp2 > 0 ) - { - tmp = sub( bands, p2a_bands ); - tmp = sub( tmp, lowband ); /*Q0 */ - - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ - IF( tmp1 != 0 ) - { - exp = norm_s( tmp1 ); - tmp1 = shl( tmp1, exp ); /*Q(exp) */ - tmp1 = div_s( 16384, tmp1 ); /*Q(15+14-exp = 29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp1 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_tmp_fx[i], tmp1, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, 16384, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 32, exp ) ); /*Q15 */ - tmp = extract_l( L_min( L_tmp, 6554 ) ); /*Q15 */ - Mpy_32_16_ss( Ep_vari_fx, tmp1, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 15, exp ) ); /*Q15 */ - tmp = extract_l( L_shr( L_min( L_tmp, 13107 ), 1 ) ); /*Q14 */ - alpha_fx = add( tmp, 16384 ); /*Q14 */ - } - ELSE - { - alpha_fx = 16384; /* Q14 */ - move16(); - } - - IF( add( sub( i, bands ), p2a_bands ) > 0 ) - { - tmp = sub( bands, p2a_bands ); - IF( sub( hHQ_core->last_bitalloc_max_band[( i - ( tmp + 1 ) )], 1 ) == 0 ) - { - tmp = sub( tmp, lowband ); - Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q14 */ - tmp = extract_l( L_min( L_max( L_tmp, 16384 ), 20480 ) ); /*Q14 */ - L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14*/ - } - ELSE - { - tmp = sub( tmp, lowband ); - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ - IF( tmp1 != 0 ) - { - exp = norm_s( tmp1 ); - tmp1 = shl( tmp1, exp ); /*Q(exp) */ - tmp1 = div_s( 16384, tmp1 ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp1 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_tmp_fx[i], tmp1, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 29, exp ) ); /*Q14 */ - tmp = extract_l( L_min( L_max( L_tmp, 13926 ), 16384 ) ); /*Q14 */ - L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ - } - } - Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q Q_band_energy */ - move32(); - } - lowband = 6; - move16(); - Ep_avrg_fx = 0; - move32(); - Ep_avrgL_fx = 0; - move32(); - Ep_peak_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - IF( sub( i, lowband ) >= 0 ) - { - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - ELSE - { - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ - IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) - { - Ep_peak_fx = Ep_tmp_fx[i]; /* Q15 */ - move32(); - } - } - } - - Mpy_32_16_ss( Ep_peak_fx, 24576, &L_tmp, &lo ); - Mpy_32_16_ss( Ep_peak_fx, 19661, &L_tmp2, &lo ); - Mpy_32_16_ss( Ep_avrgL_fx, 24576, &L_tmp3, &lo ); - - test(); - test(); - test(); - test(); - test(); - IF( ( L_sub( L_shr( Ep_avrgL_fx, 1 ), Ep_avrg_fx ) > 0 && L_sub( L_tmp, L_shr( Ep_avrgL_fx, 2 ) ) > 0 && L_sub( L_shr( Ep_avrgL_fx, 1 ), L_tmp2 ) < 0 ) || - ( L_sub( L_shr( Ep_avrg_fx, 1 ), Ep_avrgL_fx ) > 0 && L_sub( L_shr( Ep_avrg_fx, 3 ), L_tmp3 ) < 0 && L_sub( L_tmp, L_shr( Ep_avrgL_fx, 2 ) ) > 0 ) ) - { - adjustFlag = 1; - move16(); - FOR( i = 0; i < lowband; i++ ) - { - tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 28, exp ) ); /*Q14 0.5 */ - tmp = extract_l( L_min( L_tmp, 19661 ) ); /*Q14 */ - Mpy_32_16_ss( L_band_energy_tmp[i], tmp, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ - move32(); - } - } -#undef WMC_TOOL_SKIP - - hq2_bit_alloc_fx( L_band_energy_tmp, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient ); - - /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ - FOR( i = 0; i < 2; i++ ) - { - push_indice( hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); - } - } - ELSE IF( EQ_16( st->bwidth, SWB ) && EQ_16( hqswb_clas, HQ_HARMONIC ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) - { - /* bit allocation for harmonic mode */ - hq2_bit_alloc_har_fx( L_band_energy, bit_budget, bands, Rk_fx, p2a_bands, bwe_br, p2a_flags, band_width ); - } - ELSE - { - - /* estimate number of bits per band */ - hq2_bit_alloc_fx( L_band_energy, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient ); - } - - tcq_core_LR_enc_ivas_fx( hBstr, inp_vector, L_t_audio, L_y2, bit_budget, bands, band_start, band_end, band_width, Rk_fx, npulses, k_sort, p2a_flags, p2a_bands, hHQ_core->last_bitalloc_max_band, inner_frame, adjustFlag, is_transient ); - - test(); - test(); - IF( ( EQ_16( inner_frame, L_FRAME8k ) && LE_32( st->core_brate, ACELP_13k20 ) ) || EQ_16( inner_frame, L_FRAME16k ) ) - { - j = 0; - FOR( i = 2; i > 0; i-- ) - { - IF( npulses[bands - i] > 0 ) - { - hHQ_core->last_bitalloc_max_band[j] = 1; - move16(); - } - ELSE - { - hHQ_core->last_bitalloc_max_band[j] = 0; - move16(); - } - j++; - } - } - - /* Denormalize the coded MDCT spectrum */ - mdct_spectrum_denorm_ivas_fx( inp_vector, L_y2, band_start, band_end, band_width, L_band_energy, npulses, bands, ld_slope_fx, pd_thresh_fx ); - - /* Apply fine gain quantization to denormalized coded spectrum */ - mdct_spectrum_fine_gain_enc_ivas_fx( st, L_t_audio, L_y2, band_start, band_end, k_sort, bands, L_qint, Ngq, gqlevs, gqbits ); - - /* reStore the subband information*/ - IF( EQ_16( flag_spt, 1 ) ) - { - spt_shorten_domain_band_restore_fx( bands, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width ); - } - - /* Inject noise into components having relatively low pulse energy per band */ - ni_seed = add( add( add( npulses[0], npulses[1] ), npulses[2] ), npulses[3] ); /* Q0 */ - - Copy32( L_y2, L_y2_ni, band_end[bands - 1] + 1 ); /* Q12 */ - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) - { - test(); - IF( EQ_16( hqswb_clas, HQ_NORMAL ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - preset_hq2_swb_fx( hqswb_clas, band_end, &har_bands, p2a_bands, length, bands, &lowlength, &highlength, L_m ); - - swb_bwe_enc_lr_ivas_fx( st, L_y2, SWB_BWE_LR_Qs, L_t_audio, L_m, bwe_br, - bands, band_start, band_end, L_band_energy, SWB_BWE_LR_Qbe, p2a_flags, hqswb_clas, lowlength, highlength, - hHQ_core->prev_frm_index, har_bands, &hHQ_core->prev_frm_hfe2, &hHQ_core->prev_stab_hfe2, band_width, L_y2_ni, &ni_seed ); - - post_hq2_swb_fx( L_m, lowlength, highlength, hqswb_clas, har_bands, bands, p2a_flags, band_start, band_end, L_y2, npulses ); - - IF( EQ_16( hqswb_clas, HQ_NORMAL ) ) - { - spt_swb_peakpos_tmp_save_fx( L_y2, bands, band_start, band_end, prev_SWB_peak_pos_tmp ); - FOR( k = 0; k < SPT_SHORTEN_SBNUM; k++ ) - { - test(); - IF( p2a_flags[bands - SPT_SHORTEN_SBNUM + k] == 0 || npulses[bands - SPT_SHORTEN_SBNUM + k] == 0 ) - { - prev_SWB_peak_pos_tmp[k] = 0; - move16(); - } - } - } - Copy32( L_y2_ni, L_y2, lowlength ); /* Q12 */ - } - ELSE - { - Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* HQ_TRANSIENT Q12*/ - } - } - ELSE - { - Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* NB, WB Q12*/ - } - - updat_prev_frm_fx( L_y2, L_t_audio, bwe_br, length, inner_frame, bands, st->bwidth, is_transient, hqswb_clas, &hHQ_core->prev_hqswb_clas, hHQ_core->prev_SWB_peak_pos, prev_SWB_peak_pos_tmp, &hHQ_core->prev_frm_hfe2, &hHQ_core->prev_stab_hfe2, bws_cnt ); - - IF( NE_16( st->bwidth, SWB ) ) - { - /* reset HQ classifier memories */ - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - } - - - test(); - test(); - test(); - IF( NE_16( hqswb_clas, HQ_HARMONIC ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( st->bwidth, SWB ) ) - { - hHQ_core->prev_frm_index[0] = -1; - move16(); - hHQ_core->prev_frm_index[1] = -1; - move16(); - } - - /* update number of unused bits */ - *num_bits = 0; - move16(); - - hHQ_core->hvq_hangover = 0; - move16(); - - return; -} -#endif - -/*--------------------------------------------------------------------------* - * small_symbol_enc_tran() - * - * Huffman encoding of differential energies, estimating or packing bits - * if flag_pack = 0, LC mode info. is output else LC mode info. is input - * if flag_pack = 0, estimatng else packing bits - *--------------------------------------------------------------------------*/ - -static Word16 small_symbol_enc_tran_fx( /* o : bits */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX]; - - FOR( i = 0; i < BANDS; i++ ) - { - difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ - } - ELSE - { - bits = 0; - move16(); - encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} - -#ifndef CLEANUP_HQ_CORE -static Word16 small_symbol_enc_tran_ivas_fx( /* o : bits */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX]; - - FOR( i = 0; i < BANDS; i++ ) - { - difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ - } - ELSE - { - bits = 0; - move16(); - encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} -#endif - -/*--------------------------------------------------------------------------* - * small_symbol_enc() - * - * Huffman encoding of differential energies, estimating or packing bits - * if flag_pack = 0, LC mode info. is output else LC mode info. is input - * if flag_pack = 0, estimatng else packing bits - *--------------------------------------------------------------------------*/ - -/* o : bits */ -static Word16 small_symbol_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; - - /* Preparing lossless coding input */ - difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */ - move16(); - - FOR( i = 1; i < BANDS; ++i ) - { - difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* splitting MSB and LSB */ - FOR( i = 0; i < BANDS; ++i ) - { - LSB[i] = s_and( difidx[i], 1 ); /* Q0 */ - move16(); - difidx[i] = shr( difidx[i], 1 ); /* Q0 */ - move16(); - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - /* Encoding MSB bits */ - bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ - - /* Encoding LSB bit packing */ - bits = add( bits, BANDS ); /* Q0 */ - } - ELSE - { - /* Encoding MSB bits */ - bits = 0; - move16(); - encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); - - /* Encoding LSB bit packing */ - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); - } - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} - -#ifndef CLEANUP_HQ_CORE -static Word16 small_symbol_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; - - /* Preparing lossless coding input */ - difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */ - move16(); - - FOR( i = 1; i < BANDS; ++i ) - { - difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* splitting MSB and LSB */ - FOR( i = 0; i < BANDS; ++i ) - { - LSB[i] = s_and( difidx[i], 1 ); /* Q0 */ - move16(); - difidx[i] = shr( difidx[i], 1 ); /* Q0 */ - move16(); - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - /* Encoding MSB bits */ - bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies Q0*/ - - /* Encoding LSB bit packing */ - bits = add( bits, BANDS ); /* Q0 */ - } - ELSE - { - /* Encoding MSB bits */ - bits = 0; - move16(); - encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); - - /* Encoding LSB bit packing */ - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); - } - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} -#endif - -/* o : bits Q0 */ -static Word16 large_symbol_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode0, /* i/o: LC mode info Q0*/ - const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/ -) -{ - Word16 i, bits, tmp; - Word16 LSB1[BANDS_MAX]; - Word16 min_q, max_q, offset0; - Word16 min_bits, min_bits_pos; - Word16 tdifidx0[BANDS_MAX], tdifidx1[BANDS_MAX]; - Word16 basic_shift; - Word16 bitsmode0, bitsmode1; - Word16 lsbdepth1; - Word16 cnt_outlyer, pos_outlyer, cnt_outlyer0; - - min_q = 513; /* Q0 */ - move16(); - max_q = -1; - move16(); - - cnt_outlyer0 = 0; - move16(); - cnt_outlyer = 0; - move16(); - bitsmode0 = 0; - move16(); - bitsmode1 = 0; - move16(); - pos_outlyer = 0; - move16(); - lsbdepth1 = 0; - move16(); - - test(); - test(); - IF( flag_pack == 0 || ( EQ_16( flag_pack, 1 ) && *hLCmode0 == 0 ) ) - { - test(); - test(); - IF( GT_16( qbidx[0], sub( ABS_ENG_OFFSET, 1 ) ) || LT_16( qbidx[0], -ABS_ENG_OFFSET ) ) - { - cnt_outlyer0 = 2; - move16(); - } - ELSE IF( GT_16( qbidx[0], 3 ) || LT_16( qbidx[0], -4 ) ) - { - cnt_outlyer0 = 1; - move16(); - } - ELSE - { - cnt_outlyer0 = 0; - move16(); - } - - cnt_outlyer = 0; - move16(); - pos_outlyer = -1; - move16(); - FOR( i = 1; i < BANDS; ++i ) - { - test(); - IF( GT_16( qbidx[i], 3 ) || LT_16( qbidx[i], -4 ) ) - { - cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */ - pos_outlyer = i; - move16(); - } - - test(); - IF( GT_16( qbidx[i], ( ABS_ENG_OFFSET - 1 ) ) || LT_16( qbidx[i], -ABS_ENG_OFFSET ) ) - { - cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */ - } - } - - test(); - test(); - IF( cnt_outlyer0 == 0 && LE_16( cnt_outlyer, 1 ) ) - { - bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */ - move16(); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - /* 01 */ - bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */ - } - - FOR( i = 0; i < pos_outlyer; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - ELSE IF( EQ_16( cnt_outlyer0, 1 ) && LE_16( cnt_outlyer, 1 ) ) - { - bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */ - move16(); - tdifidx0[0] = qbidx[0]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - /* 11 */ - bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */ - } - ELSE - { - pos_outlyer = 0; - move16(); - } - - FOR( i = 1; i < pos_outlyer; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - ELSE - { - bitsmode0 = 20000; - move16(); - } - } - - test(); - IF( flag_pack == 0 || EQ_16( *hLCmode0, 1 ) ) - { - /* components 0 range : -256~255 */ - max_q = MINIMUM_ENERGY_LOWBRATE; - move16(); - min_q = MAXIMUM_ENERGY_LOWBRATE; - move16(); - FOR( i = 0; i < BANDS; ++i ) - { - max_q = s_max( qbidx[i], max_q ); - min_q = s_min( qbidx[i], min_q ); - } - - /* Counting bits for transmitting all components using same method */ - FOR( i = 0;; ++i ) - { - /*if (max_q <= ((2<<(i+1))-1) && min_q >= -(2<<(i+1))) */ - test(); - IF( LE_16( max_q, sub( shl( 2, add( i, 1 ) ), 1 ) ) && GE_16( min_q, -shl( 2, add( i, 1 ) ) ) ) - { - BREAK; - } - } - basic_shift = i; - move16(); - - min_bits = 1000; /* Q0 */ - move16(); - min_bits_pos = basic_shift; /* Q0 */ - move16(); - tmp = add( basic_shift, 3 ); - FOR( offset0 = basic_shift; offset0 < tmp; offset0++ ) - { - max_q = MINIMUM_ENERGY_LOWBRATE; - move16(); - min_q = MAXIMUM_ENERGY_LOWBRATE; - move16(); - - bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ - FOR( i = 0; i < BANDS; ++i ) - { - bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); - } - - IF( GT_16( min_bits, bitsmode1 ) ) - { - min_bits_pos = offset0; /* Q0 */ - move16(); - min_bits = bitsmode1; /* Q0 */ - move16(); - } - } - - bitsmode1 = min_bits; - move16(); - lsbdepth1 = min_bits_pos; - move16(); - - FOR( i = 0; i < BANDS; ++i ) - { - LSB1[i] = s_and( qbidx[i], sub( shl( 1, lsbdepth1 ), 1 ) ); - tdifidx1[i] = shr( qbidx[i], lsbdepth1 ); - move16(); - move16(); - } } /* Preparing lossless coding input */ @@ -2501,128 +1109,33 @@ static Word16 large_symbol_enc_fx( { /* estimating # of bits */ /* Encoding MSB bits */ - IF( LT_16( bitsmode0, bitsmode1 ) ) - { - bits = bitsmode0; /* Q0 */ - move16(); - *hLCmode0 = 0; - move16(); - } - ELSE - { - bits = bitsmode1; /* Q0 */ - move16(); - *hLCmode0 = 1; - move16(); - } + bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */ + bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ + + /* Encoding LSB bit packing */ + bits = add( bits, BANDS ); /* Q0 */ } ELSE - { - /* Encoding MSB bits */ - IF( *hLCmode0 == 0 ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE, 0, BITS_DE_8SMODE ); - bits = BITS_DE_8SMODE; - move16(); - IF( cnt_outlyer0 == 0 ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 0, BITS_DE_8SMODE_N0 ); - bits = add( bits, BITS_DE_8SMODE_N0 ); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - /* 01 */ - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); - bits = add( bits, BITS_DE_8SPOS ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - } - ELSE - { - /* 00 */ - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - } - - FOR( i = 0; i < pos_outlyer; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - ELSE IF( EQ_16( cnt_outlyer0, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); - bits = add( bits, BITS_DE_8SMODE_N0 ); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); - bits = add( bits, BITS_DE_8SPOS ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - } - ELSE - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); /* Q0 */ - } - - FOR( i = 1; i < pos_outlyer; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = pos_outlyer + 1; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - } - ELSE - { - bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); - push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); - - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); - bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */ - } + { + /* Encoding MSB bits */ + bits = 0; + move16(); + encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); - IF( lsbdepth1 > 0 ) - { - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); - } - /*bits += BANDS * lsbdepth1; */ - bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */ - } + /* Encoding LSB bit packing */ + FOR( i = 0; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); } } - return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ + return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } -#ifndef CLEANUP_HQ_CORE -static Word16 large_symbol_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + +/* o : bits Q0 */ +static Word16 large_symbol_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ const Word16 BANDS, /* i : number of bands Q0*/ Word16 *hLCmode0, /* i/o: LC mode info Q0*/ @@ -2709,7 +1222,7 @@ static Word16 large_symbol_enc_ivas_fx( IF( EQ_16( cnt_outlyer, 1 ) ) { /* 01 */ - bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) ); /* Q0 */ + bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */ } FOR( i = 0; i < pos_outlyer; ++i ) @@ -2719,7 +1232,7 @@ static Word16 large_symbol_enc_ivas_fx( bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ } - FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i ) + FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) { tdifidx0[i] = qbidx[i]; /* Q0 */ move16(); @@ -2732,7 +1245,7 @@ static Word16 large_symbol_enc_ivas_fx( move16(); tdifidx0[0] = qbidx[0]; /* Q0 */ move16(); - bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); /* Q0 */ + bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); IF( EQ_16( cnt_outlyer, 1 ) ) { /* 11 */ @@ -2751,7 +1264,7 @@ static Word16 large_symbol_enc_ivas_fx( bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ } - FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i ) + FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) { tdifidx0[i] = qbidx[i]; /* Q0 */ move16(); @@ -2760,7 +1273,7 @@ static Word16 large_symbol_enc_ivas_fx( } ELSE { - bitsmode0 = 20000; /* Q0 */ + bitsmode0 = 20000; move16(); } } @@ -2804,11 +1317,10 @@ static Word16 large_symbol_enc_ivas_fx( min_q = MAXIMUM_ENERGY_LOWBRATE; move16(); - bitsmode1 = ( BITS_DE_8SMODE + BITS_MAX_DEPTH ); /* Q0 */ - move16(); + bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ FOR( i = 0; i < BANDS; ++i ) { - bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); /* Q0 */ + bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); } IF( GT_16( min_bits, bitsmode1 ) ) @@ -2820,9 +1332,9 @@ static Word16 large_symbol_enc_ivas_fx( } } - bitsmode1 = min_bits; /* Q0 */ + bitsmode1 = min_bits; move16(); - lsbdepth1 = min_bits_pos; /* Q0 */ + lsbdepth1 = min_bits_pos; move16(); FOR( i = 0; i < BANDS; ++i ) @@ -2896,288 +1408,94 @@ static Word16 large_symbol_enc_ivas_fx( } } ELSE IF( EQ_16( cnt_outlyer0, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); - bits = add( bits, BITS_DE_8SMODE_N0 ); /* Q0 */ - IF( EQ_16( cnt_outlyer, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); - bits = add( bits, BITS_DE_8SPOS ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - } - ELSE - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); /* Q0 */ - } - - FOR( i = 1; i < pos_outlyer; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = pos_outlyer + 1; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - } - ELSE - { - bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); - push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); - push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); - - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); - bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */ - } - - IF( lsbdepth1 > 0 ) - { - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); - } - /*bits += BANDS * lsbdepth1; */ - bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */ - } - } - } - - return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} -#endif - -/*-------------------------------------------------------------------* - * band_energy_quant() - * - * - *-------------------------------------------------------------------*/ - -static Word16 band_energy_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ - const Word16 band_start[], /* i : Q0 : band start table */ - const Word16 band_end[], /* i : Q0 : band end table */ - Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */ - const Word16 bands_fx, /* i : Q0 : number of bands */ - const Word32 L_qint, /* i : Q29 */ - const Word16 eref_fx, /* i : Q10 */ - const Word16 is_transient_fx /* i : Q0 : indicator for HQ_TRANSIENT */ -) -{ - Word16 i, k; - Word16 ebits; - Word16 hLCmode0, hLCmode1, deng_bits; - Word16 deng_cmode = 0; - Word16 hbits; - move16(); - - Word32 L_E; - Word16 QE; - - Word16 rev_qint_fx; /* 1/qint */ - Word16 Qrev_qint; /* Q value for 1/qint */ - - Word16 bq0_fx; - Word16 bq1_fx[BANDS_MAX]; - Word16 bq2_fx[BANDS_MAX]; - - Word16 bq1_temp_fx[BANDS_MAX]; - Word16 bq2_temp_fx[BANDS_MAX]; - - Word32 L_tmp; - Word16 temp_fx; - Word16 frac, exp; - Word16 exp_safe; - Word16 exp_norm; - Word16 exp_norm2; - Word16 exp_normd; - - /* Calculate the band energies */ - exp_safe = 4; - move16(); /* 4: never overflow happen at L_E */ - FOR( k = 0; k < bands_fx; k++ ) - { - L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */ - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Qs */ - } - exp_norm = norm_l( L_tmp ); - exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */ - - QE = add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 ); - L_E = L_shl( 590L, sub( QE, 15 ) ); /* 590 0.018f(Q15 -> QE) */ - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - /*E += yos[i] * yos[i]; */ - temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Qs+exp_norm-16 */ - L_E = L_mac( L_E, temp_fx, temp_fx ); /* (Qs+exp_norm-16)*2+1 */ - } - - /*band_energy[k] = (float) log2_f (E + 1.0e-1f); */ - exp_norm2 = norm_l( L_E ); - exp = add( add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 ), exp_norm2 ); - L_E = L_shl( L_E, exp_norm2 ); /* (Qs+exp_norm-16)*2 + 1 + exp_norm2 */ - frac = Log2_norm_lc( L_E ); - exp = sub( 30, exp ); - L_tmp = L_Comp( exp, frac ); - L_band_energy[k] = L_shr( L_tmp, 2 ); /* Q16->Qbe(Q14) */ - move32(); - } - - IF( is_transient_fx ) - { - reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); - } - - - /* Quantize the reference and band energies */ - exp_normd = norm_l( L_qint ); - rev_qint_fx = div_s( 0x4000, round_fx( L_shl( L_qint, exp_normd ) ) ); /* Q14-(29+exp_normd-16)+15 */ - Qrev_qint = sub( 14 - ( 29 - 16 ) + 15, exp_normd ); - - bq0_fx = round_fx( L_shl( L_mult( eref_fx, rev_qint_fx ), sub( 5, Qrev_qint ) ) ); /* 16-(10+Qrev_qint+1) */ - FOR( k = 0; k < bands_fx; k++ ) - { - /*bq1[k] = round_f (band_energy[k] / qint); */ - L_tmp = Mpy_32_16_1( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */ - bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */ - move16(); - } - - IF( is_transient_fx ) - { - - Copy( bq1_fx, bq1_temp_fx, bands_fx ); /* Q0 */ - - /* Calculate the differential energies */ - diffcod_lrmdct_fx( bands_fx, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient_fx ); - } - - /* Calculate the differential energies */ - bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */ - move16(); - FOR( k = 1; k < bands_fx; k++ ) - { - bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */ - move16(); - } - - /* Modifying qbidx to be located in the range -256~255 */ - FOR( i = 0; i < bands_fx; ++i ) - { - IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) ) - { - bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */ - move16(); - } - IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) ) - { - bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */ - move16(); - } - } - - /* Get number of bits by Huffman0 coding */ - ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 ); /* Q0 */ - - IF( is_transient_fx ) - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ - } - ELSE - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ - } - - /* comparing used bits */ - test(); - IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) ) - { - deng_cmode = 0; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 ); - deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */ - } - ELSE - { - /* setting energy difference coding mode and storing it */ - deng_cmode = 1; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); + { + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); + bits = add( bits, BITS_DE_8SMODE_N0 ); + IF( EQ_16( cnt_outlyer, 1 ) ) + { + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); + bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ + push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); + bits = add( bits, BITS_DE_8SPOS ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + bits = add( bits, BITS_ABS_ENG ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + bits = add( bits, BITS_ABS_ENG ); + } + ELSE + { + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); + bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + bits = add( bits, BITS_ABS_ENG ); /* Q0 */ + } - deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */ + FOR( i = 1; i < pos_outlyer; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ + } - /* packing indice */ - IF( is_transient_fx ) - { - Copy( bq2_temp_fx, bq2_fx, bands_fx ); /* Q0 */ - small_symbol_enc_tran_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); + FOR( i = pos_outlyer + 1; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ + } + } } ELSE { - small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); - } - } - - /* Reconstruct quantized spectrum */ - bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */ - move16(); - FOR( k = 1; k < bands_fx; k++ ) - { - bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */ - move16(); - } + bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ + push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); + push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); - FOR( k = 0; k < bands_fx; k++ ) - { - L_band_energy[k] = Mpy_32_16_1( L_qint, bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */ - move32(); - } + FOR( i = 0; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); + bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */ + } - IF( is_transient_fx ) - { - reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); + IF( lsbdepth1 > 0 ) + { + FOR( i = 0; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); + } + /*bits += BANDS * lsbdepth1; */ + bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */ + } + } } - return ( deng_bits ); /* Q0 */ + return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } -#ifndef CLEANUP_HQ_CORE -static Word16 band_energy_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ - const Word16 band_start[], /* i : Q0 : band start table */ - const Word16 band_end[], /* i : Q0 : band end table */ - Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */ - const Word16 bands, /* i : Q0 : number of bands */ - const Word32 L_qint, /* i : Q29 */ - const Word16 eref_fx, /* i : Q10 */ - const Word16 is_transient /* i : Q0 : indicator for HQ_TRANSIENT */ + +/*-------------------------------------------------------------------* + * band_energy_quant() + * + * + *-------------------------------------------------------------------*/ + +static Word16 band_energy_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ + const Word16 band_start[], /* i : Q0 : band start table */ + const Word16 band_end[], /* i : Q0 : band end table */ + Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */ + const Word16 bands_fx, /* i : Q0 : number of bands */ + const Word32 L_qint, /* i : Q29 */ + const Word16 eref_fx, /* i : Q10 */ + const Word16 is_transient_fx /* i : Q0 : indicator for HQ_TRANSIENT */ ) { Word16 i, k; Word16 ebits; Word16 hLCmode0, hLCmode1, deng_bits; Word16 deng_cmode = 0; - move16(); Word16 hbits; + move16(); + Word32 L_E; Word16 QE; @@ -3197,13 +1515,12 @@ static Word16 band_energy_quant_ivas_fx( Word16 exp_safe; Word16 exp_norm; Word16 exp_norm2; - Word16 exp_normd; - /* Calculate the band energies */ + /* Calculate the band energies */ exp_safe = 4; move16(); /* 4: never overflow happen at L_E */ - FOR( k = 0; k < bands; k++ ) + FOR( k = 0; k < bands_fx; k++ ) { L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */ FOR( i = band_start[k]; i <= band_end[k]; i++ ) @@ -3233,254 +1550,135 @@ static Word16 band_energy_quant_ivas_fx( move32(); } - IF( is_transient ) + IF( is_transient_fx ) { - reverse_transient_frame_energies_fx( L_band_energy, bands ); + reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); } -#define WMC_TOOL_SKIP + + /* Quantize the reference and band energies */ exp_normd = norm_l( L_qint ); rev_qint_fx = div_s( 0x4000, round_fx( L_shl( L_qint, exp_normd ) ) ); /* Q14-(29+exp_normd-16)+15 */ Qrev_qint = sub( 14 - ( 29 - 16 ) + 15, exp_normd ); bq0_fx = round_fx( L_shl( L_mult( eref_fx, rev_qint_fx ), sub( 5, Qrev_qint ) ) ); /* 16-(10+Qrev_qint+1) */ - FOR( k = 0; k < bands; k++ ) + FOR( k = 0; k < bands_fx; k++ ) { /*bq1[k] = round_f (band_energy[k] / qint); */ - L_tmp = L_mls( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */ + L_tmp = Mpy_32_16_1( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */ bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */ move16(); } -#undef WMC_TOOL_SKIP - IF( is_transient ) + IF( is_transient_fx ) { - Copy( bq1_fx, bq1_temp_fx, bands ); /* Q0 */ + Copy( bq1_fx, bq1_temp_fx, bands_fx ); /* Q0 */ /* Calculate the differential energies */ - diffcod_lrmdct_fx( bands, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient ); /* Q0 */ + diffcod_lrmdct_fx( bands_fx, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient_fx ); } /* Calculate the differential energies */ bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */ move16(); - FOR( k = 1; k < bands; k++ ) + FOR( k = 1; k < bands_fx; k++ ) { bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */ move16(); } - /* Modifying qbidx to be located in the range -256~255 */ - FOR( i = 0; i < bands; ++i ) + FOR( i = 0; i < bands_fx; ++i ) { IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) ) { bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */ move16(); - } - IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) ) - { - bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */ - move16(); - } - } - - /* Get number of bits by Huffman0 coding */ - ebits = large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 0 ); /* Q0 */ - - IF( is_transient ) - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_tran_ivas_fx( hBstr, bq2_temp_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */ - } - ELSE - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */ - } - - test(); - IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) ) - { - deng_cmode = 0; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 1 ); - deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */ - } - ELSE - { - /* setting energy difference coding mode and storing it */ - deng_cmode = 1; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - - deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */ - - /* packing indice */ - IF( is_transient ) - { - Copy( bq2_temp_fx, bq2_fx, bands ); /* Q0 */ - small_symbol_enc_tran_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 1, is_transient ); - } - ELSE - { - small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 1, is_transient ); - } - } - - /* Reconstruct quantized spectrum */ - bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */ - move16(); - FOR( k = 1; k < bands; k++ ) - { - bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */ - move16(); - } - - FOR( k = 0; k < bands; k++ ) - { -#define WMC_TOOL_SKIP - L_band_energy[k] = L_mls( L_qint, (Word16) bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */ - move32(); -#undef WMC_TOOL_SKIP - } - - IF( is_transient ) - { - reverse_transient_frame_energies_fx( L_band_energy, bands ); - } - - return ( deng_bits ); /* Q0 */ -} -#endif - -/*-------------------------------------------------------------------* - * p2a_threshold_quant() - * - * - *-------------------------------------------------------------------*/ - -static Word16 p2a_threshold_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: : bit stream */ - const Word32 *L_t_audio, /* i : Q12 : input spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */ - const Word16 bands, /* i : Q0 : number of subbands */ - const Word16 p2a_bands, /* i : Q0 : tonality indicator */ - const Word16 p2a_th_fx, /* i : Q11 : threshold tonal or not */ - Word16 *p2a_flags_fx /* i/o: Q0 : tonality flag */ -) -{ - Word16 i, j, k; - Word32 L_a, L_p, L_e; - Word16 Qa; - Word32 L_tmp; - Word16 temp_fx; - Word16 exp_norm; - Word16 exp_safe; - Word16 exp_normn, exp_normd; - - Word16 norm_a_fx, Qnorm_a; - Word16 pa_fx, Qpa; - - Word16 exp, frac; - - Word32 L_p2a; - Word16 p2a_fx; - - exp_safe = 4; /* never happen overflow. */ - move16(); - - set16_fx( p2a_flags_fx, 1, bands ); - move16(); - - j = 0; - move16(); - FOR( k = ( bands - p2a_bands ); k < bands; k++ ) - { - L_a = L_deposit_l( 0 ); - L_p = L_deposit_l( 0 ); - - L_tmp = L_deposit_l( 0 ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Q12 */ - } - exp_norm = norm_l( L_tmp ); - exp_norm = sub( exp_norm, exp_safe ); - - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */ - L_e = L_mult( temp_fx, temp_fx ); /* 2*(exp_norm-4)+1 */ - - IF( GT_32( L_e, L_p ) ) - { - L_p = L_add( L_e, 0 ); - } - L_a = L_add( L_a, L_e ); - } - Qa = sub( shl( exp_norm, 1 ), 7 ); /* (exp_norm-4)*2+1 */ - - IF( L_a > 0x0L ) - { - /* a /= band_width[k]; */ - exp_normn = norm_l( L_a ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( band_width[k] ); - norm_a_fx = div_l( L_shl( L_a, exp_normn ), shl( band_width[k], exp_normd ) ); /* (Qa+exp_normn)-exp_normd-1); */ - Qnorm_a = sub( sub( add( Qa, exp_normn ), exp_normd ), 1 ); - - /*p2a = 10.0f * (float) log10 (p / a); */ - p2a_fx = 0; - move16(); - IF( norm_a_fx > 0 ) - { - exp_normn = norm_l( L_p ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( norm_a_fx ); - pa_fx = div_l( L_shl( L_p, exp_normn ), shl( norm_a_fx, exp_normd ) ); /* Qpa + exp_normn + Qnorm_a + exp_normd - 1 */ - Qpa = sub( sub( add( Qa, exp_normn ), add( Qnorm_a, exp_normd ) ), 1 ); + } + IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) ) + { + bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */ + move16(); + } + } - L_tmp = L_deposit_h( pa_fx ); - Qpa = add( Qpa, 16 ); - exp = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( 30, exp ); - exp = sub( exp, Qpa ); - L_tmp = L_Comp( exp, frac ); + /* Get number of bits by Huffman0 coding */ + ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 ); /* Q0 */ - /* 10/( log(10)/log(2) ) = 3.01029995663981195211 24660(Q13) */ - L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ + IF( is_transient_fx ) + { + /* Get number of bits by Huffman coding */ + hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ + } + ELSE + { + /* Get number of bits by Huffman coding */ + hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ + } - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ - } + /* comparing used bits */ + test(); + IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) ) + { + deng_cmode = 0; + move16(); + push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); + large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 ); + deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */ + } + ELSE + { + /* setting energy difference coding mode and storing it */ + deng_cmode = 1; + move16(); + push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - IF( LE_16( p2a_fx, p2a_th_fx ) ) - { - p2a_flags_fx[k] = 0; - move16(); - } + deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */ + + /* packing indice */ + IF( is_transient_fx ) + { + Copy( bq2_temp_fx, bq2_fx, bands_fx ); /* Q0 */ + small_symbol_enc_tran_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); } ELSE { - p2a_flags_fx[k] = 0; - move16(); + small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); } + } - push_indice( hBstr, IND_HQ2_P2A_FLAGS, p2a_flags_fx[k], 1 ); - j = add( j, 1 ); + /* Reconstruct quantized spectrum */ + bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */ + move16(); + FOR( k = 1; k < bands_fx; k++ ) + { + bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */ + move16(); } - return ( j ); /* Q0 */ + FOR( k = 0; k < bands_fx; k++ ) + { + L_band_energy[k] = Mpy_32_16_1( L_qint, bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */ + move32(); + } + + IF( is_transient_fx ) + { + reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); + } + + return ( deng_bits ); /* Q0 */ } -#ifndef CLEANUP_HQ_CORE -static Word16 p2a_threshold_quant_ivas_fx( + +/*-------------------------------------------------------------------* + * p2a_threshold_quant() + * + * + *-------------------------------------------------------------------*/ + +static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, /* i/o: : bit stream */ const Word32 *L_t_audio, /* i : Q12 : input spectrum */ const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ @@ -3513,6 +1711,7 @@ static Word16 p2a_threshold_quant_ivas_fx( move16(); set16_fx( p2a_flags_fx, 1, bands ); + move16(); j = 0; move16(); @@ -3532,7 +1731,7 @@ static Word16 p2a_threshold_quant_ivas_fx( FOR( i = band_start[k]; i <= band_end[k]; i++ ) { temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */ - L_e = L_mult( temp_fx, temp_fx ); /* (exp_norm-4)*2 + 1 */ + L_e = L_mult( temp_fx, temp_fx ); /* 2*(exp_norm-4)+1 */ IF( GT_32( L_e, L_p ) ) { @@ -3594,7 +1793,7 @@ static Word16 p2a_threshold_quant_ivas_fx( return ( j ); /* Q0 */ } -#endif + /*-------------------------------------------------------------------* * mdct_spectrum_fine_gain_enc() @@ -3759,163 +1958,3 @@ static void mdct_spectrum_fine_gain_enc_fx( return; } -#ifndef CLEANUP_HQ_CORE - -static void mdct_spectrum_fine_gain_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_ybuf[], /* i : Q12 : input spectrum */ - Word32 L_y2[], /* i/o: Q12 : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 k_sort[], /* i : Q0 : sort table by band_energy */ - const Word16 bands, /* i : Q0 : nubmber of subbands */ - const Word32 L_qint, /* i : Q29 : */ - const Word16 Ngq, /* i : Q0 : */ - const Word16 gqlevs, /* i : Q0 : quantized level */ - const Word16 gqbits /* i : Q0 : quantized bits */ -) -{ - Word16 i, k; - - Word16 delta_fx, Qdelta; - Word32 L_delta; - Word32 L_q; - - Word16 gain_table_fx[MAX_GQLEVS]; - Word16 Qgt; - Word16 gamma_fx; - Word16 Qgamma; - - Word16 exp_safe; - Word16 exp_normn, exp_normd; - Word16 exp_norm; - - Word32 L_temp; - Word16 temp_lo_fx, temp_hi_fx, temp_fx, temp2_fx; - - Word32 L_Eyy, L_Exy; - /*Word16 QE; */ - - Word16 d_fx; - Word16 dmin_fx; - Word16 imin_fx; - - /* Fine gain quantization on only the most significant energy bands */ - - /*delta = qint / gqlevs; */ - exp_normn = norm_l( L_qint ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( gqlevs ); - delta_fx = div_l( L_shl( L_qint, exp_normn ), shl( gqlevs, exp_normd ) ); - Qdelta = add( sub( exp_normn, exp_normd ), 28 ); /* 29+exp_normn-(exp_normd)-1; */ - L_delta = L_shl( L_deposit_h( delta_fx ), sub( 13, Qdelta ) ); /* Q29 */ - /*q = (-qint + delta) / 2.0f; */ - L_q = L_shr( L_sub( L_delta, L_qint ), 1 ); /* Q29 */ - - FOR( i = 0; i < gqlevs; i++ ) - { - /*gain_table[i] = (float) pow (2.0f, q * 0.5f); */ - L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) ); /* Q16 */ - temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); - Qgt = sub( 14, temp_hi_fx ); - gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */ - move16(); - - /*q += delta; */ - L_q = L_add( L_q, L_delta ); - gain_table_fx[i] = shl( gain_table_fx[i], sub( 14, Qgt ) ); /* Qgt -> Q14 */ - move16(); - } - - FOR( k = sub( bands, Ngq ); k < bands; k++ ) - { - /*Eyy = 0.0f; */ - /*Exy = 0.0f; */ - /*for (i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++) */ - /*{ */ - /* Eyy += y2[i] * y2[i]; */ - /* Exy += ybuf[i] * y2[i]; */ - /*} */ - exp_safe = 4; - move16(); /* 4 is too large. but never happen overflow */ - L_temp = L_deposit_l( 0 ); - FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ ) - { - L_temp = L_or( L_temp, L_abs( L_y2[i] ) ); /* Q12 */ - L_temp = L_or( L_temp, L_abs( L_ybuf[i] ) ); /* Q12 */ - } - exp_norm = norm_l( L_temp ); - exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */ - - L_Eyy = L_deposit_l( 0 ); - L_Exy = L_deposit_l( 0 ); - /*QE = add(shl(add(Qs-16, exp_norm), 1), 1); //(Qs+exp_norm-16)*2+1; */ - FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ ) - { - /*Eyy += y2[i] * y2[i]; */ - temp_fx = round_fx( L_shl( L_y2[i], exp_norm ) ); /* Q12 + exp_norm - 16 */ - L_Eyy = L_mac( L_Eyy, temp_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */ - - /*Exy += ybuf[i] * y2[i]; */ - temp2_fx = round_fx( L_shl( L_ybuf[i], exp_norm ) ); /* Q12 + exp_norm - 16 */ - L_Exy = L_mac( L_Exy, temp2_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */ - } - - test(); - IF( L_Eyy > 0x0L && L_Exy > 0x0L ) - { - /*gamma = Exy / Eyy; */ - exp_normn = norm_l( L_Exy ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_l( L_Eyy ); - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ - Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ - gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ - - dmin_fx = 32767; - move16(); - imin_fx = -1; - move16(); - FOR( i = 0; i < gqlevs; i++ ) - { - d_fx = abs_s( sub( gamma_fx, gain_table_fx[i] ) ); /* Q14 */ - IF( LT_16( d_fx, dmin_fx ) ) - { - dmin_fx = d_fx; /* Q14 */ - move16(); - imin_fx = i; /* Q0 */ - move16(); - } - } - - gamma_fx = gain_table_fx[imin_fx]; /* Q14 */ - move16(); - - FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ ) - { - /*y2[i] *= gamma; */ - /* This IF statement for keeping same mantissa evenif y2 is plus or minus */ - IF( L_y2[i] >= 0x0 ) - { - L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 ); /* Q12 */ - move32(); - } - ELSE - { - L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) ); /* Q12 */ - move32(); - } - } - } - ELSE - { - imin_fx = 0; - move16(); - } - - push_indice( st_fx->hBstr, IND_HQ2_SUBBAND_GAIN, imin_fx, gqbits ); - } - - return; -} -#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 969649190..74343fd20 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3905,15 +3905,6 @@ void hq_lr_enc_fx( const Word16 is_transient_fx /* i : Q0 : transient flag */ ); -#ifndef CLEANUP_HQ_CORE -void hq_lr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ -); -#endif void hq_hr_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure fx */ Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ @@ -4089,27 +4080,6 @@ ivas_error tcq_core_LR_enc_fx( const Word16 adjustFlag, const Word16 is_transient ); -#ifndef CLEANUP_HQ_CORE -ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector[], - const Word32 coefs_norm_fx[], - Word32 coefs_quant_fx[], - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *Rk_fx, - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); -#endif /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ Word16 encode_envelope_indices_fx( BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 639e470fe..843efcf49 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -1024,205 +1024,6 @@ static void EncodeSWBSubbands_fx( return; } -#ifndef CLEANUP_HQ_CORE -static void EncodeSWBSubbands_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word32 *L_spectra, /* i/o: MDCT domain spectrum */ - Word16 QsL, /* i : Q value for L_spectra */ - const Word16 fLenLow_fx, /* i : lowband length */ - const Word16 fLenHigh_fx, /* i : highband length */ - const Word16 nBands_fx, /* i : number of subbands */ - const Word16 nBands_search_fx, /* i : number of subbands to be searched for BWE */ - const Word16 *sbWidth_fx, /* i : subband lengths */ - const Word16 *subband_offsets_fx, /* i : Subband offset for BWE */ - Word16 *lagIndices_fx, /* o : lowband index for each subband */ - const Word16 BANDS_fx, /* i : noise estimate from WB part */ - const Word16 *band_start_fx, /* i : Number subbands/Frame */ - const Word16 *band_end_fx, /* i : Band Start of each SB */ - Word32 *L_band_energy, /* i : Band end of each SB, :Qbe */ - Word16 Qbe, /* i : Q value of band energy */ - const Word16 *p2a_flags_fx, /* i : BAnd energy of each SB */ - const Word16 hqswb_clas_fx, /* i : lowband synthesis */ - Word16 *prev_frm_index_fx, /* i : clas information */ - const Word16 har_bands_fx, /* i/o: Index of the previous Frame */ - const Word16 *subband_search_offset_fx, /* i : Number of harmonic LF bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band width */ - const Word32 L_spectra_ni[], /* i : Qs noise injected spectra */ - Word16 *ni_seed_fx /* i/o: random seed */ -) -{ - Word16 i, k; - Word16 sspectra_fx[L_FRAME32k]; - Word16 sspectra_ni_fx[L_FRAME32k]; - Word16 sspectra_diff_fx[L_FRAME32k]; - Word16 Qss; /* Q value of Smoothed Spectrum low-subband */ - Word32 L_be_tonal[SWB_HAR_RAN1]; /* Q */ - Word16 ss_min_fx; /* Qss */ - Word32 L_th_g[NB_SWB_SUBBANDS]; - Word16 QbeL; - GainItem_fx pk_sf_fx[(NB_SWB_SUBBANDS) *8]; - Word16 pul_res_fx[NB_SWB_SUBBANDS]; - - GainItem_fx Nbiggest_fx[NB_SWB_SUBBANDS * N_NBIGGEST_PULSEARCH]; - - Word32 L_xSynth_har[L_FRAME32k]; /* Qs */ - - Word16 lagGains_fx[NB_SWB_SUBBANDS]; - Word16 QlagGains[NB_SWB_SUBBANDS]; - Word16 har_freq_est1, har_freq_est2; - Word16 flag_dis; - Word16 pos_max_hfe2; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - - har_freq_est1 = 0; - move16(); - har_freq_est2 = 0; - move16(); - flag_dis = 1; - move16(); - pos_max_hfe2 = 0; - move16(); - - set16_fx( sspectra_fx, 0, fLenLow_fx ); - set16_fx( sspectra_ni_fx, 0, fLenLow_fx ); - set32_fx( L_xSynth_har, 0, L_FRAME32k ); - set16_fx( pul_res_fx, 0, NB_SWB_SUBBANDS ); - - - IF( EQ_16( hqswb_clas_fx, HQ_HARMONIC ) ) - { - pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2 ); - noise_extr_corcod_fx( L_spectra, L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, fLenLow_fx, hHQ_core->prev_hqswb_clas, &hHQ_core->prev_ni_ratio_fx, &Qss ); - /* Find best indices for each group */ - getswbindices_har_fx( - L_spectra, - QsL, sspectra_ni_fx, - nBands_search_fx, lagIndices_fx, prev_frm_index_fx, fLenLow_fx, subband_offsets_fx, sbWidth_fx, subband_search_offset_fx ); - - /* Write the indices into the bitstream */ - FOR( k = 0; k < nBands_search_fx; k++ ) - { - push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_mode0_Har[k] ); - } - - IF( flag_dis == 0 ) - { - test(); - IF( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) ) - { - har_freq_est2 = add( har_freq_est2, lagIndices_fx[0] ); - move16(); - } - } - - gethar_noisegn_fx( st_fx->hBstr, L_spectra, QsL, sspectra_diff_fx, Qss, L_xSynth_har, - sbWidth_fx, lagIndices_fx, BANDS_fx, har_bands_fx, fLenLow_fx, fLenHigh_fx, - subband_offsets_fx, subband_search_offset_fx, band_start_fx, band_end_fx, band_width_fx, - L_band_energy, Qbe, L_be_tonal, &QbeL, sspectra_fx, - har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx ); - - - Gettonl_scalfact_fx( L_xSynth_har, QsL, L_spectra_ni, fLenLow_fx, fLenHigh_fx, har_bands_fx, BANDS_fx, L_band_energy, Qbe, band_start_fx, band_end_fx, - p2a_flags_fx, L_be_tonal, QbeL, pk_sf_fx, Qss, pul_res_fx ); - - IF( flag_dis == 0 ) - { - *prev_frm_hfe2 = 0; - move16(); - } - ELSE - { - *prev_frm_hfe2 = har_freq_est2; - move16(); - } - - FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) - { - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) - { - L_spectra[i] = L_xSynth_har[i - fLenLow_fx]; - move32(); /* QsL */ - } - } - } - ELSE - { - ss_min_fx = spectrumsmooth_noiseton_fx( L_spectra, /*QsL,*/ L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, &Qss, fLenLow_fx, ni_seed_fx ); - - /* Get lag indices */ - GetSWBIndices_fx( sspectra_fx, /*Qss,*/ L_spectra + fLenLow_fx, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx, - Nbiggest_fx, subband_offsets_fx, sspectra_fx ); - - /* Bitstream operations */ - FOR( k = 0; k < nBands_fx; k++ ) - { - IF( EQ_16( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k], 1 ) ) - { - lagIndices_fx[k] = 0; - move16(); - lagGains_fx[k] = 0; - move16(); - QlagGains[k] = 15; - move16(); - } - ELSE - { - push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_modeNormal[k] ); - } - } - - convert_lagIndices_pls2smp_fx( lagIndices_fx, nBands_fx, lagIndices_fx, sspectra_fx, sbWidth_fx, fLenLow_fx ); - - GetlagGains_fx( sspectra_ni_fx, Qss, &L_band_energy[BANDS_fx - NB_SWB_SUBBANDS], Qbe, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx, lagGains_fx, QlagGains ); - FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) - { - lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */ - move16(); - } - - FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) - { - L_th_g[k] = L_deposit_l( 0 ); - move32(); - IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 ) - { - L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> QsL */ - move32(); - } - } - - GetSynthesizedSpecThinOut_fx( sspectra_ni_fx, Qss, L_xSynth_har, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, lagGains_fx, QlagGains, fLenLow_fx ); - - /*Level adjustment for the missing bands*/ - noiseinj_hf_fx( L_xSynth_har, QsL, L_th_g, L_band_energy, Qbe, hHQ_core->prev_En_sb_fx, p2a_flags_fx, BANDS_fx, band_start_fx, band_end_fx, fLenLow_fx, fLenHigh_fx ); - - - FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) - { - IF( p2a_flags_fx[k] == 0 ) - { - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) - { - L_spectra[i] = L_xSynth_har[i - fLenLow_fx]; - move32(); /* Qob */ - } - } - ELSE - { - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) - { - L_spectra[i] = L_spectra_ni[i]; - move32(); - } - } - } - } - - return; -} -#endif /*--------------------------------------------------------------------------* * swb_bwe_enc_lr() @@ -1312,89 +1113,3 @@ void swb_bwe_enc_lr_fx( return; } -#ifndef CLEANUP_HQ_CORE - -void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, /* i : Q value */ - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -) -{ - Word16 k; - Word16 nBands_fx; - Word16 nBands_search_fx; - Word16 wBands_fx[NB_SWB_SUBBANDS]; - Word16 lagIndices_fx[NB_SWB_SUBBANDS]; - Word16 swb_lowband_fx, swb_highband_fx, allband_fx; - - const Word16 *subband_offsets_fx; - const Word16 *subband_search_offset_fx; - - Word32 *p_L_m; - - subband_search_offset_fx = subband_search_offsets_13p2kbps_Har; - subband_offsets_fx = subband_offsets_sub5_13p2kbps_Har; - - hf_parinitiz_fx( L_total_brate, hqswb_clas_fx, lowlength_fx, highlength_fx, wBands_fx, &subband_search_offset_fx, &subband_offsets_fx, &nBands_fx, &nBands_search_fx, &swb_lowband_fx, &swb_highband_fx ); - allband_fx = add( swb_lowband_fx, swb_highband_fx ); - move16(); - - /* Prepare m[], low part from WB core, high part from 32k input */ - Copy32( L_m_core, L_m, swb_lowband_fx ); - Copy32( &L_m_orig[swb_lowband_fx], &L_m[swb_lowband_fx], swb_highband_fx ); - - EncodeSWBSubbands_ivas_fx( - st_fx, - L_m, QsL, - swb_lowband_fx, swb_highband_fx, nBands_fx, nBands_search_fx, wBands_fx, subband_offsets_fx, - lagIndices_fx, - BANDS_fx, band_start_fx, band_end_fx, - L_band_energy, Qbe, - p2a_flags_fx, - hqswb_clas_fx, prev_frm_index_fx, har_bands_fx, subband_search_offset_fx, - prev_frm_hfe2, prev_stab_hfe2, - band_width_fx, L_y2_ni, ni_seed_fx ); - - p_L_m = &L_m[sub( allband_fx, 1 )]; - *p_L_m = Mult_32_16( *p_L_m, 2028 ); - move32(); - p_L_m--; /* 0.0625 = 2028 (Q15) */ - *p_L_m = Mult_32_16( *p_L_m, 4096 ); - move32(); - p_L_m--; /* 0.125 = 4096 (Q15) */ - *p_L_m = Mult_32_16( *p_L_m, 8192 ); - move32(); - p_L_m--; /* 0.25 = 8192 (Q15) */ - *p_L_m = Mult_32_16( *p_L_m, 16384 ); - move32(); - p_L_m--; /* 0.5 = 16384 (Q15) */ - - /* set low frequencies to zero */ - FOR( k = 0; k < swb_lowband_fx; k++ ) - { - L_m[k] = L_deposit_l( 0 ); - move32(); - } - - return; -} -#endif diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index ffe9b86f7..517c1c0b4 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -493,489 +493,3 @@ ivas_error tcq_core_LR_enc_fx( return error; } -#ifndef CLEANUP_HQ_CORE - -ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector_fx[], /* x5 */ - const Word32 coefs_norm_fx[], /* Q12 */ - Word32 coefs_quant_fx[], /* Q12 */ - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *R_fx, /* Q16 */ - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ) -{ - Word16 i, j, k, size, nb_bytes; - - Word16 USQ_TCQ[NB_SFM]; /* TCQ is selected by default*/ - Word16 coefs_norm_dec_fx[L_FRAME32k]; /* New output buffer (TCQ+USQ)*/ - Word32 savedstates[TCQ_MAX_BAND_SIZE]; - ARCODEC arenc_fx, *parenc_fx; - TCQ_BITSTREAM bs_fx, *pbs_fx; - Word16 k_num[2]; - Word32 bit_surplus_fx[2]; - - Word16 flag_wbnb = 0; - Word16 lsbtcq_bits = TCQ_AMP; - Word16 tcq_arbits = 2; - Word16 nzb = 0; - Word16 nzbands = 0; - Word16 bcount = 0; - Word32 bsub_fx = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move32(); - Word32 abuffer_fx[MAX_PULSES]; - Word16 mbuffer_fx[MAX_PULSES]; - Word32 sbuffer_fx[MAX_PULSES]; - Word16 dpath[280]; - Word32 Rk_sort_fx[NB_SFM]; - Word32 step_scale_fx[NB_SFM]; - Word16 pulses_fx, nzp_fx; - - Word32 gain_fx, crosscorr_fx, selfcorr_fx; - Word16 hi, lo, exp; - Word32 surplus_fx, delta_fx, est_frame_bits_fx; - - Word32 leftbits = 0; - Word32 sepbits = 0; - Word32 divider = 0; - move32(); - move32(); - move32(); - ivas_error error; - - error = IVAS_ERR_OK; - move16(); - set16_fx( dpath, 0, 280 ); - set32_fx( abuffer_fx, 0, MAX_PULSES ); - set32_fx( sbuffer_fx, 0, MAX_PULSES ); - set16_fx( mbuffer_fx, 0, MAX_PULSES ); - /* initialization */ - set32_fx( Rk_sort_fx, 0, NB_SFM ); - set16_fx( USQ_TCQ, 0, NB_SFM ); - set16_fx( coefs_norm_dec_fx, 0, L_FRAME32k ); - - InitLSBTCQ_fx( &bcount ); - - test(); - test(); - IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 ) - { - flag_wbnb = 1; - move16(); - lsbtcq_bits = 0; - move16(); - tcq_arbits = 0; - move16(); - } - - /* TCQ Index initialize */ - parenc_fx = &arenc_fx; - pbs_fx = &bs_fx; - - pbs_fx->curPos = 7; - move16(); - pbs_fx->numbits = L_deposit_l( 0 ); - pbs_fx->numByte = L_deposit_l( 0 ); - move32(); - move32(); - FOR( i = 0; i < MAX_SIZEBUF_PBITSTREAM; i++ ) - { - pbs_fx->buf[i] = 0; - move16(); - } - ar_encoder_start_fx( parenc_fx, pbs_fx, L_deposit_l( bit_budget ) ); - - /* Bits distribution analysis */ - FOR( i = 0; i < BANDS; i++ ) - { - IF( GE_32( ar_div( R_fx[i], sfmsize[i] ), 49152 ) ) - { - /* USQ used for high importance bands*/ - USQ_TCQ[i] = 1; - move16(); - } - ELSE - { - /* TCQ used for usual bands */ - USQ_TCQ[i] = 0; - move16(); - } - - IF( R_fx[i] > 0 ) - { - /* nzbands++; */ - nzbands = add( nzbands, 1 ); - } - } - - FOR( j = 0; j < BANDS; j++ ) - { - IF( R_fx[j] > 0 ) - { - nzb = add( nzb, 1 ); - } - } - - bsub_fx = L_shl( add( tcq_arbits, lsbtcq_bits ), 16 ); /* Q16 */ - IF( bsub_fx > 0 ) - { - bsub_fx = L_add( bsub_fx, 2048 ); - } - FOR( j = BANDS - 1; j >= 0; j-- ) - { - IF( R_fx[j] > 0 ) - { - R_fx[j] = L_sub( R_fx[j], ar_div( bsub_fx, nzb ) ); - move32(); - - IF( R_fx[j] < 0 ) - { - bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), R_fx[j] ) ); - R_fx[j] = L_deposit_l( 0 ); - move32(); - } - ELSE - { - bsub_fx = L_sub( bsub_fx, ar_div( bsub_fx, nzb ) ); - } - /* nzb--; */ - nzb = sub( nzb, 1 ); - } - } - - /* Sort the bit allocation table (R) in ascending order, figure out number of pulses per band */ - srt_vec_ind_fx( R_fx, Rk_sort_fx, k_sort, BANDS ); - - /* Quantize spectral band shapes using TCQ */ - /* Select ISC */ - set32_fx( coefs_quant_fx, 0, add( sfm_end[BANDS - 1], 1 ) ); - Copy32( coefs_norm_fx, coefs_quant_fx, add( sfm_end[BANDS - 1], 1 ) ); - - delta_fx = L_deposit_l( 0 ); - est_frame_bits_fx = L_deposit_l( 0 ); - - test(); - test(); - IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 ) - { - surplus_fx = -131072; - move32(); - bit_allocation_second_fx( R_fx, Rk_sort_fx, BANDS, sfmsize, k_sort, k_num, p2a_flags, p2a_bands, last_bitalloc, input_frame ); - - nzbands = 0; - move16(); - FOR( j = 0; j < BANDS; j++ ) - { - test(); - IF( NE_16( j, k_num[0] ) && NE_16( j, k_num[1] ) ) - { - leftbits = L_add( leftbits, R_fx[k_sort[j]] ); - IF( R_fx[k_sort[j]] > 0 ) - { - nzbands = add( nzbands, 1 ); - } - } - ELSE - { - sepbits = L_add( sepbits, R_fx[k_sort[j]] ); - } - } - /* Separate the position information from the input signal(coefs_norm) */ - /* Gather the NZ coefficients*/ - FOR( k = 0; k < BANDS; k++ ) /* Loop through non-zero blocks */ - { - test(); - IF( NE_16( k, k_num[0] ) && NE_16( k, k_num[1] ) ) - { - test(); - test(); - IF( R_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 ) /* Then have non-zero block AND WILL BE ENCODED BY TCQ */ - { - /* Encode Position Info, NZ Info, Signs */ - size = sfmsize[k_sort[k]]; - move16(); - - /* Determine scale step, ISC and TCQ quantizer */ - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, - L_add( R_fx[k_sort[k]], delta_fx ), - /* R_fx[k_sort[k]], */ - &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 0, &nzp_fx, 0, 0, 0, 0 ); - leftbits = L_sub( leftbits, L_add( R_fx[k_sort[k]], delta_fx ) ); - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - nzbands = sub( nzbands, 1 ); - } - /* Have USQ coded band */ - ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) ) - { - size = sfmsize[k_sort[k]]; - move16(); - - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, - L_add( R_fx[k_sort[k]], delta_fx ), - /* R_fx[k_sort[k]], */ - &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, 0, 0, 0, 0 ); - leftbits = L_sub( leftbits, L_add( R_fx[k_sort[k]], delta_fx ) ); - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - nzbands = sub( nzbands, 1 ); - } - ELSE /* Then have zero block */ - { - npulses[k_sort[k]] = 0; - move16(); - size = sfmsize[k_sort[k]]; - move16(); - } - - delta_fx = L_deposit_l( 0 ); - test(); - IF( R_fx[k_sort[k]] > 0 && surplus_fx < 0 ) - { - /* delta_fx = L_deposit_h( div_l( surplus_fx, nzbands ) ); */ - IF( LE_16( nzbands, 1 ) ) - { - divider = 0; - move32(); - } - ELSE - { - divider = 2; - move32(); - } - - IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 ) - { - /* Overflow possible => start to distribute negative surplus */ - delta_fx = ar_div( surplus_fx + sepbits, nzbands ); - } - ELSE - { - delta_fx = 0; - move32(); - } - surplus_fx = L_sub( surplus_fx, delta_fx ); - } - } - } - - test(); - test(); - test(); - IF( ( GT_32( surplus_fx, 524288 ) && EQ_16( input_frame, L_FRAME8k ) ) || ( GT_32( surplus_fx, 786432 ) && EQ_16( input_frame, L_FRAME16k ) ) ) - { - bit_surplus_fx[0] = Mult_32_16( surplus_fx, 24576 ); /* Q16 */ - move32(); - bit_surplus_fx[1] = Mult_32_16( surplus_fx, 8192 ); /* Q16 */ - move32(); - } - ELSE - { - bit_surplus_fx[0] = surplus_fx; - move32(); - bit_surplus_fx[1] = L_deposit_l( 0 ); - move32(); - } - - FOR( k = 0; k < BANDS; k++ ) - { - FOR( j = 0; j < 2; j++ ) - { - IF( EQ_16( k, k_num[j] ) ) - { - R_fx[k_sort[k]] = L_add( R_fx[k_sort[k]], bit_surplus_fx[j] ); - move32(); - - test(); - test(); - IF( R_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 ) /* Then have non-zero block AND WILL BE ENCODED BY TCQ */ - { - /* Encode Position Info, NZ Info, Signs */ - size = sfmsize[k_sort[k]]; - move16(); - - /* Determine scale step, ISC and TCQ quantizer */ - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]], &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 0, &nzp_fx, 0, 0, 0, 0 ); - - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - } - /* Have USQ coded band */ - ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) ) - { - size = sfmsize[k_sort[k]]; - move16(); - - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]], &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, 0, 0, 0, 0 ); - - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - } - ELSE /* Then have zero block */ - { - npulses[k_sort[k]] = 0; - move16(); - size = sfmsize[k_sort[k]]; - move16(); - } - } - } - } - } - ELSE - { - surplus_fx = L_deposit_l( 0 ); - - /* Separate the position information from the input signal(coefs_norm) */ - /* Gather the NZ coefficients*/ - FOR( k = 0; k < BANDS; k++ ) /* Loop through non-zero blocks */ - { - IF( R_fx[k_sort[k]] > 0 ) - { - size = sfmsize[k_sort[k]]; - move16(); - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]] + delta_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, &bcount, abuffer_fx, mbuffer_fx, sbuffer_fx ); - - npulses[k_sort[k]] = pulses_fx; - move16(); - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - - /* nzbands--; */ - nzbands = sub( nzbands, 1 ); - } - ELSE /* Then have zero block */ - { - npulses[k_sort[k]] = 0; - move16(); - size = sfmsize[k_sort[k]]; - move16(); - } - - /* Surplus distribution */ - /* if( surplus > 0.0f && nzbands > 0 ) */ - test(); - IF( surplus_fx > 0 && nzbands > 0 ) - { - /* delta = surplus / nzbands; - surplus -= delta; */ - - delta_fx = ar_div( surplus_fx, nzbands ); - surplus_fx = L_sub( surplus_fx, delta_fx ); - } - } - } - - TCQLSB_fx( bcount, /*abuffer, */ abuffer_fx, /*mbuffer, */ mbuffer_fx, /*sbuffer, */ sbuffer_fx, dpath ); - - /* Save TCQ path to bitstream */ - SaveTCQdata_fx( parenc_fx, dpath, lsbtcq_bits ); - - /* Add tcq sequence to decoding buffer */ - InitLSBTCQ_fx( &bcount ); - - ar_encoder_done_fx( parenc_fx ); - - /* Loop through non-zero blocks */ - FOR( i = 0; i < L_FRAME32k; i++ ) - { - coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) ); - move16(); - } - - IF( !flag_wbnb ) - { - FOR( k = 0; k < BANDS; k++ ) - { - IF( R_fx[k_sort[k]] > 0 ) - { - size = sfmsize[k_sort[k]]; - move16(); - RestoreTCQ_fx( &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &bcount, mbuffer_fx ); - } - } - } - - nb_bytes = shr( bit_budget, 3 ); - - j = sub( bit_budget, shl( nb_bytes, 3 ) ); - FOR( i = 0; i < nb_bytes; i++ ) - { - push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, pbs_fx->buf[i], 8 ); - } - IF( j > 0 ) - { - push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, shr( pbs_fx->buf[nb_bytes], sub( 8, j ) ), j ); - } - /* Clear decoding buffer */ - set32_fx( coefs_quant_fx, 0, sfm_end[BANDS - 1] + 1 ); - - /* New analysis of decoded frame */ - FOR( i = 0; i < BANDS; i++ ) - { - IF( R_fx[k_sort[i]] > 0 ) - { - gain_fx = L_deposit_l( 0 ); - - crosscorr_fx = L_deposit_l( 0 ); - selfcorr_fx = L_deposit_l( 0 ); - - FOR( j = 0; j < sfmsize[k_sort[i]]; j++ ) - { - crosscorr_fx = L_add( crosscorr_fx, Mult_32_16( coefs_norm_fx[sfm_start[k_sort[i]] + j], shl( coefs_norm_dec_fx[sfm_start[k_sort[i]] + j], 2 ) ) ); /*1 */ - selfcorr_fx = L_mac0( selfcorr_fx, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j], coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ); - } - - exp = sub( norm_l( crosscorr_fx ), 1 ); - gain_fx = ar_div( L_shl( crosscorr_fx, exp ), selfcorr_fx ); /* 1 + exp */ - gain_fx = L_shl_sat( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ - lo = L_Extract_lc( gain_fx, &hi ); - /* Use optimal gain */ - FOR( j = 0; j < sfmsize[k_sort[i]]; j++ ) - { - inp_vector_fx[sfm_start[k_sort[i]] + j] = coefs_norm_dec_fx[sfm_start[k_sort[i]] + j]; - move32(); - coefs_quant_fx[sfm_start[k_sort[i]] + j] = L_add( L_shl( L_mult0( hi, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 12 ), - L_shr( L_mult0( lo, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 3 ) ); /* Q12 */ - move32(); - } - } - } - - - return error; -} -#endif -- GitLab From 515174be40efa14a4d6f476bf10dddf9eeaa9919 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:12:02 +0100 Subject: [PATCH 519/750] [cleanup] accept REMOVE_UNUSED_CODE_IVAS_DEC --- lib_com/ivas_prot_fx.h | 8 - lib_com/options.h | 1 - lib_dec/ivas_ism_dtx_dec_fx.c | 6 - lib_dec/ivas_jbm_dec_fx.c | 637 ------------------------- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 52 -- 5 files changed, 704 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7ffa702b9..7962a009b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1571,10 +1571,6 @@ void ivas_sba_dirac_stereo_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ const Word16 output_frame /* i : output frame length per channel */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - const Word16 mcmasa /* i : McMASA flag */ -#endif ); ivas_error ivas_osba_render_sf_fx( @@ -4271,10 +4267,6 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const Word16 sce_id_dtx, /* i : SCE DTX ID */ const Word16 nchan_transport /* i : number of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - Word16 *Q_cngNoiseLevel -#endif ); ivas_error stereo_dft_enc_create_fx( diff --git a/lib_com/options.h b/lib_com/options.h index 02b867f60..e8c6b548e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index b98640b7a..d283832b3 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -161,16 +161,11 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const Word16 sce_id_dtx, /* i : SCE DTX ID */ const Word16 nchan_transport /* i : number of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - Word16 *Q_cngNoiseLevel /* i : stores Q factor of hFdCngCom->cngNoiseLevel for various channels*/ -#endif ) { Word32 fac_fx, cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx; Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant, exp; HANDLE_FD_CNG_COM hFdCngCom; -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 Q_cngNoiseLevel[MAX_SCE]; FOR( ch = 0; ch < nchan_transport; ch++ ) @@ -189,7 +184,6 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( move16(); } } -#endif hFdCngCom = hSCE[sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom; cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index d703a4104..55788b01c 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -77,11 +77,7 @@ ivas_error ivas_dec_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 ch, n, output_frame, nchan_out, i, s; -#else - Word16 ch, n, output_frame, nchan_out, i, ii; -#endif Decoder_State *st; /* used for bitstream handling */ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */ Word16 nchan_remapped; @@ -91,11 +87,6 @@ ivas_error ivas_dec_fx( ivas_error error; Word16 num_md_sub_frames; Word32 ism_total_brate; -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 s; - CPE_DEC_HANDLE hCPE; - SCE_DEC_HANDLE hSCE; -#endif push_wmops( "ivas_dec" ); /*----------------------------------------------------------------* @@ -127,41 +118,16 @@ ivas_error ivas_dec_fx( *----------------------------------------------------------------*/ test(); -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - test(); - IF( st_ivas->bfi != 0 && st_ivas->ini_frame == 0 ) - { - /* zero output when first frame(s) is lost */ - FOR( n = 0; n < nchan_out; n++ ) - { - set32_fx( p_output_fx[n], 0, output_frame ); - } - } - ELSE -#endif IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; move32(); -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); - set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); - set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); -#endif IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - } -#endif /* HP filtering */ FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ ) { @@ -175,38 +141,13 @@ ivas_error ivas_dec_fx( IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[st_ivas->hISMDTX.sce_id_dtx], 0, L_FRAME48k ); -#endif IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 Q_cngNoiseLevel[MAX_SCE]; - FOR( ch = 0; ch < 4; ch++ ) - { - IF( st_ivas->hSCE[ch] != NULL ) - { - Word16 shift = getScaleFactor32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - if ( LT_16( sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) - { - shift = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); - } - scale_sig32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-(cngNoiseLevelExp -shift) ) - st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); - Q_cngNoiseLevel[ch] = sub( 31, st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); - move16(); - move16(); - } - } - - ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); -#else ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); -#endif ivas_param_ism_dec_dequant_md_fx( st_ivas ); } @@ -234,9 +175,6 @@ ivas_error ivas_dec_fx( test(); IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[n], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) ) { return error; @@ -254,11 +192,7 @@ ivas_error ivas_dec_fx( { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); -#else - Scale_sig32( p_output_fx[0], L_FRAME48k, 3 ); -#endif } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) { @@ -312,15 +246,8 @@ ivas_error ivas_dec_fx( } /* core-decoding of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = Q11; - move16(); -#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -328,21 +255,10 @@ ivas_error ivas_dec_fx( } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); - set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - } -#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -388,213 +304,8 @@ ivas_error ivas_dec_fx( ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); -#else - { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 ) /* Guard bits */; - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) - } - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - move16(); - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - - q = hCPE->hStereoDft->q_dft; - move16(); - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - IF( LE_16( st_ivas->nchan_transport, 1 ) ) - { - st = hCPE->hCoreCoder[0]; - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && ( st->last_core == ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ - { - IF( !st->tcxonly ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - } - } - ELSE /* ACELP core */ - { - test(); - test(); - IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ - { - test(); - test(); - test(); - test(); - IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - } - } - } - - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - } - - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); - - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); - } - - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 - } - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB - } - IF( hCPE->hStereoDft != NULL ) - { - IF( LE_16( st_ivas->nchan_transport, 1 ) ) - { - st = hCPE->hCoreCoder[0]; - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && st->core == ACELP_CORE && EQ_16( st->con_tcx, 1 ) ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ - { - IF( !st->tcxonly ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - } - } - ELSE /* ACELP core */ - { - test(); - test(); - IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ - { - test(); - test(); - test(); - test(); - IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - } - } - } - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - test(); - } - - st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - move16(); - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) { @@ -673,11 +384,7 @@ ivas_error ivas_dec_fx( ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC FOR( i = 0; i < CPE_CHANNELS; i++ ) -#else - FOR( i = 0; i < 2; i++ ) -#endif { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } @@ -730,34 +437,6 @@ ivas_error ivas_dec_fx( move16(); } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - /* set ISM parameters and decode ISM metadata in OMASA format */ - Word16 q_output = 11; - move16(); - - // NOTE: the following is done to calculate the number of hIsmMetaData indices - Word16 tmp_nchan_ism; - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) - { - tmp_nchan_ism = 1; - move16(); - } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - tmp_nchan_ism = 0; - move16(); - } - ELSE - { - tmp_nchan_ism = st_ivas->nchan_ism; - move16(); - } - - FOR( n = 0; n < tmp_nchan_ism; n++ ) - { - set32_fx( p_output_fx[n], 0, L_FRAME48k ); - } -#endif /* MASA metadata decoding */ IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { @@ -788,16 +467,6 @@ ivas_error ivas_dec_fx( return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - /* shifting both the channels from variable q_output to constant Q-factor (Q11) */ - FOR( Word16 k = 0; k < output_frame; k++ ) - { - p_output_fx[0][k] = L_shr( p_output_fx[0][k], sub( Q11, q_output ) ); - move32(); - p_output_fx[1][k] = L_shr( p_output_fx[1][k], sub( Q11, q_output ) ); - move32(); - } -#endif IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) { Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ @@ -808,21 +477,13 @@ ivas_error ivas_dec_fx( hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 output_q = Q11; -#else - Word16 output_q = 11; -#endif move16(); IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC output_q = Q8; -#else - output_q = 8; -#endif move16(); } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) @@ -892,40 +553,19 @@ ivas_error ivas_dec_fx( } /* core-decoding of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC // this is just to keep formatting correct (clang-format otherwise brekas the indentation) ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) { return error; } -#else - ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ){ - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ){ - return error; - } -#endif -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -956,116 +596,7 @@ ivas_error ivas_dec_fx( ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); -#else - { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], output_frame ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s) - } - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - move16(); - } - - q = hCPE->hStereoDft->q_dft; - move16(); - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - } - - ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); - - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); - } - - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 - } - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - move16(); - } - - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } -#endif } /* HP filtering */ @@ -1147,11 +678,7 @@ ivas_error ivas_dec_fx( { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); // Q11 -#else - Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); // Q11 -#endif /* add W */ FOR( n = 0; n < nchan_out; n++ ) @@ -1176,11 +703,7 @@ ivas_error ivas_dec_fx( /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 -#else - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 -#endif IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) { @@ -1237,11 +760,7 @@ ivas_error ivas_dec_fx( /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 -#else - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 -#endif ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); @@ -1299,21 +818,10 @@ ivas_error ivas_dec_fx( IF( EQ_16( st_ivas->nCPE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -1352,30 +860,16 @@ ivas_error ivas_dec_fx( IF( st_ivas->hOutSetup.separateChannelEnabled ) { /* Decode the transport audio signals */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ n = LFE_CHANNEL - 1; move16(); /* Decode the separated channel to output[n] to be combined with the synthesized channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[n], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; @@ -1402,15 +896,8 @@ ivas_error ivas_dec_fx( } ELSE { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -1422,136 +909,12 @@ ivas_error ivas_dec_fx( { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif } } IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); -#else - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) - } - - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - - move16(); - move16(); - } - - q = hCPE->hStereoDft->q_dft; - move16(); - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - IF( st_ivas->hSpar != NULL ) - { - st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - move16(); - } - - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - } - - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); - - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 - } - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - move16(); - } - IF( st_ivas->hSpar != NULL ) - { - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } -#endif } /* HP filtering */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index dfc51cc74..18f94bc9f 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1232,18 +1232,12 @@ void ivas_sba_dirac_stereo_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ const Word16 output_frame /* i : output frame length per channel Q0*/ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - const Word16 mcmasa /* i : McMASA flag Q0*/ -#endif ) { Word16 dtx_flag, fd_cng_flag; Word16 sba_mono_flag; Word16 memOffset; -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word32 output_Fs; -#endif Word32 tmp_buf[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; Word32 tmp_synth[L_FRAME16k]; Word32 hb_gain[NB_DIV]; @@ -1256,7 +1250,6 @@ void ivas_sba_dirac_stereo_dec_fx( SCE_DEC_HANDLE hSCE; CPE_DEC_HANDLE hCPE; STEREO_DFT_DEC_DATA_HANDLE hStereoDft; -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 mcmasa; mcmasa = 0; @@ -1406,49 +1399,23 @@ void ivas_sba_dirac_stereo_dec_fx( /*----------------------------------------------------------------* * Processing *----------------------------------------------------------------*/ -#endif -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC FOR( i = 0; i < CPE_CHANNELS; i++ ) -#else - FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) -#endif { set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC q = hStereoDft->q_dft; move16(); q_dft[0] = hStereoDft->q_dft; move16(); q_dft[1] = hStereoDft->q_dft; move16(); -#else - hSCE = st_ivas->hSCE[0]; - hCPE = st_ivas->hCPE[0]; - hStereoDft = hCPE->hStereoDft; - - q = hCPE->hStereoDft->q_dft; - move16(); - q_dft[0] = hCPE->hStereoDft->q_dft; - move16(); - q_dft[1] = hCPE->hStereoDft->q_dft; - move16(); -#endif -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ -#else - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ -#endif IF( hSCE != NULL ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ -#else - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ -#endif hSCE->q_prev_hb_synth_fx = hStereoDft->q_dft; move16(); } @@ -1479,11 +1446,7 @@ void ivas_sba_dirac_stereo_dec_fx( test(); test(); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); -#else - hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); -#endif stereo_dft_dec_update_fx( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); @@ -1530,13 +1493,8 @@ void ivas_sba_dirac_stereo_dec_fx( } /* DFT Stereo upmix */ -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#else - stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#endif /* DFT synthesis */ stereo_dft_dec_synthesize_fx( hCPE, DFT, 0, output[0], output_frame ); @@ -1594,23 +1552,14 @@ void ivas_sba_dirac_stereo_dec_fx( set32_fx( output[ch], 0, output_frame ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ -#else - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ -#endif IF( hSCE != NULL ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ -#else - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ -#endif hSCE->q_prev_hb_synth_fx = Q11; move16(); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC /*----------------------------------------------------------------* * Adjust scaling of buffers *----------------------------------------------------------------*/ @@ -1710,7 +1659,6 @@ void ivas_sba_dirac_stereo_dec_fx( hCPE->q_output_mem_fx[ii] = Q11; move16(); } -#endif return; } -- GitLab From 98c5071a9bd7aa41bf8b24e91a0339d7c00e3eb5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:17:43 +0100 Subject: [PATCH 520/750] [cleanup] accept FIX_2294_CLANG_18_WARNINGS_ENC --- lib_com/options.h | 1 - lib_enc/avq_cod_fx.c | 4 ---- lib_enc/ext_sig_ana_fx.c | 4 ---- lib_enc/ivas_core_enc_fx.c | 2 -- lib_enc/ivas_cpe_enc_fx.c | 2 -- 5 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e8c6b548e..fe4c2e092 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 943e2d2a2..e54dfeda2 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -609,11 +609,7 @@ void AVQ_cod_lpc_fx( Word16 i, l, pos; Word32 I; Word32 x1[8]; -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC UWord16 I16 = 0; -#else - UWord16 I16; -#endif /* quantize all subvector using estimated gain */ diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 76f90c260..331817147 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1132,11 +1132,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { Word16 Q; -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, L_subframe, 16 ); -#else - Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, N_MAX + L_MDCT_OVLP_MAX, 16 ); -#endif Q = add( q_mdstWin, 16 ); move16(); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 206a3e25c..7ad9cfcc4 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -116,9 +116,7 @@ ivas_error ivas_core_enc_fx( { set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET ); set16_fx( old_syn_12k8_16k_fx[i], 0, L_FRAME16k ); -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC set16_fx( voice_factors_fx[i], 0, NB_SUBFR16k ); -#endif } push_wmops( "ivas_core_enc" ); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index ef7e3f83e..ca73c2752 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -340,14 +340,12 @@ ivas_error ivas_cpe_enc_fx( Word16 q_band_energies_LR; Word16 q_fr_bands[2], q_lf_E[2]; -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC q_band_energies_LR = 0; q_lf_E[0] = 0; q_lf_E[1] = 0; move16(); move16(); move16(); -#endif IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx, &q_band_energies_LR, NULL, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ), -- GitLab From 01232dd2076fbfe950a3af61f9f6b7aba4e2886e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:18:33 +0100 Subject: [PATCH 521/750] [cleanup] accept REMOVE_CAM_FROM_IVAS --- lib_com/options.h | 1 - lib_enc/decision_matrix_enc_fx.c | 76 -------------- lib_enc/enc_prm_fx.c | 173 ------------------------------- lib_enc/evs_enc_fx.c | 4 - lib_enc/ivas_core_enc_fx.c | 7 -- lib_enc/prot_fx_enc.h | 11 -- 6 files changed, 272 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fe4c2e092..7bd18d8f7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index f73a524ce..0b51816dc 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -760,82 +760,6 @@ void signalling_enc_fx( void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ) -#ifndef REMOVE_CAM_FROM_IVAS -{ - Word16 i; - Word16 sfr; - RF_ENC_HANDLE hRF = st->hRF; - - /* write partial copy into bitstream */ - IF( EQ_16( st->rf_mode, 1 ) ) - { - enc_prm_rf_ivas_fx( st, hRF->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset ); - hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; /*Q0*/ - move16(); - } - - /* Shift the RF indices such that the partial copy associated with - (n-fec_offset)th frame is included in the bitstream in nth frame. */ - IF( hRF != NULL ) - { - FOR( i = st->rf_fec_offset; i >= 0; i-- ) - { - /* rf frame type */ - hRF->rf_indx_frametype[i + 1] = hRF->rf_indx_frametype[i]; - move16(); - /* rf target bits buffer */ - hRF->rf_targetbits_buff[i + 1] = hRF->rf_targetbits_buff[i]; - move16(); - /* lsf indx */ - hRF->rf_indx_lsf[i + 1][0] = hRF->rf_indx_lsf[i][0]; - hRF->rf_indx_lsf[i + 1][1] = hRF->rf_indx_lsf[i][1]; - hRF->rf_indx_lsf[i + 1][2] = hRF->rf_indx_lsf[i][2]; - move16(); - move16(); - move16(); - /* ES pred energy */ - hRF->rf_indx_EsPred[i + 1] = hRF->rf_indx_EsPred[i]; - move16(); - /* LTF mode, sfr params: pitch, fcb and gain */ - FOR( sfr = 0; sfr < st->nb_subfr; sfr++ ) - { - hRF->rf_indx_ltfMode[i + 1][sfr] = hRF->rf_indx_ltfMode[i][sfr]; - hRF->rf_indx_pitch[i + 1][sfr] = hRF->rf_indx_pitch[i][sfr]; - hRF->rf_indx_fcb[i + 1][sfr] = hRF->rf_indx_fcb[i][sfr]; - hRF->rf_indx_gain[i + 1][sfr] = hRF->rf_indx_gain[i][sfr]; - move16(); - move16(); - move16(); - move16(); - } - - /* shift the nelp indices */ - hRF->rf_indx_nelp_iG1[i + 1] = hRF->rf_indx_nelp_iG1[i]; - hRF->rf_indx_nelp_iG2[i + 1][0] = hRF->rf_indx_nelp_iG2[i][0]; - hRF->rf_indx_nelp_iG2[i + 1][1] = hRF->rf_indx_nelp_iG2[i][1]; - hRF->rf_indx_nelp_fid[i + 1] = hRF->rf_indx_nelp_fid[i]; - move16(); - move16(); - move16(); - move16(); - /* tbe gain Fr shift */ - hRF->rf_indx_tbeGainFr[i + 1] = hRF->rf_indx_tbeGainFr[i]; - hRF->rf_clas[i + 1] = hRF->rf_clas[i]; - hRF->rf_gain_tcx[i + 1] = hRF->rf_gain_tcx[i]; - hRF->rf_tcxltp_param[i + 1] = hRF->rf_tcxltp_param[i]; - move16(); - move16(); - move16(); - move16(); - } - } - return; -} - -void signalling_enc_rf_fx( - Encoder_State *st /* i : encoder state structure */ -) -#endif { Word16 i; Word16 sfr; diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 74b27351a..dae4570cc 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -99,179 +99,6 @@ static void enc_prm_hm_ivas_fx( * * * encode RF parameters for ACELP and TCX partial copy * *-----------------------------------------------------------------*/ -#ifndef REMOVE_CAM_FROM_IVAS -void enc_prm_rf_ivas_fx( - Encoder_State *st, - const Word16 rf_frame_type, /* Q0 */ - const Word16 fec_offset /* Q0 */ -) -{ - Word16 sfr, nb_subfr, n, index; - Word16 ltp_mode, ltf_mode, gains_mode; - RF_ENC_HANDLE hRF = st->hRF; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - - nb_subfr = st->nb_subfr; /* Q0 */ - move16(); - /* partial copy bitstream writing */ - test(); - IF( GE_16( rf_frame_type, RF_TCXFD ) && LE_16( rf_frame_type, RF_TCXTD2 ) ) - { - /* TCX frames partial copy write */ - - /* LSF indices */ - IF( EQ_16( rf_frame_type, RF_TCXFD ) ) - { - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], lsf_numbits[0] ); /* VQ 1 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], lsf_numbits[1] ); /* VQ 2 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][2], lsf_numbits[2] ); /* VQ 3 */ - } - - /* classification */ - test(); - IF( EQ_16( hRF->rf_clas[fec_offset], UNVOICED_CLAS ) ) - { - index = 0; - move16(); - } - ELSE IF( ( EQ_16( hRF->rf_clas[fec_offset], VOICED_TRANSITION ) ) || ( EQ_16( hRF->rf_clas[fec_offset], UNVOICED_TRANSITION ) ) ) - { - index = 1; - move16(); - } - ELSE IF( EQ_16( hRF->rf_clas[fec_offset], VOICED_CLAS ) ) - { - index = 2; - move16(); - } - ELSE - { - index = 3; - move16(); - } - push_next_indice( hBstr, index, 2 ); - - IF( EQ_16( rf_frame_type, RF_TCXFD ) ) - { - /* TCX global gain = 7 bits */ - push_next_indice( hBstr, hRF->rf_gain_tcx[fec_offset], 7 ); - /*window info - 1 bit for long overlap - 2 if minimum or half overlap*/ - } - ELSE - { - /*gains adapt - gains inov*/ - - /*LPC on full rate -> excitation */ - /* pitch and gain */ - /* LTP data */ - test(); - test(); - IF( ( EQ_16( rf_frame_type, RF_TCXTD1 ) || EQ_16( rf_frame_type, RF_TCXTD2 ) ) && hTcxEnc->tcxltp != 0 ) - { - push_next_indice( hBstr, hRF->rf_tcxltp_param[fec_offset], 9 ); - } - } - } - ELSE IF( EQ_16( rf_frame_type, 7 ) ) /* NELP bitstream writing */ - { - /* LSF indices */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ - - /* NELP gain indices */ - push_next_indice( hBstr, hRF->rf_indx_nelp_iG1[fec_offset], 5 ); - push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][0], 6 ); - push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][1], 6 ); - - /* NELP filter selection index */ - push_next_indice( hBstr, hRF->rf_indx_nelp_fid[fec_offset], 2 ); - - /* tbe gainFr */ - push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 5 ); - } - ELSE IF( GE_16( rf_frame_type, 4 ) ) /* rf_frame_type ALL_PRED: 4, NO_PRED: 5, GEN_PRED: 6 */ - { - /* LSF indices */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ - - /* ES pred */ - push_next_indice( hBstr, hRF->rf_indx_EsPred[fec_offset], 3 ); - - ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type]; - ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type]; - gains_mode = ACELP_GAINS_MODE[1][1][rf_frame_type]; - move16(); - move16(); - move16(); - /* Subframe parameters */ - FOR( sfr = 0; sfr < nb_subfr; sfr++ ) - { - /* Pitch lag (5, or 8 bits) */ - n = ACELP_LTP_BITS_SFR[ltp_mode][sfr]; - move16(); - IF( n != 0 ) - { - push_next_indice( hBstr, hRF->rf_indx_pitch[fec_offset][sfr], n ); - } - - /* Adaptive codebook filtering (1 bit) */ - IF( EQ_16( ltf_mode, 2 ) ) - { - push_next_indice( hBstr, hRF->rf_indx_ltfMode[fec_offset][sfr], 1 ); - } - - /*Innovative codebook*/ - test(); - test(); - test(); - IF( ( EQ_16( rf_frame_type, RF_NOPRED ) ) || - ( EQ_16( rf_frame_type, RF_GENPRED ) && - ( sfr == 0 || EQ_16( sfr, 2 ) ) ) ) - { - push_next_indice( hBstr, hRF->rf_indx_fcb[fec_offset][sfr], 7 ); - } - - /* Gains (5b, 6b or 7b / subfr) */ - test(); - IF( sfr == 0 || EQ_16( sfr, 2 ) ) - { - n = ACELP_GAINS_BITS[gains_mode]; - move16(); - push_next_indice( hBstr, hRF->rf_indx_gain[fec_offset][sfr], n ); - } - } - /* tbe gainFr */ - push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 2 ); - } - - /***************/ - /*IMPORTANT: The last three bits are always the rf_frame_type in the bitstream (for both acelp and tcx partial copy); - the rf_frame_type indicates the length of the partial copy payload at the decoder. - The 2 bits before the rf_frame_type contains the fec_offset */ - - /***************/ - /* write FEC offset just before the rf_frame_type */ - test(); - test(); - IF( EQ_16( fec_offset, 2 ) ) - { - push_next_indice( hBstr, 0, 2 ); - } - ELSE IF( EQ_16( fec_offset, 3 ) || EQ_16( fec_offset, 5 ) || EQ_16( fec_offset, 7 ) ) - { - push_next_indice( hBstr, shr( sub( fec_offset, 1 ), 1 ), 2 ); - } - - /* write RF frame type last in the bitstream */ - push_next_indice( hBstr, rf_frame_type, 3 ); -} -#endif void enc_prm_rf_fx( Encoder_State *st, diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 34abe9537..3d64f4eb0 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -535,15 +535,11 @@ ivas_error evs_enc_fx( * Channel-aware mode - write signaling information into the bitstream *---------------------------------------------------------------------*/ -#ifdef REMOVE_CAM_FROM_IVAS signaling_enc_rf_fx( st ); /*---------------------------------------------------------------------* * Updates *---------------------------------------------------------------------*/ -#else - signalling_enc_rf_fx( st ); -#endif #ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 7ad9cfcc4..5f84252c1 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -866,13 +866,6 @@ ivas_error ivas_core_enc_fx( st->q_inp = q_inp[1]; move16(); -#ifndef REMOVE_CAM_FROM_IVAS - /*---------------------------------------------------------------------* - * Channel-aware mode - write signaling information into the bitstream - *---------------------------------------------------------------------*/ - - signaling_enc_rf_fx( st ); -#endif /*---------------------------------------------------------------------* * Common updates *---------------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 74343fd20..cbe995f22 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2644,12 +2644,6 @@ void enc_prm_rf_fx( const Word16 rf_frame_type, const Word16 fec_offset ); -#ifndef REMOVE_CAM_FROM_IVAS -void enc_prm_rf_ivas_fx( - Encoder_State *st, - const Word16 rf_frame_type, - const Word16 fec_offset ); -#endif void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, @@ -2850,11 +2844,6 @@ void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ); -#ifndef REMOVE_CAM_FROM_IVAS -void signalling_enc_rf_fx( - Encoder_State *st /* i : encoder state structure */ -); -#endif void IGFEncResetTCX10BitCounter_fx( const IGF_ENC_INSTANCE_HANDLE hInstance /**< in: | instance handle of IGF Encoder */ ); -- GitLab From c4bc44745ff42095941c8d1f5a70071c3b2033e9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:20:16 +0100 Subject: [PATCH 522/750] [cleanup] accept OPT_BE_2311_HARM_GSC_GAIN --- lib_com/gs_gains_fx.c | 164 ------------------------------------------ lib_com/options.h | 1 - lib_com/prot_fx.h | 11 --- lib_dec/gs_dec_fx.c | 11 --- 4 files changed, 187 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 98b086e41..61e7144e8 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -967,164 +967,6 @@ Word16 gsc_gainQ_ivas_fx( return mean_4g_fx[0]; } #endif -#ifndef OPT_BE_2311_HARM_GSC_GAIN -/*==========================================================================*/ -/* FUNCTION : Word16 gsc_gaindec_fx() */ -/*--------------------------------------------------------------------------*/ -/* PURPOSE : Generic signal frequency band decoding and application */ -/*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) pvq_bits_fx : core used Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) core_fx : core used Q0 */ -/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ -/*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) y_gainQ_fx : quantized gain per band */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ (Word16) : average frequency gain */ -/*==========================================================================*/ -Word16 gsc_gaindec_fx( /* o : average frequency gain */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ -) -{ - Word16 idx_g_fx, i; - Word16 mean_4g_fx; - Word16 y_gain_tmp3_fx[MBANDS_GN]; - - test(); - test(); - IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && EQ_16( bwidth_fx, NB ) ) - { - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) ); - VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 ); - - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) ); - VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 ); - - IF( LT_32( core_brate_fx, ACELP_9k60 ) ) - { - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 5 ) ); - VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 ); - - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 4 ) ); - VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 ); - } - ELSE - { - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) ); - VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 ); - - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 7 ) ); - VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); - } - test(); - IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) ) - { - /* Some energy is needed in high band for stat_noise_uv_enc - to be functional in inactive speech */ - y_gainQ_fx[10] = mean_fx( y_gainQ_fx + 6, 3 ); - move16(); - y_gainQ_fx[11] = mean_fx( y_gainQ_fx + 7, 3 ); - move16(); - y_gainQ_fx[12] = mean_fx( y_gainQ_fx + 8, 3 ); - move16(); - y_gainQ_fx[13] = mean_fx( y_gainQ_fx + 9, 3 ); - move16(); - y_gainQ_fx[14] = mean_fx( y_gainQ_fx + 10, 3 ); - move16(); - y_gainQ_fx[15] = mean_fx( y_gainQ_fx + 11, 3 ); - move16(); - } - ELSE - { - set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 ); - } - } - ELSE - { - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); - - VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 ); - - IF( LE_32( core_brate_fx, ACELP_9k60 ) ) - { - /*--------------------------------------------------------------------------------------* - * UQ of the first 8 bands and half of the last 8 bands - *--------------------------------------------------------------------------------------*/ - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 ); - - /*----------------------------------------------------------------------* - * Interpolation of the last 4 Q bands to create bands 8-16 - * And scaling - *----------------------------------------------------------------------*/ - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - - VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 ); - - Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 ); - set16_fx( y_gainQ_fx + 12, 0, 4 ); - - fft_rel_fx( y_gainQ_fx + 8, 4, 2 ); - - y_gainQ_fx[15] = y_gainQ_fx[11]; - move16(); - y_gainQ_fx[11] = 0; - move16(); - ifft_rel_fx( y_gainQ_fx + 8, 8, 3 ); - FOR( i = 8; i < 16; i++ ) - { - y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ - move16(); - } - /*----------------------------------------------------------------------* - * Copy the true Q values in the specific bands - *----------------------------------------------------------------------*/ - y_gainQ_fx[8] = y_gain_tmp3_fx[0]; - move16(); - y_gainQ_fx[10] = y_gain_tmp3_fx[1]; - move16(); - y_gainQ_fx[12] = y_gain_tmp3_fx[2]; - move16(); - y_gainQ_fx[14] = y_gain_tmp3_fx[3]; - move16(); - } - ELSE - { - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); - VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 ); - VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 ); - } - } - - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - - return mean_4g_fx; -} -#endif /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ @@ -1147,12 +989,8 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* _ (Word16) : average frequency gain */ /*==========================================================================*/ -#ifndef OPT_BE_2311_HARM_GSC_GAIN -Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ -#else /*! r: average frequency gain */ Word16 gsc_gaindec_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ const Word32 core_brate_fx, /* i : core used */ @@ -1325,13 +1163,11 @@ Word16 gsc_gaindec_fx( } #ifndef OPT_NBE_2311_HARM_GSC_GAIN -#ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) { GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); } ELSE -#endif { /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); diff --git a/lib_com/options.h b/lib_com/options.h index 7bd18d8f7..a527e0dd5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1637d7baa..281b88faf 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1504,17 +1504,6 @@ Word16 gsc_gaindec_fx( const Word16 bwidth_fx /* i : i signal bandwidth */ ); -#ifndef OPT_BE_2311_HARM_GSC_GAIN -/*! r: average frequency gain */ -Word16 gsc_gaindec_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ -); -#endif #ifndef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 05b111fbe..a314bb232 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -667,18 +667,7 @@ void gsc_dec_fx( i--; } -#ifndef OPT_BE_2311_HARM_GSC_GAIN - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ - } - ELSE - { - mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ - } -#else mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ -#endif st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); -- GitLab From 594a1deb7c8930147169ab5a16c6429032fc1bab Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:21:03 +0100 Subject: [PATCH 523/750] [cleanup] accept HARM_CORECODER_UPDT --- lib_com/options.h | 1 - lib_com/prot_fx.h | 30 -- lib_dec/amr_wb_dec_fx.c | 4 - lib_dec/evs_dec_fx.c | 8 - lib_dec/ivas_core_dec_fx.c | 4 - lib_dec/ivas_mct_dec_fx.c | 4 - lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 - lib_dec/updt_dec_fx.c | 390 ------------------------- lib_enc/amr_wb_enc_fx.c | 4 - lib_enc/core_enc_updt_fx.c | 57 ---- lib_enc/evs_enc_fx.c | 4 - lib_enc/ivas_core_enc_fx.c | 4 - lib_enc/ivas_mct_enc_fx.c | 4 - lib_enc/long_enr_fx.c | 15 - lib_enc/prot_fx_enc.h | 3 - lib_enc/updt_enc_fx.c | 229 --------------- 16 files changed, 765 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a527e0dd5..7d73f2d34 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 281b88faf..b83e22afa 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5282,15 +5282,6 @@ Word32 sign_l( const Word32 x /* i : input value of x */ ); -#ifndef HARM_CORECODER_UPDT -void ivas_updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ -); -#endif /* Random generator with Gaussian distribution with mean 0 and std 1 */ Word32 rand_gauss( Word16 *seed ); @@ -7754,23 +7745,12 @@ void updt_IO_switch_dec_fx( Decoder_State *st_fx /* o : Decoder static variables structure */ ); -#ifndef HARM_CORECODER_UPDT -void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost /* i : Synthesis Q value */ -); -#endif void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ -#ifdef HARM_CORECODER_UPDT const Word16 *synth16, /* i : decoded synthesis Qpostd */ const Word32 *synth, /* i : decoded synthesis Qpostd */ -#else - const Word16 *synth, /* i : decoded synthesis */ -#endif const Word16 Qpostd /* i : Synthesis Q value */ ); @@ -10437,16 +10417,6 @@ void swb_pre_proc_ivas_fx( CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ); -#ifndef HARM_CORECODER_UPDT -void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ -); - -void updt_enc_common_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Q_new /* i : CUrrent frame scaling */ -); -#endif /* o : Q(2x - 31 - gb) */ Word32 sum2_f_32_fx( const Word32 *vec, /* i : input vector, Qx */ diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index db508ec27..f05299be6 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -997,11 +997,7 @@ ivas_error amr_wb_dec_fx( st_fx->last_flag_cna = flag_cna; move16(); -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st_fx, -1, -1, NULL, NULL, 0 ); -#else - updt_dec_common_fx( st_fx, -1, -1, NULL, 0 ); -#endif /*----------------------------------------------------------------* * Overlap of ACELP synthesis with old MDCT memory diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 8a227b191..e7b378a6d 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -1387,11 +1387,7 @@ ivas_error evs_dec_fx( move16(); } -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, NULL, Qpostd ); -#else - updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, Qpostd ); -#endif } ELSE { @@ -1401,11 +1397,7 @@ ivas_error evs_dec_fx( move16(); } -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, NULL, Qpostd ); -#else - updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, Qpostd ); -#endif } pop_wmops(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 9331f95f9..efd629036 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1525,11 +1525,7 @@ ivas_error ivas_core_dec_fx( save_synthesis_hq_fec_fx( st, NULL, output_fx_loc, output_frame, 0, hCPE ); /* Updates */ -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, NULL, output_32_fx[n], Q11 ); -#else - ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_32_fx[n], Q11 ); -#endif Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( exp_max ) ); // Q0 diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 5e2264916..d3a4b7f74 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -385,11 +385,7 @@ ivas_error ivas_mct_dec_fx( save_synthesis_hq_fec_fx( sts[n], NULL, output_fx_, output_frame, 0, hCPE ); /* CoreCoder common updates */ -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, NULL, output_fx[( cpe_id * CPE_CHANNELS ) + n], Q11 ); -#else - ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[( cpe_id * CPE_CHANNELS ) + n], 11 ); -#endif } /* n_channels loop */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 18f94bc9f..0f18a6eab 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1467,11 +1467,7 @@ void ivas_sba_dirac_stereo_dec_fx( stereo_dft_dec_core_switching_fx( hCPE, output[0] /*hSCE->save_output*/, hSCE->save_synth_fx, hSCE->save_hb_synth_fx, DFT, output_frame, 0, dtx_flag, &q, &q_dft[0] ); /* do updates here after skipping this in SCE decoder (needs to be done after core switching) */ -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, NULL, hSCE->save_synth_fx, q ); -#else - ivas_updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, hSCE->save_synth_fx, q ); -#endif q_synth = sub( getScaleFactor32( tmp_synth, hSCE->hCoreCoder[0]->L_frame ), 10 ); scale_sig32( tmp_synth, hSCE->hCoreCoder[0]->L_frame, q_synth ); /*hSCE->q_save_synth_fx + q_synth*/ diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 7f42e6b69..7489e9278 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -396,29 +396,21 @@ void updt_IO_switch_dec_fx( * Updates for BW switching *-------------------------------------------------------------------*/ -#ifdef HARM_CORECODER_UPDT static void updt_bw_switching_fx( -#else -void updt_bw_switching_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *synth, /* i : synthesis signal Qpost */ -#ifdef HARM_CORECODER_UPDT const Word32 *synth32, /* i : synthesis signal32 Qpost */ -#endif const Word16 Qpost /* i : Synthesis Q value */ ) { test(); IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { -#ifdef HARM_CORECODER_UPDT IF( st_fx->element_mode != EVS_MONO ) { st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth32, Qpost, L_FRAME32k ); } ELSE -#endif { st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11 } @@ -466,354 +458,6 @@ void updt_bw_switching_fx( * * Common updates for MODE1 and MODE2 *-------------------------------------------------------------------*/ -#ifndef HARM_CORECODER_UPDT -void updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis Qpostd */ - const Word16 Qpostd /* i : Synthesis Q value */ - -) -{ - Word16 i; - Word32 L_tmp; - - TCX_DEC_HANDLE hTcxDec; - hTcxDec = st_fx->hTcxDec; - - st_fx->last_codec_mode = st_fx->codec_mode; - move16(); - st_fx->last_extl = st_fx->extl; - move16(); - st_fx->last_L_frame = st_fx->L_frame; - move16(); - - st_fx->prev_old_bfi = st_fx->prev_bfi; - move16(); - st_fx->prev_bfi = st_fx->bfi; - move16(); - if ( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->old_bfi_cnt = st_fx->nbLostCmpt; - move16(); - } - move16(); - st_fx->last_con_tcx = st_fx->con_tcx; - move16(); - st_fx->con_tcx = 0; - - move16(); - if ( st_fx->hHQ_nbfec != NULL ) - { - st_fx->hHQ_nbfec->prev_last_core = st_fx->last_core; - } - if ( st_fx->hTcxDec != NULL ) - { - hTcxDec->tcxConceal_recalc_exc = 0; - move16(); - } - test(); - test(); - IF( ( GE_16( st_fx->rf_frame_type, RF_TCXFD ) && LE_16( st_fx->rf_frame_type, RF_TCXTD2 ) && st_fx->use_partial_copy && st_fx->bfi ) || !st_fx->bfi ) - { - test(); - test(); - test(); - test(); - if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL ) - { - hTcxDec->tcxConceal_recalc_exc = 1; - move16(); - } - st_fx->last_good = st_fx->clas_dec; - move16(); - } - IF( st_fx->use_partial_copy ) - { - st_fx->prev_rf_frame_type = st_fx->rf_frame_type; - move16(); - } - ELSE - { - st_fx->prev_rf_frame_type = INACTIVE; - move16(); - } - - if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) ) - { - st_fx->rf_flag_last = st_fx->rf_flag; - move16(); - } - - IF( EQ_16( st_fx->codec_mode, MODE1 ) ) - { - test(); - if ( !st_fx->bfi && ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) ) - { - move16(); - st_fx->last_active_brate = st_fx->total_brate; - } - - move16(); - move16(); - st_fx->last_core = st_fx->core; - if ( st_fx->hHQ_core != NULL ) - { - st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx; - } - } - ELSE IF( EQ_16( st_fx->codec_mode, MODE2 ) ) - { - test(); - if ( ( !st_fx->bfi ) && ( st_fx->last_is_cng == 0 ) ) - { - move16(); - st_fx->last_active_brate = st_fx->total_brate; - } - /* INFO: moved from update_decoder_LPD_cng() */ - if ( NE_16( st_fx->m_frame_type, ACTIVE_FRAME ) ) - { - move16(); - st_fx->last_is_cng = 1; - } - - - if ( !st_fx->bfi ) - { - st_fx->last_core = st_fx->core; - } - move16(); - move16(); - st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ - } - move16(); - st_fx->last_core_brate = st_fx->core_brate; - - /* save synthesis for core switching */ - test(); - IF( EQ_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->core, AMR_WB_CORE ) ) - { - Copy_Scale_sig( synth + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); - } - test(); - test(); - test(); - IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) ) - - { - /* reset LP memories */ - set16_fx( st_fx->mem_MA_fx, 0, M ); - IF( EQ_32( st_fx->sr_core, INT_FS_16k ) ) - { - Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); - } - ELSE - { - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - } - } - IF( EQ_16( st_fx->codec_mode, MODE2 ) ) - { - test(); - IF( EQ_16( st_fx->use_partial_copy, 1 ) && EQ_16( st_fx->rf_frame_type, RF_NELP ) ) - { - st_fx->last_nelp_mode_dec = 1; - move16(); - } - ELSE - { - st_fx->last_nelp_mode_dec = 0; - move16(); - } - } - - st_fx->prev_use_partial_copy = st_fx->use_partial_copy; - move16(); - - st_fx->prev_tilt_code_dec_fx = 0; - move16(); - - st_fx->prev_Q_exc = st_fx->Q_exc; - move16(); - - L_tmp = L_mult( st_fx->tilt_code_dec_fx[0], 4096 ); - FOR( i = 1; i < NB_SUBFR; i++ ) - { - L_tmp = L_mac( L_tmp, st_fx->tilt_code_dec_fx[i], 4096 ); - } - st_fx->prev_tilt_code_dec_fx = round_fx( L_tmp ); - - IF( EQ_16( st_fx->core, HQ_CORE ) ) - { - st_fx->prev_coder_type = GENERIC; - move16(); - } - ELSE IF( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->prev_coder_type = st_fx->coder_type; - move16(); - } - - test(); - IF( ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) && EQ_16( st_fx->first_CNG, 1 ) && st_fx->hTdCngDec != NULL ) - { - if ( GE_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) - { - st_fx->hTdCngDec->act_cnt = 0; - move16(); - } - - st_fx->hTdCngDec->act_cnt = add( st_fx->hTdCngDec->act_cnt, 1 ); - - test(); - if ( ( EQ_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) && ( st_fx->hTdCngDec->ho_hist_size > 0 ) ) - { - st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 ); - } - - st_fx->hTdCngDec->act_cnt2 = add( st_fx->hTdCngDec->act_cnt2, 1 ); - if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) - { - st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; - move16(); - } - } - - test(); - test(); - if ( LE_32( st_fx->core_brate, SID_2k40 ) && st_fx->first_CNG == 0 && ( EQ_16( st_fx->cng_type, LP_CNG ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - st_fx->first_CNG = 1; - move16(); - } - - /* update bandwidth switching parameters */ - st_fx->last_flag_cna = st_fx->flag_cna; - move16(); - if ( st_fx->hFdCngDec != NULL ) - { - st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type; - move16(); - } - - if ( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - st_fx->m_old_frame_type = st_fx->m_frame_type; - move16(); - } - test(); - test(); - /* update bandwidth switching parameters */ - IF( EQ_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->last_bwidth = WB; - - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt = 0; - st_fx->bws_cnt1 = 0; - move16(); - move16(); - move16(); - move16(); - } - ELSE IF( EQ_16( st_fx->codec_mode, MODE1 ) && ( ( GT_32( st_fx->core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, EVS_MONO ) ) ) ) - { - updt_bw_switching_fx( st_fx, synth, Qpostd ); - } - ELSE - { - st_fx->last_bwidth = st_fx->bwidth; - st_fx->prev_bws_cnt = st_fx->bws_cnt; - move32(); - move16(); - } - - /* synchronisation of CNG seeds*/ - test(); - test(); - test(); - test(); - IF( st_fx->hTdCngDec != NULL && ( st_fx->bfi || ( NE_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_32( st_fx->core_brate, SID_2k40 ) ) ) && NE_16( st_fx->core, AMR_WB_CORE ) ) - { - Random( &( st_fx->hTdCngDec->cng_seed ) ); - Random( &( st_fx->hTdCngDec->cng_ener_seed ) ); - } - - test(); - test(); - test(); - IF( st_fx->hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) ) - { - /* update the parameters used in waveform adjustment */ - concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); - } - - st_fx->last_total_brate_ber = st_fx->total_brate; - move32(); - IF( st_fx->bfi == 0 ) - { - st_fx->last_total_brate = st_fx->total_brate; - st_fx->last_bits_frame_nominal = st_fx->bits_frame_nominal; - move32(); - move32(); - } - st_fx->last_low_rate_mode = st_fx->low_rate_mode; - move16(); - if ( LT_16( st_fx->ini_frame, MAX_FRAME_COUNTER ) ) - { - st_fx->ini_frame = add( st_fx->ini_frame, 1 ); - } - - return; -} - - -static void ivas_updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 *synth, /* i : fixed point synthesis signal Qpost */ - const Word16 Qpost ) -{ - test(); - IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) - { - st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ); - } - - st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q - move32(); - st_fx->prev_enerLL_fx = st_fx->enerLL_fx; // enerLL_fx_Q - move32(); - st_fx->last_bwidth = st_fx->bwidth; - move32(); - - IF( EQ_16( st_fx->core, ACELP_CORE ) ) - { - st_fx->last_inner_frame = L_FRAME32k; - move16(); - test(); - if ( EQ_16( st_fx->bwidth, WB ) && ( st_fx->bws_cnt == 0 ) ) - { - st_fx->last_inner_frame = L_FRAME16k; - move16(); - } - } - ELSE - { - test(); - test(); - test(); - IF( !( GE_16( st_fx->last_inner_frame, L_FRAME16k ) && LE_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && st_fx->bws_cnt > 0 && LT_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) ) - { - st_fx->last_inner_frame = inner_frame_tbl[st_fx->bwidth]; - move16(); - } - } - st_fx->prev_bws_cnt = st_fx->bws_cnt; - move16(); - return; -} -#endif static Word32 sum_32_32_fx( const Word32 *x, const Word16 length ) // Qx { @@ -826,20 +470,12 @@ static Word32 sum_32_32_fx( const Word32 *x, const Word16 length ) // Qx return W_round64_L( sum ); } -#ifdef HARM_CORECODER_UPDT void updt_dec_common_fx( -#else -void ivas_updt_dec_common_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ -#ifdef HARM_CORECODER_UPDT const Word16 *synth16, /* i : decoded synthesis Qpostd */ const Word32 *synth, /* i : decoded synthesis Qpostd */ -#else - const Word32 *synth, /* i : decoded synthesis Qpostd */ -#endif const Word16 Qpostd /* i : Synthesis Q value */ ) @@ -916,11 +552,7 @@ void ivas_updt_dec_common_fx( test(); test(); -#ifdef HARM_CORECODER_UPDT if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) ) -#else - if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( st_fx->bfi != 0 || st_fx->use_partial_copy != 0 ) ) -#endif { st_fx->rf_flag_last = st_fx->rf_flag; move16(); @@ -937,7 +569,6 @@ void ivas_updt_dec_common_fx( st_fx->last_active_brate = st_fx->total_brate; } -#ifdef HARM_CORECODER_UPDT IF( st_fx->element_mode == EVS_MONO ) { st_fx->last_core = st_fx->core; @@ -954,15 +585,6 @@ void ivas_updt_dec_common_fx( st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ move16(); } -#else - move16(); - move16(); - if ( !st_fx->bfi || st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = st_fx->core; - } - st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ -#endif if ( st_fx->hHQ_core != NULL ) { @@ -1000,11 +622,7 @@ void ivas_updt_dec_common_fx( test(); IF( EQ_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->core, AMR_WB_CORE ) ) { -#ifdef HARM_CORECODER_UPDT Copy_Scale_sig( synth16 + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); -#else - Copy_Scale_sig_32_16( synth + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); -#endif } test(); @@ -1113,12 +731,10 @@ void ivas_updt_dec_common_fx( st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 ); } -#ifdef HARM_CORECODER_UPDT if ( EQ_16( st_fx->element_mode, EVS_MONO ) ) { st_fx->hTdCngDec->act_cnt2 = add( st_fx->hTdCngDec->act_cnt2, 1 ); } -#endif if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) { st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; @@ -1169,11 +785,7 @@ void ivas_updt_dec_common_fx( } ELSE IF( EQ_16( st_fx->codec_mode, MODE1 ) && ( ( GT_32( st_fx->core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, EVS_MONO ) ) ) ) { -#ifdef HARM_CORECODER_UPDT updt_bw_switching_fx( st_fx, synth16, synth, Qpostd ); -#else - ivas_updt_bw_switching_fx( st_fx, synth, Qpostd ); -#endif } ELSE { @@ -1200,13 +812,11 @@ void ivas_updt_dec_common_fx( IF( hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) ) { /* update the parameters used in waveform adjustment */ -#ifdef HARM_CORECODER_UPDT IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { concealment_update2_x( (const Word16 *) synth16, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); } ELSE -#endif { concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); } diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index c1865862f..f6dbe7938 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -595,11 +595,7 @@ void amr_wb_enc_fx( updt_enc_fx( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf ); /* update main codec parameters */ -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new ); -#else - updt_enc_common_fx( st, Etot, Q_new ); -#endif #ifdef DEBUG_MODE_INFO dbgwrite( &st->codec_mode, sizeof( short ), 1, input_frame, "res/codec" ); diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c index 9ec6eda6f..f6aba6f61 100644 --- a/lib_enc/core_enc_updt_fx.c +++ b/lib_enc/core_enc_updt_fx.c @@ -11,57 +11,6 @@ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#ifndef HARM_CORECODER_UPDT -void core_encode_update_fx( Encoder_State *st ) -{ - Word16 n; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /*--------------------------------------------------------------* - * Update Buffers - *---------------------------------------------------------------*/ - - /* Update Input Signal Buffers */ - - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - - Copy( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n ); - Copy( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n ); - - - IF( !st->tcxonly ) - { - n = add( st->L_frame, shr( st->L_frame, 2 ) ); - Copy( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n ); - } - - - IF( hTcxEnc != NULL ) - { - IF( ( st->core == ACELP_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core, AMR_WB_CORE ) ) - { - Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame ); - } - } - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) ); - if ( hTcxEnc != NULL ) - { - Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n ); - } - /* Update previous mode */ - - test(); - test(); - test(); - IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && EQ_16( st->codec_mode, MODE2 ) ) ) - { - /* reset LP memories */ - set16_fx( st->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - } -} -#endif /*-------------------------------------------------------------------* * core_encode_update_cng_fx() @@ -202,11 +151,7 @@ void core_encode_update_cng_fx( * Common updates of buffers *-------------------------------------------------------------------*/ -#ifdef HARM_CORECODER_UPDT void core_encode_update_fx( -#else -void core_encode_update_ivas_fx( -#endif Encoder_State *st /* i/o: Encoder state structure */ ) { @@ -232,13 +177,11 @@ void core_encode_update_ivas_fx( test(); IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) ) { -#ifdef HARM_CORECODER_UPDT IF( st->element_mode == EVS_MONO ) { Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame ); } ELSE -#endif { Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 3d64f4eb0..5fd5a8963 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -541,11 +541,7 @@ ivas_error evs_enc_fx( * Updates *---------------------------------------------------------------------*/ -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new ); -#else - updt_enc_common_fx( st, Etot, Q_new ); -#endif if ( EQ_16( st->mdct_sw, MODE1 ) ) { diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 5f84252c1..cd1e34af4 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -872,11 +872,7 @@ ivas_error ivas_core_enc_fx( IF( !MCT_flag ) /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */ { -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new[n] ); -#else - updt_enc_common_ivas_fx( st, Q_new[n] ); -#endif } IF( st->hBWE_FD != NULL ) diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 58552eb7f..091b8c6b2 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -484,11 +484,7 @@ ivas_error ivas_mct_enc_fx( move16(); /* common encoder updates */ -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); -#else - updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); -#endif } } diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 45660c619..61354bf87 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -145,11 +145,6 @@ void ivas_long_enr_fx( move32(); } -#ifndef HARM_CORECODER_UPDT - /*-----------------------------------------------------------------* - * Initialize parameters for energy tracking and signal dynamics - *-----------------------------------------------------------------*/ -#endif return; } @@ -170,9 +165,6 @@ void long_enr_fx( * and total active speech energy *-----------------------------------------------------------------*/ -#ifndef HARM_CORECODER_UPDT - { -#endif IF( LT_16( st_fx->ini_frame, 4 ) ) { st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ @@ -215,15 +207,8 @@ void long_enr_fx( } } -#ifdef HARM_CORECODER_UPDT /* Update */ st_fx->hNoiseEst->Etot_last_fx = Etot; -#else -} -/*-----------------------------------------------------------------* - * Initialize parameters for energy tracking and signal dynamics - *-----------------------------------------------------------------*/ -#endif return; } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index cbe995f22..5f773c341 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -828,9 +828,6 @@ void sc_vbr_enc_init_fx( void updt_enc_common_fx( Encoder_State *st, /* i/o: encoder state structure */ -#ifndef HARM_CORECODER_UPDT - const Word16 Etot, /* i : total energy */ -#endif const Word16 Q_new /* i : CUrrent frame scaling */ ); diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 95026eead..d0826c429 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -306,231 +306,6 @@ void updt_IO_switch_enc_fx( *-------------------------------------------------------------------*/ void updt_enc_common_fx( -#ifndef HARM_CORECODER_UPDT - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Etot, /* i : total energy */ - const Word16 Q_new /* i : CUrrent frame scaling */ -) -{ - /*---------------------------------------------------------------------* - * Updates - main main codec parameters - *---------------------------------------------------------------------*/ - - st->last_sr_core = st->sr_core; - move32(); - st->last_codec_mode = st->codec_mode; - move16(); - st->last_L_frame = st->L_frame; - move16(); - st->last_core = st->core; - move16(); - - st->last_core_brate = st->core_brate; - move32(); - st->last_total_brate = st->total_brate; - move32(); - st->last_extl = st->extl; - move16(); - st->last_input_bwidth = st->input_bwidth; - move16(); - st->last_bwidth = st->bwidth; - move16(); - IF( GT_16( st->element_mode, EVS_MONO ) ) - { - st->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot ); - } - ELSE - { - st->hNoiseEst->Etot_last_fx = Etot; - } - move16(); - st->last_coder_type_raw = st->coder_type_raw; - move16(); - - st->prev_Q_new = Q_new; - move16(); - - test(); - IF( GT_32( st->core_brate, SID_2k40 ) && st->hDtxEnc != NULL ) - { - st->hDtxEnc->last_active_brate = st->total_brate; - move32(); - } - - IF( st->hBWE_TD != NULL ) - { - st->hBWE_TD->prev_coder_type = st->coder_type; - move16(); - IF( EQ_16( st->core, HQ_CORE ) ) - { - /* in the HQ core, coder_type is not used so it could have been set to anything */ - st->hBWE_TD->prev_coder_type = GENERIC; - move16(); - } - } - - test(); - IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL ) - { - IF( GT_32( st->core_brate, SID_2k40 ) ) - { - IF( EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - IF( GE_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) ) - { - st->hTdCngEnc->act_cnt = 0; - move16(); - } - st->hTdCngEnc->act_cnt = add( st->hTdCngEnc->act_cnt, 1 ); - move16(); - - test(); - IF( EQ_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) && st->hTdCngEnc->ho_hist_size > 0 ) - { - st->hTdCngEnc->ho_hist_size = sub( st->hTdCngEnc->ho_hist_size, 1 ); - move16(); - } - } - - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - st->hTdCngEnc->act_cnt2 = add( st->hTdCngEnc->act_cnt2, 1 ); - st->hTdCngEnc->act_cnt2 = s_min( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ); - move16(); - move16(); - - test(); - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) - { - } - } - } - - test(); - test(); - test(); - IF( ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) && st->hDtxEnc->first_CNG == 0 && EQ_16( st->cng_type, LP_CNG ) ) - { - st->hDtxEnc->first_CNG = 1; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Increase the counter of initialization frames - * Limit the max number of init. frames - *-----------------------------------------------------------------*/ - - if ( LT_16( st->ini_frame, MAX_FRAME_COUNTER ) ) - { - st->ini_frame = add( st->ini_frame, 1 ); - move16(); - } - - /* synchronisation of CNG seeds */ - test(); - test(); - test(); - IF( st->hTdCngEnc != NULL && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && NE_16( st->core, AMR_WB_CORE ) ) - { - Random( &( st->hTdCngEnc->cng_seed ) ); - Random( &( st->hTdCngEnc->cng_ener_seed ) ); - } - - /*---------------------------------------------------------------------* - * Updates - MODE2 - *---------------------------------------------------------------------*/ - - IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) ) - { - st->codec_mode = MODE2; - move16(); - - st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); - move32(); - - // st->L_frame = extract_l(Mult_32_16(st->sr_core, INV_FRAME_PER_SEC_Q15)); /*(int16_t)(st->sr_core / FRAMES_PER_SEC);*/ - - IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) - { - st->preemph_fac = PREEMPH_FAC; - st->gamma = GAMMA1; - st->L_frame = L_FRAME; - move16(); - move16(); - move16(); - } - ELSE - { - st->preemph_fac = PREEMPH_FAC_16k; - st->gamma = GAMMA16k; - st->L_frame = L_FRAME16k; - move16(); - move16(); - move16(); - } - - st->igf = getIgfPresent_fx( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode ); - move16(); - } - - /* update FER clas */ - IF( NE_16( st->core, AMR_WB_CORE ) ) - { - st->last_clas = st->clas; - move16(); - } - - /* Update Core */ - core_encode_update_fx( st ); - - /*---------------------------------------------------------------------* - * RF mode updates - *---------------------------------------------------------------------*/ - - IF( st->rf_mode ) - { - IF( st->hSC_VBR != NULL ) - { - st->hSC_VBR->last_nelp_mode = 0; - move16(); - IF( EQ_16( st->hRF->rf_frame_type, RF_NELP ) ) - { - st->hSC_VBR->last_nelp_mode = 1; - move16(); - } - } - } - - st->rf_mode_last = st->rf_mode; - move16(); - - IF( st->Opt_RF_ON ) - { - st->L_frame = L_FRAME; - st->rf_mode = 1; - move16(); - move16(); - } - - /*---------------------------------------------------------------------* - * Other updates - *---------------------------------------------------------------------*/ - - test(); - IF( GT_16( st->element_mode, EVS_MONO ) && st->hTcxEnc != NULL ) - { - } - return; -} - -void updt_enc_common_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 Q_new /* i : CUrrent frame scaling */ ) @@ -708,11 +483,7 @@ void updt_enc_common_ivas_fx( } /* Update Core */ -#ifdef HARM_CORECODER_UPDT core_encode_update_fx( st ); -#else - core_encode_update_ivas_fx( st ); -#endif /*---------------------------------------------------------------------* * RF mode updates -- GitLab From ff8c5ae99ccaaa31955e38df5bd3be4b722ef7c3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:22:21 +0100 Subject: [PATCH 524/750] [cleanup] accept HARM_CORE_SW --- lib_com/ivas_prot_fx.h | 12 - lib_com/options.h | 1 - lib_com/prot_fx.h | 64 -- lib_dec/acelp_core_switch_dec_fx.c | 252 ----- lib_dec/amr_wb_dec_fx.c | 4 - lib_dec/core_switching_dec_fx.c | 1480 +--------------------------- lib_dec/evs_dec_fx.c | 12 - lib_dec/ivas_core_dec_fx.c | 40 - lib_dec/ivas_mct_dec_fx.c | 4 - lib_dec/swb_tbe_dec_fx.c | 6 - lib_enc/amr_wb_enc_fx.c | 4 - lib_enc/core_switching_enc_fx.c | 572 ----------- lib_enc/evs_enc_fx.c | 4 - lib_enc/ivas_core_enc_fx.c | 8 - lib_enc/prot_fx_enc.h | 4 - 15 files changed, 51 insertions(+), 2416 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7962a009b..2f280d47d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2961,18 +2961,6 @@ void stereo_icBWE_preproc_fx( Word16 shb_speech_nonref[], /* o : SHB speech non-ref channel */ Word16 q_shb_speech_nonref /* i : Q SHB speech non-ref channel */ ); -#ifndef HARM_CORE_SW - -void core_switching_pre_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz */ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz */ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ -); -#endif Word16 ivas_acelp_tcx20_switching_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *inp_fx, /* i : new input signal */ diff --git a/lib_com/options.h b/lib_com/options.h index 7d73f2d34..ec24990e5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ #define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index b83e22afa..bde8b871d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7054,13 +7054,6 @@ ivas_error acelp_core_switch_dec_bfi_fx( const Word16 coder_type /* i : coder type */ ); -#ifndef HARM_CORE_SW -ivas_error acelp_core_switch_dec_bfi_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -); -#endif void pred_lt4( const Word16 excI[], /* in : excitation buffer Q_exc*/ Word16 excO[], /* out: excitation buffer Q_exc*/ @@ -7652,26 +7645,14 @@ void hq_configure_bfi_fx( void bandwidth_switching_detect_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ); -#ifndef HARM_CORE_SW - -void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); -#endif void bw_switching_pre_proc_fx( -#ifdef HARM_CORE_SW Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 last_element_brate, /* i : last element bitrate */ const Word16 nchan_out, /* i : number of output channels */ const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ -#else - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ -#endif ); ivas_error core_switching_pre_dec_fx( -#ifdef HARM_CORE_SW Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ @@ -7681,24 +7662,9 @@ ivas_error core_switching_pre_dec_fx( const Word16 Q_old_synthFB, Word16 *Q_olapBufferSynth, Word16 *Q_olapBufferSynth2 -#else - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ -#endif ); ivas_error core_switching_post_dec_fx( -#ifndef HARM_CORE_SW - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -); - -ivas_error core_switching_post_dec_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ @@ -9420,15 +9386,6 @@ void stereo_dft_dec_open( const Word16 nchan_transport /* i : number of transport channels */ ); -#ifndef HARM_CORE_SW -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ); -#endif UWord32 mvl2s_r( const Word32 x[], /* i : input vector */ const Word16 q, @@ -10237,11 +10194,7 @@ void ivas_swb_tbe_dec_fx( const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ -#ifdef HARM_CORE_SW const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ -#else - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ -#endif Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ Word16 *pitch_buf_fx, /* i : Q6 */ @@ -10288,18 +10241,6 @@ void wtda_fx32( const Word16 L /* i : length */ ); -#ifndef HARM_CORE_SW -ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ); -#endif void hp20_fx_32( Word32 signal_fx[], const Word16 lg, @@ -10765,11 +10706,6 @@ ivas_error IGF_Reconfig_fx( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -#ifndef HARM_CORE_SW -void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -); -#endif void residu_ivas_fx( const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ const Word16 a_exp, diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index d2353fd73..dd477874f 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -351,256 +351,8 @@ ivas_error acelp_core_switch_dec_fx( * * ACELP core decoder in the first ACELP->HQ switching frame in case of BAD frame *-------------------------------------------------------------------*/ -#ifndef HARM_CORE_SW -ivas_error acelp_core_switch_dec_bfi_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -) -{ - Word16 old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ - Word16 syn[L_FRAME16k]; /* synthesis signal buffer */ - Word16 lsf_new[M]; /* LSFs at the end of the frame */ - Word16 lsp_new[M]; /* LSPs at the end of the frame */ - Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ - Word16 old_exc2[L_FRAME16k + L_EXC_MEM], *exc2; /* total excitation buffer */ - Word16 tmp_noise; /* Long term temporary noise energy */ - Word16 FEC_pitch; /* FEC pitch */ - Word16 old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ - Word16 *bwe_exc; /* Excitation for SWB TBE */ - Word16 tmp1[NBPSF_PIT_MAX]; - Word16 tmp2[M]; - Word16 tmp3; - Word16 tmp4[L_TRACK_HIST]; - Word16 tmp5[L_TRACK_HIST]; - Word16 tmp6[L_TRACK_HIST]; - Word16 tmp7; - Word32 tmp8; - Word16 voice_factors[NB_SUBFR16k]; - Word16 pitch_buf[NB_SUBFR16k]; - Word16 Q_exc; - Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI]; - Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX]; - Word16 i; - CLDFB_SCALE_FACTOR scaleFactor; - Word32 workBuffer[128 * 3]; - MUSIC_POSTFILT_HANDLE hMusicPF; - BPF_DEC_HANDLE hBPF; - ivas_error error; - - hMusicPF = st_fx->hMusicPF; - hBPF = st_fx->hBPF; - error = IVAS_ERR_OK; - move32(); - - FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH_BFI; i++ ) - { - set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - imagBuffer[i] = imagBufferTmp[i]; - } - - /*----------------------------------------------------------------* - * Initialization - *----------------------------------------------------------------*/ - Q_exc = st_fx->Q_exc; - move16(); - st_fx->bpf_off = 1; - move16(); - st_fx->clas_dec = st_fx->last_good; - move16(); - tmp_noise = 0; - move16(); - - Copy( st_fx->old_exc_fx, old_exc, L_EXC_MEM_DEC ); // Q_exc - exc = old_exc + L_EXC_MEM_DEC; - IF( st_fx->hWIDec != NULL ) - { - Copy( st_fx->hWIDec->old_exc2_fx, old_exc2, L_EXC_MEM ); - } - ELSE - { - set16_fx( old_exc2, 0, L_EXC_MEM ); - } - exc2 = old_exc2 + L_EXC_MEM; - IF( st_fx->hBWE_TD != NULL ) - { - Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); // Q_exc - bwe_exc = old_bwe_exc + PIT16k_MAX * 2; - } - ELSE - { - bwe_exc = NULL; - } - - st_fx->GSC_noisy_speech = 0; - move16(); - st_fx->relax_prev_lsf_interp = 0; - move16(); - - /* SC-VBR */ - if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) ) - { - st_fx->nelp_mode_dec = 1; - move16(); - } - - Copy( st_fx->mem_AR_fx, tmp1, M ); - Copy( st_fx->mem_MA_fx, tmp2, M ); - - /* LSF estimation and A(z) calculation */ - lsf_dec_bfi( MODE1, lsf_new, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx, - st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good, - st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth ); - - FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq, lsf_new, lsp_new ); - - Copy( tmp1, st_fx->mem_AR_fx, M ); - Copy( tmp2, st_fx->mem_MA_fx, M ); - - /*----------------------------------------------------------------* - * Excitation decoding - *----------------------------------------------------------------*/ - - IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) - { - Word16 gain_buf[NB_SUBFR16k]; - Scale_sig( exc - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0 - st_fx->Q_exc = 0; - move16(); - /* SC-VBR */ - decod_nelp_fx( st_fx, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, &Q_exc, st_fx->bfi, gain_buf ); - FEC_pitch = pitch_buf[3]; - move16(); - Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &Q_exc, st_fx->Q_subfr, exc2, L_FRAME, coder_type ); - st_fx->Q_exc = Q_exc; - move16(); - } - ELSE - { - tmp1[0] = st_fx->bfi_pitch_fx; - move16(); - tmp1[1] = st_fx->bfi_pitch_frame; - move16(); - tmp1[2] = st_fx->lp_gainp_fx; - move16(); - tmp1[3] = st_fx->lp_gainc_fx; - move16(); - tmp1[4] = st_fx->upd_cnt; - move16(); - tmp1[5] = st_fx->seed; - move16(); - - /* calculation of excitation signal */ - FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc, exc2, syn /* dummy buffer */, pitch_buf, voice_factors, &FEC_pitch, bwe_exc, lsf_new, &Q_exc, &tmp_noise ); - Rescale_exc( NULL, exc, bwe_exc, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0, - &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type ); - - st_fx->seed = tmp1[5]; - move16(); - st_fx->bfi_pitch_fx = tmp1[0]; - move16(); - st_fx->bfi_pitch_frame = tmp1[1]; - move16(); - st_fx->lp_gainp_fx = tmp1[2]; - move16(); - st_fx->lp_gainc_fx = tmp1[3]; - move16(); - st_fx->upd_cnt = tmp1[4]; - move16(); - } - - /*------------------------------------------------------------------* - * Synthesis - *-----------------------------------------------------------------*/ - - Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, - hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL ); - Copy( st_fx->mem_syn2_fx, tmp1, M ); - syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn ); - - tmp8 = st_fx->enr_old_fx; - move32(); - frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp8, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); - - /*------------------------------------------------------------------* - * Perform fixed deemphasis through 1/(1 - g*z^-1) - *-----------------------------------------------------------------*/ - tmp1[0] = st_fx->mem_deemph_fx; - move16(); /*if in acelp_core_dec_fx deemph_fx is used*/ - /*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp1[0] ); /*Q0*/ - } - ELSE - { - deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp1[0] ); /*Q0*/ - } - - /*----------------------------------------------------------------* - * Bass post-filter - *----------------------------------------------------------------*/ - - st_fx->bpf_off = 1; - move16(); - Copy( hBPF->pst_old_syn_fx, tmp1, NBPSF_PIT_MAX ); - - tmp3 = st_fx->stab_fac_smooth_fx; - move16(); - Copy( hBPF->mem_mean_pit_fx, tmp4, L_TRACK_HIST ); - Copy( hBPF->Track_on_hist, tmp5, L_TRACK_HIST ); - Copy( hBPF->vibrato_hist, tmp6, L_TRACK_HIST ); - tmp7 = hBPF->psf_att_fx; - move16(); - - bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn, st_fx->L_frame, pitch_buf, - st_fx->bpf_off, st_fx->stab_fac_fx, &tmp3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ ); - - Copy( tmp1, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); - Copy( tmp4, hBPF->mem_mean_pit_fx, L_TRACK_HIST ); - Copy( tmp5, hBPF->Track_on_hist, L_TRACK_HIST ); - Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST ); - hBPF->psf_att_fx = tmp7; - move16(); - /*----------------------------------------------------------------* - * Resamping to the output sampling frequency - *----------------------------------------------------------------*/ - /* CLDFB analysis of the synthesis at internal sampling rate */ - IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) ) - { - return error; - } - cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer ); - cldfb_restore_memory( st_fx->cldfbAna ); - - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - /* CLDFB synthesis of the combined signal */ - IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) ) - { - return error; - } - cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, - negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer ); - - /* output to Q0 */ - Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); // Q0 - - cldfb_restore_memory( st_fx->cldfbSyn ); - - return error; -} -#endif -#ifdef HARM_CORE_SW ivas_error acelp_core_switch_dec_bfi_fx( -#else -ivas_error acelp_core_switch_dec_bfi_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 synth_out[], /* o : synthesis Q_syn */ const Word16 coder_type /* i : coder type */ @@ -768,9 +520,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( move16(); Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) -#endif { Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) ); // Q_syn } @@ -828,7 +578,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( * Resamping to the output sampling frequency *----------------------------------------------------------------*/ -#ifdef HARM_CORE_SW IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { CLDFB_SCALE_FACTOR scaleFactor; @@ -858,7 +607,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( cldfb_restore_memory( st_fx->cldfbSyn ); } ELSE -#endif { /* CLDFB analysis of the synthesis at internal sampling rate */ Qtmp = sub( 11, st_fx->Q_syn ); diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index f05299be6..3806f8c2a 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -172,11 +172,7 @@ ivas_error amr_wb_dec_fx( } /* Updates in case of EVS -> AMR-WB IO switching */ -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index e55c64f7f..1454f8c41 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -11,7 +11,6 @@ #include "ivas_prot_fx.h" -#ifdef HARM_CORE_SW /*---------------------------------------------------------------------* * Local prototypes *---------------------------------------------------------------------*/ @@ -20,131 +19,6 @@ static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_fra static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); -#else -/*---------------------------------------------------------------------* - * bandwidth_switching_detect_fx() - * - * - *---------------------------------------------------------------------*/ - -static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); -static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); - -void bandwidth_switching_detect_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -) -{ - test(); - test(); - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt = 0; - st_fx->bws_cnt1 = 0; - move16(); - move16(); - move16(); - - return; - } - /* update band-width switching counter */ - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); /* Q0 */ - move16(); - } - ELSE IF( st_fx->bws_cnt1 > 0 ) - { - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 ); /* Q0 */ - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, SWB ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); /* Q0 */ - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - } - } - - /* update band-width switching counter */ - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); /* Q0 */ - move16(); - } - ELSE IF( st_fx->bws_cnt > 0 ) - { - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 ); /* Q0 */ - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - } - } - - return; -} -#endif /*---------------------------------------------------------------------* * Calc_freq_ener_fx() @@ -186,15 +60,10 @@ static Word32 Calc_freq_ener_fx( *---------------------------------------------------------------------*/ void bw_switching_pre_proc_fx( -#ifdef HARM_CORE_SW Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 last_element_brate, /* i : last element bitrate */ const Word16 nchan_out, /* i : number of output channels */ const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ -#else - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ -#endif ) { Word16 i; @@ -203,7 +72,6 @@ void bw_switching_pre_proc_fx( IF( st_fx->element_mode > EVS_MONO ) { -#ifdef HARM_CORE_SW test(); test(); test(); @@ -226,7 +94,6 @@ void bw_switching_pre_proc_fx( } return; -#endif } test(); @@ -262,972 +129,50 @@ void bw_switching_pre_proc_fx( L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ move32(); - } - ELSE - { - IF( st_fx->hHQ_core->old_is_transient[0] ) - { - L_tmp = L_deposit_l( 0 ); - FOR( i = 0; i < 32; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ - st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - L_tmp = L_deposit_l( 0 ); - FOR( ; i < 64; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ - st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - } - ELSE - { - L_tmp = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ - st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - L_tmp = L_deposit_l( 0 ); - FOR( ; i < L_FRAME; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ - st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - } - } - - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( st_fx->last_bwidth == 0 && LE_16( st_fx->extl, SWB_CNG ) ) - { - st_fx->prev_ener_shb_fx = 0; - move16(); - set16_fx( st_fx->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV ); - } - ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) ) - { - st_fx->attenu_fx = 3277; /* Q15 */ - move16(); - } - - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && !( EQ_16( st_fx->last_extl, WB_TBE ) || EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && GT_32( st_fx->core_brate, ACELP_8k00 ) ) ) - { - st_fx->prev_fractive = 0; - move16(); - } - - return; -} - -#ifndef HARM_CORE_SW -/*---------------------------------------------------------------------* - * core_switching_pre_dec_fx() - * - * Preprocessing/preparation for ACELP/HQ core switching - *---------------------------------------------------------------------*/ -ivas_error core_switching_pre_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ -) -{ - Word16 oldLenClasBuff, newLenClasBuff, i; - BPF_DEC_HANDLE hBPF; - TD_BWE_DEC_HANDLE hBWE_TD; - FD_BWE_DEC_HANDLE hBWE_FD; - HQ_DEC_HANDLE hHQ_core; - TCX_DEC_HANDLE hTcxDec; - ivas_error error; - - hBWE_TD = st_fx->hBWE_TD; - hBWE_FD = st_fx->hBWE_FD; - hHQ_core = st_fx->hHQ_core; - hBPF = st_fx->hBPF; - hTcxDec = st_fx->hTcxDec; - - error = IVAS_ERR_OK; - move32(); - test(); - test(); - test(); - /* Codec switching */ - IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && st_fx->element_mode > EVS_MONO ) ) - { - st_fx->mem_deemph_fx = st_fx->syn[M]; /* Q_syn */ - move16(); - set16_fx( st_fx->agc_mem_fx, 0, 2 ); /* Q0 */ - Scale_sig( &( st_fx->mem_deemph_fx ), 1, st_fx->Q_syn ); /* Brings mem_deemph to Qsyn */ - - Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/ - - st_fx->bpf_off = 1; - move16(); - Scale_sig( st_fx->hPFstat->mem_pf_in, L_SUBFR, st_fx->Q_syn ); /* Post_filter mem */ /* st_fx->Q_syn*/ - Scale_sig( st_fx->hPFstat->mem_res2, DECMEM_RES2, st_fx->Q_syn ); /* NB post_filter mem */ /* st_fx->Q_syn */ - Scale_sig( st_fx->hPFstat->mem_stp, L_SUBFR, st_fx->Q_syn ); /* Post_filter mem */ /* st_fx->Q_syn */ - IF( hBPF != NULL ) - { - set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ - hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st_fx->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ - hBPF->pst_mem_deemp_err_fx = 0; - move16(); - move16(); - } - move16(); - st_fx->psf_lp_noise_fx = round_fx( L_shl( st_fx->lp_noise, 1 ) ); /* 2 * lp_noise_q - 16 */ - - /* reset old HB synthesis buffer */ - IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) - { - st_fx->old_bwe_delay = NS2SA_FX2( st_fx->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); /* Q0 */ - } - ELSE - { - st_fx->old_bwe_delay = NS2SA_FX2( st_fx->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); /* Q0 */ - } - move16(); - set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - - /* reset upd_cnt */ - st_fx->upd_cnt = MAX_UPD_CNT; - move16(); - st_fx->igf = 0; - move16(); - - - test(); - IF( hBWE_TD != NULL && NE_16( st_fx->last_core, ACELP_CORE ) ) - { - hBWE_TD->prev_hb_synth_fx_exp = 31; - move16(); - /* reset BWE memories */ - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); /* Q_exc */ - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - } - - test(); - IF( GE_32( st_fx->output_Fs, 16000 ) && st_fx->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st_fx->hBWE_zero ); - } - IF( st_fx->hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - IF( st_fx->hHQ_core != NULL ) - { - set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - IF( GT_32( st_fx->output_Fs, 16000 ) ) - { - set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - /* pre-echo */ - hHQ_core->pastpre = 0; - move16(); - } - /* reset the GSC pre echo energy threshold in case of switching */ - IF( st_fx->hGSCDec != NULL ) - { - st_fx->hGSCDec->Last_frame_ener_fx = MAX_32; - } - move32(); - - test(); - IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) - { - IF( st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = HQ_CORE; - move16(); - Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /* st_fx->q_prev_synth_buffer_fx */ - } - IF( hHQ_core != NULL ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - } - - IF( st_fx->prev_bfi != 0 ) - { - Word16 delay_comp; - - /*switch off Hq Voicing as it was not uodated in MODE2*/ - IF( hHQ_core != NULL ) - { - hHQ_core->oldHqVoicing = 0; - hHQ_core->HqVoicing = 0; - move16(); - move16(); - } - - delay_comp = NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ); - - test(); - test(); - IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) ) - { - - Word16 no_col; - Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH]; - Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; - CLDFB_SCALE_FACTOR scaleFactor; - Word32 workBuffer[128 * 3]; - - FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) - { - set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - move32(); - imagBuffer[i] = imagBufferTmp[i]; - move32(); - } - - no_col = s_min( st_fx->cldfbAna->no_col, idiv1616( sub( add( delay_comp, st_fx->cldfbAna->no_channels ), 1 ), st_fx->cldfbAna->no_channels ) ); /* Q0 */ - - /* CLDFB analysis of the synthesis at internal sampling rate */ - IF( ( error = cldfb_save_memory( st_fx->cldfbAna ) ) != IVAS_ERR_OK ) - { - return error; - } - cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, hTcxDec->syn_Overl, 0, no_col, workBuffer ); - cldfb_restore_memory( st_fx->cldfbAna ); - - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - /* CLDFB synthesis of the combined signal */ - IF( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ) != IVAS_ERR_OK ) - { - return error; - } - cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, hHQ_core->fer_samples_fx, 0, no_col, workBuffer ); - cldfb_restore_memory( st_fx->cldfbSyn ); - } - - test(); - test(); - IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) ) - { - lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( st_fx->output_frame_fx, 1 ), shr( st_fx->last_L_frame, 1 ) ); - /*Set to zero the remaining part*/ - set16_fx( hHQ_core->fer_samples_fx + delay_comp + shr( st_fx->output_frame_fx, 1 ), 0, shr( st_fx->output_frame_fx, 1 ) - delay_comp ); - } - } - - st_fx->use_acelp_preq = 0; - move16(); - st_fx->reset_mem_AR = 0; - move16(); - } - - /*FEC*/ - IF( LE_16( st_fx->L_frame, L_FRAME16k ) ) - { - test(); - IF( LE_16( st_fx->last_L_frame, L_FRAME16k ) && NE_16( st_fx->core, HQ_CORE ) ) - { - IF( NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) - { - IF( GT_16( st_fx->L_frame, st_fx->last_L_frame ) ) - { - oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->last_L_frame, getInvFrameLen( st_fx->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); - newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - } - ELSE - { - oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - newLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->L_frame, getInvFrameLen( st_fx->last_L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); - } - lerp( &st_fx->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st_fx->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); - } - } - ELSE - { - set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); - st_fx->classifier_Q_mem_syn = 0; - move16(); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) - { - st_fx->last_ppp_mode_dec = 0; - move16(); - st_fx->last_nelp_mode_dec = 0; - move16(); - } - - test(); - test(); - test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st_fx->act_count = 3; - move16(); - st_fx->uv_count = 0; - move16(); - } - - test(); - test(); - IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ) - { - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - st_fx->hPFstat->reset = 1; - move16(); - } - - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* Q2.56 */ - Copy( TRWB2_Ave_fx, st_fx->lsfoldbfi1_fx, M ); /* Q2.56 */ - Copy( TRWB2_Ave_fx, st_fx->lsfoldbfi0_fx, M ); /* Q2.56*/ - Copy( TRWB2_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); /* Q2.56 */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ /* Q2.56 */ - Copy( TRWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); /* Q2.56 */ - Copy( TRWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); /* Q2.56 */ - Copy( TRWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); /* Q2.56 */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); - } - - - set16_fx( st_fx->agc_mem_fx, 0, 2 ); - st_fx->mem_deemph_fx = 0; - move16(); - IF( !st_fx->last_con_tcx ) - { - set16_fx( st_fx->mem_syn2_fx, 0, M ); - } - set16_fx( st_fx->mem_syn1_fx, 0, M ); - IF( hBWE_TD != NULL ) - { - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move16(); - } - /* Reset ACELP parameters */ - set16_fx( st_fx->mem_MA_fx, 0, M ); - IF( EQ_32( st_fx->sr_core, INT_FS_16k ) ) - { - Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); /* Q2.56 */ - } - ELSE - { - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); /* Q2.56 */ - } - st_fx->tilt_code_fx = 0; - move16(); - st_fx->gc_threshold_fx = 0; - move16(); - st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); /* Q16 */ - move32(); - set16_fx( st_fx->dm_fx.prev_gain_pit, 0, 6 ); - st_fx->dm_fx.prev_state = 0; - move16(); - - st_fx->last_coder_type = GENERIC; - move16(); - - frame_ener_fx( output_frame, UNVOICED_CLAS, st_fx->previoussynth_fx, -1, &st_fx->enr_old_fx, 1, 0, 0, 0 ); - st_fx->lp_gainp_fx = 0; - move16(); - - /* the sqrt below needs to be changed to use basop Sqrt16 */ - /*st_fx->lp_gainc_fx = (float)sqrt( st_fx->lp_ener_fx ); */ - IF( st_fx->lp_ener_fx != 0 ) - { - Word32 L_tmp; - Word16 tmp, exp; - exp = norm_l( st_fx->lp_ener_fx ); /* In Q6 */ - tmp = extract_h( L_shl( st_fx->lp_ener_fx, exp ) ); - exp = sub( exp, 30 - 6 ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - - st_fx->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ - move16(); - } - - - st_fx->last_voice_factor_fx = 0; - move16(); - st_fx->Last_GSC_noisy_speech_flag = 0; - move16(); - - /* reset CLDFB memories */ - cldfb_reset_memory( st_fx->cldfbAna ); - cldfb_reset_memory( st_fx->cldfbBPF ); - cldfb_reset_memory( st_fx->cldfbSyn ); - - /* reset TBE memories */ - test(); - test(); - - IF( !st_fx->last_con_tcx && !( ( EQ_16( st_fx->last_core, HQ_CORE ) ) && st_fx->element_mode > EVS_MONO ) ) - { - set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); - } - ELSE IF( LT_16( st_fx->L_frame, L_FRAME16k ) ) - { - /* resample from 16kHz to 12.8kHZ */ - synth_mem_updt2( st_fx->L_frame, L_FRAME16k, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC ); - } - - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - } - - test(); - IF( GE_32( st_fx->output_Fs, 16000L ) && st_fx->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st_fx->hBWE_zero ); - } - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( hHQ_core != NULL && EQ_16( st_fx->core, HQ_CORE ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) || ( st_fx->element_mode != EVS_MONO && NE_16( st_fx->last_core, HQ_CORE ) ) ) ) - { - set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - IF( GT_32( st_fx->output_Fs, 16000 ) ) - { - set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - if ( st_fx->element_mode != EVS_MONO ) - { - } - else - { - set16_fx( hHQ_core->old_out_fx, 0, output_frame ); - hHQ_core->Q_old_wtda_LB = 15; - hHQ_core->Q_old_wtda = 15; - move16(); - } - } - - test(); - /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ - IF( hHQ_core != NULL ) - { - hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 ); /* Q0 */ - move16(); - IF( hHQ_core->pastpre <= 0 ) - { - reset_preecho_dec_fx( hHQ_core ); - } - } - IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) ) - { - st_fx->VAD = 0; - move16(); - st_fx->m_frame_type = ZERO_FRAME; - move16(); - } - ELSE IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - st_fx->VAD = 0; - move16(); - st_fx->m_frame_type = SID_FRAME; - move16(); - } - ELSE - { - st_fx->VAD = 1; - move16(); - st_fx->m_frame_type = ACTIVE_FRAME; - move16(); - } - - /*switch on CNA on active frames*/ - IF( st_fx->element_mode == EVS_MONO ) /* for IVAS modes, st->flag_cna is set earlier */ - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( NE_16( st_fx->core, AMR_WB_CORE ) && st_fx->VAD && LE_32( st_fx->total_brate, CNA_MAX_BRATE ) ) - { - st_fx->flag_cna = 1; - move16(); - } - ELSE IF( EQ_16( st_fx->core, AMR_WB_CORE ) && st_fx->VAD && LE_32( st_fx->total_brate, ACELP_8k85 ) ) - { - st_fx->flag_cna = 1; - move16(); - } - ELSE IF( st_fx->VAD || ( EQ_16( st_fx->cng_type, FD_CNG ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) - { - st_fx->flag_cna = 0; - move16(); - } - } - if ( EQ_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - - test(); - test(); - test(); - test(); - IF( st_fx->hFdCngDec && ( ( NE_16( st_fx->last_L_frame, st_fx->L_frame ) ) || - ( NE_16( st_fx->hFdCngDec->hFdCngCom->frameSize, st_fx->L_frame ) ) || - st_fx->ini_frame == 0 || NE_16( st_fx->bwidth, st_fx->last_bwidth ) ) ) - { - - IF( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - Word32 tmp; - - tmp = st_fx->total_brate; - move32(); - test(); - if ( EQ_16( st_fx->rf_flag, 1 ) && EQ_32( st_fx->total_brate, ACELP_13k20 ) ) - { - tmp = ACELP_9k60; - move32(); - } - configureFdCngDec_fx( st_fx->hFdCngDec, st_fx->bwidth, tmp, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode ); - } - ELSE - { - configureFdCngDec_fx( st_fx->hFdCngDec, 1, ACELP_8k00, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode ); - - if ( st_fx->VAD ) - { - st_fx->hFdCngDec->hFdCngCom->CngBitrate = st_fx->total_brate; - move32(); - } - } - - test(); - test(); - IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) ) - { - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - } - - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); - test(); - IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) ) - { - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ ) - { - st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* q_olapBuffer */ - move16(); - } - } - ELSE - { - FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ ) - { - st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 /* Q14*/ ); /* q_olapBuffer */ - move16(); - } - } - } - } - } - - return error; -} - - -/*---------------------------------------------------------------------* - * core_switching_post_dec() - * - * Postprocessing for ACELP/HQ core switching - *---------------------------------------------------------------------*/ - -ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -) -{ - Word16 i, delay_comp, delta; - Word16 tmpF, tmp, Fs_kHz, shift, *ptmp1, *ptmp2; - Word32 L_tmp; - Word16 synth_subfr_out[SWITCH_MAX_GAP], synth_subfr_bwe[SWITCH_MAX_GAP]; - Word16 mem_synth[NS2SA( 16000, DELAY_CLDFB_NS ) + 2]; - Word16 Qtmp; - Word16 Qsubfr; - TD_BWE_DEC_HANDLE hBWE_TD; - FD_BWE_DEC_HANDLE hBWE_FD; - HQ_DEC_HANDLE hHQ_core; - ivas_error error; - - (void) ( last_element_mode ); - hBWE_TD = st_fx->hBWE_TD; - hBWE_FD = st_fx->hBWE_FD; - hHQ_core = st_fx->hHQ_core; - error = IVAS_ERR_OK; - move32(); - - /* Rescale synthesis in Q0 to avoid multiple rescaling after */ - tmp = Find_Max_Norm16( synth, output_frame ); - Scale_sig( synth, output_frame, tmp ); - *Qsynth = add( *Qsynth, tmp ); - move16(); - - test(); - test(); - test(); - IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) - { - if ( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) - { - return error; - } /*the output at Q0*/ - } - - /* set multiplication factor according to the sampling rate */ - tmp = extract_l( L_shr( st_fx->output_Fs, 13 ) ); /* Q0 */ - Fs_kHz = shl( add( tmp, 1 ), 3 ); /* Q0 */ - - delta = 1; - move16(); - if ( GE_16( output_frame, L_FRAME16k ) ) - { - delta = shr( Fs_kHz, 3 ); /* Q0 */ - } - - /* set delay compensation between HQ synthesis and ACELP synthesis */ - delay_comp = i_mult2( delta, HQ_DELAY_COMP ); /* Q0 */ - - IF( EQ_16( st_fx->core, HQ_CORE ) ) - { - st_fx->use_acelp_preq = 0; - move16(); - /* rescaling to the min exp of the 2 */ - /* Qtmp=s_min(*Qsynth,st_fx->Q_old_postdec); - Scale_sig(synth, output_frame, sub(Qtmp,*Qsynth)); - Scale_sig(st_fx->delay_buf_out_fx, delay_comp, sub(Qtmp,st_fx->Q_old_postdec));*/ - - hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - - test(); - test(); - test(); - IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) - { - if ( ( error = acelp_core_switch_dec_fx( st_fx, synth_subfr_out, synth_subfr_bwe, output_frame, core_switching_flag, mem_synth, &Qsubfr ) ) != IVAS_ERR_OK ) - { - return error; - } - } - test(); - test(); - IF( core_switching_flag && EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->prev_bfi ) - { - Copy( st_fx->delay_buf_out_fx, synth_subfr_out, delay_comp ); /* hHQ_core->Q_old_postdec */ - Qsubfr = hHQ_core->Q_old_postdec; - move16(); - } - - /* delay HQ synthesis to synchronize with ACELP synthesis */ - /* rescaling to the min exp of the 2 */ - Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec ); - Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qtmp */ - *Qsynth = Qtmp; - move16(); - Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */ - hHQ_core->Q_old_postdec = Qtmp; - move16(); - delay_signal_fx( synth, output_frame, st_fx->delay_buf_out_fx, delay_comp ); /* Qsynth, Q0 */ - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) - { - /* mem_over_hp_fx : Qsubfr */ - core_switching_OLA_fx( mem_synth, st_fx->last_L_frame, st_fx->output_Fs, synth, synth_subfr_out, synth_subfr_bwe, output_frame, st_fx->bwidth, Qsynth, &Qsubfr ); - } - ELSE IF( core_switching_flag && EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->prev_bfi ) /* HQ | ACELP | TRANSITION with ACELP frame lost */ - { - /* Overlapp between old->out (stocked in st_fx->fer_samples)and good HQ frame on L/2 */ - ptmp1 = &synth[delay_comp]; /* Qsynth */ - shift = i_mult2( Fs_kHz, 10 ); - tmp = i_mult2( delta, shr( N16_CORE_SW, 1 ) ); - - Scale_sig( hHQ_core->fer_samples_fx, output_frame, *Qsynth ); /* Qsynth */ - ptmp2 = &hHQ_core->fer_samples_fx[tmp]; - tmp = div_s( 1, shift ); /*Q15*/ - tmpF = 0; - move16(); - - FOR( i = 0; i < shift; i++ ) - { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ - *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ - ptmp1++; - ptmp2++; - tmpF = add( tmpF, tmp ); - } - } - ELSE IF( ( !core_switching_flag && EQ_16( st_fx->core, HQ_CORE ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */ - || ( core_switching_flag && st_fx->prev_bfi && NE_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) ) ) - { - /* Overlapp between CELP estimation (BFI) and good HQ frame on L/2 */ - shift = i_mult2( Fs_kHz, 10 ); - tmp = div_s( 1, shift ); /*Q15*/ - tmpF = 0; - move16(); - ptmp1 = synth; - Scale_sig( hHQ_core->fer_samples_fx, output_frame, *Qsynth ); /* Qsynth */ - ptmp2 = hHQ_core->fer_samples_fx; - FOR( i = 0; i < shift; i++ ) - { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ - *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ - move16(); - tmpF = add( tmpF, tmp ); - ptmp1++; - ptmp2++; - } - } - - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - IF( !( EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && EQ_32( st_fx->core_brate, HQ_32k ) ) ) - { - set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - } - Copy_Scale_sig( synth, st_fx->previoussynth_fx, output_frame, negate( *Qsynth ) ); /*scaling of st_fx->previoussynth_fx set at Q0*/ - - /*Set post-filtering flag to zero*/ - st_fx->hPFstat->on = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->last_core, HQ_CORE ) ) /* MDCT to ACELP transition */ - { - Qtmp = s_min( s_min( *Qsynth, hHQ_core->Q_old_postdec ), hHQ_core->Q_old_wtda ); - - Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qsynth */ - Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */ - Scale_sig( hHQ_core->old_out_fx, L_FRAME48k, sub( Qtmp, hHQ_core->Q_old_wtda ) ); /* Qtmp */ - *Qsynth = Qtmp; - move16(); - hHQ_core->Q_old_postdec = Qtmp; - move16(); - hHQ_core->Q_old_wtda = Qtmp; - move16(); - - Copy( st_fx->delay_buf_out_fx, synth, delay_comp ); /* copy the HQ/ACELP delay synchroniation buffer at the beginning of ACELP frame Q0*/ - - tmp = i_mult2( delta, N_ZERO_8 ); - shift = i_mult2( Fs_kHz, 3 ); - test(); - IF( st_fx->prev_bfi && hHQ_core->HqVoicing ) - { - Copy_Scale_sig( hHQ_core->fer_samples_fx, &hHQ_core->old_out_fx[tmp], shift, *Qsynth ); /* Qsynth */ - } - - ptmp2 = &hHQ_core->old_out_fx[tmp]; - tmp = div_s( 1, shift ); - ptmp1 = &synth[delay_comp]; - tmpF = 0; - move16(); - FOR( i = 0; i < shift; i++ ) - { - *ptmp1 = add( mult_r( tmpF, *ptmp1 ), mult_r( sub( 32767, tmpF ), *ptmp2++ ) ); /* Q0 */ - move16(); - ptmp1++; - tmpF = add( tmpF, tmp ); - } - } - - set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); - hHQ_core->oldHqVoicing = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - - /* reset SWB BWE buffers */ - test(); - test(); - test(); - IF( st_fx->bws_cnt == 0 || ( st_fx->bws_cnt > 0 && NE_16( st_fx->coder_type, INACTIVE ) && NE_16( st_fx->coder_type, AUDIO ) ) ) - { - st_fx->attenu_fx = 3277; /* Q15 */ - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || ( NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) || - ( ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_extl, SWB_TBE ) ) && st_fx->extl < 0 && NE_16( st_fx->core, HQ_CORE ) ) || ( st_fx->last_core == ACELP_CORE && st_fx->core == ACELP_CORE && ( ( NE_16( st_fx->prev_coder_type, INACTIVE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) || ( NE_16( st_fx->prev_coder_type, AUDIO ) && EQ_16( st_fx->coder_type, AUDIO ) ) ) && st_fx->bws_cnt > 0 ) ) - { - set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); - hBWE_FD->old_wtda_swb_fx_exp = 0; - move16(); - if ( NE_16( st_fx->last_extl, WB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - } - - hBWE_FD->prev_Energy_fx = 0; - move16(); - hBWE_FD->prev_L_swb_norm = 8; - move16(); - hBWE_FD->prev_frica_flag = 0; - move16(); - set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); - hBWE_FD->prev_td_energy_fx = 0; - move16(); - hBWE_FD->prev_weight_fx = 6554; - move16(); /*0.2 in Q15*/ - hBWE_FD->prev_fb_ener_adjust_fx = 0; - move16(); - } - - /* reset WB BWE buffers */ - test(); - IF( NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) ) - { - set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); - - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) + } + ELSE + { + IF( st_fx->hHQ_core->old_is_transient[0] ) { - hBWE_FD->prev_mode = NORMAL; - move16(); + L_tmp = L_deposit_l( 0 ); + FOR( i = 0; i < 32; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ + st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); + L_tmp = L_deposit_l( 0 ); + FOR( ; i < 64; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ + st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); + } + ELSE + { + L_tmp = L_deposit_l( 0 ); + FOR( i = 0; i < L_FRAME / 2; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ + st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); + L_tmp = L_deposit_l( 0 ); + FOR( ; i < L_FRAME; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ + st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); } - hBWE_FD->prev_Energy_wb_fx = 0; - move16(); - hBWE_FD->prev_L_swb_norm = 8; - move16(); - set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); - hBWE_FD->prev_flag = 0; - move16(); } - /* reset SWB TBE buffers */ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); + test(); test(); test(); @@ -1235,78 +180,34 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); - IF( ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || EQ_16( st_fx->extl, SWB_CNG ) ) && - ( NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || EQ_16( st_fx->last_core, HQ_CORE ) ) ) || - ( LT_16( st_fx->bwidth, st_fx->last_bwidth ) && NE_16( st_fx->last_extl, SWB_TBE ) ) || st_fx->old_ppp_mode || ( ( EQ_16( st_fx->prev_coder_type, AUDIO ) || EQ_16( st_fx->prev_coder_type, INACTIVE ) ) && st_fx->bws_cnt > 0 ) || ( st_fx->bws_cnt == 0 && EQ_16( st_fx->prev_bws_cnt, N_WS2N_FRAMES ) ) ) + IF( st_fx->last_bwidth == 0 && LE_16( st_fx->extl, SWB_CNG ) ) { - swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); - - set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 ); - swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 ); - - IF( EQ_16( output_frame, L_FRAME16k ) ) - { - /* reset in case that SWB TBE layer is transmitted, but the output is 16kHz sampled */ - set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - set32_fx( hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - } - set16_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN ); - set32_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx_32, 0, INTERP_3_2_MEM_LEN ); + st_fx->prev_ener_shb_fx = 0; + move16(); + set16_fx( st_fx->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV ); } - ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && - ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) || - NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_flag, st_fx->rf_flag_last ) ) ) + ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) ) { - set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->gain_prec_swb_fx = 16384; - move16(); /*Q14 = 1 */ + st_fx->attenu_fx = 3277; /* Q15 */ + move16(); } - /* Interp_3_2 CNG buffers reset */ test(); test(); test(); - IF( st_fx->hTdCngDec != NULL && EQ_32( st_fx->output_Fs, 48000 ) && ( ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) && ( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) ) ) - { - set16_fx( st_fx->hTdCngDec->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN ); - } - - /* reset FB TBE buffers */ test(); test(); - IF( EQ_16( st_fx->extl, FB_TBE ) && ( NE_16( st_fx->last_extl, FB_TBE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) ) + IF( EQ_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && !( EQ_16( st_fx->last_extl, WB_TBE ) || EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && GT_32( st_fx->core_brate, ACELP_8k00 ) ) ) { - set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->fb_tbe_demph_fx = 0; + st_fx->prev_fractive = 0; move16(); - fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); } - /* reset WB TBE buffers */ - test(); - IF( NE_16( st_fx->last_extl, WB_TBE ) && EQ_16( st_fx->extl, WB_TBE ) ) - { - wb_tbe_extras_reset_fx( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); - wb_tbe_extras_reset_synth_fx( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_32and48k_WB_upsample_fx, hBWE_TD->mem_resamp_HB_fx ); - - set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); - set16_fx( hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); - set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 ); - } - - return error; + return; } -#endif -#ifdef HARM_CORE_SW + ivas_error core_switching_post_dec_fx( -#else -ivas_error core_switching_post_dec_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ @@ -1353,11 +254,7 @@ ivas_error core_switching_post_dec_ivas_fx( test(); IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { -#ifdef HARM_CORE_SW IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) -#else - IF( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) -#endif { return error; } /*the output at Q0*/ @@ -1426,9 +323,7 @@ ivas_error core_switching_post_dec_ivas_fx( /* delay HQ synthesis to synchronize with ACELP synthesis */ /* rescaling to the min exp of the 2 */ -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) -#endif { Word16 NonZero = 1; move16(); @@ -1781,7 +676,6 @@ ivas_error core_switching_post_dec_ivas_fx( move16(); } -#ifdef HARM_CORE_SW IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); @@ -1790,7 +684,6 @@ ivas_error core_switching_post_dec_ivas_fx( hHQ_core->prev_stab_hfe2 = 0; move16(); } -#endif } } ELSE @@ -2234,34 +1127,22 @@ static void smoothTransitionDtxToTcx_fx( * Preprocessing/preparation for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW ivas_error core_switching_pre_dec_fx( -#else -ivas_error core_switching_pre_dec_ivas_fx( -#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ const Word16 nchan_out, /* i : number of output channels */ const Word16 last_element_mode, /* i : last_element_mode */ const Word32 last_element_brate, /* i : last element bitrate */ -#ifdef HARM_CORE_SW const Word16 Q_old_synthFB, -#else - Word16 Q_old_synthFB, -#endif Word16 *Q_olapBufferSynth, Word16 *Q_olapBufferSynth2 ) { Word32 tmp_fx; /*Q-12*/ Word16 i, oldLenClasBuff, newLenClasBuff; ivas_error error; -#ifdef HARM_CORE_SW Word16 tmp, exp = Q25; Word32 L_tmp; -#else - Word16 exp = 25; -#endif move16(); BPF_DEC_HANDLE hBPF; TD_BWE_DEC_HANDLE hBWE_TD; @@ -2298,15 +1179,10 @@ ivas_error core_switching_pre_dec_ivas_fx( Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ -#ifndef HARM_CORE_SW - set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ -#endif } IF( hBPF != NULL ) { -#ifdef HARM_CORE_SW set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ -#endif hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ hBPF->pst_mem_deemp_err_fx = 0; move16(); @@ -2353,9 +1229,7 @@ ivas_error core_switching_pre_dec_ivas_fx( #endif { hf_synth_reset_fx( st->hBWE_zero ); -#ifdef HARM_CORE_SW IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment -#endif set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } @@ -2400,12 +1274,7 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_core = HQ_CORE; move16(); -#ifdef HARM_CORE_SW Copy( hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /* st->q_prev_synth_buffer_fx */ -#else - Copy32( hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - // Copy_Scale_sig_32_16( hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 -#endif } IF( hHQ_core != NULL ) @@ -2438,7 +1307,6 @@ ivas_error core_switching_pre_dec_ivas_fx( delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { test(); @@ -2484,7 +1352,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { /*TODO To be tested:control not entering the block*/ test(); @@ -2555,7 +1422,6 @@ ivas_error core_switching_pre_dec_ivas_fx( { IF( NE_16( st->L_frame, st->last_L_frame ) ) { -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { IF( GT_16( st->L_frame, st->last_L_frame ) ) @@ -2572,7 +1438,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { IF( GT_16( st->L_frame, st->last_L_frame ) ) { @@ -2593,10 +1458,8 @@ ivas_error core_switching_pre_dec_ivas_fx( ELSE { set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); -#ifdef HARM_CORE_SW st->classifier_Q_mem_syn = 0; move16(); -#endif } } @@ -2722,7 +1585,6 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_coder_type = GENERIC; move16(); -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); @@ -2744,7 +1606,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ st->lp_gainp_fx = 0; @@ -2761,7 +1622,6 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); /* reset CLDFB memories */ -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { cldfb_reset_memory( st->cldfbAna ); @@ -2769,7 +1629,6 @@ ivas_error core_switching_pre_dec_ivas_fx( cldfb_reset_memory( st->cldfbSyn ); } ELSE -#endif { cldfb_reset_memory_fx( st->cldfbAna ); cldfb_reset_memory_fx( st->cldfbBPF ); @@ -2802,9 +1661,7 @@ ivas_error core_switching_pre_dec_ivas_fx( #endif { hf_synth_reset_fx( st->hBWE_zero ); -#ifdef HARM_CORE_SW IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment -#endif set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } @@ -2875,23 +1732,11 @@ ivas_error core_switching_pre_dec_ivas_fx( /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ Word16 offset; offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); -#ifdef HARM_CORE_SW Word32 old_synthFB_fx[L_FRAME_PLUS * 2]; -#else - Word32 *old_synthFB_fx; - IF( ( old_synthFB_fx = (Word32 *) malloc( hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); - } -#endif Copy_Scale_sig_16_32_no_sat( hTcxDec->old_synthFB_fx, old_synthFB_fx, hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 Copy32( old_synthFB_fx + hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); st->cldfbAna->Q_cldfb_state = Q10; move16(); -#ifndef HARM_CORE_SW - IF( old_synthFB_fx ) - free( old_synthFB_fx ); -#endif } } @@ -2951,17 +1796,12 @@ ivas_error core_switching_pre_dec_ivas_fx( } ELSE { -#ifdef HARM_CORE_SW set16_fx( hHQ_core->old_out_fx, 0, output_frame ); set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); hHQ_core->Q_old_wtda_LB = Q15; move16(); hHQ_core->Q_old_wtda = Q15; move16(); -#else - set16_fx( hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( hHQ_core->old_out_LB_fx32, 0, L_FRAME16k ); -#endif } } @@ -3030,7 +1870,6 @@ ivas_error core_switching_pre_dec_ivas_fx( /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ IF( NE_16( st->core, AMR_WB_CORE ) ) { -#ifdef HARM_CORE_SW L_tmp = st->total_brate; move32(); test(); @@ -3048,25 +1887,10 @@ ivas_error core_switching_pre_dec_ivas_fx( { configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); } -#else - test(); - IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode ); - } - ELSE - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); - } -#endif } ELSE { -#ifdef HARM_CORE_SW configureFdCngDec_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); -#else - configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); -#endif if ( st->VAD ) { @@ -3085,7 +1909,6 @@ ivas_error core_switching_pre_dec_ivas_fx( lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); @@ -3113,7 +1936,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); @@ -3146,14 +1968,6 @@ ivas_error core_switching_pre_dec_ivas_fx( return error; } -#ifndef HARM_CORE_SW -/*---------------------------------------------------------------------* - * core_switching_hq_prepare_dec() - * - * Preprocessing in the first HQ frame after ACELP frame - * Modify bit allocation for HQ core by removing ACELP subframe budget - *---------------------------------------------------------------------*/ -#endif /*---------------------------------------------------------------------* * bandwidth_switching_detect() @@ -3161,11 +1975,7 @@ ivas_error core_switching_pre_dec_ivas_fx( * Classification for band-width switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW void bandwidth_switching_detect_fx( -#else -void bandwidth_switching_detect_ivas_fx( -#endif Decoder_State *st_fx /* i/o: encoder state structure */ ) { @@ -3281,191 +2091,3 @@ void bandwidth_switching_detect_ivas_fx( return; } -#ifndef HARM_CORE_SW -/*---------------------------------------------------------------------* - * bw_switching_pre_proc() - * - * Band-width switching pre-processing - *---------------------------------------------------------------------*/ -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out /* i : number of output channels */, - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ) -{ - Word16 i; - Word32 syn_dct_fx[L_FRAME]; - - - IF( st->element_mode > EVS_MONO ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) - { - /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ - Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; - Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) ); - st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 - move16(); - } - - return; - } - - - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) - { - /*----------------------------------------------------------------------* - * Calculate tilt of the ACELP core synthesis - *----------------------------------------------------------------------*/ - - st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame ); - move16(); - /*-------------------------------------------------------------------------------* - * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis - *-------------------------------------------------------------------------------*/ - edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q ); - Word64 W_tmp = 0; - move64(); - Word32 tmp; - Word16 shift; - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); - tmp = L_shr( tmp, 8 ); - - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - W_tmp = 0; - move64(); - FOR( ; i < L_FRAME; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32 - tmp = L_shr( tmp, 7 ); // divide by 128 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - } - ELSE - { - IF( st->hHQ_core->old_is_transient[0] ) - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < 32; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < 64; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = Q_audio; - move16(); - } - ELSE - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < L_FRAME; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) - { - st->prev_ener_shb_fx = 0; - move16(); - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV ); - } - } - ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) - { - st->attenu_fx = 3277; // 0.1f in Q15 - move16(); - } - - test(); - test(); - test(); - test(); - test(); - if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) - { - st->prev_fractive = 0; - move16(); - } - - return; -} -#endif diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index e7b378a6d..f320e323f 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -315,11 +315,7 @@ ivas_error evs_dec_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ) != IVAS_ERR_OK ) -#else - IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -350,11 +346,7 @@ ivas_error evs_dec_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, NULL, NULL, 0, output_frame, core_switching_flag, 0, 1, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -363,11 +355,7 @@ ivas_error evs_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx ); -#else - bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx ); -#endif /*---------------------------------------------------------------------* * WB TBE decoding diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index efd629036..b71f0df7d 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -76,11 +76,7 @@ ivas_error ivas_core_dec_fx( Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q15 Word16 core_switching_flag[CPE_CHANNELS]; Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q6 -#ifdef HARM_CORE_SW Word16 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; -#else - Word32 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; -#endif Word16 unbits[CPE_CHANNELS]; Word16 sid_bw[CPE_CHANNELS]; FRAME_MODE frameMode[CPE_CHANNELS]; @@ -437,11 +433,7 @@ ivas_error ivas_core_dec_fx( * Detect bandwidth switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW bandwidth_switching_detect_fx( st ); -#else - bandwidth_switching_detect_ivas_fx( st ); -#endif /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching @@ -456,11 +448,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -484,9 +472,6 @@ ivas_error ivas_core_dec_fx( IF( st->core == ACELP_CORE ) { /* ACELP core decoder */ -#ifndef HARM_CORE_SW - Word16 old_syn_12k8_16k_fx_16[L_FRAME16k]; -#endif Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx; IF( save_hb_synth_32_fx ) @@ -537,11 +522,7 @@ ivas_error ivas_core_dec_fx( st->Q_syn_factor = 0; move16(); -#ifdef HARM_CORE_SW IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -574,12 +555,6 @@ ivas_error ivas_core_dec_fx( hSCE->q_save_hb_synth_fx = Q11; move16(); } -#ifndef HARM_CORE_SW - IF( st->hBWE_FD != NULL ) - { - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) - } -#endif } Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0 @@ -861,13 +836,6 @@ ivas_error ivas_core_dec_fx( move16(); } -#ifndef HARM_CORE_SW - Word16 q_audio, old_syn_fx; - old_syn_fx = Q11; - move16(); - q_audio = Q12; - move16(); -#endif test(); test(); @@ -920,11 +888,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx } -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -954,11 +918,7 @@ ivas_error ivas_core_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n] ); -#else - ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio ); -#endif IF( st->hHQ_core == NULL ) { diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index d3a4b7f74..d44ebdb3f 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -364,11 +364,7 @@ ivas_error ivas_mct_dec_fx( dirac_stereo_flag = 0; } -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index ed2060cef..7e9bf3a18 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -5478,11 +5478,7 @@ void ivas_swb_tbe_dec_fx( const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ -#ifdef HARM_CORE_SW const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ -#else - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ -#endif Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ Word16 *pitch_buf_fx, /* i : Q6 */ @@ -5553,10 +5549,8 @@ void ivas_swb_tbe_dec_fx( hBWE_TD = st->hBWE_TD; -#ifdef HARM_CORE_SW Word32 old_syn_12k8_16k_fx[L_FRAME16k]; Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) -#endif /* initializations */ GainFrame_fx = 0; diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index f6dbe7938..51994c772 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -136,11 +136,7 @@ void amr_wb_enc_fx( /* Updates in case of HQ -> AMR-WB IO mode switching */ Q_new = 0; move16(); /* prevent compiler warning only*/ -#ifdef HARM_CORE_SW core_switching_pre_enc_fx( st, NULL, 0, NULL, 0, 0, 0 ); -#else - core_switching_pre_enc_fx( st, NULL, NULL, 0, 0 ); -#endif set16_fx( hf_gain_fx, 0, NB_SUBFR ); set16_fx( old_inp, 0, L_INP_12k8 ); diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 29272023d..95688a82a 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -21,13 +21,9 @@ void core_switching_pre_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ -#endif const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ -#endif const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ) @@ -212,12 +208,10 @@ void core_switching_pre_enc_fx( set16_fx( hLPDmem->mem_syn2, 0, M ); set16_fx( hLPDmem->mem_syn, 0, M ); set16_fx( hLPDmem->mem_syn1_fx, 0, M ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hLPDmem->q_mem_syn = Q15; } -#endif hLPDmem->mem_w0 = 0; move16(); hLPDmem->tilt_code = 0; @@ -249,13 +243,11 @@ void core_switching_pre_enc_fx( } Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/ -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); } ELSE -#endif { set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); } @@ -366,7 +358,6 @@ void core_switching_pre_enc_fx( Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) @@ -382,7 +373,6 @@ void core_switching_pre_enc_fx( } } ELSE -#endif { Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ } @@ -400,7 +390,6 @@ void core_switching_pre_enc_fx( Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) @@ -416,7 +405,6 @@ void core_switching_pre_enc_fx( } } ELSE -#endif { Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ } @@ -424,12 +412,8 @@ void core_switching_pre_enc_fx( tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/ -#ifdef HARM_CORE_SW hBWE_FD->Q_new_input_hp = 0; move16(); -#else - add( 0, 0 ); -#endif IF( NE_16( st_fx->last_extl, WB_BWE ) ) { @@ -445,7 +429,6 @@ void core_switching_pre_enc_fx( move16(); /* Set to a High Exponent so it is 1^-30 */ } -#ifdef HARM_CORE_SW /*---------------------------------------------------------------------* * band-width switching from WB -> SWB/FB *---------------------------------------------------------------------*/ @@ -473,7 +456,6 @@ void core_switching_pre_enc_fx( } } -#endif return; } @@ -514,19 +496,15 @@ void core_switching_post_enc_fx( hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); hBWE_FD->mem_deemph_old_syn_fx = 0; move16(); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hBWE_FD->q_mem_deemph_old_syn = 0; move16(); } -#endif } ELSE { -#ifdef HARM_CORE_SW IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) -#endif { *Qmus = Qsp; /* Write Qout */ move16(); @@ -565,7 +543,6 @@ void core_switching_post_enc_fx( test(); test(); test(); -#ifdef HARM_CORE_SW test(); test(); test(); @@ -573,19 +550,16 @@ void core_switching_post_enc_fx( test(); test(); test(); -#endif IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) ) ) { set16_fx( hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { InitSWBencBufferStates_fx( st_fx->hBWE_TD, NULL ); } ELSE -#endif { set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); } @@ -595,26 +569,18 @@ void core_switching_post_enc_fx( hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { set16_fx( st_fx->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); } ELSE -#endif { set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 ); } } -#ifdef HARM_CORE_SW ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && ( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) ) || ( NE_16( st_fx->last_bwidth, st_fx->bwidth ) ) || ( NE_16( st_fx->last_codec_mode, MODE1 ) ) || ( NE_16( st_fx->rf_mode_last, st_fx->rf_mode ) ) ) ) -#else - ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && - ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) || - NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_mode, st_fx->rf_mode_last ) ) ) -#endif { set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); @@ -639,7 +605,6 @@ void core_switching_post_enc_fx( fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q ); } -#ifdef HARM_CORE_SW /* Fade towards init value for non HQ_CORE */ test(); IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->hHQ_core != NULL ) @@ -649,7 +614,6 @@ void core_switching_post_enc_fx( st_fx->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st_fx->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st_fx->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ move32(); } -#endif } return; @@ -784,539 +748,3 @@ void core_switching_hq_prepare_enc_fx( } return; } -#ifndef HARM_CORE_SW - -void core_switching_pre_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ -) -{ - Word16 Sample_Delay_HP, Sample_Delay_LP; - Word16 tmp16; - Word16 tmp; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - /* Mode switching */ - test(); - test(); - test(); - IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) ) - { - IF( hLPDmem != NULL ) - { - Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); - } - - if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - st_fx->igf = 0; - move16(); - } - - IF( hBWE_TD != NULL ) - { - IF( st_fx->last_core != ACELP_CORE ) - { - /* reset BWE memories */ - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - } - - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - test(); - IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) - { - if ( st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = HQ_CORE; - move16(); - } - IF( hHQ_core != NULL ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - test(); - /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/ - IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - test(); - IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) ) - { - Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); - - st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); - move16(); - } - - st_fx->use_acelp_preq = 0; - move16(); - } - - test(); - test(); - test(); - if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) - { - /* very first frame is HQ_CORE */ - st_fx->last_core = HQ_CORE; - move16(); - } - - test(); - test(); - IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */ - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - - IF( hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) - { - IF( hSC_VBR != NULL ) - { - hSC_VBR->last_last_ppp_mode = 0; - move16(); - hSC_VBR->last_ppp_mode = 0; - move16(); - hSC_VBR->last_nelp_mode = 0; - move16(); - } - } - - test(); - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st_fx->act_count = 3; - move16(); - st_fx->uv_count = 0; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) /* EVS and HQ -> ACELP */ || - ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) || - ( st_fx->core == ACELP_CORE && GT_16( st_fx->last_L_frame, L_FRAME16k ) ) /* TCX @ 25.6/32 kHz -> ACELP */ ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); - } - - /* Reset ACELP parameters */ - IF( hLPDmem != NULL ) - { - move16(); - hLPDmem->syn[M] = 0; - move16(); - set16_fx( hLPDmem->mem_syn2, 0, M ); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn1_fx, 0, M ); - hLPDmem->q_mem_syn = Q15; - move16(); - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - /* set16_fx( st_fx->dispMem, 0, 8 ); */ - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); - } - st_fx->Nb_ACELP_frames = 0; - move16(); - - set16_fx( st_fx->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - init_gp_clip_fx( st_fx->clip_var_fx ); - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = add( NB_SUBFR, 1 ); - - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - tmp16 = NB_SUBFR; - move16(); - } - - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); - /* Reset old ACELP buffers */ - test(); - IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) - { - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - } - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - - /* reset BWE memories */ - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - test(); - test(); - test(); - IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) ) - { - /* Reset the ACELP core in case of TCX->ACELP core switching */ - st_fx->Nb_ACELP_frames = 0; - move16(); - - IF( hLPDmem != NULL ) - { - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - init_gp_clip_fx( st_fx->clip_var_fx ); - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - } - - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = shr( st_fx->L_frame, 6 ); - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); - /* Reset old TD BWE buffers */ - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* reset BWE memories */ - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - test(); - test(); - test(); - IF( GE_32( st_fx->input_Fs, 16000 ) && NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && hBWE_FD != NULL ) - { - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - IF( ( GE_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || - ( GE_32( st_fx->input_Fs, 48000 ) && NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) ) - { - /* we are switching to SWB BWE - reset SWB BWE buffers */ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); - IF( ( st_fx->element_mode > EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8 - hBWE_FD->prev_Q_input_lp = q_old_inp_12k8; - move16(); - Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - ELSE - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k - hBWE_FD->prev_Q_input_lp = q_old_inp_16k; - move16(); - Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - - tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); - Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); - hBWE_FD->Q_new_input_hp = 0; - move16(); - - IF( NE_16( st_fx->last_extl, WB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - hBWE_FD->EnergyLF_fx = 0; - hBWE_FD->EnergyLF_exp = 0; - move32(); - move16(); - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); /*8.0 in Q0 */ - st_fx->EnergyLT_fx_exp = 30; - move16(); /* Set to a High Exponent so it is 1^-30 */ - } - - /*---------------------------------------------------------------------* - * band-width switching from WB -> SWB/FB - *---------------------------------------------------------------------*/ - - IF( st_fx->element_mode > EVS_MONO ) - { - IF( st_fx->bwidth_sw_cnt == 0 ) - { - test(); - IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - } - } - ELSE - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) ) - { - st_fx->bwidth_sw_cnt = 0; - move16(); - } - } - } - - return; -} - - -/*---------------------------------------------------------------------* - * core_switching_post_enc() - * - * Postprocessing for ACELP/HQ core switching - *---------------------------------------------------------------------*/ - -void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -) -{ - IF( EQ_16( st->core, HQ_CORE ) ) - { - st->use_acelp_preq = 0; - move16(); - - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - st->hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - st->hBWE_FD->q_mem_deemph_old_syn = 0; - move16(); - } - ELSE - { - IF( st->hBWE_TD == NULL ) - { - return; - } - - test(); - /* reset SWB TBE buffers */ - IF( EQ_16( st->extl, WB_TBE ) && NE_16( st->last_extl, WB_TBE ) ) - { - wb_tbe_extras_reset_fx( st->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, st->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); - - IF( NE_16( st->last_extl, WB_BWE ) ) - { - set16_fx( st->hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( st->hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - } - - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); - set16_fx( st->hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); - set32_fx( st->hBWE_TD->mem_csfilt_fx, 0, 2 ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - - IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && - ( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) ) - { - set16_fx( st->hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - - InitSWBencBufferStates_fx( st->hBWE_TD, NULL ); - swb_tbe_reset_fx( st->hBWE_TD->mem_csfilt_fx, st->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, st->hBWE_TD->state_lpc_syn_fx, st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->state_syn_shbexc_fx, &( st->hBWE_TD->tbe_demph_fx ), &( st->hBWE_TD->tbe_premph_fx ), st->hBWE_TD->mem_stp_swb_fx, &( st->hBWE_TD->gain_prec_swb_fx ) ); - - set16_fx( st->hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); - set16_fx( st->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); - } - ELSE IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && ( ( EQ_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) || ( NE_16( st->last_codec_mode, MODE1 ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) ) ) - { - set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - } - ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) - { - TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); - } - - test(); - test(); - test(); - test(); - /* Interp_3_2 CNG buffers reset */ - IF( EQ_16( st->extl, FB_TBE ) && ( ( NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) || NE_16( st->L_frame, st->last_L_frame ) ) ) - { - set16_fx( st->hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->fb_tbe_demph_fx = 0; - move16(); - fb_tbe_reset_enc_fx( st->hBWE_TD->elliptic_bpf_2_48k_mem_fx, &st->hBWE_TD->prev_fb_energy_fx, st->hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &st->hBWE_TD->prev_fb_energy_fx_Q ); - } - /* Fade towards init value for non HQ_CORE */ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/ - move32(); - st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ - move32(); - } - } - - return; -} -#endif diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 5fd5a8963..5f696e899 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -260,11 +260,7 @@ ivas_error evs_enc_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW core_switching_pre_enc_fx( st, old_inp_12k8, 0, old_inp_16k, 0, 0, 0 ); -#else - core_switching_pre_enc_fx( st, old_inp_12k8, old_inp_16k, 0, 0 ); -#endif /*---------------------------------------------------------------------* * ACELP core encoding diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index cd1e34af4..334b84581 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -325,11 +325,7 @@ ivas_error ivas_core_enc_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW core_switching_pre_enc_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode ); -#else - core_switching_pre_enc_ivas_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode ); -#endif /*---------------------------------------------------------------------* * ACELP core encoding @@ -672,11 +668,7 @@ ivas_error ivas_core_enc_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW core_switching_post_enc_fx( st, NULL, NULL, NULL, 0, 0, 0, NULL ); -#else - core_switching_post_enc_ivas_fx( st ); -#endif /*---------------------------------------------------------------------* * WB TBE encoding diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 5f773c341..2f606063e 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -127,13 +127,9 @@ void core_switching_post_enc_fx( void core_switching_pre_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ -#endif const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ -#endif const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ); -- GitLab From b25dd1a456dae190fd9bbc23069cf7e6c57a1c25 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:24:06 +0100 Subject: [PATCH 525/750] [cleanup] accept HARM_PREPROC --- lib_com/options.h | 1 - lib_enc/amr_wb_enc_fx.c | 8 - lib_enc/dtx_fx.c | 569 ------------------------- lib_enc/init_enc_fx.c | 11 - lib_enc/ivas_core_pre_proc_front_fx.c | 33 -- lib_enc/ivas_front_vad_fx.c | 12 - lib_enc/ivas_stereo_switching_enc_fx.c | 4 - lib_enc/pitch_ol2_fx.c | 222 ---------- lib_enc/pre_proc_fx.c | 13 - lib_enc/prot_fx_enc.h | 48 --- lib_enc/vad_fx.c | 200 --------- 11 files changed, 1121 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ec24990e5..78413540e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ #define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ #define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 51994c772..985c2852b 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -310,11 +310,7 @@ void amr_wb_enc_fx( } /* apply DTX hangover for CNG analysis */ -#ifdef HARM_PREPROC vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL, NULL ); -#else - vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL ); -#endif /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled @@ -336,11 +332,7 @@ void amr_wb_enc_fx( move16(); } -#ifdef HARM_PREPROC dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new ); -#else - dtx_fx( st, vad_flag_dtx, inp, Q_new ); -#endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index b9ec0c872..b6b4e5a34 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -63,11 +63,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ None */ /*==================================================================================*/ -#ifdef HARM_PREPROC void dtx_fx( -#else -void dtx_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ @@ -82,7 +78,6 @@ void dtx_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word32 total_brate_ref; -#ifdef HARM_PREPROC Word16 flag_lp_noise; flag_lp_noise = 0; @@ -96,7 +91,6 @@ void dtx_ivas_fx( flag_lp_noise = 1; move16(); } -#endif total_brate_ref = st_fx->total_brate; move32(); @@ -113,11 +107,7 @@ void dtx_ivas_fx( test(); test(); test(); -#ifdef HARM_PREPROC last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || flag_lp_noise || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); -#else - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); -#endif test(); test(); @@ -125,11 +115,7 @@ void dtx_ivas_fx( test(); last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || -#ifdef HARM_PREPROC flag_lp_noise; -#else - LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); -#endif } /* Initialization */ @@ -244,11 +230,7 @@ void dtx_ivas_fx( test(); br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || -#ifdef HARM_PREPROC flag_lp_noise; -#else - LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 ); -#endif } test(); @@ -638,466 +620,6 @@ void dtx_ivas_fx( return; } -#ifndef HARM_PREPROC -/*==================================================================================*/ -/* FUNCTION : dtx_fx() */ -/*----------------------------------------------------------------------------------*/ -/* PURPOSE : Discontinuous transmission operation */ -/*----------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Encoder_State_Fx) st_fx : encoder state structure */ -/* _ (Word16) vad : vad flag Q0 */ -/* _ (Word16[]) speech_fx : Pointer to the speech frame qSpeech */ -/* _ (Word16) qSpeech : speech buffer qformat value */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ -/*----------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ -/* _ (Encoder_State_Fx) st_fx : encoder state structure */ -/*----------------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*==================================================================================*/ -void dtx_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad, /* i : vad flag for DTX Q0*/ - const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ - -) -{ - Word16 alpha, j, i, Q_speech2; - Word32 L_tmp; - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - - Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; - - IF( st_fx->dtx_sce_sba != 0 ) - { - last_br_cng_flag = 1; - last_br_flag = 1; - br_dtx_flag = 1; - move16(); - move16(); - move16(); - } - ELSE - { - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); - - last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); - br_dtx_flag = 0; - move16(); - } - /* Initialization */ - IF( st_fx->ini_frame == 0 ) - { - st_fx->active_cnt = CNG_TYPE_HO; - move16(); - - st_fx->cng_type = FD_CNG; - move16(); - test(); - IF( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - } - test(); - test(); - IF( st_fx->Opt_DTX_ON && vad == 0 && - GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */ - st_fx->fd_cng_reset_flag == 0 && - NE_16( st_fx->last_core, AMR_WB_CORE ) && - st_fx->Opt_AMR_WB == 0 ) - { - test(); - test(); - test(); - IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) && - NE_32( st_fx->last_total_brate_cng, st_fx->total_brate ) && last_br_cng_flag ) - { - st_fx->total_brate = st_fx->last_total_brate_cng; - move32(); - test(); - IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) - { - st_fx->Opt_SC_VBR = 0; - move16(); - } - st_fx->rf_mode = st_fx->last_rf_mode_cng; - move16(); - st_fx->bwidth = st_fx->last_bwidth_cng; - move16(); - st_fx->codec_mode = st_fx->last_codec_mode_cng; - move16(); - } - test(); - test(); - IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag ) - - { - st_fx->total_brate = st_fx->last_total_brate; - move32(); - test(); - IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) - { - st_fx->Opt_SC_VBR = 0; - move16(); - } - - st_fx->Opt_RF_ON = 0; - move16(); - test(); - test(); - test(); - IF( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && NE_16( st_fx->bwidth, NB ) ) - { - st_fx->Opt_RF_ON = 1; - move16(); - } - st_fx->rf_mode = st_fx->Opt_RF_ON; - move16(); - st_fx->bwidth = st_fx->last_bwidth; - move32(); - IF( ( st_fx->element_mode > EVS_MONO ) ) - { - st_fx->codec_mode = MODE1; - move16(); - } - ELSE - { - st_fx->codec_mode = get_codec_mode( st_fx->total_brate ); - } - } - } - - /*------------------------------------------------------------------------* - * Select SID or FRAME_NO_DATA frame if DTX is enabled - *------------------------------------------------------------------------*/ - - if ( st_fx->dtx_sce_sba == 0 ) - { - br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || - EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) ); - } - test(); - test(); - test(); - test(); - IF( st_fx->Opt_DTX_ON && vad == 0 && - GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */ - br_dtx_flag && - st_fx->fd_cng_reset_flag == 0 ) - { - /* reset counter */ - st_fx->active_cnt = 0; - move16(); - - IF( st_fx->Opt_AMR_WB ) - { - st_fx->last_total_brate_cng = -1; - st_fx->last_rf_mode_cng = st_fx->rf_mode; - move32(); - move16(); - } - ELSE - { - st_fx->last_total_brate_cng = st_fx->total_brate; - st_fx->last_bwidth_cng = st_fx->bwidth; - st_fx->last_codec_mode_cng = st_fx->codec_mode; - move32(); - move16(); - move16(); - } - - IF( hDtxEnc->cnt_SID == 0 ) - { - /* this will be a SID frame */ - IF( st_fx->Opt_AMR_WB ) - { - st_fx->core_brate = SID_1k75; - move32(); - } - ELSE - { - st_fx->core_brate = SID_2k40; - move32(); - } - } - ELSE - { - /* this will be a no data frame */ - st_fx->core_brate = FRAME_NO_DATA; - move32(); - } - - test(); - test(); - IF( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB ) - { - /* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */ - st_fx->core_brate = SID_2k40; - move32(); - } - - { - test(); - test(); - test(); - test(); - IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ - { - test(); - test(); - IF( EQ_16( st_fx->element_mode, EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) ) - { - st_fx->codec_mode = MODE2; - move16(); - } - } - ELSE - { - st_fx->cng_type = LP_CNG; - move16(); - IF( st_fx->codec_mode == MODE2 ) - { - hTdCngEnc->lp_cng_mode2 = 1; - move16(); - } - st_fx->codec_mode = MODE1; - move16(); - } - } - - /* reset the bitstream (IVAS format signalling was already written) */ - IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) - { - reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); - } - } - - /*------------------------------------------------------------------------* - * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame) - *------------------------------------------------------------------------*/ - /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */ - test(); - test(); - IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) ) - { - IF( hDtxEnc != NULL ) - { - hDtxEnc->cnt_SID = 0; - move16(); - - /* change SID update rate */ - /* first SID update is only 8 (3) frames after the active speech end */ - IF( !st_fx->Opt_AMR_WB ) - { - hDtxEnc->max_SID = FIXED_SID_RATE; - move16(); - } - ELSE - { - hDtxEnc->max_SID = 3; - move16(); /* first SID update is only 3 frames after the active speech end */ - } - - IF( LT_16( hDtxEnc->interval_SID, hDtxEnc->max_SID ) ) - { - hDtxEnc->max_SID = hDtxEnc->interval_SID; - move16(); /* change SID update rate */ - } - - hDtxEnc->cng_cnt = 0; - move16(); /* reset the counter of CNG frames for averaging */ - } - test(); - IF( GE_16( st_fx->active_cnt, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_SCE ) ) - { - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st_fx->cng_type, LP_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 589824l /*9.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 2949120l /*45.f Q16*/ ) ) ) ) - { - st_fx->cng_type = FD_CNG; - move16(); - } - ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 131072l /*2.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 655360l /*10.f Q16*/ ) ) ) ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - } - st_fx->last_total_brate_cng = -1; - } - ELSE IF( st_fx->Opt_AMR_WB ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - st_fx->active_cnt = add( st_fx->active_cnt, 1 ); - st_fx->active_cnt = s_min( st_fx->active_cnt, 200 ); - } - - /*------------------------------------------------------------------------* - * Update speech and background noise long-term energy - *------------------------------------------------------------------------*/ - IF( hDtxEnc != NULL ) - { - hDtxEnc->frame_ener_fx = L_deposit_l( 0 ); - - IF( st_fx->Opt_DTX_ON ) - { - Q_speech2 = add( shl( Q_speech, 1 ), 7 ); - FOR( j = 0; j < 16; j++ ) - { - L_tmp = L_mult0( *speech, *speech ); /*2*Q_speech*/ - speech++; - FOR( i = 1; i < L_FRAME / 16; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ - speech++; - } - hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */ - } - - /* Active speech (voiced) */ - - IF( EQ_16( st_fx->clas, VOICED_CLAS ) ) - { - alpha = ALPHA_ENER_SLOW_FX; - move16(); - if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) ) - { - alpha = ALPHA_ENER_FAST_FX; /*Q15 */ - move16(); - } - - /*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/ - hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - - hDtxEnc->VarDTX_cnt_voiced = add( hDtxEnc->VarDTX_cnt_voiced, 1 ); - - hDtxEnc->VarDTX_cnt_voiced = s_min( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT ); - } - /* Background noise */ - ELSE IF( !st_fx->Opt_AMR_WB ) - { - alpha = ALPHA_ENER_SLOW_FX; /*Q15 */ - move16(); - if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) ) - { - alpha = ALPHA_ENER_FAST_FX; /*Q15 */ - move16(); - } - - /*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/ - hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - move32(); - - hDtxEnc->VarDTX_cnt_noise = add( hDtxEnc->VarDTX_cnt_noise, 1 ); - - hDtxEnc->VarDTX_cnt_noise = s_min( hDtxEnc->VarDTX_cnt_noise, MIN_CNT ); - } - } - } - - /* Update of the SID counter */ - update_SID_cnt_fx( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB ); - - /* Update encoded bandwidth */ - test(); - test(); - IF( st_fx->Opt_DTX_ON && ( st_fx->core_brate == SID_2k40 || st_fx->core_brate == FRAME_NO_DATA ) ) - { - - st_fx->bwidth = st_fx->last_bwidth; - move16(); - test(); - IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) ) - { - st_fx->bwidth = st_fx->last_bwidth_cng; - move16(); - } - - test(); - test(); - IF( st_fx->Opt_RF_ON && ( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) && ( EQ_16( st_fx->bwidth, NB ) ) ) - { - st_fx->codec_mode = MODE1; - move16(); - reset_rf_indices_fx( st_fx ); - st_fx->Opt_RF_ON = 0; - move16(); - st_fx->rf_mode = 0; - move16(); - } - - test(); - test(); - IF( st_fx->Opt_RF_ON && NE_32( st_fx->total_brate, ACELP_13k20 ) ) - { - reset_rf_indices_fx( st_fx ); - move16(); - st_fx->Opt_RF_ON = 0; - move16(); - st_fx->rf_mode = 0; - move16(); - } - - /* Set and limit the encoded bandwidth */ - IF( EQ_16( st_fx->codec_mode, MODE2 ) ) - { - Word16 n, bits_frame_nominal; - - UWord16 lsb; - Word16 tmpbandwidthMin; - - Mpy_32_16_ss( st_fx->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ - bits_frame_nominal = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ - - FOR( n = 0; n < FRAME_SIZE_NB; n++ ) - { - IF( EQ_16( FrameSizeConfig[n].frame_bits, bits_frame_nominal ) ) - { - BREAK; - } - } - if ( n == FRAME_SIZE_NB ) - { - assert( !"Bitrate not supported: not part of EVS" ); - } - tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min; - if ( EQ_16( st_fx->rf_mode, 1 ) ) - { - tmpbandwidthMin = WB; - } - st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin ); - } - } - - return; -} -#endif /*---------------------------------------------------------------------* * update_SID_cnt() @@ -1544,97 +1066,6 @@ void td_cng_enc_init_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) -#ifndef HARM_PREPROC -{ - - hTdCngEnc->cng_seed = RANDOM_INITSEED; - hTdCngEnc->cng_ener_seed = RANDOM_INITSEED; - hTdCngEnc->cng_ener_seed1 = RANDOM_INITSEED; - hTdCngEnc->lp_ener_fx = 0; - hTdCngEnc->old_enr_index = -1; - hTdCngEnc->Enew_fx = 0; - - hTdCngEnc->lp_sp_enr_fx = 0; - hTdCngEnc->last_allow_cn_step = 0; - move16(); - move32(); - move16(); - move16(); - move32(); - move16(); - move16(); - - IF( Opt_DTX_ON ) - { - hTdCngEnc->cng_hist_ptr = -1; - move16(); - set16_fx( hTdCngEnc->cng_lsp_hist_fx, 0, DTX_HIST_SIZE * M ); - set16_fx( hTdCngEnc->cng_ener_hist_fx, 0, DTX_HIST_SIZE ); - - hTdCngEnc->ho_hist_ptr = -1; - move16(); - hTdCngEnc->ho_sid_bw = L_deposit_l( 0 ); - set16_fx( hTdCngEnc->ho_lsp_hist_fx, 0, HO_HIST_SIZE * M ); - set32_fx( hTdCngEnc->ho_ener_hist_fx, 0, HO_HIST_SIZE ); - set32_fx( hTdCngEnc->ho_env_hist_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG ); - hTdCngEnc->ho_hist_size = 0; - move16(); - hTdCngEnc->act_cnt = 0; - move16(); - } - - set16_fx( hTdCngEnc->ho_16k_lsp, 0, HO_HIST_SIZE ); - hTdCngEnc->act_cnt2 = 0; - hTdCngEnc->num_ho = 0; - move16(); - move16(); - - hTdCngEnc->ho_circ_ptr = -1; - move16(); - set16_fx( hTdCngEnc->ho_lsp_circ_fx, 0, HO_HIST_SIZE * M ); - set32_fx( hTdCngEnc->ho_ener_circ_fx, 0, HO_HIST_SIZE ); - set32_fx( hTdCngEnc->ho_env_circ_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG ); - hTdCngEnc->ho_circ_size = 0; - hTdCngEnc->burst_ho_cnt = 0; - move16(); - move16(); - - hTdCngEnc->cng_buf_cnt = 0; - - - set32_fx( hTdCngEnc->lp_env_fx, 0, 20 ); - set32_fx( hTdCngEnc->cng_res_env_fx, 0, 20 * 8 ); - set16_fx( hTdCngEnc->exc_mem_fx, 0, 24 ); - set16_fx( hTdCngEnc->exc_mem1_fx, 0, 30 ); - set16_fx( hTdCngEnc->exc_mem2_fx, 0, 30 ); - set32_fx( hTdCngEnc->old_env_fx, 0, NUM_ENV_CNG ); - - /* SWB CNG/DTX */ - hTdCngEnc->last_wb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->last_shb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->mov_wb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->shb_cng_ini_cnt = 1; - move16(); - hTdCngEnc->shb_NO_DATA_cnt = 0; - move16(); - hTdCngEnc->last_SID_bwidth = s_min( max_bwidth, SWB ); - hTdCngEnc->last_vad = 0; - move16(); - - return; -} - -void td_cng_enc_init_ivas_fx( - TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ - const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ -) -#endif { hTdCngEnc->cng_seed = RANDOM_INITSEED; move16(); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index b58fe5177..4a55101d5 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -686,18 +686,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_PREPROC td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); -#else - IF( st->element_mode == EVS_MONO ) - { - td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } - ELSE - { - td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } -#endif } ELSE { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8090f9ede..abe017232 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -168,13 +168,8 @@ ivas_error pre_proc_front_ivas_fx( Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ CLDFB_SCALE_FACTOR cldfbScale; -#ifdef HARM_PREPROC Word16 temp1F_icatdmResampBuf_fx[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */ Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ -#else - Word16 *temp1F_icatdmResampBuf_fx; - Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ -#endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; Word16 snr_sum_he_fx; /* HE SAD parameters */ @@ -214,20 +209,8 @@ ivas_error pre_proc_front_ivas_fx( Word16 Qfact_PS, q_lf_E_fx; Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX]; Word32 bckr_temp[NB_BANDS]; -#ifndef HARM_PREPROC - mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); - temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); - set16_fx( fft_buff_fx, 0, 512 ); -#endif Word16 Q_min; Word16 input_frame_full; -#ifndef HARM_PREPROC - FOR( Word16 k = 0; k < CLDFB_NO_COL_MAX; k++ ) - { - set32_fx( realBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); - } -#endif Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; Word16 Q_inp_const = -1; move16(); @@ -771,11 +754,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { -#ifdef HARM_PREPROC *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ -#else - *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ -#endif move16(); } ELSE @@ -949,11 +928,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef HARM_PREPROC dtx_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); -#else - dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); -#endif test(); test(); @@ -1161,11 +1136,7 @@ ivas_error pre_proc_front_ivas_fx( Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); /* Q7 */ /* Detection of very short stable pitch period */ -#ifdef HARM_PREPROC StableHighPitchDetect_fx( element_mode, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); -#else - StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); -#endif /* 1/4 pitch precision improvement */ IF( LE_32( element_brate, IVAS_32k ) ) @@ -1590,10 +1561,6 @@ ivas_error pre_proc_front_ivas_fx( *Q_new = sub( *Q_new, Q_inp_const ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1 move16(); -#ifndef HARM_PREPROC - free( mem_decim_dummy_fx ); - free( temp1F_icatdmResampBuf_fx ); -#endif pop_wmops(); #ifdef FIX_2344_ALIGN_PREPROC return; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index b6df30eda..dcec13574 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -287,11 +287,7 @@ ivas_error front_vad_fx( move16(); } -#ifdef HARM_PREPROC vad_flag_dtx[n] = dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ -#else - vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ -#endif move16(); if ( EQ_16( n_chan, 1 ) ) @@ -604,11 +600,7 @@ ivas_error front_vad_spar_fx( corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ -#ifdef HARM_PREPROC dtx_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); -#else - dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); -#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */ @@ -693,11 +685,7 @@ ivas_error front_vad_spar_fx( st->old_pitch_la = st->pitch[2]; /* Q0 */ move16(); -#ifdef HARM_PREPROC StableHighPitchDetect_fx( IVAS_SCE /* needs to be other than EVS_MONO */, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); -#else - StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); -#endif IF( st->hSpMusClas != NULL ) { diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index d99a95d7a..a87edb39f 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -385,11 +385,7 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_PREPROC td_cng_enc_init_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); -#else - td_cng_enc_init_ivas_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); -#endif } /* allocate TCA data structure */ diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 51cda9c13..ff9a2ab64 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -211,210 +211,6 @@ void pitch_ol2_fx( return; } -#ifndef HARM_PREPROC -/*-------------------------------------------------------------------* - * StableHighPitchDetect() - * - * stable very short pitch detection - *-------------------------------------------------------------------*/ -void StableHighPitchDetect_fx( - Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */ - Word16 pitch[], /* i/o: OL pitch buffer */ - const Word16 voicing[], /* i : OL pitch gains */ - const Word16 wsp[], /* i : weighted speech */ - const Word16 localVAD, /* i : local VAD flag */ - Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains */ - Word16 *voicing0_sm, /* i/o: smoothed high pitch gains */ - Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy*/ - Word16 *predecision_flag, /* i/o: predecision flag */ - Word32 *diff_sm, /* i/o: smoothed pitch frequency difference */ - Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency */ - Word16 Q_new, - Word16 EspecdB[] ) -{ - Word16 i, pitch_freq_point; - Word16 T, Tp, pit_min; - Word16 energy0_16, energy1_16, ratio, voicing_m; - Word32 energy0, energy1, cor_max, diff, sum_energy; - const Word16 *pt_wsp; - Word16 tmp, tmp1, exp, diff16, cor_max16, exp1, exp2, pit_min_up; - Word32 L_tmp, L_tmp1; - Word16 Top; - - /*voicing = (voicing[0] + voicing[1] + voicing[2] )/3;*/ - L_tmp = L_mult( voicing[0], 10923 /*1/3 in Q15*/ ); - L_tmp = L_mac( L_tmp, voicing[1], 10923 /*1/3 in Q15*/ ); - L_tmp = L_mac( L_tmp, voicing[2], 10923 /*1/3 in Q15*/ ); - voicing_m = round_fx_sat( L_tmp ); - /**voicing_sm = 0.75f*(*voicing_sm) + 0.25f*voicing;*/ - *voicing_sm = round_fx( L_mac( L_mult( *voicing_sm, 24576 /*0.75f Q15*/ ), voicing_m, 8192 /*0.25f Q15*/ ) ); - move16(); - /* pitch_freq_point = (short)(L_FFT/(mult_fact*T_op[1])+0.5f);*/ - Top = pitch[1]; - move16(); - exp = norm_s( Top ); - tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ - L_tmp = L_mult0( tmp, L_FFT ); /*Q(29 - exp)*/ - pitch_freq_point = extract_h( L_add( L_shl( L_tmp, sub( exp, 13 ) ), 32768 ) ); /* Q0*/ - diff = L_deposit_l( 0 ); - sum_energy = L_deposit_l( 0 ); - FOR( i = 1; i < 2 * pitch_freq_point; i++ ) - { - diff = L_add( diff, sub( EspecdB[pitch_freq_point], EspecdB[i] ) ); - sum_energy = L_add( sum_energy, EspecdB[i] ); - } - /*sum_energy /= (2*pitch_freq_point-1);*/ - tmp = sub( shl( pitch_freq_point, 1 ), 1 ); - exp = norm_s( tmp ); - tmp1 = div_s( shl( 1, sub( 14, exp ) ), tmp ); /*Q(29-exp)*/ - L_tmp = Mult_32_16( sum_energy, tmp1 ); - sum_energy = L_shl( L_tmp, sub( exp, 14 ) ); - /**diff_sm = 0.2f * diff + 0.8f * *diff_sm;*/ - *diff_sm = L_add( Mult_32_16( diff, 6554 ), Mult_32_16( *diff_sm, 26214 ) ); - move32(); - /**energy_sm = 0.2f * sum_energy + 0.8f * *energy_sm;*/ - *energy_sm = L_add( Mult_32_16( sum_energy, 6554 ), Mult_32_16( *energy_sm, 26214 ) ); - move32(); - /*diff /= sum_energy;*/ - - IF( sum_energy ) - { - exp = norm_l( sum_energy ); - tmp = extract_h( L_shl( sum_energy, exp ) ); - exp = sub( sub( 30, exp ), 7 ); - IF( tmp < 0 ) - { - tmp = abs_s( tmp ); - tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ - BASOP_SATURATE_WARNING_OFF_EVS - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); - BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); - } - ELSE - { - tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ - BASOP_SATURATE_WARNING_OFF_EVS - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); - BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); - } - } - ELSE - { - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); - } - test(); - test(); - if ( LT_32( *diff_sm, -1280 /*-10.0f Q7*/ ) && LT_32( *energy_sm, 4928 /*38.5f Q7*/ ) && LT_16( diff16, -26214 /*-.8f Q15*/ ) ) - { - *predecision_flag = 1; - move16(); - } - test(); - test(); - if ( GT_32( *diff_sm, 1280 /*10.0f Q7*/ ) && GT_32( *energy_sm, 10624 /*83.0f Q7*/ ) && GT_16( diff16, 16384 /*.5 Q15*/ ) ) - { - *predecision_flag = 0; - move16(); - } - - /* short pitch possiblity pre-decision */ - maximum_fx( EspecdB, 7, &energy0_16 ); - maximum_fx( EspecdB + 8, 7, &energy1_16 ); - ratio = s_max( sub( energy1_16, energy0_16 ), 0 ); /*Q7 */ - /*ratio *= max(voicing,0);*/ - tmp = s_max( voicing_m, 0 ); - ratio = mult_r( ratio, tmp ); /*Q7*/ - /**LF_EnergyRatio_sm = (15*(*LF_EnergyRatio_sm) + ratio)/16;*/ - L_tmp = L_mult( ratio, 2048 ); - L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); - *LF_EnergyRatio_sm = round_fx( L_tmp ); - move16(); - test(); - if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) - { - *predecision_flag = 1; - move16(); - } - - if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) ) - { - *predecision_flag = 0; - move16(); - } - - /* short pitch candidate detection */ - Tp = pitch[1]; - move16(); - cor_max = 0; - move16(); - pt_wsp = wsp + 3 * L_SUBFR; - pit_min = PIT_MIN_DOUBLEEXTEND; - move16(); - pit_min_up = PIT_MIN; - move16(); - FOR( T = pit_min; T <= pit_min_up; T++ ) - { - energy1 = Dot_product( pt_wsp, pt_wsp - T, L_SUBFR ); - test(); - IF( ( GT_32( energy1, cor_max ) ) || ( EQ_16( T, pit_min ) ) ) - { - cor_max = L_add( energy1, 0 ); - Tp = T; - move16(); - } - } - energy0 = Dot_product12( pt_wsp, pt_wsp, L_SUBFR, &exp1 ); - exp1 = sub( exp1, shl( Q_new, 1 ) ); - energy1 = Dot_product12( pt_wsp - Tp, pt_wsp - Tp, L_SUBFR, &exp2 ); - exp2 = sub( exp2, shl( Q_new, 1 ) ); - /* cor_max *= inv_sqrt( energy0*energy1 );*/ - L_tmp = Mult_32_32( energy0, energy1 ); - exp = norm_l( L_tmp ); - L_tmp1 = L_shl( L_tmp, exp ); - - exp = 31 - exp - ( 31 - exp1 - exp2 ); - move16(); - L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ - cor_max = Mult_32_32( cor_max, L_tmp1 ); - exp = 31 - ( shl( Q_new, 1 ) + 1 ) - ( 31 - exp ) + 31; - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ - /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ - *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); - move16(); - - /* final short pitch detection */ - test(); - test(); - test(); - *flag_spitch = 0; - move16(); - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 16384 ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } - - return; -} - - -/*-------------------------------------------------------------------* - * pitch_ol2() - * - * Open-loop pitch precision improvement with 1/4 resolution - * The pitch is searched in the interval vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst, NULL ); -#else - vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst ); -#endif /*----------------------------------------------------------------* * NB/WB/SWB/FB bandwidth detector @@ -336,11 +332,7 @@ void pre_proc_fx( * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ -#ifdef HARM_PREPROC dtx_fx( st, -1, -1, vad_flag_dtx, inp_12k8, *Q_new ); -#else - dtx_fx( st, vad_flag_dtx, inp_12k8, *Q_new ); -#endif /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator @@ -458,13 +450,8 @@ void pre_proc_fx( move16(); /* Detection of very short stable st->pitch period (MODE1 bit-rates) */ -#ifdef HARM_PREPROC StableHighPitchDetect_fx( EVS_MONO, &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); -#else - StableHighPitchDetect_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, - &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); -#endif /* 1/4 pitch precision improvement */ IF( LE_32( st->total_brate, ACELP_24k40 ) ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2f606063e..e18c097f5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -140,15 +140,6 @@ Word16 correlation_shift_fx( ); void dtx_fx( -#ifndef HARM_PREPROC - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad, /* i : vad flag Q0*/ - const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ -); - -void dtx_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ @@ -158,18 +149,6 @@ void dtx_ivas_fx( ); Word16 dtx_hangover_addition_fx( -#ifndef HARM_PREPROC - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad_flag, /* i Q0 */ - const Word16 lp_snr, /* i Q8 */ - const Word16 cldfb_subtraction, /* i Q0 number of DTX-HO frames CLDFB wants to reduce */ - Word16 *vad_hover_flag_ptr, - VAD_HANDLE hVAD, /* i/o: VAD data handle */ - NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ -); - -Word16 ivas_dtx_hangover_addition_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -577,9 +556,7 @@ void speech_music_classif_fx( ); void StableHighPitchDetect_fx( -#ifdef HARM_PREPROC const Word16 element_mode, /* i : element mode */ -#endif Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ Word16 pitch[], /* i/o: OL pitch buffer */ const Word16 voicing[], /* i : OL pitch gains */ @@ -593,24 +570,6 @@ void StableHighPitchDetect_fx( Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency */ Word16 Q_new, Word16 EspecdB[] ); -#ifndef HARM_PREPROC - -void StableHighPitchDetect_ivas_fx( - Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */ - Word16 pitch[], /* i/o: OL pitch buffer Q0 */ - const Word16 voicing[], /* i : OL pitch gains Q15 */ - const Word16 wsp[], /* i : weighted speech Qx */ - const Word16 localVAD, - Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains Q15 */ - Word16 *voicing0_sm, /* i/o: smoothed high pitch gains Q15 */ - Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy Q7 */ - Word16 *predecision_flag, /* i/o: predecision flag */ - Word32 *diff_sm, /* i/o: smoothed pitch frequency difference Q7 */ - Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency Q7 */ - Word16 Q_new, - Word16 EspecdB[] /* Q7 */ -); -#endif void swb_bwe_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -1168,13 +1127,6 @@ void td_cng_enc_init_fx( const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); -#ifndef HARM_PREPROC -void td_cng_enc_init_ivas_fx( - TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ - const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ -); -#endif void dtx_enc_init_fx( Encoder_State *st, /* i : Encoder state handle */ const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 21abc589d..5f1356def 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -229,204 +229,6 @@ static void sign_thr_snr_acc_fx( *-----------------------------------------------------------------*/ Word16 dtx_hangover_addition_fx( -#ifndef HARM_PREPROC - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad_flag, /* i Q0 */ - const Word16 lp_snr, /* i Q8 */ - const Word16 cldfb_subtraction, /* i Q0 number of DTX-HO frames CLDFB wants to reduce */ - Word16 *vad_hover_flag_ptr, - VAD_HANDLE hVAD, /* i/o: VAD data handle */ - NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ -) -{ - Word16 hangover_short_dtx; /* Q0 */ - Word16 flag_dtx; /* Q0 */ - Word16 tmp; /* Q0 */ - if ( hNoiseEst == NULL ) - { - hNoiseEst = st_fx->hNoiseEst; - move16(); - } - - if ( hVAD == NULL ) - { - move16(); - hVAD = st_fx->hVAD; - } - - - flag_dtx = 0; - move16(); - - /* Determine initial hangover length */ - hangover_short_dtx = 2; - move16(); - - test(); - test(); - if ( ( ( LT_16( lp_snr, ( 16 * 256 ) ) ) && ( st_fx->input_bwidth != NB ) ) || ( GT_16( hVAD->prim_act_he_fx, 31130 ) ) ) /*.95*Q15*/ - { - hangover_short_dtx = 3; - move16(); - } - - /* Adjust hangover according to activity history */ - IF( GT_16( hVAD->vad_prim_cnt_16, 12 ) ) /* 12 requires roughly > 80% primary activity */ - { - hangover_short_dtx = add( hangover_short_dtx, 2 ); - } - - IF( GT_16( hVAD->vad_flag_cnt_50, 40 ) ) /* 40 requires roughtly > 80% flag activity */ - { - hangover_short_dtx = add( hangover_short_dtx, 5 ); - } - - /* Keep hangover_short lower than maximum hangover count */ - if ( GT_16( hangover_short_dtx, HANGOVER_LONG_FX - 1 ) ) - { - hangover_short_dtx = ( HANGOVER_LONG_FX - 1 ); - move16(); - } - - /* Only allow short HO if not sufficient active frames in clean speech*/ - - tmp = 3; - move16(); /* default for EVS*/ - if ( EQ_16( st_fx->core, AMR_WB_CORE ) ) - { - tmp = 2; - move16(); /* default for AMRWBIO*/ - } - - /* need to be a bit stricter with the DTXHO in very clean WB, SWB cond for EVS12k8VAD section */ - test(); - test(); - if ( ( NE_16( st_fx->input_bwidth, NB ) ) /* WB or SWB or FB */ - && ( NE_16( st_fx->core, AMR_WB_CORE ) ) && ( GT_16( lp_snr, 25 * 256 ) ) ) - { - tmp = 2; - move16(); - } - - /* limit dtx hangover addition up to "tmp" frames in clean cond */ - IF( tmp != 0 ) - { - test(); - test(); - test(); - if ( ( GT_16( hangover_short_dtx, tmp ) ) && ( ( LT_16( hVAD->vad_prim_cnt_16, 7 ) ) || ( ( GT_16( lp_snr, ( 16 * 256 ) ) ) && ( LT_16( hVAD->prim_act_he_fx, 27853 ) ) /*0.85f*2^15 */ - ) ) ) - { - hangover_short_dtx = tmp; - move16(); - } - } - - - /* hangover adjustment from combined FFT+CLDFBVAD */ - IF( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /* Q0 */ - hangover_short_dtx = s_max( hangover_short_dtx, 0 ); - } - - IF( vad_flag != 0 ) /* Speech present */ - { - flag_dtx = 1; - move16(); - - /* Add hangover after sufficient # of active frames or sufficient activity during last second */ - test(); - if ( ( GE_16( hVAD->nb_active_frames, ACTIVE_FRAMES_FX ) ) || ( GT_16( hVAD->vad_flag_cnt_50, 45 ) ) ) /* 45 requires roughly > 90% flag activity */ - { - hVAD->hangover_cnt_dtx = 0; - move16(); - } - - /* inside HO period */ - test(); - IF( ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) && ( hVAD->hangover_cnt_dtx != 0 ) ) - { - hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); /* Q0 */ - move16(); - } - hVAD->hangover_terminate_flag = 0; - move16(); /* float fix FIX_HO_TERMINATE */ - - /* Music hangover when music detected */ - test(); - test(); - test(); - if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ - { - hVAD->hangover_cnt_music = 0; - move16(); - } - - /* inside Music HO period */ - test(); - IF( ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) && ( hVAD->hangover_cnt_music != 0 ) ) - { - hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); - move16(); - } - } - ELSE - { - /* Reset the counter of speech frames necessary to start hangover algorithm */ - IF( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) /* inside HO period */ - { - hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); - move16(); - } - IF( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) /* inside HO period */ - { - hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); - move16(); - } - - /* fast terminate DTX hangover if st->hangover_terminate_flag is set */ - IF( hVAD->hangover_terminate_flag != 0 ) - { - hVAD->hangover_cnt = HANGOVER_LONG_FX; - move16(); - hVAD->hangover_cnt_dtx = HANGOVER_LONG_FX; - move16(); - hVAD->hangover_terminate_flag = 0; - move16(); - /* Only shorten music hangover when low energy frames */ - if ( LT_16( hNoiseEst->Etot_lp_fx, 20 * 256 ) ) - { - hVAD->hangover_cnt_music = HANGOVER_LONG_MUSIC_FX; - move16(); - } - } - - if ( LE_16( hVAD->hangover_cnt_dtx, hangover_short_dtx ) ) /* "hard" hangover */ - { - flag_dtx = 1; - move16(); - } - - if ( LE_16( hVAD->hangover_cnt_music, 15 ) ) /* "hard" hangover music */ - { - flag_dtx = 1; - move16(); - } - } - - - test(); - if ( flag_dtx != 0 && st_fx->localVAD == 0 ) - { - *vad_hover_flag_ptr = 1; - move16(); - } - - return flag_dtx; -} -Word16 ivas_dtx_hangover_addition_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -549,7 +351,6 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); /* float fix FIX_HO_TERMINATE */ /* Music hangover when music detected */ -#ifdef HARM_PREPROC test(); test(); test(); @@ -562,7 +363,6 @@ Word16 ivas_dtx_hangover_addition_fx( } } ELSE -#endif { test(); test(); -- GitLab From d0e32552402a39fe6b1d19faff139e77f3f05e4e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:24:54 +0100 Subject: [PATCH 526/750] [cleanup] accept FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN --- lib_com/options.h | 1 - lib_enc/enc_gen_voic_fx.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 78413540e..d3e224d4d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 5e0a67dbc..f7ba1ce2f 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -310,15 +310,8 @@ void encod_gen_voic_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } -#ifndef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN - IF( st_fx->element_mode == EVS_MONO ) - { -#endif /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#ifndef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN - } -#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames -- GitLab From 5d7f6b54e52b5a85a229acf778a4c5667205eb17 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:25:32 +0100 Subject: [PATCH 527/750] [cleanup] accept FIX_2257_INCR_GUARD_BITS --- lib_com/cldfb_fx.c | 2 -- lib_com/options.h | 1 - 2 files changed, 3 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 49ca0627c..f0c0d8158 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -595,9 +595,7 @@ void cldfbAnalysis_ts_fx_var_q( IF( NE_16( h_cldfb->Q_cldfb_state, *q_cldfb ) ) { Word16 norm_st = L_norm_arr( timeBuffer_fx, offset ); -#ifdef FIX_2257_INCR_GUARD_BITS norm_st = sub( norm_st, find_guarded_bits_fx( shr( h_cldfb->no_channels, 2 ) ) ); -#endif IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) ) { scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ); diff --git a/lib_com/options.h b/lib_com/options.h index d3e224d4d..f1179d81a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ -- GitLab From 49fca380f64187357a00cf6471cdc3790e2541bc Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:26:12 +0100 Subject: [PATCH 528/750] [cleanup] accept FIX_2315_AGC_MEMORY_RESET --- lib_com/options.h | 1 - lib_dec/core_switching_dec_fx.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f1179d81a..f0f793557 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ #define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 1454f8c41..ec5a641da 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1539,14 +1539,9 @@ ivas_error core_switching_pre_dec_fx( /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); -#ifndef FIX_2315_AGC_MEMORY_RESET - set16_fx( st->agc_mem_fx, 0, 2 ); -#endif } -#ifdef FIX_2315_AGC_MEMORY_RESET set16_fx( st->agc_mem_fx, 0, 2 ); -#endif st->mem_deemph_fx = 0; move16(); IF( !st->last_con_tcx ) -- GitLab From b1148c8286c141818b299b5134d0c98222bc2e1b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:26:59 +0100 Subject: [PATCH 529/750] [cleanup] accept FIX_2312_CONDITION_MISSING_GSC_DEC_LR --- lib_com/gs_gains_fx.c | 4 ---- lib_com/options.h | 1 - 2 files changed, 5 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 61e7144e8..35d802de7 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1074,10 +1074,8 @@ Word16 gsc_gaindec_fx( idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); -#ifdef FIX_2312_CONDITION_MISSING_GSC_DEC_LR IF( !( coder_type == INACTIVE && st_fx->tdm_LRTD_flag == 0 && EQ_16( st_fx->idchan, 1 ) ) || GT_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) { -#endif idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 ); @@ -1118,13 +1116,11 @@ Word16 gsc_gaindec_fx( move16(); y_gainQ_fx[14] = y_gain_tmp3_fx[3]; /*Q12*/ move16(); -#ifdef FIX_2312_CONDITION_MISSING_GSC_DEC_LR } ELSE { set16_fx( y_gainQ_fx + 3, 0, MBANDS_GN16k - 3 ); } -#endif } ELSE { diff --git a/lib_com/options.h b/lib_com/options.h index f0f793557..21f84c317 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ #define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ -- GitLab From 1f539ba780ba915a7198eb93912d3c6cb78f2d60 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:27:41 +0100 Subject: [PATCH 530/750] [cleanup] accept FIX_2313_HF_RESET_16KHZ --- lib_com/options.h | 1 - lib_dec/core_switching_dec_fx.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 21f84c317..6cf18783d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ #define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ec5a641da..4d2948ba9 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1222,11 +1222,7 @@ ivas_error core_switching_pre_dec_fx( move16(); test(); -#ifdef FIX_2313_HF_RESET_16KHZ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { hf_synth_reset_fx( st->hBWE_zero ); IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment @@ -1649,11 +1645,7 @@ ivas_error core_switching_pre_dec_fx( } test(); -#ifdef FIX_2313_HF_RESET_16KHZ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { hf_synth_reset_fx( st->hBWE_zero ); IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment @@ -1704,11 +1696,7 @@ ivas_error core_switching_pre_dec_fx( move16(); test(); -#ifdef FIX_2313_HF_RESET_16KHZ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { hf_synth_reset_fx( st->hBWE_zero ); set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -- GitLab From de08a5eb27ba1c73ca8a219df4717ee4256c1347 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:28:24 +0100 Subject: [PATCH 531/750] [cleanup] accept OPT_2308_FIND_TARGET --- lib_com/options.h | 1 - lib_enc/find_tar_fx.c | 45 ------------------------------------------- 2 files changed, 46 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6cf18783d..df29d7f16 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index a315c4301..9a236731f 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -173,12 +173,8 @@ void find_targets_ivas_fx( { Word16 i; Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */ -#ifndef OPT_2308_FIND_TARGET - Word16 scale, scaleq, j, d, s, s2, tmp; -#else Word16 scale, scaleq, j, d, s, tmp; Word32 s2; -#endif Word16 Aqs[M + 1]; Word32 h1_32[6 * L_SUBFR]; Word16 sf; @@ -238,57 +234,17 @@ void find_targets_ivas_fx( { Copy( p_Aq, Aqs, M + 1 ); /* Q12 */ s = add( scaleq, 1 ); -#ifndef OPT_2308_FIND_TARGET - s2 = shr( 16384, d ); -#else s2 = L_shr( ( 16384 << 16 ), d ); -#endif } ELSE { Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */ s = add( scale, 1 ); -#ifndef OPT_2308_FIND_TARGET - s2 = 16384; - move16(); -#else s2 = ( 16384 << 16 ); move32(); -#endif } set32_fx( h1_32, 0, L_subfr ); -#ifndef OPT_2308_FIND_TARGET - FOR( i = 0; i < M; i++ ) - { - Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ - FOR( j = 1; j <= i; j++ ) - { - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ - } - h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ - move32(); - } - - Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ - FOR( j = 1; j <= M; j++ ) - { - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ - } - h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */ - move32(); - - FOR( i = M + 1; i < L_subfr; i++ ) - { - Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ - FOR( j = 2; j <= M; j++ ) - { - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ - } - h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ - move32(); - } -#else FOR( i = 0; i < M; i++ ) { Ltmp64 = W_mult_32_16( s2, Ap[i] ); /* Q27 */ @@ -319,7 +275,6 @@ void find_targets_ivas_fx( move32(); } -#endif sf = sub( L_norm_arr( h1_32, L_subfr ), 1 ); Copy_Scale_sig32_16( h1_32, h1, L_subfr, sf ); // Q11 + sf -- GitLab From 110b4754d9514f53c06c2845f4613b7c621c5af6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:29:09 +0100 Subject: [PATCH 532/750] [cleanup] accept OPT_NBE_2311_HARM_GSC_GAIN --- lib_com/gs_gains_fx.c | 542 ------------------------------------------ lib_com/options.h | 1 - lib_com/prot_fx.h | 26 -- lib_enc/gs_enc_fx.c | 16 -- 4 files changed, 585 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 35d802de7..cc48a5e63 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -392,9 +392,7 @@ void Ener_per_band_comp_ivas_fx( static void GSC_gain_adj( const Word16 coder_type, /* i : Coder type */ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN const Word16 Mbands_gn, /* i : Number of band */ -#endif const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ @@ -404,24 +402,14 @@ static void GSC_gain_adj( { /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 Fac_div; Fac_div = 102; move16(); -#endif -#ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) -#else - IF( coder_type != INACTIVE ) -#endif { -#ifdef OPT_NBE_2311_HARM_GSC_GAIN FOR( i = 0; i < Mbands_gn; i++ ) -#else - FOR( i = 0; i < MBANDS_GN; i++ ) -#endif { old_y_gain[i] = y_gain_tmp[i]; move16(); @@ -434,7 +422,6 @@ static void GSC_gain_adj( Gain_off = 0; move16(); -#ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ { @@ -444,9 +431,6 @@ static void GSC_gain_adj( move16(); } ELSE IF( LE_32( core_brate, ACELP_7k20 ) ) -#else - IF( LE_32( core_brate, ACELP_7k20 ) ) -#endif { Gain_off = 32767; move16(); /* 8 -> Q12 */ @@ -478,11 +462,7 @@ static void GSC_gain_adj( old_y_gain[i] = y_gain_tmp[i]; move16(); /*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, Fac_div /* 20/MBANDS_GN in Q15 */ ) ) ) ); -#else - y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 102 /* 20/MBANDS_GN in Q15 */ ) ) ) ); -#endif move16(); } } @@ -490,483 +470,6 @@ static void GSC_gain_adj( return; } -#ifndef OPT_NBE_2311_HARM_GSC_GAIN -/*-------------------------------------------------------------------* - * GSC_gain_adj_ivas_fx() - * - * Quantization of the energy per band - *-------------------------------------------------------------------*/ - -static void GSC_gain_adj_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - const Word16 Mbands_gn, /* i : Number of band */ - const Word32 core_brate, /* i : Bit rate */ - const Word16 mean_g, /* i : Average gain Q12 */ - Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ - const Word16 *y_gain_tmp, /* i : Dequantized gains */ - Word16 *y_gainQ /* i/o: Output gains Q12 */ -) -{ - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - Word16 Gain_off, i; - - test(); - IF( ( coder_type != INACTIVE ) && NE_16( coder_type, UNVOICED ) ) - { - FOR( i = 0; i < Mbands_gn; i++ ) - { - old_y_gain[i] = y_gain_tmp[i]; - move16(); - y_gainQ[i] = add( y_gain_tmp[i], mean_g ); - move16(); - } - } - ELSE - { - Gain_off = 0; - move16(); - - test(); - IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) - { - Gain_off = 18432; - move16(); /* 9 -> Q11 */ - } - IF( LE_32( core_brate, ACELP_7k20 ) ) - { - Gain_off = 16384; - move16(); /* 8 -> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_8k00 ) ) - { - Gain_off = 13517; - move16(); /* 6.6f -> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_9k60 ) ) - { - Gain_off = 9830; - move16(); /*4.8f-> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_11k60 ) ) - { - Gain_off = 7168; - move16(); /* 3.5f -> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_13k20 ) ) - { - Gain_off = 6144; - move16(); /* 3.0f -> Q11 dB */ - } - - /*mimic ACELP decay of energy for low rates*/ - FOR( i = 0; i < Mbands_gn; i++ ) - { - old_y_gain[i] = y_gain_tmp[i]; - move16(); - y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 205 /* 20/MBANDS_GN in Q16 */ ) ) ) ); - move16(); - } - } - - return; -} - -/*-------------------------------------------------------------------* - * GSC_gain_DQ() - * - * Form the final vector after gain quantization/Dequantization - * Common to both encoder and decoder - *-------------------------------------------------------------------*/ - -static void GSC_gain_DQ_fx( - const Word16 element_mode, /* i : element mode */ - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word16 coder_type, /* i : Coder type */ - const Word16 Mbands_gn, /* i : Number of band */ - const Word32 core_brate, /* i : Core bitrate */ - const Word16 mean_g, /* i : Average gain Q12 */ - const Word16 *Gain_in, /* i : Unquantized gain vector Q12 */ - Word16 *Gain_out /* o : Level adjusted unquantized gain vector Q12 */ -) -{ - Word16 Gain_off; - Word16 i; - - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - Gain_off = 0; - move16(); - - test(); - IF( coder_type == INACTIVE || EQ_16( coder_type, UNVOICED ) ) - { - test(); - IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) - { - Gain_off = 1843; // 9/20 in Q12 - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_7k20 ) ) - { - Gain_off = 1638; // 8/20 in Q12; /* 0 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_8k00 ) ) - { - Gain_off = 1351; // 6.6f/20 in Q12 /* ~-3.3 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_9k60 ) ) - { - Gain_off = 983; // 4.8f/20 in Q12 /* ~-2.4 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_11k60 ) ) - { - Gain_off = 717; // 3.5f/20 in Q12 /* ~-2.4 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_13k20 ) ) - { - Gain_off = 614; // 3.0f/20 in Q12 /* ~-2.4 dB */ - move16(); - } - } - - test(); - IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) - { - FOR( i = 0; i < Mbands_gn; i++ ) - { - Gain_out[i] = add( Gain_in[i], mean_g ); // Q12 - move16(); - } - } - ELSE - { - /*mimic ACELP decay of energy for low rates*/ - test(); - IF( element_mode == EVS_MONO && EQ_16( enc_dec, DEC ) ) - { - /* This is to keep EVS mono bit-exact with the standard (there might be a small desynchronization between encoder and decoder but there is no real quality or interop. issue) */ - FOR( i = 0; i < Mbands_gn; i++ ) - { - Gain_out[i] = add( Gain_out[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12 - move16(); - // Gain_out[i] += mean_g - i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ); - } - } - ELSE - { - FOR( i = 0; i < Mbands_gn; i++ ) - { - Gain_out[i] = add( Gain_in[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12 - move16(); - // Gain_out[i] = Gain_in[i] + mean_g - ( i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ) ); - } - } - } - - return; -} - - -/*-------------------------------------------------------------------* - * gsc_gainQ() - * - * Quantization of the energy per band - *-------------------------------------------------------------------*/ - -Word16 gsc_gainQ_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 y_gain4[], - /* i : Energy per band */ // Q12 - Word16 y_gainQ[], - /* o : quantized energy per band */ // Q12 - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 L_frame, /* i : frame length */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word32 core_brate_inp /* i : true core bitrate */ -) -{ - Word16 y_gain_tmp[MBANDS_GN16k]; - Word16 y_gain_tmp2[MBANDS_GN16k]; - Word16 i, idx_g = 0; - move16(); - Word16 mean_4g_fx[1], ftmp1_fx; - Word16 Mbands_gn = MBANDS_GN; - move16(); - Word16 y_gain_tmp3[MBANDS_GN]; - Word32 L_tmp; - - if ( EQ_16( L_frame, L_FRAME16k ) ) - { - Mbands_gn = MBANDS_GN16k; - move16(); - } - - mean_4g_fx[0] = 0; - move32(); - - test(); - test(); - IF( ( EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && bwidth == NB ) - { - L_tmp = 0; - move32(); - FOR( i = 0; i < 10; i++ ) - { - L_tmp = L_add( L_tmp, y_gain4[i] ); - } - L_tmp = L_sub( Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ), 2457 /* 0.6f in Q12 */ ); // Q12 - ftmp1_fx = extract_l( L_tmp ); - FOR( i = 0; i < Mbands_gn; i++ ) - { - IF( LT_16( y_gain4[i], ftmp1_fx ) ) - { - y_gain_tmp2[i] = ftmp1_fx; /*Q12*/ - } - ELSE - { - y_gain_tmp2[i] = y_gain4[i]; /*Q12*/ - } - move16(); - } - - /* Quantized mean gain without clipping */ - L_tmp = 0; - move32(); - FOR( i = 0; i < 10; i++ ) - { - L_tmp = L_add( L_tmp, y_gain4[i] ); - } - L_tmp = Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ); // Q12 - mean_4g_fx[0] = extract_l( L_tmp ); // Q12 - move16(); - idx_g = vquant_fx( mean_4g_fx, Gain_meanNB_fx, mean_4g_fx, Gain_mean_dicNB_fx, 1, 64 ); - push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); - - FOR( i = 0; i < Mbands_gn; i++ ) - { - y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12 - move16(); - } - - if ( LT_16( y_gain_tmp[9], -1229 /* -0.3f in Q12 */ ) ) - { - y_gain_tmp[9] = -1229; /* -0.3f in Q12 */ - move16(); - } - - set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 ); - idx_g = vquant_fx( y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - IF( LT_32( core_brate, ACELP_9k60 ) ) - { - idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NB_fx, 3, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NB_fx, 4, 16 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); - } - ELSE - { - idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NBHR_fx, 3, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NBHR_fx, 4, 128 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); - } - - test(); - IF( LE_32( core_brate, ACELP_9k60 ) && coder_type == INACTIVE ) - { - /* Some energy is needed in high band for stat_noise_uv_enc() to be functional in inactive speech */ - y_gain_tmp[10] = mean_fx( y_gain_tmp + 6, 3 ); /*Q12*/ - move16(); - y_gain_tmp[11] = mean_fx( y_gain_tmp + 7, 3 ); /*Q12*/ - move16(); - y_gain_tmp[12] = mean_fx( y_gain_tmp + 8, 3 ); /*Q12*/ - move16(); - y_gain_tmp[13] = mean_fx( y_gain_tmp + 9, 3 ); /*Q12*/ - move16(); - y_gain_tmp[14] = mean_fx( y_gain_tmp + 10, 3 ); /*Q12*/ - move16(); - y_gain_tmp[15] = mean_fx( y_gain_tmp + 11, 3 ); /*Q12*/ - move16(); - } - ELSE - { - set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 ); - } - } - ELSE - { - L_tmp = 0; - move32(); - FOR( i = 0; i < 16; i++ ) - { - L_tmp = L_add( L_tmp, y_gain4[i] ); - } - L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12 - ftmp1_fx = extract_l( L_tmp ); - FOR( i = 0; i < Mbands_gn; i++ ) - { - IF( LT_16( y_gain4[i], sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) ) - { - y_gain_tmp2[i] = sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ ); - } - ELSE IF( GT_16( y_gain4[i], add( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) ) - { - y_gain_tmp2[i] = add( ftmp1_fx, 2457 /* 0.6 in Q12*/ ); - } - ELSE - { - y_gain_tmp2[i] = y_gain4[i]; - } - move16(); - } - - L_tmp = 0; - move32(); - FOR( i = 0; i < 16; i++ ) - { - L_tmp = L_add( L_tmp, y_gain_tmp2[i] ); - } - L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12 - mean_4g_fx[0] = extract_l( L_tmp ); // Q12 - move16(); - idx_g = vquant_fx( mean_4g_fx, mean_m_fx, mean_4g_fx, mean_gain_dic_fx, 1, 64 ); - push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); - - /* Subtraction of the average gain */ - FOR( i = 0; i < Mbands_gn; i++ ) - { - y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12 - move16(); - } - - IF( LT_32( core_brate, ACELP_9k60 ) ) - { - /* prediction and quantization of the average gain */ - - /*--------------------------------------------------------------------------------------* - * Quantization of the first 8 bands - * Keep only 4 bands out of the last 8 bands - *--------------------------------------------------------------------------------------*/ - - Copy( y_gain_tmp, y_gain_tmp2, 8 ); - - y_gain_tmp2[8] = y_gain_tmp[8]; - move16(); - y_gain_tmp2[9] = y_gain_tmp[10]; - move16(); - y_gain_tmp2[10] = y_gain_tmp[12]; - move16(); - y_gain_tmp2[11] = y_gain_tmp[14]; - move16(); - - idx_g = 0; - move16(); - idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - test(); - test(); - test(); - IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) - { - idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - /*----------------------------------------------------------------------* - * Vector quantization of the first 8 bands + quantization of the 4 bands out of the last 8 - * Interpolation of the last 4 bands Q to create bands 8-16 - *----------------------------------------------------------------------*/ - - idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 ); - - /* Update to quantized vector */ - Copy( y_gain_tmp2, y_gain_tmp, 8 ); - - Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 ); - set16_fx( y_gain_tmp + 8, 0, 8 ); - fft_rel_fx( y_gain_tmp2 + 8, 4, 2 ); - - Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 ); - y_gain_tmp[15] = y_gain_tmp2[11]; - move16(); - ifft_rel_fx( y_gain_tmp + 8, 8, 3 ); - - FOR( i = 8; i < 16; i++ ) - { - y_gain_tmp[i] = shl( mult( y_gain_tmp[i], 23101 /* 1.41 in Q14 */ ), 1 ); /*Q12*/ - move16(); - } - - y_gain_tmp[8] = y_gain_tmp3[0]; - move16(); - y_gain_tmp[10] = y_gain_tmp3[1]; - move16(); - y_gain_tmp[12] = y_gain_tmp3[2]; - move16(); - y_gain_tmp[14] = y_gain_tmp3[3]; - move16(); - } - ELSE - { - Copy( y_gain_tmp2, y_gain_tmp, 3 ); - set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 ); - } - } - ELSE - { - IF( EQ_16( L_frame, L_FRAME ) ) - { - idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); - } - ELSE - { - idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); - - idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16HR_fx + 4, y_gain_tmp + 4, YG_dicHR_2_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16HR_fx + 8, y_gain_tmp + 8, YG_dicHR_3_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16HR_16kHz_fx, y_gain_tmp + 12, YG_dicHR_4_16kHz_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 ); - push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 ); - } - } - } - - GSC_gain_DQ_fx( element_mode, ENC, coder_type, Mbands_gn, core_brate, mean_4g_fx[0], y_gain_tmp, y_gainQ ); - - return mean_4g_fx[0]; -} -#endif /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ @@ -1158,19 +661,7 @@ Word16 gsc_gaindec_fx( } } -#ifndef OPT_NBE_2311_HARM_GSC_GAIN - IF( st_fx->element_mode == EVS_MONO ) - { - GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - } - ELSE - { - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - } -#else GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); -#endif return mean_4g_fx; } @@ -1182,7 +673,6 @@ Word16 gsc_gaindec_fx( * Quantization of the energy per band *-------------------------------------------------------------------*/ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 idchan, /* i : channel ID */ @@ -1195,43 +685,23 @@ Word16 gsc_gainQ_fx( const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const Word32 core_brate_inp /* i : true core bitrate */ ) -#else -Word16 gsc_gainQ_fx( /*Q12*/ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 y_gain4[], /* i : Energy per band Q12 */ - Word16 y_gainQ[], /* o : quantized energy per band Q12 */ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth /* i : input signal bandwidth */ -) -#endif { -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 y_gain_tmp[MBANDS_GN16k], y_gain_tmp2[MBANDS_GN16k]; -#else - Word16 y_gain_tmp[MBANDS_GN], y_gain_tmp2[MBANDS_GN]; -#endif Word16 i, idx_g = 0; move16(); Word16 mean_4g[1] = { 0 }, tmp16, tmp1, tmp2; move16(); Word16 Mbands_gn = MBANDS_GN; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 y_gain_tmp3[MBANDS_GN16k]; -#else - Word16 y_gain_tmp3[MBANDS_GN]; -#endif Word16 cnt; Word32 L_tmp; mean_4g[0] = 0; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN if ( EQ_16( L_frame, L_FRAME16k ) ) { Mbands_gn = MBANDS_GN16k; move16(); } -#endif test(); test(); @@ -1385,13 +855,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); -#ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); test(); test(); IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) { -#endif idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); @@ -1424,20 +892,16 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); y_gain_tmp[14] = y_gain_tmp3[3]; move16(); -#ifdef OPT_NBE_2311_HARM_GSC_GAIN } ELSE { Copy( y_gain_tmp2, y_gain_tmp, 3 ); set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 ); } -#endif } ELSE { -#ifdef OPT_NBE_2311_HARM_GSC_GAIN IF( EQ_16( L_frame, L_FRAME ) ) -#endif { idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); @@ -1451,7 +915,6 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); } -#ifdef OPT_NBE_2311_HARM_GSC_GAIN ELSE { idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 ); @@ -1469,16 +932,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 ); push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 ); } -#endif } } /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); -#else - GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); -#endif return mean_4g[0]; /*Q12*/ } diff --git a/lib_com/options.h b/lib_com/options.h index df29d7f16..a317b3ec5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bde8b871d..289923aa5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1504,19 +1504,8 @@ Word16 gsc_gaindec_fx( const Word16 bwidth_fx /* i : i signal bandwidth */ ); -#ifndef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 y_gain4[], /* i : Energy per band Q13 */ - Word16 y_gainQ[], /* o : quantized energy per band Q13 */ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth /* i : signal bandwidth */ -); - -Word16 gsc_gainQ_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 y_gain4[], /* i : Energy per band Q12 */ Word16 y_gainQ[], /* o : quantized energy per band Q12 */ @@ -1528,21 +1517,6 @@ Word16 gsc_gainQ_ivas_fx( const Word32 core_brate_inp /* i : true core bitrate */ ); -#else -Word16 gsc_gainQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 idchan, /* i : channel ID */ - const Word16 y_gain4[], /* i : Energy per band Q12 */ - Word16 y_gainQ[], /* o : quantized energy per band Q12 */ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 L_frame, /* i : frame length */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word32 core_brate_inp /* i : true core bitrate */ -); -#endif - void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 79b419633..4037aaa5e 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -997,25 +997,9 @@ void gsc_enc_fx( i--; } -#ifndef OPT_NBE_2311_HARM_GSC_GAIN -#ifdef FIX_1904_HARM_GSC_ENC - 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 - } - 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(); -#else mean_gain = gsc_gainQ_fx( hBstr, 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_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ move16(); -#endif /*--------------------------------------------------------------------------------------* * Frequency encoder -- GitLab From 70adb62b3fc50f91b54e273e2326887c334b6b26 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:30:07 +0100 Subject: [PATCH 533/750] [cleanup] accept FIX_2261_REMOVE_LP_RESCALING --- lib_com/options.h | 1 - lib_enc/acelp_core_enc_fx.c | 14 -------------- lib_enc/ivas_core_enc_fx.c | 9 --------- lib_enc/ivas_front_vad_fx.c | 3 --- lib_enc/ivas_ism_enc_fx.c | 6 ------ 5 files changed, 33 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a317b3ec5..f71b23a4c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 1aa59f93f..920d100e4 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1067,13 +1067,6 @@ ivas_error acelp_core_enc_ivas_fx( move16(); st->hLPDmem->q_mem_syn = st->Q_syn; move16(); -#ifndef FIX_2261_REMOVE_LP_RESCALING - // Scaling Aq to Q12 - FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) - { - Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); - } -#endif /* synthesis at 12.8kHz sampling rate */ syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn ); @@ -1208,13 +1201,6 @@ ivas_error acelp_core_enc_ivas_fx( st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15 move16(); } -#ifndef FIX_2261_REMOVE_LP_RESCALING - // Scaling Aq to Q12 - FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) - { - Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); - } -#endif test(); IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 334b84581..3a19ad171 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -223,9 +223,6 @@ ivas_error ivas_core_enc_fx( // fft_buff_fx_exp = add(fft_buff_fx_exp,1); FOR( i = 0; i < st->nb_subfr; i++ ) { -#ifndef FIX_2261_REMOVE_LP_RESCALING - Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 -#endif Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } @@ -349,12 +346,6 @@ ivas_error ivas_core_enc_fx( test(); IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { -#ifndef FIX_2261_REMOVE_LP_RESCALING - FOR( i = 0; i < st->nb_subfr; i++ ) - { - Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 - } -#endif TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; Word16 Q_spec_old, L_spec; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index dcec13574..bab92da6e 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -631,9 +631,6 @@ ivas_error front_vad_spar_fx( } relE_fx = sub( Etot_fx[0], extract_h( st->lp_speech_32fx ) ); -#ifndef FIX_2261_REMOVE_LP_RESCALING - Scale_sig( A_fx, ( L_FRAME / L_SUBFR ) * ( M + 1 ), -2 ); // Q12 -#endif st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */ st->mem_wsp_q = Q_inp_12k8; move16(); diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 02d0b86f0..40f683925 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -238,12 +238,6 @@ ivas_error ivas_ism_enc_fx( /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ -#ifndef FIX_2261_REMOVE_LP_RESCALING - FOR( i = 0; i < hSCE->hCoreCoder[0]->nb_subfr; i++ ) - { - Scale_sig( &A_fx[sce_id][0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[sce_id][0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 - } -#endif set16_fx( old_wsp_fx[sce_id][0], 0, L_WSP ); q_old_wsp = Q15; -- GitLab From 9208e1f558183c7cd112b2cd3376866680ec2e3b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:30:56 +0100 Subject: [PATCH 534/750] [cleanup] accept NONBE_OPT_2239_IVAS_FILTER_PROCESS --- lib_com/ivas_filters_fx.c | 199 -------------------------------- lib_com/ivas_prot_fx.h | 16 --- lib_com/ivas_stat_com.h | 7 -- lib_com/ivas_transient_det_fx.c | 62 ---------- lib_com/options.h | 1 - lib_dec/ivas_lfe_dec_fx.c | 4 - lib_enc/ivas_lfe_enc_fx.c | 4 - 7 files changed, 293 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index ffbdf7187..bcba83b89 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -67,40 +67,18 @@ void ivas_filters_init_fx( filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN]; move32(); move32(); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; move16(); move16(); -#else - filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1; - filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1; - move16(); - move16(); -#endif } -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; move64(); move64(); move64(); -#else - filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; - move32(); - move32(); - move32(); - filter_state->state_e[0][0] = 0; - filter_state->state_e[0][1] = 0; - filter_state->state_e[0][2] = 0; - move16(); - move16(); - move16(); -#endif } ELSE { @@ -117,7 +95,6 @@ void ivas_filters_init_fx( move32(); move32(); move32(); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); filter_state->num_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); @@ -126,19 +103,8 @@ void ivas_filters_init_fx( move16(); move16(); move16(); -#else - filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i]; - filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN]; - filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2]; - filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3]; - move16(); - move16(); - move16(); - move16(); -#endif } -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; @@ -151,38 +117,11 @@ void ivas_filters_init_fx( move64(); move64(); move64(); -#else - filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0; - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - filter_state->state_e[0][0] = 0; - filter_state->state_e[0][1] = 0; - filter_state->state_e[0][2] = 0; - filter_state->state_e[1][0] = 0; - filter_state->state_e[1][1] = 0; - filter_state->state_e[1][2] = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); -#endif } return; } -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in ); /*-----------------------------------------------------------------------------------------* @@ -309,141 +248,3 @@ void ivas_filter_process_fx64( return; } -#else -static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); - -/*-----------------------------------------------------------------------------------------* - * Function ivas_filter_process() - * - * Process call for selecting the type filter - *-----------------------------------------------------------------------------------------*/ - -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : number of samples to filter */ - Word16 q_factor ) -{ - Word16 pIn_Out_e[L_FRAME_MAX]; - Word16 i; - - SWITCH( filter_state->order ) - { - case IVAS_FILTER_ORDER_1: - set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length ); - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - FOR( i = 0; i < length; i++ ) - { - pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor) - move32(); - } - BREAK; - case IVAS_FILTER_ORDER_4: - set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length ); - /* biquad-1 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* biquad-2 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - FOR( i = 0; i < length; i++ ) - { - pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor) - move32(); - } - BREAK; - default: - BREAK; - } - - return; -} - -void ivas_filter_process_exp_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ - const Word16 length, /* i : number of samples to filter */ - Word16 *pIn_Out_e ) -{ - SWITCH( filter_state->order ) - { - case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - BREAK; - case IVAS_FILTER_ORDER_4: - /* biquad-1 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* biquad-2 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - BREAK; - default: - BREAK; - } - - return; -} - -/*-----------------------------------------------------------------------------------------* - * Function ivas_iir_2_filter() - * - * Process call for filtering a signal - *-----------------------------------------------------------------------------------------*/ - -static void ivas_iir_2_filter_fx( - ivas_filters_process_state_t *filter_state, - Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) - const Word16 length, - const Word16 stage, - Word16 *pIn_Out_e ) -{ - Word16 i, j; - - Word32 *pIn_fx = pIn_Out_fx; - Word32 *pOut_fx = pIn_Out_fx; - Word32 tmp_pIn_buf_i_fx; - Word16 tmp_pIn_buf_i_e; - - Word32 L_tmp_prod, L_tmp; - Word16 L_prod_e, L_tmp_e; - - FOR( i = 0; i < length; i++ ) - { - tmp_pIn_buf_i_fx = pIn_fx[i]; - move32(); - tmp_pIn_buf_i_e = pIn_Out_e[i]; - move16(); - - L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(pIn_Out_e[i]+ filter_state->num_e[stage][0]) - L_prod_e = add( pIn_Out_e[i], filter_state->num_e[stage][0] ); - - pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &pIn_Out_e[i] ); // Q31 - pIn_Out_e[i] - move32(); - - FOR( j = 1; j < filter_state->filt_len; j++ ) - { - L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e - L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e ); - - L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e - - L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] ) - L_prod_e = add( pIn_Out_e[i], filter_state->den_e[stage][j] ); - - filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1] - move32(); - /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/ - IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) ) - { - filter_state->state_fx[stage][j - 1] = 0; - move32(); - filter_state->state_e[stage][j - 1] = 0; - move16(); - } - } - } - - return; -} -#endif diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 2f280d47d..31dfb1ea2 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3775,7 +3775,6 @@ void ivas_lfe_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ @@ -3787,21 +3786,6 @@ void ivas_filter_process_fx64( Word64 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length /* i : number of samples to filter */ ); -#else -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i : signal subject to filtering */ - const Word16 length, /* i : number of samples to filter */ - Word16 q_factor -); - -void ivas_filter_process_exp_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ - const Word16 length, /* i : number of samples to filter */ - Word16 *pIn_Out_e -); -#endif ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 2d8df33a0..d3737fa19 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -655,16 +655,9 @@ typedef struct ivas_filters_process_state_t Word16 filt_len; Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#else - Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#endif } ivas_filters_process_state_t; diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 2b200933a..9c54f91f4 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -44,11 +44,7 @@ *------------------------------------------------------------------------------------------*/ #define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS #define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32 -#else -#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 -#endif #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 #define IVAS_TDET_PARM_TRANS_THR ( 107374182 ) // Q30 @@ -396,7 +392,6 @@ void ivas_td_decorr_get_ducking_gains_fx( Word32 duck_mult_fac = hTranDet->duck_mult_fac; /*Q29*/ move32(); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; Word32 fast_fx, slow_fx; Word16 fast_e, slow_e; @@ -465,63 +460,6 @@ void ivas_td_decorr_get_ducking_gains_fx( hTranDet->out_duck_gain = out_duck_gain; /*Q30*/ move32(); } -#else - Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; - Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k]; - - Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ - - set16_fx( e_fast_e, 31 - Q11, L_FRAME48k ); - - /* env hpf */ - ivas_filter_process_exp_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, e_fast_e ); - - - FOR( i = 0; i < frame_len; i++ ) - { - // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ - e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] ); - move32(); - e_slow_fx[i] = e_fast_fx[i]; - move32(); - e_slow_e[i] = e_fast_e[i]; - move16(); - } - - /* env fast*/ - ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e ); - - /* env slow */ - ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e ); - - IF( tdet_flag ) - { - FOR( i = 0; i < frame_len; i++ ) - { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/ - pIn_duck_gains[i] = in_duck_gain; /*Q30*/ - move32(); - } - hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ - move32(); - } - ELSE - { - FOR( i = 0; i < frame_len; i++ ) - { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/ - pIn_duck_gains[i] = in_duck_gain; /*Q30*/ - move32(); - out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_fast_e[i], e_slow_fx[i], e_slow_e[i], duck_mult_fac ); /*Q30*/ - pOut_duck_gains[i] = out_duck_gain; /*Q30*/ - move32(); - } - hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ - move32(); - hTranDet->out_duck_gain = out_duck_gain; /*Q30*/ - move32(); - } -#endif return; } diff --git a/lib_com/options.h b/lib_com/options.h index f71b23a4c..04289323f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,7 +115,6 @@ /* #################### Start BASOP optimization switches ############################ */ -#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 31ad2acf2..20b2ac7c7 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -407,11 +407,7 @@ void ivas_lfe_dec_fx( IF( hLFE->filter_state.order > 0 ) { /* Low Pass Filter */ -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame ); -#else - ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); -#endif } /* add delay to make overall max(block_offset, 11.5) */ diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 9ed990f8a..a76db70a1 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -684,11 +684,7 @@ void ivas_lfe_lpf_enc_apply_fx( const Word16 input_frame /* i : input frame length per channel */ ) { -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame ); -#else - ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); -#endif return; } -- GitLab From 32e2dc3685167e224d61f9990bf85f4b82ef2c87 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:31:44 +0100 Subject: [PATCH 535/750] [cleanup] accept NONBE_OPT_2193_EIG2X2 --- lib_com/options.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 371 ------------------ 2 files changed, 372 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 04289323f..1986a5d7b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,7 +115,6 @@ /* #################### Start BASOP optimization switches ############################ */ -#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 011d4b253..f20e58c42 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3463,7 +3463,6 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( return; } -#ifdef NONBE_OPT_2193_EIG2X2 static Word32 eig2x2_div_fx( Word32 num, Word32 den ); static Word32 eig2x2_div_fx( Word32 num, Word32 den ) @@ -3474,7 +3473,6 @@ static Word32 eig2x2_div_fx( Word32 num, Word32 den ) } return div_w_newton( num, den ); } -#endif static void eig2x2_fx( const Word32 E1_fx, /*q_E*/ @@ -3489,7 +3487,6 @@ static void eig2x2_fx( Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/ Word16 *q_D ) { -#ifdef NONBE_OPT_2193_EIG2X2 Word32 pm_fx, add_fx; Word32 tmp1, tmp2, e1, e2, c_re, c_im, c0_im, c1_im; Word32 s0_fx, s1_fx, nval0_fx, nval1_fx; @@ -3801,374 +3798,6 @@ static void eig2x2_fx( move32(); Uim_fx[i11][1] = Mpy_32_32( c1_im, nval1_fx ); move32(); -#else - Word16 chA, chB, ch; - Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx; - Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im; - Word16 q_crossSquare, q_tmp1, q_tmp2, exp_tmp3, exp, q_e, q_c, q_U_1, q_U_2; - Word32 epsilon_mant = 1180591621; - Word16 epsilon_exp = -39; - move32(); - move16(); - - pm_fx = 0; - move32(); - add_fx = 0; - move32(); - q_tmp2 = 0; - move16(); - - FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) - { - FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) - { - Ure_fx[chA][chB] = 0; - move32(); - Uim_fx[chA][chB] = 0; - move32(); - } - } - - exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); - c_re = L_shl( Cre_fx, exp ); - c_im = L_shl( Cim_fx, exp ); - q_c = add( q_C, exp ); - - exp = sub( get_min_scalefactor( E1_fx, E2_fx ), 2 ); - e1 = L_shl( E1_fx, exp ); - e2 = L_shl( E2_fx, exp ); - q_e = add( q_E, exp ); - - /*crossSquare_fx = (c_re * c_re) + (c_im * c_im) - a_fx = (e1 + e2) * (e1 + e2) - 4.0f * ((e1 * e2) - crossSquare_fx) = (e1 - e2)^2 + 4 * crossSquare_fx - pm_fx = 0.5f * sqrtf(max(0.0f, a_fx)) - add_fx = 0.5f * (e1 + e2)*/ - - IF( L_and( c_re == 0, c_im == 0 ) ) - { - /* if c_re = 0 and c_im = 0, then crossSquare_fx = (c_re * c_re) + (c_im * c_im) = 0 - a_fx = (E1 - E2)^2 - pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */ - crossSquare_fx = 0; - move32(); - q_crossSquare = Q31; - move16(); - pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 ); - q_tmp2 = q_e; - move16(); - } - ELSE - { - crossSquare_fx = Madd_32_32( Mpy_32_32( c_re, c_re ), c_im, c_im ); - q_crossSquare = sub( add( q_c, q_c ), 31 ); - IF( EQ_32( e1, e2 ) ) - { - /* if e1 - e2 = 0, then a_fx = 4 * crossSquare_fx - pm_fx = 0.5 * sqrt(max(0, 4 * crossSquare_fx)) = sqrt(0, crossSquare_fx)*/ - test(); - test(); - IF( EQ_32( c_re, 0 ) || LT_32( L_abs( c_re ), ONE_IN_Q15 ) ) - { - /* if c_re = 0, then crossSquare_fx = c_im^2 => pm_fx = max(0, c_im) */ - pm_fx = L_max( 0, L_abs( c_im ) ); - q_tmp2 = q_c; - move16(); - } - ELSE IF( c_im == 0 || LT_32( L_abs( c_im ), ONE_IN_Q15 ) ) - { - /* if c_im = 0, then crossSquare_fx = c_re^2 => pm_fx = max(0, c_re) */ - pm_fx = L_max( 0, L_abs( c_re ) ); - q_tmp2 = q_c; - move16(); - } - ELSE - { - exp = sub( 31, q_crossSquare ); - pm_fx = Sqrt32( L_max( 0, crossSquare_fx ), &exp ); - q_tmp2 = sub( 31, exp ); - } - } - ELSE - { - /* if e1, e2 >> c_re, c_im then (e1 - e2)^2 ~ (e1 - e2)^2 + 4 * crossSquare_fx - a_fx = (E1 - E2)^2 - pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */ - - IF( GT_16( sub( q_c, q_e ), Q15 ) ) - { - pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 ); - q_tmp2 = q_e; - move16(); - } - ELSE - { - tmp2 = crossSquare_fx; - move32(); - q_tmp2 = sub( q_crossSquare, 2 ); // crossSquare_fx = 4 * crossSquare_fx; - - tmp1 = Mpy_32_32( L_sub( e1, e2 ), L_sub( e1, e2 ) ); - q_tmp1 = sub( add( q_e, q_e ), 31 ); - - a_fx = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); // (E1 - E2)^2 + 4 * crossSquare_fx - q_tmp2 = sub( 31, q_tmp2 ); - - exp = sub( 31, q_tmp2 ); - pm_fx = Sqrt32( L_max( 0, L_sub( a_fx, 1 ) ), &exp ); - pm_fx = L_shr( pm_fx, 1 ); - q_tmp2 = sub( 31, exp ); - } - } - } - // add_fx = 0.5 * (e1 + e2) - add_fx = L_shr( L_add( e1, e2 ), 1 ); - q_tmp1 = q_e; - move16(); - - IF( LT_16( q_tmp1, q_tmp2 ) ) - { - D_fx[0] = L_add( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ); - move32(); - D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ) ); - move32(); - *q_D = sub( q_tmp1, 1 ); - move16(); - } - ELSE - { - D_fx[0] = L_add( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) ); - move32(); - D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) ) ); - move32(); - *q_D = sub( q_tmp2, 1 ); - move16(); - } - - /* Numeric case, when input is practically zeros */ - // IF( D_fx[0] < EPSILON_FX ) - - IF( LT_32( L_shl_sat( D_fx[0], sub( sub( 31, *q_D ), EPSILON_EXP ) ), EPSILON_MANT ) ) - { - Ure_fx[0][0] = ONE_IN_Q31; - move32(); - Ure_fx[1][1] = ONE_IN_Q31; - move32(); - *q_U = Q31; - move16(); - - return; - } - - /* Numeric case, when input is near an identity matrix with a gain */ - tmp1 = Mpy_32_32( INV_1000_Q31, add_fx ); - - IF( LT_16( q_tmp1, q_tmp2 ) ) - { - IF( LT_32( L_shr( pm_fx, sub( q_tmp2, q_tmp1 ) ), tmp1 ) ) - { - Ure_fx[0][0] = ONE_IN_Q30; - move32(); - Ure_fx[1][1] = ONE_IN_Q30; - move32(); - *q_U = Q30; - move16(); - - return; - } - } - ELSE - { - IF( LT_32( pm_fx, L_shr( tmp1, sub( q_tmp1, q_tmp2 ) ) ) ) - { - Ure_fx[0][0] = ONE_IN_Q30; - move32(); - Ure_fx[1][1] = ONE_IN_Q30; - move32(); - *q_U = Q30; - move16(); - - return; - } - } - - q_U_1 = 0; - q_U_2 = 0; - move16(); - move16(); - - /* Eigenvectors */ - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - Word16 q_diff = sub( q_e, *q_D ); - IF( q_diff > 0 ) - { - tmp1 = L_sub( D_fx[ch], L_shr( e1, q_diff ) ); - tmp2 = L_sub( D_fx[ch], L_shr( e2, q_diff ) ); - q_tmp1 = *q_D; - move16(); - } - ELSE - { - tmp1 = L_sub( L_shl( D_fx[ch], q_diff ), e1 ); - tmp2 = L_sub( L_shl( D_fx[ch], q_diff ), e2 ); - q_tmp1 = q_e; - move16(); - } - - IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) ) - { - s_fx = tmp2; - move32(); - exp = sub( norm_l( s_fx ), 1 ); - tmp2 = Mpy_32_32( s_fx, s_fx ); - q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); - - tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); - q_tmp2 = sub( 31, q_tmp2 ); - - tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - - tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); - exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); - normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 - q_tmp2 = sub( 31, exp ); - - q_diff = sub( q_c, q_tmp1 ); - IF( q_diff > 0 ) - { - c_re = L_shr( c_re, q_diff ); - c_im = L_shr( c_im, q_diff ); - q_c = q_tmp1; - move16(); - } - ELSE - { - s_fx = L_shl( s_fx, q_diff ); - q_tmp1 = q_c; - move16(); - } - - Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx ); - move32(); - Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx ); - move32(); - Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx ); - move32(); - q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); - - IF( q_U_2 != 0 ) - { - q_diff = sub( q_U_2, q_U_1 ); - IF( q_diff > 0 ) - { - Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], q_diff ); - Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], q_diff ); - Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], q_diff ); - q_U_2 = q_U_1; - move32(); - move32(); - move32(); - move16(); - } - ELSE IF( GT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch] = L_shl( Ure_fx[1][ch], q_diff ); - Ure_fx[0][ch] = L_shl( Ure_fx[0][ch], q_diff ); - Uim_fx[1][ch] = L_shl( Uim_fx[1][ch], q_diff ); - q_U_1 = q_U_2; - move32(); - move32(); - move32(); - move16(); - } - } - q_U_2 = q_U_1; - move16(); - } - ELSE - { - s_fx = tmp1; - move32(); - - exp = sub( norm_l( s_fx ), 1 ); - tmp2 = Mpy_32_32( s_fx, s_fx ); - q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); - - tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); - q_tmp2 = sub( 31, q_tmp2 ); - - tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - - tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); - exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); - normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 - q_tmp2 = sub( 31, exp ); - - q_diff = sub( q_c, q_tmp1 ); - IF( q_diff > 0 ) - { - c_re = L_shr( c_re, q_diff ); - c_im = L_shr( c_im, q_diff ); - q_c = q_tmp1; - move16(); - } - ELSE - { - s_fx = L_shl( s_fx, q_diff ); - q_tmp1 = q_c; - move16(); - } - - Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx ); - move32(); - Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx ); - move32(); - Uim_fx[0][ch] = Mpy_32_32( L_negate( c_im ), normVal_fx ); - move32(); - q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); - - IF( q_U_1 != 0 ) - { - q_diff = sub( q_U_2, q_U_1 ); - IF( q_diff > 0 ) - { - Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], q_diff ); - Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], q_diff ); - Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], q_diff ); - q_U_2 = q_U_1; - move32(); - move32(); - move32(); - move16(); - } - ELSE IF( GT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch - 1] = L_shl( Ure_fx[1][ch - 1], q_diff ); - Ure_fx[0][ch - 1] = L_shl( Ure_fx[0][ch - 1], q_diff ); - Uim_fx[1][ch - 1] = L_shl( Uim_fx[1][ch - 1], q_diff ); - q_U_1 = q_U_2; - move32(); - move32(); - move32(); - move16(); - } - } - q_U_1 = q_U_2; - move16(); - } - } - - if ( q_U_1 != 0 ) - { - *q_U = q_U_1; - move16(); - } - - if ( q_U_1 == 0 ) - { - *q_U = q_U_2; - move16(); - } -#endif return; } -- GitLab From 36b1701ca255628fdb745269ff0d939d45959885 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:34:17 +0100 Subject: [PATCH 536/750] formatting --- lib_com/gs_gains_fx.c | 16 ++++---- lib_com/ivas_filters_fx.c | 1 - lib_com/ivas_transient_det_fx.c | 2 +- lib_com/options.h | 4 -- lib_com/prot_fx.h | 17 ++++---- lib_dec/core_switching_dec_fx.c | 3 +- lib_dec/swb_tbe_dec_fx.c | 8 ++-- lib_dec/updt_dec_fx.c | 12 +++--- lib_enc/core_switching_enc_fx.c | 10 ++--- lib_enc/enc_gen_voic_fx.c | 4 +- lib_enc/hq_lr_enc_fx.c | 1 - lib_enc/long_enr_fx.c | 70 ++++++++++++++++----------------- lib_enc/lsf_enc_fx.c | 42 ++++++++++---------- lib_enc/prot_fx_enc.h | 30 +++++++------- lib_isar/isar_lcld_decoder.c | 10 ++--- lib_rend/lib_rend_fx.c | 1 - 16 files changed, 109 insertions(+), 122 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index cc48a5e63..a36d3ddeb 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -391,8 +391,8 @@ void Ener_per_band_comp_ivas_fx( *-------------------------------------------------------------------*/ static void GSC_gain_adj( - const Word16 coder_type, /* i : Coder type */ - const Word16 Mbands_gn, /* i : Number of band */ + const Word16 coder_type, /* i : Coder type */ + const Word16 Mbands_gn, /* i : Number of band */ const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ @@ -494,12 +494,12 @@ static void GSC_gain_adj( /*! r: average frequency gain */ Word16 gsc_gaindec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ + const Word32 core_brate_fx, /* i : core used */ + Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth_fx /* i : input signal bandwidth */ ) { Word16 idx_g_fx, i; diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index bcba83b89..5f1b1423b 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -247,4 +247,3 @@ void ivas_filter_process_fx64( return; } - diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 9c54f91f4..ea3acdb9e 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -43,7 +43,7 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) +#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) #define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32 #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 diff --git a/lib_com/options.h b/lib_com/options.h index 1986a5d7b..b38e1d635 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,10 +113,6 @@ /* ##################### End NON-BE switches ########################### */ -/* #################### Start BASOP optimization switches ############################ */ - - -/* #################### End BASOP optimization switches ############################ */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 289923aa5..420992dcf 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7635,8 +7635,7 @@ ivas_error core_switching_pre_dec_fx( const Word32 last_element_brate, /* i : last element bitrate */ const Word16 Q_old_synthFB, Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 -); + Word16 *Q_olapBufferSynth2 ); ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -7689,9 +7688,9 @@ void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth16, /* i : decoded synthesis Qpostd */ - const Word32 *synth, /* i : decoded synthesis Qpostd */ - const Word16 Qpostd /* i : Synthesis Q value */ + const Word16 *synth16, /* i : decoded synthesis Qpostd */ + const Word32 *synth, /* i : decoded synthesis Qpostd */ + const Word16 Qpostd /* i : Synthesis Q value */ ); void update_decoder_LPD_cng( @@ -10167,11 +10166,11 @@ void ivas_swb_tbe_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ Word16 *Q_white_exc ); Word16 swb_bwe_dec_fx32( diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 4d2948ba9..3bfcb453d 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1182,7 +1182,7 @@ ivas_error core_switching_pre_dec_fx( } IF( hBPF != NULL ) { - set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ + set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ hBPF->pst_mem_deemp_err_fx = 0; move16(); @@ -2073,4 +2073,3 @@ void bandwidth_switching_detect_fx( return; } - diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 7e9bf3a18..b9fb6f1b7 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -5477,11 +5477,11 @@ void ivas_swb_tbe_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ Word16 *Q_white_exc ) { Word16 i, j, cnt, n; diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 7489e9278..868c62fe7 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -397,10 +397,10 @@ void updt_IO_switch_dec_fx( *-------------------------------------------------------------------*/ static void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ const Word32 *synth32, /* i : synthesis signal32 Qpost */ - const Word16 Qpost /* i : Synthesis Q value */ + const Word16 Qpost /* i : Synthesis Q value */ ) { test(); @@ -474,9 +474,9 @@ void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth16, /* i : decoded synthesis Qpostd */ - const Word32 *synth, /* i : decoded synthesis Qpostd */ - const Word16 Qpostd /* i : Synthesis Q value */ + const Word16 *synth16, /* i : decoded synthesis Qpostd */ + const Word32 *synth, /* i : decoded synthesis Qpostd */ + const Word16 Qpostd /* i : Synthesis Q value */ ) { diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 95688a82a..497f4ad9e 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -19,11 +19,11 @@ *---------------------------------------------------------------------*/ void core_switching_pre_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ + const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index f7ba1ce2f..5e1a43a8c 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -310,8 +310,8 @@ void encod_gen_voic_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } - /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ - st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ + /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ + st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index b2b7ac9cb..74a3a15df 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -23,7 +23,6 @@ static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_a static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[] /*Q12*/, Word32 L_y2[] /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint /*Q29*/, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits ); - /*--------------------------------------------------------------------------* * spt_shorten_domain_set() * diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 61354bf87..46e455617 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -165,50 +165,50 @@ void long_enr_fx( * and total active speech energy *-----------------------------------------------------------------*/ - IF( LT_16( st_fx->ini_frame, 4 ) ) + IF( LT_16( st_fx->ini_frame, 4 ) ) + { + st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ + move16(); + tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/ + st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp ); /* Q8 */ + move16(); + } + ELSE + { + /* if ( st->ini_frame < 150 ) { + st->lp_noise = 0.95f * st->lp_noise + 0.05f * st->totalNoise; + } else { + st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise; + } */ + alpha = 655; /* 0.02 Q15 */ + move16(); + if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */ { - st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ - move16(); - tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/ - st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp ); /* Q8 */ + alpha = 1638; /* 0.05 Q15 */ move16(); } - ELSE + st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */ + move16(); + + test(); + IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) ) { - /* if ( st->ini_frame < 150 ) { - st->lp_noise = 0.95f * st->lp_noise + 0.05f * st->totalNoise; - } else { - st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise; - } */ - alpha = 655; /* 0.02 Q15 */ - move16(); - if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */ + IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 10 * 256 ) ) /* 10.0 in Q8 */ { - alpha = 1638; /* 0.05 Q15 */ + /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */ + st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */ move16(); } - st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */ - move16(); - - test(); - IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) ) + ELSE { - IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 10 * 256 ) ) /* 10.0 in Q8 */ - { - /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */ - st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */ - move16(); - } - ELSE - { - st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/ - move16(); - } + st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/ + move16(); } } + } - /* Update */ - st_fx->hNoiseEst->Etot_last_fx = Etot; + /* Update */ + st_fx->hNoiseEst->Etot_last_fx = Etot; - return; - } + return; +} diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 3995f1ab7..b423a7ae6 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -62,14 +62,14 @@ static void lsf_mid_enc_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, Wo /*===========================================================================*/ void lsf_enc_fx( - Encoder_State *st_fx, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ + Encoder_State *st_fx, /* i/o: state structure */ + Word16 *lsf_new, /* o : quantized LSF vector */ + Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ + Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ + Word16 *Aq, /* o : quantized A(z) for 4 subframes */ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ) { Word16 nBits = 0; @@ -357,10 +357,10 @@ void lsf_enc_fx( static void lsfq_CNG_fx( const Word16 element_mode, /* i : element mode */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/ - const Word16 *lsf, /*x2.56 unquantized LSF vector */ - const Word16 *wghts, /*Q10 LSF weights */ - Word16 *qlsf, /*x2.56 quantized LSF vecotor */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/ + const Word16 *lsf, /*x2.56 unquantized LSF vector */ + const Word16 *wghts, /*Q10 LSF weights */ + Word16 *qlsf, /*x2.56 quantized LSF vecotor */ Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ) @@ -2737,17 +2737,17 @@ static void FFT_Mid_Interpol_16k_fx( static void lsf_mid_enc_fx( const Word16 element_mode, /* i : element mode */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 nb_bits, /* i : number of bits */ - const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/ - const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/ - const Word16 qlsp1[], /* i : quantized LSPs from frame end */ - Word16 lsp[], /* i/o: mid-frame LSP */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - Word32 Bin_Ener_old[], /* i/o: per bin old log energy spectrum */ - Word32 Bin_Ener[], /* i : per bin log energy spectrum */ - Word16 Q_ener, /* i : Q value of Bin_ener */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 nb_bits, /* i : number of bits */ + const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/ + const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/ + const Word16 qlsp1[], /* i : quantized LSPs from frame end */ + Word16 lsp[], /* i/o: mid-frame LSP */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + Word32 Bin_Ener_old[], /* i/o: per bin old log energy spectrum */ + Word32 Bin_Ener[], /* i : per bin log energy spectrum */ + Word16 Q_ener, /* i : Q value of Bin_ener */ Word16 ppp_mode, Word16 nelp_mode ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index e18c097f5..f6fc25fde 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -125,11 +125,11 @@ void core_switching_post_enc_fx( ); void core_switching_pre_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ + const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ); @@ -557,10 +557,10 @@ void speech_music_classif_fx( void StableHighPitchDetect_fx( const Word16 element_mode, /* i : element mode */ - Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ - Word16 pitch[], /* i/o: OL pitch buffer */ - const Word16 voicing[], /* i : OL pitch gains */ - const Word16 wsp[], /* i : weighted speech */ + Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ + Word16 pitch[], /* i/o: OL pitch buffer */ + const Word16 voicing[], /* i : OL pitch gains */ + const Word16 wsp[], /* i : weighted speech */ const Word16 localVAD, Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains */ Word16 *voicing0_sm, /* i/o: smoothed high pitch gains */ @@ -1752,14 +1752,14 @@ void CNG_reset_enc_fx( ); void lsf_enc_fx( - Encoder_State *st_fx, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ + Encoder_State *st_fx, /* i/o: state structure */ + Word16 *lsf_new, /* o : quantized LSF vector */ + Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ + Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ + Word16 *Aq, /* o : quantized A(z) for 4 subframes */ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ); void Es_pred_enc_fx( diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index d34c56dac..5f41dd707 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -105,7 +105,6 @@ struct LCLD_DECODER Word32 ***pppiQLCLDImag; PredictionDecoder *psPredictionDecoder; - }; static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables ); @@ -781,8 +780,7 @@ static void ApplyRMSEnvelope_fx( const Word32 iNumBands, const Word32 *piBandwid static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, Word32 **ppiSignReal, Word32 **ppiSignImag, Word32 **ppfReal, Word32 **ppfImag, const Word32 *piBandwidths ); -static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag -); +static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag ); static void InvMSCoding_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiffs, const Word32 *piMSPredCoefs, Word32 ***pppfReal, Word32 ***pppfImag ); @@ -1004,8 +1002,7 @@ Word32 DecodeLCLDFrame( psLCLDDecoder->pppiAlloc[n], psLCLDDecoder->pppiQLCLDReal[n], psLCLDDecoder->pppiQLCLDImag[n], - pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] - ); + pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] ); ReplaceSign_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiLCLDSignReal[n], @@ -1275,8 +1272,7 @@ static void InvQuantizeSpectrum_fx( Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, - Word32 **ppfImag -) + Word32 **ppfImag ) { Word32 b, k, n; Word32 iBlockOffest, iFBOffset; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 232c38ee5..67b72c030 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5721,7 +5721,6 @@ ivas_error IVAS_REND_DisableHeadRotation( } - /*-------------------------------------------------------------------* * IVAS_REND_SetOrientationTrackingMode() * -- GitLab From f420cac7ece4c7fb5e595b4462b82e9ef6944f7c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 22 Jan 2026 09:56:49 +0100 Subject: [PATCH 537/750] [fix] wrong variable used for number of samples to scale --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b1085638d..71bf1687b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7682,7 +7682,7 @@ static ivas_error renderMcToBinauralRoom( #endif { #ifdef FIX_BASOP_2351_EXTREND_SCALE - Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numChannels, sub( Q11, exp ) ); /* Q11 */ + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ #else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ #endif -- GitLab From 79e06d753da7e7f5282212e8a3f8b9994d0e2ef2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 22 Jan 2026 10:19:30 +0100 Subject: [PATCH 538/750] [fix] wrong variable used for ISM split rendering output buffer --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 71bf1687b..d14c35478 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7130,7 +7130,7 @@ static ivas_error renderIsmToSplitBinaural( FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { #ifdef FIX_BASOP_2351_EXTREND_SCALE - Scale_sig32( tmpProcessing[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ + Scale_sig32( tmpProcessing[i], output_frame, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #else Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #endif -- GitLab From 8041f52d854a24525b8e6db1710a31937ca1a468 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 22 Jan 2026 12:49:40 +0100 Subject: [PATCH 539/750] SIMPLIFY_SCALING_OLD_INP, REMOVE_UNUSED_BUFFER_CORE_ENC, REMOVE_SCALING_SHB_SPEECH, SCALING_SWB_SPEECH_32 --- lib_com/ivas_prot_fx.h | 23 +++++++- lib_com/options.h | 4 ++ lib_com/prot_fx.h | 8 ++- lib_enc/ivas_core_enc_fx.c | 80 +++++++++++++++++++++++--- lib_enc/ivas_mdct_core_enc_fx.c | 38 ++++++++++-- lib_enc/ivas_stereo_icbwe_enc_fx.c | 23 ++++++-- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 11 +++- lib_enc/ivas_tcx_core_enc_fx.c | 52 +++++++++++++---- lib_enc/swb_pre_proc_fx.c | 14 ++++- 9 files changed, 218 insertions(+), 35 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0fb526b41..e2f98b524 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1357,11 +1357,15 @@ void stereo_tcx_init_dec_fx( const Word16 last_element_mode /* i : element mode of previous frame */ ); -void stereo_icBWE_enc_ivas_fx( +void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ +#ifdef SCALING_SWB_SPEECH_32 + Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel Q15-shb_speech_nonref_e*/ +#else Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel */ +#endif Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ const Word32 *voice_factors_fx /* i : voicing factors Q31 */ ); @@ -3083,15 +3087,24 @@ void InternalTCXDecoder_fx( void stereo_tcx_core_enc( Encoder_State *st, /* i/o: encoder state structure */ +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new-1*/ + Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new-1*/ +#else const Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz */ const Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz */ +#endif const Word16 Aw_fx[], /* i : weighted A(z) unquant. for subframes,Q12*/ Word16 lsp_new_fx[], /* i : LSPs at the end of the frame, Q15 */ Word16 lsp_mid_fx[], /* i : LSPs in the middle of the frame, Q15 */ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : pitch for each subframe, Q6 */ const Word16 last_element_mode, /* i : last element mode, Q0 */ const Word16 vad_hover_flag, /* i : VAD hangover flag, Q0 */ +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 Q_new_inp /* i : Q factor of input buffer */ +#else Word16 Q_new +#endif ); Word16 transient_analysis_ivas_fx( @@ -6420,7 +6433,10 @@ UWord16 get_indice_st( void stereo_mdct_core_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/ +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ +#endif Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ ); @@ -6468,6 +6484,9 @@ void stereo_switching_dec( void ivas_mdct_core_whitening_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ +#endif Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..fa11260fa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,6 +116,10 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define SIMPLIFY_SCALING_OLD_INP +#define REMOVE_UNUSED_BUFFER_CORE_ENC +#define REMOVE_SCALING_SHB_SPEECH +#define SCALING_SWB_SPEECH_32 /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index fac7485fb..0d97361bb 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10488,10 +10488,12 @@ void Copy_Scale_sig32( ); void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ +#ifndef SCALING_SWB_SPEECH_32 Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ +#endif + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ Word16 *Q_shb_spch, Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 206a3e25c..cf1456364 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -88,11 +88,15 @@ ivas_error ivas_core_enc_fx( STEREO_TD_ENC_DATA_HANDLE hStereoTD; Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; /* Q15 */ Word32 shb_speech_fx32[L_FRAME16k]; +#ifndef SCALING_SWB_SPEECH_32 Word32 *new_swb_speech_fx; +#endif Word16 *inp_fx[CPE_CHANNELS]; Word16 *shb_speech_fx; Word16 Q_shb_spch; +#ifndef SCALING_SWB_SPEECH_32 Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; +#endif Word16 new_inp_resamp16k_fx[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ Word16 *hb_speech_fx; Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; /* 2 * Q_new */ @@ -110,8 +114,9 @@ ivas_error ivas_core_enc_fx( Word16 max_num_indices_BWE; Word16 i, shift, Q_min; +#ifndef SCALING_SWB_SPEECH_32 set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); - +#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET ); @@ -364,9 +369,10 @@ ivas_error ivas_core_enc_fx( TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; Word16 Q_spec_old, L_spec; +#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0 Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 - +#endif Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( negate( 1 ), st->hTcxEnc->q_Txnq ) ); /* Q(-1) */ st->hTcxEnc->q_Txnq = -Q1; move16(); @@ -374,10 +380,14 @@ ivas_error ivas_core_enc_fx( move16(); /* TCX core encoder */ +#ifdef SIMPLIFY_SCALING_OLD_INP + stereo_tcx_core_enc( st, old_inp_12k8_fx[n] + L_INP_MEM, old_inp_16k_fx[n] + L_INP_MEM, Aw_fx[n], lsp_new_fx[n], lsp_mid_fx[n], pitch_buf_fx[n], last_element_mode, vad_hover_flag[0], Q_new[n] ); +#else stereo_tcx_core_enc( st, old_inp_12k8_fx[n] + L_INP_MEM, old_inp_16k_fx[n] + L_INP_MEM, Aw_fx[n], lsp_new_fx[n], lsp_mid_fx[n], pitch_buf_fx[n], last_element_mode, vad_hover_flag[0], 0 ); Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q_new[n], Q1 ) ); // Q_new[n] - 1 Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q_new[n], Q1 ) ); // Q_new[n] - 1 +#endif Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( st->hTcxEnc->Q_old_out ) ); // scaling back to Q0 st->hTcxEnc->Q_old_out = 0; @@ -458,7 +468,9 @@ ivas_error ivas_core_enc_fx( FOR( n = 0; n < n_CoreChannels; n++ ) { st = sts[n]; +#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 +#endif IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc; @@ -471,15 +483,22 @@ ivas_error ivas_core_enc_fx( Q_spec_old[1] = hCPE->hCoreCoder[1]->hTcxEnc->spectrum_long_e; move16(); +#ifdef SIMPLIFY_SCALING_OLD_INP + ivas_mdct_core_whitening_enc_fx( hCPE, old_inp_16k_fx, Q_new, old_wsp_fx, pitch_buf_fx_new, hMCT->p_mdst_spectrum_long_fx[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long_fx[cpe_id], + hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, 1, hMCT->nchan_out_woLFE, mdst_spectrum_e, orig_spectrum_e ); +#else ivas_mdct_core_whitening_enc_fx( hCPE, old_inp_16k_fx, old_wsp_fx, pitch_buf_fx_new, hMCT->p_mdst_spectrum_long_fx[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long_fx[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, 1, hMCT->nchan_out_woLFE, mdst_spectrum_e, orig_spectrum_e ); +#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = sts[i]; Word16 nSubframes = NB_DIV; move16(); +#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q_new[i], Q1 ) ); // Q_new[n] - 1 +#endif if ( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) { nSubframes = 1; @@ -544,8 +563,9 @@ ivas_error ivas_core_enc_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = sts[i]; +#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q1, Q_new[i] ) ); // Q0 - +#endif test(); IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { @@ -571,11 +591,17 @@ ivas_error ivas_core_enc_fx( Q_spec_old[1] = hCPE->hCoreCoder[1]->hTcxEnc->spectrum_long_e; move16(); +#ifdef SIMPLIFY_SCALING_OLD_INP + stereo_mdct_core_enc_fx( hCPE, old_inp_16k_fx, Q_new, old_wsp_fx, pitch_buf_fx ); +#else stereo_mdct_core_enc_fx( hCPE, old_inp_16k_fx, old_wsp_fx, pitch_buf_fx ); +#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { +#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q_new[i], Q1 ) ); // Q_new[n] - 1 +#endif st = sts[i]; IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) { @@ -643,8 +669,9 @@ ivas_error ivas_core_enc_fx( * Postprocessing, BWEs and Updates *---------------------------------------------------------------------*/ +#ifndef REMOVE_UNUSED_BUFFER_CORE_ENC Word16 tmp_input_fx[L_FRAME48k], tmp_old_input_fx[L_FRAME48k], q_inp[2]; - +#endif FOR( n = 0; n < n_CoreChannels; n++ ) { st = sts[n]; @@ -659,11 +686,12 @@ ivas_error ivas_core_enc_fx( move16(); } +#ifndef REMOVE_UNUSED_BUFFER_CORE_ENC Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame ); Copy( st->input_fx, tmp_input_fx, input_frame ); q_inp[0] = st->q_old_inp; q_inp[1] = st->q_inp; - +#endif Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( -1, st->q_inp ) ); st->q_inp = -1; move16(); @@ -713,7 +741,9 @@ ivas_error ivas_core_enc_fx( * SWB(FB) BWE encoding *---------------------------------------------------------------------*/ +#ifndef SCALING_SWB_SPEECH_32 new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; +#endif new_swb_speech_fx_16 = new_swb_speech_buffer_fx_16 + STEREO_DFT_OVL_MAX; set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); shb_speech_fx = new_inp_resamp16k_fx[n]; /* reuse existing buffer: shb_speech[L_FRAME16k] */ @@ -746,7 +776,17 @@ ivas_error ivas_core_enc_fx( st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 ); } +#ifdef SCALING_SWB_SPEECH_32 + Word32 *new_swb_speech_fx; + Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; + set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); + new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; +#endif +#ifdef SCALING_SWB_SPEECH_32 + swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx ,& Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); +#else swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); +#endif st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 ); } @@ -765,10 +805,11 @@ ivas_error ivas_core_enc_fx( // IF( st->tcxonly == 0 ) #endif { +#ifndef REMOVE_SCALING_SHB_SPEECH shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch Q_shb_spch = add( Q_shb_spch, shift ); - +#endif IF( st->hBWE_FD ) { shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); @@ -800,6 +841,11 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { +#ifdef REMOVE_SCALING_SHB_SPEECH + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Q_shb_spch = add( Q_shb_spch_16, shift ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch +#endif Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 /* SWB(FB) BWE encoder */ swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); @@ -817,6 +863,11 @@ ivas_error ivas_core_enc_fx( IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && ( GE_16( input_frame, L_FRAME32k ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) { /* SHB DTX/CNG encoder */ +#ifdef REMOVE_SCALING_SHB_SPEECH + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Q_shb_spch = add( Q_shb_spch_16, shift ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch +#endif Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 #ifdef HARM_NON_LINEARITY swb_CNG_enc_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); @@ -840,10 +891,21 @@ ivas_error ivas_core_enc_fx( stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 ); +#ifndef SCALING_SWB_SPEECH_32 Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp - Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 +#endif + Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 - stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); +#ifdef REMOVE_SCALING_SHB_SPEECH + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Q_shb_spch = add( Q_shb_spch_16, shift ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch +#endif +#ifdef SCALING_SWB_SPEECH_32 + stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); +#else + stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); +#endif IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { @@ -861,12 +923,14 @@ ivas_error ivas_core_enc_fx( } } +#ifndef REMOVE_UNUSED_BUFFER_CORE_ENC Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame ); Copy( tmp_input_fx, st->input_fx, input_frame ); st->q_old_inp = q_inp[0]; move16(); st->q_inp = q_inp[1]; move16(); +#endif #ifndef REMOVE_CAM_FROM_IVAS /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index f4889bf5f..ac3305d74 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1117,7 +1117,10 @@ void enc_prm_igf_mdct( void ivas_mdct_core_whitening_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ + Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/ +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ +#endif Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word32 *mdst_spectrum_long_fx[CPE_CHANNELS], /* o : buffer for MDST spectrum mdst_spectrum_e*/ @@ -1183,6 +1186,13 @@ void ivas_mdct_core_whitening_enc_fx( move16(); move16(); +#ifdef SIMPLIFY_SCALING_OLD_INP + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + Scale_sig( new_samples_fx[ch], L_INP, sub( Q1, Q_new_inp[ch] ) ); // Q0 + } +#endif + /*--------------------------------------------------------------* * Initialization *---------------------------------------------------------------*/ @@ -1222,6 +1232,7 @@ void ivas_mdct_core_whitening_enc_fx( windowedSignal_fx[0] = orig_spectrum_long[0]; /* NOTE temporarily available */ windowedSignal_fx[1] = temp_buffer; /* orig_spectrum_long isn't long enough */ + /*--------------------------------------------------------------* * TCX20/TCX10 switching decision *---------------------------------------------------------------*/ @@ -1321,6 +1332,7 @@ void ivas_mdct_core_whitening_enc_fx( move32(); } } + /*--------------------------------------------------------------* * Transform Kernel Switching, Stereo Pre-Processing, and TNS *---------------------------------------------------------------*/ @@ -1522,6 +1534,7 @@ void ivas_mdct_core_whitening_enc_fx( move16(); move16(); } + FOR( n = 0; n < nSubframes; n++ ) { test(); @@ -1708,7 +1721,6 @@ void ivas_mdct_core_whitening_enc_fx( init_tcx_enc_info_fx( sts[ch], &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); - nSubframes = NB_DIV; move16(); shift = 1; @@ -1758,6 +1770,7 @@ void ivas_mdct_core_whitening_enc_fx( } } } + TCX_ENC_HANDLE hTcxEnc = NULL; q_min = 0; move16(); @@ -1810,10 +1823,12 @@ void ivas_mdct_core_whitening_enc_fx( } } TNSAnalysisStereo_fx( sts, mdst_spectrum_fx, 0, tnsSize, tnsBits, param_core, mct_on ); + /*--------------------------------------------------------------* * Envelope Quantization and FDNS *---------------------------------------------------------------*/ - /* Common q for spectrum and mdst */ + + /* Common q for spectrum and mdst */ q_min = 0; move16(); q_com = Q31; @@ -2062,7 +2077,6 @@ void ivas_mdct_core_whitening_enc_fx( init_tcx_enc_info_fx( st, &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); - IF( NE_16( st->hTcxEnc->tcxMode, TCX_20 ) ) { /* nSubframes = NB_DIV = 2 */ @@ -2091,6 +2105,7 @@ void ivas_mdct_core_whitening_enc_fx( Scale_sig32( st->hTcxEnc->spectrum_fx[n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, st->hTcxEnc->spectrum_e[n] ) ); } } + /*--------------------------------------------------------------* * TNS *---------------------------------------------------------------*/ @@ -2313,6 +2328,7 @@ void ivas_mdct_core_whitening_enc_fx( /*--------------------------------------------------------------------------------* * SNS parameters *--------------------------------------------------------------------------------*/ + test(); test(); test(); @@ -2474,11 +2490,25 @@ void ivas_mdct_core_whitening_enc_fx( } } +#ifdef SIMPLIFY_SCALING_OLD_INP + // scaling the input buffer back to Q_new-1 - actually not needed because the buffer is not used in the subsequent processing + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + Scale_sig( new_samples_fx[ch], L_INP, sub( Q_new_inp[ch], Q1 ) ); // Q0 + } +#endif + pop_wmops(); return; } +/*--------------------------------------------------------------* + * ivas_mdct_quant_coder() + * + * Spectrum quantization and coding + *---------------------------------------------------------------*/ + void ivas_mdct_quant_coder_fx( CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 61a2f0490..9fc7059b7 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -611,13 +611,23 @@ static void icbwe_dft_stereo_param_ivas_fx( return; } -void stereo_icBWE_enc_ivas_fx( +/*-------------------------------------------------------------------* + * stereo_icBWE_enc() + * + * Encode the spatial mapping of reference to the non-reference channels in HB + *-------------------------------------------------------------------*/ + +void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ - Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ - Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ - const Word32 *voice_factors_fx /* i : voicing factors Q31 */ +#ifdef SCALING_SWB_SPEECH_32 + Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel Q15-shb_speech_nonref_e*/ +#else + Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ +#endif + Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ + const Word32 *voice_factors_fx /* i : voicing factors Q31 */ ) { Word16 i, j, k, nbSubFr; @@ -641,6 +651,11 @@ void stereo_icBWE_enc_ivas_fx( Word32 temp1_fx, temp2_fx; Word16 temp1_e, temp2_e, shb_frame_ref_e, shb_frame_nonref_e, gDes_e, tmp, exp; +#ifdef SCALING_SWB_SPEECH_32 + Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; + + Copy_Scale_sig_16_32_no_sat( shb_speech_nonref_fx_16, shb_speech_nonref_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp +#endif /* initialization */ hStereoDft = hCPE->hStereoDft; diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 705635d88..2c197ed0b 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -126,9 +126,13 @@ static void sync_tcx_mode_fx( * * joint stereo mdct core encoder *-------------------------------------------------------------------*/ + void stereo_mdct_core_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q_new-1*/ +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ +#endif Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ ) @@ -284,8 +288,13 @@ void stereo_mdct_core_enc_fx( * - TNS *---------------------------------------------------------------*/ +#ifdef SIMPLIFY_SCALING_OLD_INP + ivas_mdct_core_whitening_enc_fx( hCPE, new_samples, Q_new_inp, old_wsp, pitch_buf_fx, p_mdst_spectrum_long_fx, + tnsBits, p_orig_spectrum_long_fx, tnsSize, p_param, hBstr, 0, CPE_CHANNELS, mdst_spectrum_e, orig_spectrum_e ); +#else ivas_mdct_core_whitening_enc_fx( hCPE, new_samples, old_wsp, pitch_buf_fx, p_mdst_spectrum_long_fx, tnsBits, p_orig_spectrum_long_fx, tnsSize, p_param, hBstr, 0, CPE_CHANNELS, mdst_spectrum_e, orig_spectrum_e ); +#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 1b2833473..9d83d8df1 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -151,16 +151,26 @@ void stereo_tcx_init_enc_fx( *-------------------------------------------------------------------*/ void stereo_tcx_core_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new*/ - const Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new*/ + Encoder_State *st, /* i/o: encoder state structure */ +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new-1*/ + Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new-1*/ +#else + const Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new*/ + const Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new*/ +#endif const Word16 Aw_fx[], /* i : weighted A(z) unquant. for subframes, Q12 */ Word16 lsp_new_fx[], /* i : LSPs at the end of the frame, Q15 */ Word16 lsp_mid_fx[], /* i : LSPs in the middle of the frame, Q15 */ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : pitch for each subframe, Q6 */ const Word16 last_element_mode, /* i : last element mode, Q0 */ const Word16 vad_hover_flag, /* i : VAD hangover flag, Q0 */ - Word16 Q_new ) +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 Q_new /* i : Q factor of input buffer */ +#else + Word16 Q_new +#endif +) { TCX_ENC_HANDLE hTcxEnc; Word16 i, n; @@ -173,7 +183,8 @@ void stereo_tcx_core_enc( Word16 last_core_orig; /*Bits*/ - Word16 nbits_start, total_nbbits, nbits_header; + Word16 nbits_start, + total_nbbits, nbits_header; Word16 target_bits[2], bitsAvailable; Word16 nbits_lpc[2]; Word16 tnsSize[2]; /* number of tns parameters put into prm */ @@ -202,15 +213,12 @@ void stereo_tcx_core_enc( /*HM*/ Word16 indexBuffer[2 * ( ( N_MAX / 2 ) + 1 )]; - Word16 s; - CONTEXT_HM_CONFIG hm_cfg[2]; /* bitstream */ BSTR_ENC_HANDLE hBstr = st->hBstr; - push_wmops( "stereo_tcx_core_enc" ); /*Sanity check*/ @@ -300,11 +308,17 @@ void stereo_tcx_core_enc( IF( EQ_16( st->L_frame, L_FRAME ) ) { - p_new_samples = new_samples_12k8; /* Q_new */ +#ifdef SIMPLIFY_SCALING_OLD_INP + Scale_sig( new_samples_12k8, L_INP_12k8, sub( Q1, Q_new ) ); // Q0 +#endif + p_new_samples = new_samples_12k8; /* Q0 */ } ELSE { - p_new_samples = new_samples_16k; /* Q_new */ +#ifdef SIMPLIFY_SCALING_OLD_INP + Scale_sig( new_samples_16k, L_INP, sub( Q1, Q_new ) ); // Q0 +#endif + p_new_samples = new_samples_16k; /* Q0 */ } /*--------------------------------------------------------------* @@ -372,6 +386,10 @@ void stereo_tcx_core_enc( st->prev_Q_new = 0; st->Q_old = 0; +#ifdef SIMPLIFY_SCALING_OLD_INP + Word16 Q_new_orig = Q_new; + move16(); +#endif Q_new = 0; move16(); @@ -685,6 +703,7 @@ void stereo_tcx_core_enc( /*--------------------------------------------------------------------------------* * Encode TCX20/10 parameters *--------------------------------------------------------------------------------*/ + writeTCXparam_fx( st, hBstr, hm_cfg, param_core, nbits_header, nbits_start, add( nbits_lpc[0], nbits_lpc[1] ), NULL, NULL, NULL, -1 ); total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); @@ -709,6 +728,7 @@ void stereo_tcx_core_enc( move16(); } } + Scale_sig( st->synth, st->L_frame, -Q_new ); IF( st->tcxonly == 0 ) { @@ -716,6 +736,18 @@ void stereo_tcx_core_enc( move16(); } +#ifdef SIMPLIFY_SCALING_OLD_INP + // scaling the input buffer back to Q_new-1 - actually not needed because the buffer is not used in the subsequent processing + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + Scale_sig( new_samples_12k8, L_INP_12k8, sub( Q_new_orig, Q1 ) ); // Q_new-1 + } + ELSE + { + Scale_sig( new_samples_16k, L_INP, sub( Q_new_orig, Q1 ) ); // Q_new-1 + } +#endif + pop_wmops(); return; } diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 04d546ffa..a36715bd5 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -773,10 +773,12 @@ void swb_pre_proc_fx( /*full implementation pending*/ void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ +#ifndef SCALING_SWB_SPEECH_32 Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ +#endif + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ Word16 *Q_shb_spch, Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ @@ -1063,6 +1065,12 @@ void swb_pre_proc_ivas_fx( ELSE /* IVAS_CPE_DFT */ { Word16 out_start_ind, out_end_ind; +#ifdef SCALING_SWB_SPEECH_32 + Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; + Word32 *new_swb_speech_fx; + set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); + new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; +#endif stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, new_swb_speech_fx, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 32000, 0, NULL ); Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( st->q_inp, add( q_reImBuffer, 1 ) ) ); // st->q_inp -- GitLab From 9b0bb393eb55cfae73692b217ebd0879b7906bce Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 22 Jan 2026 08:43:21 -0500 Subject: [PATCH 540/750] proposition to harm. find_wsp --- lib_com/options.h | 1 + lib_com/prot_fx.h | 4 ++-- lib_enc/find_wsp_fx.c | 3 ++- lib_enc/ivas_core_pre_proc_front_fx.c | 6 ++++-- lib_enc/ivas_core_pre_proc_fx.c | 5 ++++- lib_enc/ivas_front_vad_fx.c | 5 ++++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b38e1d635..54e05f83f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 420992dcf..ef13554ab 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -11010,7 +11010,7 @@ void bands_and_bit_alloc_ivas_fx( const Word16 element_mode, /* i : element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); - +#ifndef FIX_2363_FIND_WSP void ivas_find_wsp_fx( const Word16 L_frame, /* i : length of the frame Q0*/ const Word16 L_subfr, /* i : length of subframe Q0*/ @@ -11024,7 +11024,7 @@ void ivas_find_wsp_fx( const Word16 gamma, /* i : weighting factor Q15 */ const Word16 L_look /* i : look-ahead Q0*/ ); - +#endif Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( Word16 *x, /* Q0 */ const Word16 nt, /* Q0 */ diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index 6e75c36c2..fe8854500 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -77,7 +77,7 @@ void find_wsp_fx( deemph_fx( &wsp[L_frame], preemph_fac, lookahead, &wtmp ); } } - +#ifndef FIX_2363_FIND_WSP /*-------------------------------------------------------------------* * ivas_find_wsp_fx() * @@ -134,3 +134,4 @@ void ivas_find_wsp_fx( deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx ); return; } +#endif \ No newline at end of file diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index abe017232..147340d38 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1085,9 +1085,11 @@ ivas_error pre_proc_front_ivas_fx( st->mem_wsp_q = *Q_new; move16(); move16(); - +#ifndef FIX_2363_FIND_WSP ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 ); - +#else + find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR ); +#endif Word16 Q_wsp = *Q_new; move16(); IF( st->vad_flag == 0 ) diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index a6e8966df..bee6b73eb 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1251,8 +1251,11 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ - +#ifndef FIX_2363_FIND_WSP ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); +#else + find_wsp_fx( A_fx, st->speech_enc_pe, st->wspeech_enc, &st->mem_wsp_enc, PREEMPH_FAC_16k, L_FRAME16k, L_LOOK_16k, L_SUBFR, Aw_fx, st->gamma, NB_SUBFR16k ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index bab92da6e..c2b31b87a 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -634,8 +634,11 @@ ivas_error front_vad_spar_fx( st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */ st->mem_wsp_q = Q_inp_12k8; move16(); +#ifndef FIX_2363_FIND_WSP ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 ); - +#else + find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR ); +#endif IF( st->vad_flag == 0 ) { /* reset the OL pitch tracker memories during inactive frames */ -- GitLab From 3203f2e4513b1f7e141e6401ef2f68e0f04b61aa Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 22 Jan 2026 14:49:19 +0100 Subject: [PATCH 541/750] Correct buffer length in output scaling in ivas_objectRenderer_fx.c --- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index b38e1d635..d5c3b2d90 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 9c76335e0..abfc23a1e 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -436,7 +436,11 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) { +#ifdef FIX_BASOP_2358_SCALING_OOB + scale_sig32( output_fx[i], output_frame, -4 ); // Q11 - 4 = Q7 +#else scale_sig32( output_fx[i], L_FRAME48k, -4 ); // Q11 - 4 = Q7 +#endif } IF( NE_32( ( error = ivas_reverb_process_fx( hReverb, transport_config, 0, output_fx, p_reverb_signal_fx, subframe_idx ) ), IVAS_ERR_OK ) ) // Q p_reverb_signal_fx = Q output_fx - 2 = 5 @@ -446,7 +450,11 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) { +#ifdef FIX_BASOP_2358_SCALING_OOB + scale_sig32( output_fx[i], output_frame, 4 ); // Q7 + 4 = Q11 +#else scale_sig32( output_fx[i], L_FRAME48k, 4 ); // Q7 + 4 = Q11 +#endif } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) -- GitLab From 7c72b652b56ed8d7b61e854684a4b893c1fca865 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 22 Jan 2026 09:19:06 -0500 Subject: [PATCH 542/750] harmonisation of mult_harm --- lib_com/options.h | 1 + lib_enc/ivas_front_vad_fx.c | 4 + lib_enc/multi_harm_fx.c | 151 ++++++++++++++++++++++++++---------- lib_enc/nois_est_fx.c | 10 +++ lib_enc/prot_fx_enc.h | 5 ++ 5 files changed, 129 insertions(+), 42 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b38e1d635..f4a802d2a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index bab92da6e..ba7c84a16 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -698,7 +698,11 @@ ivas_error front_vad_spar_fx( { cor_strong_limit = &dummy_int; } +#ifndef FIX_2364_HARM_MULT_HARM loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */ +#else + loc_harm = multi_harm_fx( EVS_MONO, st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */ +#endif } scale = getScaleFactor32( epsP_fx, M + 1 ); diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 76b465777..07a80bb85 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -22,7 +22,9 @@ /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_fx( - +#ifdef FIX_2364_HARM_MULT_HARM + const Word16 element_mode, /* i : IVAS element_mode Q0 */ +#endif const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ @@ -43,7 +45,9 @@ Word16 multi_harm_fx( Word32 L_acc; Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; Word16 mean_dyn; - +#ifdef FIX_2364_HARM_MULT_HARM + Word32 tmp2_32; +#endif /*------------------------------------------------------------------* * initialization *------------------------------------------------------------------*/ @@ -120,35 +124,65 @@ Word16 multi_harm_fx( move16(); step = 0; move16(); - - FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ ) +#ifdef FIX_2364_HARM_MULT_HARM + IF( element_mode != EVS_MONO ) { - /* we are at the end of the next minimum */ - IF( EQ_16( i, *pt_mins ) ) + FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ ) { - pt_mins++; - flor = Bin_E[i]; - move16(); /*Q7*/ - /* calculate the new step */ - /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/ - tmp16 = sub( *pt_mins, i ); - tmpdB = sub( Bin_E[*pt_mins], Bin_E[i] ); - sign_fx = shr( tmpdB, 15 ); /* 0 if positive else -1 */ - ExpdB = sub( norm_s( tmpdB ), 1 ); - tmpdB = abs_s( shl( tmpdB, ExpdB ) ); - ExpInd = norm_s( tmp16 ); - tmp16 = shl( tmp16, ExpInd ); - tmp16 = div_s( tmpdB, tmp16 ); - tmp16 = sub( s_xor( tmp16, sign_fx ), sign_fx ); - step = shr( tmp16, add( sub( ExpdB, ExpInd ), 15 ) ); /* Q7 */ + /* we are at the end of the next minimum */ + IF( EQ_16( i, *pt_mins ) ) + { + pt_mins++; + flor = Bin_E[i]; + move16(); /*Q7*/ + + /* calculate the new step */ + /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/ + + tmp16 = div_s( 1, sub( *pt_mins, i ) ); // Q15 + step = msu_r( L_mult( Bin_E[*pt_mins], tmp16 ), Bin_E[i], tmp16 ); // Q7 (15+7+1-16) + } + + /* subtract the floor */ + S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 ); + move16(); + + /* update the floor */ + flor = add( flor, step ); /*Q7*/ } + } + ELSE +#endif + { + FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ ) + { + /* we are at the end of the next minimum */ + IF( EQ_16( i, *pt_mins ) ) + { + pt_mins++; + flor = Bin_E[i]; + move16(); /*Q7*/ + /* calculate the new step */ + /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/ + tmp16 = sub( *pt_mins, i ); + tmpdB = sub( Bin_E[*pt_mins], Bin_E[i] ); + sign_fx = shr( tmpdB, 15 ); /* 0 if positive else -1 */ + ExpdB = sub( norm_s( tmpdB ), 1 ); + tmpdB = abs_s( shl( tmpdB, ExpdB ) ); + ExpInd = norm_s( tmp16 ); + tmp16 = shl( tmp16, ExpInd ); + tmp16 = div_s( tmpdB, tmp16 ); + tmp16 = sub( s_xor( tmp16, sign_fx ), sign_fx ); + step = shr( tmp16, add( sub( ExpdB, ExpInd ), 15 ) ); /* Q7 */ + } - /* subtract the floor */ - S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 ); - move16(); + /* subtract the floor */ + S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 ); + move16(); - /* update the floor */ - flor = add( flor, step ); /*Q7*/ + /* update the floor */ + flor = add( flor, step ); /*Q7*/ + } } } @@ -285,35 +319,67 @@ Word16 multi_harm_fx( Lcor_map_LT_sum = L_deposit_l( 0 ); tmp2 = 0; move16(); - +#ifdef FIX_2364_HARM_MULT_HARM + tmp2_32 = 0; + move32(); +#endif cor_strong = 0; move16(); pt1 = cor_map_LT; // Q15 move16(); pt2 = cor_map; move16(); - FOR( i = 0; i < L; i++ ) +#ifdef FIX_2364_HARM_MULT_HARM + IF( element_mode != EVS_MONO ) { - /* tmp2 += S[i]; */ - tmp2 = add( tmp2, shl( S[i], 1 ) ); /* tmp2 in Q8; max value is 128) */ + FOR( i = 0; i < L; i++ ) + { + /* tmp2 += S[i]; */ + tmp2_32 = L_add( tmp2_32, cor_map[i] ); /* tmp2_32 in Q15; max value is 128) */ - /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */ - *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 ); - move16(); + /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */ + *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 ); + move16(); - /* cor_map_LT_sum += *pt1 */ - Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */ + /* cor_map_LT_sum += *pt1 */ + Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */ - if ( GT_16( *pt1, 31130 ) /*0.95f.Q15*/ ) + if ( GT_16( *pt1, 31130 ) /*0.95f*/ ) + { + cor_strong = 1; + move16(); + } + + pt1++; + pt2++; + } + tmp2 = extract_l( L_shr_sat( tmp2_32, 7 ) ); // q15-> q8 + } + ELSE +#endif + { + FOR( i = 0; i < L; i++ ) { - cor_strong = 1; + /* tmp2 += S[i]; */ + tmp2 = add( tmp2, shl( S[i], 1 ) ); /* tmp2 in Q8; max value is 128) */ + + /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */ + *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 ); move16(); - } - pt1++; - pt2++; - } + /* cor_map_LT_sum += *pt1 */ + Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */ + + if ( GT_16( *pt1, 31130 ) /*0.95f.Q15*/ ) + { + cor_strong = 1; + move16(); + } + pt1++; + pt2++; + } + } IF( ( bwidth == NB ) ) { /* cor_map_LT_sum *= 1.53f; */ @@ -360,7 +426,7 @@ Word16 multi_harm_fx( return harm; } - +#ifndef FIX_2364_HARM_MULT_HARM /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_ivas_fx( const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ @@ -695,3 +761,4 @@ Word16 multi_harm_ivas_fx( } return harm; } +#endif \ No newline at end of file diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 756ee4ac3..188f08246 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1105,8 +1105,13 @@ void noise_est_fx( { i = 0; move16(); +#ifndef FIX_2364_HARM_MULT_HARM *loc_harm = multi_harm_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); +#else + *loc_harm = multi_harm_fx( EVS_MONO, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, + st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); +#endif move16(); } @@ -2400,8 +2405,13 @@ void noise_est_ivas_fx( { i = 0; move16(); +#ifndef FIX_2364_HARM_MULT_HARM *loc_harm = multi_harm_ivas_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); +#else + *loc_harm = multi_harm_fx( st_fx->element_mode, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, + st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); +#endif move16(); } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index f6fc25fde..6233e8689 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4207,6 +4207,9 @@ Word32 mslvq_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_fx( +#ifdef FIX_2364_HARM_MULT_HARM + const Word16 element_mode, /* i : IVAS element_mode Q0 */ +#endif const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ @@ -4221,6 +4224,7 @@ Word16 multi_harm_fx( Word16 S_map[] /* o : short-term correlation map Q7 */ ); +#ifndef FIX_2364_HARM_MULT_HARM /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_ivas_fx( const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ @@ -4236,6 +4240,7 @@ Word16 multi_harm_ivas_fx( Word16 *sp_floor, /* o: noise floor estimate Q7 */ Word16 S_map[] /* o : short-term correlation map Q7 */ ); +#endif void pvq_encode_frame_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ -- GitLab From 34be8a7fc6f0461148c81b8d40ce8c7a98f12186 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 22 Jan 2026 09:25:11 -0500 Subject: [PATCH 543/750] fix clang-format --- lib_enc/find_wsp_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index fe8854500..e2353c455 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -134,4 +134,4 @@ void ivas_find_wsp_fx( deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx ); return; } -#endif \ No newline at end of file +#endif -- GitLab From 9feb2922838009e18233776a02cd059f86483f94 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 22 Jan 2026 10:14:26 -0500 Subject: [PATCH 544/750] fix clang-format --- lib_enc/multi_harm_fx.c | 2 +- lib_enc/nois_est_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 07a80bb85..cfba37d19 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -761,4 +761,4 @@ Word16 multi_harm_ivas_fx( } return harm; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 188f08246..4fa371533 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -2410,7 +2410,7 @@ void noise_est_ivas_fx( st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); #else *loc_harm = multi_harm_fx( st_fx->element_mode, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, - st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); + st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); #endif move16(); } -- GitLab From f7d7b9fa793ec1306db899ab9a94aea179c76279 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 22 Jan 2026 17:20:01 +0100 Subject: [PATCH 545/750] move swich to correct section --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index a663938f9..208ca7b72 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ #define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ #define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ +#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ /* #################### End BE switches ################################## */ @@ -112,7 +113,6 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ -#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 8f55cce016a358701e34b1d390228c3e6231d488 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 22 Jan 2026 18:47:39 +0100 Subject: [PATCH 546/750] updt --- lib_com/ivas_prot_fx.h | 4 +++ lib_com/options.h | 3 ++- lib_enc/ivas_core_enc_fx.c | 42 ++++++++++++++++++++---------- lib_enc/ivas_stereo_icbwe_enc_fx.c | 6 +++++ 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index e2f98b524..25f1c07d6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1367,7 +1367,11 @@ void stereo_icBWE_enc_fx( Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel */ #endif Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ +#ifdef SCALING_SWB_SPEECH_32 + const Word16 *voice_factors_fx /* i : voicing factors Q15 */ +#else const Word32 *voice_factors_fx /* i : voicing factors Q31 */ + #endif ); void initMdctStereoDecData_fx( diff --git a/lib_com/options.h b/lib_com/options.h index fa11260fa..1b54ab393 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,7 +118,8 @@ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ #define SIMPLIFY_SCALING_OLD_INP #define REMOVE_UNUSED_BUFFER_CORE_ENC -#define REMOVE_SCALING_SHB_SPEECH +#define REMOVE_SCALING_SHB_SPEECH_BE +#define REMOVE_SCALING_SHB_SPEECH_NONBE #define SCALING_SWB_SPEECH_32 /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index cf1456364..181714dcb 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -783,7 +783,7 @@ ivas_error ivas_core_enc_fx( new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; #endif #ifdef SCALING_SWB_SPEECH_32 - swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx ,& Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); + swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx ,&Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); #else swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); #endif @@ -798,6 +798,9 @@ ivas_error ivas_core_enc_fx( } } +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + Word16 flag_shb_scale = 0; // just temporary to keep BE, it will disappear +#endif Word16 Q_shb_spch_16 = Q_shb_spch; move16(); #ifdef FIX_2344_ALIGN_PREPROC @@ -805,7 +808,7 @@ ivas_error ivas_core_enc_fx( // IF( st->tcxonly == 0 ) #endif { -#ifndef REMOVE_SCALING_SHB_SPEECH +#ifndef REMOVE_SCALING_SHB_SPEECH_BE shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch Q_shb_spch = add( Q_shb_spch, shift ); @@ -841,10 +844,11 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { -#ifdef REMOVE_SCALING_SHB_SPEECH +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + flag_shb_scale = 1; shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Q_shb_spch = add( Q_shb_spch_16, shift ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch #endif Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 /* SWB(FB) BWE encoder */ @@ -863,10 +867,14 @@ ivas_error ivas_core_enc_fx( IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && ( GE_16( input_frame, L_FRAME32k ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) { /* SHB DTX/CNG encoder */ -#ifdef REMOVE_SCALING_SHB_SPEECH - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Q_shb_spch = add( Q_shb_spch_16, shift ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + if( flag_shb_scale == 0 ) + { + flag_shb_scale = 1; + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Q_shb_spch = add( Q_shb_spch_16, shift ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch + } #endif Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 #ifdef HARM_NON_LINEARITY @@ -883,26 +891,32 @@ ivas_error ivas_core_enc_fx( Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer ); + test(); test(); IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL ) { +#ifndef SCALING_SWB_SPEECH_32 Word32 voice_factors_fx32[CPE_CHANNELS][NB_SUBFR16k]; +#endif stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 ); #ifndef SCALING_SWB_SPEECH_32 Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp -#endif Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 +#endif -#ifdef REMOVE_SCALING_SHB_SPEECH - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Q_shb_spch = add( Q_shb_spch_16, shift ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + if ( flag_shb_scale == 0 ) + { + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Q_shb_spch = add( Q_shb_spch_16, shift ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch + } #endif #ifdef SCALING_SWB_SPEECH_32 - stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); + stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx[0] ); #else stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); #endif diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 9fc7059b7..95d44fba5 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -627,7 +627,11 @@ void stereo_icBWE_enc_fx( Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ #endif Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ +#ifdef SCALING_SWB_SPEECH_32 + const Word16 *voice_factors_fx16 /* i : voicing factors Q15 */ +#else const Word32 *voice_factors_fx /* i : voicing factors Q31 */ +#endif ) { Word16 i, j, k, nbSubFr; @@ -653,8 +657,10 @@ void stereo_icBWE_enc_fx( #ifdef SCALING_SWB_SPEECH_32 Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; + Word32 voice_factors_fx[NB_SUBFR16k]; Copy_Scale_sig_16_32_no_sat( shb_speech_nonref_fx_16, shb_speech_nonref_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp + Copy_Scale_sig_16_32_no_sat( voice_factors_fx16, voice_factors_fx, NB_SUBFR16k, Q16 ); // Q31 #endif /* initialization */ -- GitLab From 2e264743c6ed1cb286a5a4dc7bc45230288bc956 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 22 Jan 2026 18:50:24 +0100 Subject: [PATCH 547/750] comment - just to restart the CI pipeline --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c76aeb719..ce06089a0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -114,7 +114,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ -#define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ +#define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ /* ##################### End NON-BE switches ########################### */ -- GitLab From f8f7d9444d10966158571dac506df740fefe1502 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 22 Jan 2026 20:47:31 +0100 Subject: [PATCH 548/750] clang-format --- lib_enc/FEC_enc_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index c675797d5..2cbb7da22 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -3,11 +3,11 @@ ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com.h" /* Static table prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx_enc.h" /* Function prototypes */ /*============================================================================*/ @@ -70,7 +70,7 @@ void FEC_encode_fx( /*-----------------------------------------------------------------* * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits) *-----------------------------------------------------------------*/ - + IF( NE_16( coder_type, VOICED ) ) { /* encode signal clas with 2 bits */ @@ -117,7 +117,7 @@ void FEC_encode_fx( Ltmp = Mpy_32_16( enr_lg_ent, enr_lg_frac, LG10_s3_0 ); /* Q14 */ tmpS = extract_h( L_shl( Ltmp, 1 ) ); /* Q15 + 1 -> Q0*/ - tmpS = s_min( tmpS, FEC_ENR_QLIMIT ); + tmpS = s_min( tmpS, FEC_ENR_QLIMIT ); tmpS = s_max( tmpS, 0 ); push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR ); -- GitLab From c4104ed4e64015355f42c5b205ff037e8932224a Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 22 Jan 2026 21:53:47 +0100 Subject: [PATCH 549/750] formatting --- lib_com/gs_gains_fx.c | 29 ++++++++++++++++++----------- lib_com/options.h | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 99d44a4ba..769af2692 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -73,7 +73,7 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const void Comp_and_apply_gain_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ - Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ + Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, @@ -241,6 +241,7 @@ void Comp_and_apply_gain_ivas_fx( } #endif + /*========================================================================*/ /* FUNCTION : Ener_per_band_comp_fx() */ /*------------------------------------------------------------------------*/ @@ -259,7 +260,6 @@ void Comp_and_apply_gain_ivas_fx( /* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */ /* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */ /*------------------------------------------------------------------------*/ - /*------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ @@ -267,10 +267,10 @@ void Comp_and_apply_gain_ivas_fx( /* 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 */ + 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; @@ -286,6 +286,7 @@ static Word16 Comp_band_log_ener( return tmp16; } + void Ener_per_band_comp_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ @@ -404,6 +405,7 @@ static void GSC_gain_adj( /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; Word16 Fac_div; + Fac_div = 102; move16(); @@ -541,6 +543,7 @@ Word16 gsc_gaindec_fx( idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 ); VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); } + test(); IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) ) { @@ -577,7 +580,9 @@ Word16 gsc_gaindec_fx( *--------------------------------------------------------------------------------------*/ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); + IF( !( coder_type == INACTIVE && st_fx->tdm_LRTD_flag == 0 && EQ_16( st_fx->idchan, 1 ) ) || GT_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) { idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); @@ -601,7 +606,9 @@ Word16 gsc_gaindec_fx( move16(); y_gainQ_fx[11] = 0; move16(); + ifft_rel_fx( y_gainQ_fx + 8, 8, 3 ); + FOR( i = 8; i < 16; i++ ) { y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ @@ -950,11 +957,11 @@ Word16 gsc_gainQ_fx( *-------------------------------------------------------------------*/ static Word16 VDQ_vec_fx( - Word16 *Qvec_out_fx, /* o: Quanitzed vector */ - const Word16 *mean_dic_fx, /* i: average codebook */ - const Word16 *dic_fx, /* i: codebook */ - const Word16 index_fx, /* i: index of codebook*/ - const Word16 vec_en_fx /* i: vector length */ + Word16 *Qvec_out_fx, /* o : Quanitzed vector */ + const Word16 *mean_dic_fx, /* i : average codebook */ + const Word16 *dic_fx, /* i : codebook */ + const Word16 index_fx, /* i : index of codebook */ + const Word16 vec_en_fx /* i : vector length */ ) { Word16 i, j; diff --git a/lib_com/options.h b/lib_com/options.h index a918edd65..c7cd38dd8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,8 +118,8 @@ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ - #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ + /* ##################### End NON-BE switches ########################### */ -- GitLab From dc96f9e8afb18118bf09cd557bccc8303f373d93 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 23 Jan 2026 07:39:04 +0100 Subject: [PATCH 550/750] Limit scaling to initialized values under FIX_BASOP_2358_SCALING_OOB --- Makefile | 2 +- lib_rend/ivas_objectRenderer_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c9ae4493d..690b48193 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ CFLAGS += -Wunused-but-set-variable LDLIBS += -lm # Clang sanitizer compiler options -CCCLANG = clang +CCCLANG = clang-18 ifeq "$(CLANG)" "0" CC = $(CCCLANG) endif diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index abfc23a1e..bd638a9cb 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -434,7 +434,11 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( { Word16 i; +#ifdef FIX_BASOP_2358_SCALING_OOB + FOR( i = 0; i < hBinRendererTd->NumOfSrcs; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { #ifdef FIX_BASOP_2358_SCALING_OOB scale_sig32( output_fx[i], output_frame, -4 ); // Q11 - 4 = Q7 @@ -448,7 +452,11 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( return error; } +#ifdef FIX_BASOP_2358_SCALING_OOB + FOR( i = 0; i < hBinRendererTd->NumOfSrcs; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { #ifdef FIX_BASOP_2358_SCALING_OOB scale_sig32( output_fx[i], output_frame, 4 ); // Q7 + 4 = Q11 -- GitLab From 7327b6f799e0d9c8a06016e6bb80c6c9bbafeb8b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 23 Jan 2026 07:54:58 +0100 Subject: [PATCH 551/750] Revert clang-18 in Makefile from debugging --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 690b48193..c9ae4493d 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ CFLAGS += -Wunused-but-set-variable LDLIBS += -lm # Clang sanitizer compiler options -CCCLANG = clang-18 +CCCLANG = clang ifeq "$(CLANG)" "0" CC = $(CCCLANG) endif -- GitLab From 764c841db64d968be85c72812069be4c6dab2993 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 08:04:03 +0100 Subject: [PATCH 552/750] updt --- lib_enc/cng_enc_fx.c | 16 ++++++++-- lib_enc/evs_enc_fx.c | 4 +++ lib_enc/ivas_core_enc_fx.c | 60 +++++++++++++++----------------------- lib_enc/prot_fx_enc.h | 11 +++++-- lib_enc/swb_bwe_enc_fx.c | 12 +++++++- lib_enc/swb_pre_proc_fx.c | 1 - 6 files changed, 60 insertions(+), 44 deletions(-) diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 1bc7cab41..abdbc2cd2 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2972,9 +2972,14 @@ void swb_CNG_enc_fx( #else void swb_CNG_enc_ivas_fx( #endif - Encoder_State *st, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ + Encoder_State *st, /* i/o: State structure */ +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + const Word16 *shb_speech_fx_orig, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb_spch */ + const Word16 Q_shb_spch, +#else + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ +#endif + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ ) { Word16 shb_SID_updt; @@ -2987,6 +2992,11 @@ void swb_CNG_enc_ivas_fx( test(); IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) { +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + Word16 shb_speech_fx[L_FRAME16k]; + Copy_Scale_sig( shb_speech_fx_orig, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 +#endif + /* decide if SHB SID encoding or not */ #ifdef HARM_NON_LINEARITY shb_SID_updt = shb_DTX_fx( st, shb_speech_fx, syn_12k8_16k_fx ); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 34abe9537..12e907f09 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -528,7 +528,11 @@ ivas_error evs_enc_fx( test(); IF( st->Opt_DTX_ON && GE_16( input_frame, L_FRAME32k ) ) { +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + swb_CNG_enc_fx( st, shb_speech, 0, old_syn_12k8_16k ); +#else swb_CNG_enc_fx( st, shb_speech, old_syn_12k8_16k ); +#endif } /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 181714dcb..1eb549753 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -777,13 +777,7 @@ ivas_error ivas_core_enc_fx( } #ifdef SCALING_SWB_SPEECH_32 - Word32 *new_swb_speech_fx; - Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; - set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); - new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; -#endif -#ifdef SCALING_SWB_SPEECH_32 - swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx ,&Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); + swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); #else swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); #endif @@ -798,9 +792,10 @@ ivas_error ivas_core_enc_fx( } } -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - Word16 flag_shb_scale = 0; // just temporary to keep BE, it will disappear +#ifdef REMOVE_SCALING_SHB_SPEECH_NONBE + Word16 shift_shb_spch = 0; #endif + Q_shb_spch = 0; Word16 Q_shb_spch_16 = Q_shb_spch; move16(); #ifdef FIX_2344_ALIGN_PREPROC @@ -808,11 +803,15 @@ ivas_error ivas_core_enc_fx( // IF( st->tcxonly == 0 ) #endif { -#ifndef REMOVE_SCALING_SHB_SPEECH_BE shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); +#ifdef REMOVE_SCALING_SHB_SPEECH_NONBE + shift_shb_spch = shift; +#endif +#ifndef REMOVE_SCALING_SHB_SPEECH_NONBE Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch - Q_shb_spch = add( Q_shb_spch, shift ); #endif + Q_shb_spch = add( Q_shb_spch, shift ); + IF( st->hBWE_FD ) { shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); @@ -844,13 +843,9 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - flag_shb_scale = 1; - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Q_shb_spch = add( Q_shb_spch_16, shift ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch -#endif +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 +#endif /* SWB(FB) BWE encoder */ swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); } @@ -867,18 +862,15 @@ ivas_error ivas_core_enc_fx( IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && ( GE_16( input_frame, L_FRAME32k ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) { /* SHB DTX/CNG encoder */ -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - if( flag_shb_scale == 0 ) - { - flag_shb_scale = 1; - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Q_shb_spch = add( Q_shb_spch_16, shift ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch - } -#endif +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 +#endif #ifdef HARM_NON_LINEARITY +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + swb_CNG_enc_fx( st, shb_speech_fx, Q_shb_spch_16, old_syn_12k8_16k_fx[n] ); +#else swb_CNG_enc_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); +#endif #else swb_CNG_enc_ivas_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); #endif @@ -891,7 +883,7 @@ ivas_error ivas_core_enc_fx( Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer ); - + test(); test(); IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL ) @@ -901,20 +893,16 @@ ivas_error ivas_core_enc_fx( #endif stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); - q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 ); + q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, Q16 ); #ifndef SCALING_SWB_SPEECH_32 Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp - Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 + Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 #endif -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - if ( flag_shb_scale == 0 ) - { - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Q_shb_spch = add( Q_shb_spch_16, shift ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch - } +#ifdef REMOVE_SCALING_SHB_SPEECH_NONBE + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift_shb_spch ); // Q_shb_spch #endif + #ifdef SCALING_SWB_SPEECH_32 stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx[0] ); #else diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 7e172b31d..357c8c81d 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -640,8 +640,13 @@ void swb_bwe_enc_ivas_fx( Word16 Q_slb_speech ); void swb_CNG_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ + Encoder_State *st_fx, /* i/o: State structure */ +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + const Word16 *shb_speech_fx_orig, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb_spch */ + const Word16 Q_shb_spch, +#else + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ +#endif const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */ ); @@ -880,7 +885,7 @@ void gsc_enc_fx( #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 */ + 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 */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 6e4e8b391..59504ea6b 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -262,6 +262,7 @@ void wb_bwe_enc_ivas_fx( * * SWB BWE encoder (only for 32kHz signals) *-------------------------------------------------------------------*/ + void swb_bwe_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ @@ -270,7 +271,11 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + Word16 *shb_speech_fx_orig, /* i : SHB target signal (6-14kHz) at 16kHz */ +#else + Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ +#endif Word16 Q_shb_speech, Word16 Q_slb_speech ) { @@ -304,6 +309,11 @@ void swb_bwe_enc_ivas_fx( move16(); Word16 fb_band_begin; Word16 q_new_input_hp; +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + Word16 shb_speech_fx[L_FRAME16k]; + + Copy_Scale_sig( shb_speech_fx_orig, shb_speech_fx, L_FRAME16k, Q_shb_speech ); // Q_shb_spch +#endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a36715bd5..7c549c3b1 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -771,7 +771,6 @@ void swb_pre_proc_fx( * - Common SWB TBE and SWB BWE pre-processing *-------------------------------------------------------------------*/ -/*full implementation pending*/ void swb_pre_proc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ -- GitLab From 0603217ad9ecfcb34f82f180a1887b19c27fbb02 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 23 Jan 2026 09:00:59 +0100 Subject: [PATCH 553/750] Add fix for Stereo CNG uninit value read under FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG --- lib_com/options.h | 1 + lib_enc/ivas_stereo_dft_enc_fx.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..7b964312d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,6 +119,7 @@ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 729df8737..d6af9caf0 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -3953,10 +3953,16 @@ static void stereo_dft_enc_compute_prm_fx( * Compute Side gains *-----------------------------------------------------------------*/ +#ifdef FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG + Copy32( pSideGain, hStereoDft->sidSideGain_fx, STEREO_DFT_BAND_MAX ); /* Copy all sideGain values since BW change may be reverted during CNG */ +#endif + FOR( b = 0; b < hStereoDft->nbands; b++ ) { +#ifndef FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG hStereoDft->sidSideGain_fx[b] = *( pSideGain + b ); move32(); +#endif /* Quantization */ IF( flag_quant ) -- GitLab From 9b4e5fb729ec20e4081fd7c2ec99fff7a18a29d6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 09:02:08 +0100 Subject: [PATCH 554/750] updt --- lib_com/ivas_prot_fx.h | 4 +++ lib_com/prot_fx.h | 10 +++--- lib_enc/cng_enc_fx.c | 16 ++-------- lib_enc/evs_enc_fx.c | 4 --- lib_enc/ivas_core_enc_fx.c | 50 ++++++++++++++++++------------ lib_enc/ivas_stereo_icbwe_enc_fx.c | 23 +++++++++++--- lib_enc/prot_fx_enc.h | 23 +++++++------- lib_enc/swb_bwe_enc_fx.c | 16 +++++++--- lib_enc/swb_pre_proc_fx.c | 20 +++++++----- 9 files changed, 97 insertions(+), 69 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 25f1c07d6..221b5a86e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1359,8 +1359,12 @@ void stereo_tcx_init_dec_fx( void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ +#else const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ +#endif #ifdef SCALING_SWB_SPEECH_32 Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel Q15-shb_speech_nonref_e*/ #else diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0d97361bb..3ec8936ab 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10488,16 +10488,18 @@ void Copy_Scale_sig32( ); void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ #ifndef SCALING_SWB_SPEECH_32 - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ + Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q0 */ #endif +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ +#endif Word16 *Q_shb_spch, Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ + Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers*/ CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ); diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index abdbc2cd2..0466af832 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2972,14 +2972,9 @@ void swb_CNG_enc_fx( #else void swb_CNG_enc_ivas_fx( #endif - Encoder_State *st, /* i/o: State structure */ -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - const Word16 *shb_speech_fx_orig, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb_spch */ - const Word16 Q_shb_spch, -#else - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ -#endif - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ + Encoder_State *st, /* i/o: State structure */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ ) { Word16 shb_SID_updt; @@ -2992,11 +2987,6 @@ void swb_CNG_enc_ivas_fx( test(); IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) { -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - Word16 shb_speech_fx[L_FRAME16k]; - Copy_Scale_sig( shb_speech_fx_orig, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 -#endif - /* decide if SHB SID encoding or not */ #ifdef HARM_NON_LINEARITY shb_SID_updt = shb_DTX_fx( st, shb_speech_fx, syn_12k8_16k_fx ); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 12e907f09..34abe9537 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -528,11 +528,7 @@ ivas_error evs_enc_fx( test(); IF( st->Opt_DTX_ON && GE_16( input_frame, L_FRAME32k ) ) { -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - swb_CNG_enc_fx( st, shb_speech, 0, old_syn_12k8_16k ); -#else swb_CNG_enc_fx( st, shb_speech, old_syn_12k8_16k ); -#endif } /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 1eb549753..258752d42 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -87,13 +87,17 @@ ivas_error ivas_core_enc_fx( STEREO_ICBWE_ENC_HANDLE hStereoICBWE; STEREO_TD_ENC_DATA_HANDLE hStereoTD; Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; /* Q15 */ +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Word32 shb_speech_fx32[L_FRAME16k]; +#endif #ifndef SCALING_SWB_SPEECH_32 Word32 *new_swb_speech_fx; #endif Word16 *inp_fx[CPE_CHANNELS]; Word16 *shb_speech_fx; +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Word16 Q_shb_spch; +#endif #ifndef SCALING_SWB_SPEECH_32 Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; #endif @@ -131,9 +135,10 @@ ivas_error ivas_core_enc_fx( error = IVAS_ERR_OK; move32(); +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Q_shb_spch = 0; move16(); - +#endif /*------------------------------------------------------------------* * General initialization *-----------------------------------------------------------------*/ @@ -777,7 +782,11 @@ ivas_error ivas_core_enc_fx( } #ifdef SCALING_SWB_SPEECH_32 +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); +#else swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); +#endif #else swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); #endif @@ -792,27 +801,21 @@ ivas_error ivas_core_enc_fx( } } -#ifdef REMOVE_SCALING_SHB_SPEECH_NONBE - Word16 shift_shb_spch = 0; -#endif - Q_shb_spch = 0; +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Word16 Q_shb_spch_16 = Q_shb_spch; move16(); +#endif #ifdef FIX_2344_ALIGN_PREPROC IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become: // IF( st->tcxonly == 0 ) #endif { +#ifndef REMOVE_SCALING_SHB_SPEECH_BE shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); -#ifdef REMOVE_SCALING_SHB_SPEECH_NONBE - shift_shb_spch = shift; -#endif -#ifndef REMOVE_SCALING_SHB_SPEECH_NONBE Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch -#endif Q_shb_spch = add( Q_shb_spch, shift ); - - IF( st->hBWE_FD ) +#endif + IF( st->hBWE_FD ) // VE: to be moved to the end of swb_pre_proc_ivas_fx() { shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); st->Q_old_wtda = add( st->Q_old_wtda, shift ); @@ -832,7 +835,11 @@ ivas_error ivas_core_enc_fx( Word16 Q_fb_exc; Word16 fb_exc_fx[L_FRAME16k]; +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], 0, st->voicing_fx, pitch_buf_fx[n] ); +#else swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], Q_shb_spch_16, st->voicing_fx, pitch_buf_fx[n] ); +#endif IF( EQ_16( st->extl, FB_TBE ) ) { @@ -847,7 +854,11 @@ ivas_error ivas_core_enc_fx( Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 #endif /* SWB(FB) BWE encoder */ +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_new[n], 1 ) ); +#else swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); +#endif } Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 @@ -866,11 +877,7 @@ ivas_error ivas_core_enc_fx( Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 #endif #ifdef HARM_NON_LINEARITY -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - swb_CNG_enc_fx( st, shb_speech_fx, Q_shb_spch_16, old_syn_12k8_16k_fx[n] ); -#else - swb_CNG_enc_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); -#endif + swb_CNG_enc_fx( st, shb_speech_fx, old_syn_12k8_16k_fx[n] ); #else swb_CNG_enc_ivas_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); #endif @@ -899,12 +906,17 @@ ivas_error ivas_core_enc_fx( Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 #endif -#ifdef REMOVE_SCALING_SHB_SPEECH_NONBE - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift_shb_spch ); // Q_shb_spch +#ifdef REMOVE_SCALING_SHB_SPEECH_BEaaa + Q_shb_spch = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, Q_shb_spch ); // Q_shb_spch #endif #ifdef SCALING_SWB_SPEECH_32 +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + stereo_icBWE_enc_fx( hCPE, shb_speech_fx, new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx[0] ); +#else stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx[0] ); +#endif #else stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); #endif diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 95d44fba5..d18a7ee49 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -618,19 +618,23 @@ static void icbwe_dft_stereo_param_ivas_fx( *-------------------------------------------------------------------*/ void stereo_icBWE_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ +#else const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ +#endif #ifdef SCALING_SWB_SPEECH_32 Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel Q15-shb_speech_nonref_e*/ #else - Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ + Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ #endif - Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ + Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ #ifdef SCALING_SWB_SPEECH_32 const Word16 *voice_factors_fx16 /* i : voicing factors Q15 */ #else - const Word32 *voice_factors_fx /* i : voicing factors Q31 */ + const Word32 *voice_factors_fx /* i : voicing factors Q31 */ #endif ) { @@ -655,12 +659,21 @@ void stereo_icBWE_enc_fx( Word32 temp1_fx, temp2_fx; Word16 temp1_e, temp2_e, shb_frame_ref_e, shb_frame_nonref_e, gDes_e, tmp, exp; +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + Word32 shb_speech_ref_fx[L_FRAME16k]; + Word16 shb_speech_ref_e; + + shb_speech_ref_e = add( getScaleFactor16( shb_speech_ref_fx16, L_FRAME16k ), Q16 ); + Copy_Scale_sig_16_32_no_sat( shb_speech_ref_fx16, shb_speech_ref_fx, L_FRAME16k, shb_speech_ref_e ); + shb_speech_ref_e = Q31 - shb_speech_ref_e; +#endif + #ifdef SCALING_SWB_SPEECH_32 Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; Word32 voice_factors_fx[NB_SUBFR16k]; Copy_Scale_sig_16_32_no_sat( shb_speech_nonref_fx_16, shb_speech_nonref_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp - Copy_Scale_sig_16_32_no_sat( voice_factors_fx16, voice_factors_fx, NB_SUBFR16k, Q16 ); // Q31 + Copy_Scale_sig_16_32_no_sat( voice_factors_fx16, voice_factors_fx, NB_SUBFR16k, Q16 ); // Q31 #endif /* initialization */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 357c8c81d..4c6427b78 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -635,19 +635,20 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ - Word16 Q_shb_speech, - Word16 Q_slb_speech ); - -void swb_CNG_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ #ifdef REMOVE_SCALING_SHB_SPEECH_BE - const Word16 *shb_speech_fx_orig, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb_spch */ - const Word16 Q_shb_spch, + Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 Q_slb_speech #else - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ + Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ + Word16 Q_shb_speech, + Word16 Q_slb_speech #endif - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */ +); + +void swb_CNG_enc_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */ ); #ifndef HARM_NON_LINEARITY @@ -885,7 +886,7 @@ void gsc_enc_fx( #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 */ + 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 */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 59504ea6b..763df2fa5 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -272,12 +272,14 @@ void swb_bwe_enc_ivas_fx( const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ #ifdef REMOVE_SCALING_SHB_SPEECH_BE - Word16 *shb_speech_fx_orig, /* i : SHB target signal (6-14kHz) at 16kHz */ + Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 Q_slb_speech #else Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ -#endif Word16 Q_shb_speech, - Word16 Q_slb_speech ) + Word16 Q_slb_speech +#endif +) { Word16 i; Word16 *new_input_fx; @@ -311,17 +313,21 @@ void swb_bwe_enc_ivas_fx( Word16 q_new_input_hp; #ifdef REMOVE_SCALING_SHB_SPEECH_BE Word16 shb_speech_fx[L_FRAME16k]; - - Copy_Scale_sig( shb_speech_fx_orig, shb_speech_fx, L_FRAME16k, Q_shb_speech ); // Q_shb_spch + Word16 Q_shb_speech; #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; +#ifdef REMOVE_SCALING_SHB_SPEECH_BE + Q_shb_speech = getScaleFactor16( shb_speech_fx_Q0, L_FRAME16k ); + Copy_Scale_sig( shb_speech_fx_Q0, shb_speech_fx, L_FRAME16k, Q_shb_speech ); // Q0 -> Q_shb_spch +#endif /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis *---------------------------------------------------------------------*/ + IF( EQ_16( st_fx->extl, FB_BWE ) ) { inner_frame = L_FRAME48k; diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 7c549c3b1..0cccc621c 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -772,17 +772,19 @@ void swb_pre_proc_fx( *-------------------------------------------------------------------*/ void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ #ifndef SCALING_SWB_SPEECH_32 Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ #endif - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0 */ +#ifndef REMOVE_SCALING_SHB_SPEECH_BE Word16 *Q_shb_spch, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ +#endif + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ + Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ) { Word16 Sample_Delay_SWB_BWE, inner_frame, delay; @@ -1279,9 +1281,11 @@ void swb_pre_proc_ivas_fx( regV = icbwe_regressionValuesTDM_fx; cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); - Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); + Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); // Q0 +#ifndef REMOVE_SCALING_SHB_SPEECH_BE *Q_shb_spch = 0; move16(); +#endif } IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL ) -- GitLab From 59abd0e42258c7f7f44b02da6eded3865b0b35c0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 09:35:27 +0100 Subject: [PATCH 555/750] cleaning --- lib_com/options.h | 1 - lib_com/prot_fx.h | 10 +++++----- lib_enc/ivas_core_enc_fx.c | 18 ++++++++---------- lib_enc/ivas_mdct_core_enc_fx.c | 16 ++++++++-------- lib_enc/ivas_stereo_icbwe_enc_fx.c | 5 +++-- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 6 +++--- lib_enc/ivas_tcx_core_enc_fx.c | 4 ++-- lib_enc/prot_fx_enc.h | 4 ++-- lib_enc/swb_bwe_enc_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 4 ++-- 10 files changed, 34 insertions(+), 36 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1b54ab393..7e3954141 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,6 @@ #define SIMPLIFY_SCALING_OLD_INP #define REMOVE_UNUSED_BUFFER_CORE_ENC #define REMOVE_SCALING_SHB_SPEECH_BE -#define REMOVE_SCALING_SHB_SPEECH_NONBE #define SCALING_SWB_SPEECH_32 /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 3ec8936ab..e3431d987 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10488,15 +10488,15 @@ void Copy_Scale_sig32( ); void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ #ifndef SCALING_SWB_SPEECH_32 - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q0 */ + Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ #endif + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/ #ifndef REMOVE_SCALING_SHB_SPEECH_BE - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ -#endif Word16 *Q_shb_spch, +#endif Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers*/ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 258752d42..803bf45e4 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -887,35 +887,33 @@ ivas_error ivas_core_enc_fx( * Inter-channel BWE encoding *-------------------------------------------------------------------*/ +#ifndef SCALING_SWB_SPEECH_32 Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer ); - +#endif test(); test(); IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL ) { #ifndef SCALING_SWB_SPEECH_32 Word32 voice_factors_fx32[CPE_CHANNELS][NB_SUBFR16k]; -#endif stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); +#else + stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, st->q_inp ); +#endif - q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, Q16 ); #ifndef SCALING_SWB_SPEECH_32 + q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, Q16 ); Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 #endif -#ifdef REMOVE_SCALING_SHB_SPEECH_BEaaa - Q_shb_spch = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, Q_shb_spch ); // Q_shb_spch -#endif - #ifdef SCALING_SWB_SPEECH_32 #ifdef REMOVE_SCALING_SHB_SPEECH_BE - stereo_icBWE_enc_fx( hCPE, shb_speech_fx, new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx[0] ); + stereo_icBWE_enc_fx( hCPE, shb_speech_fx, new_swb_speech_buffer_fx_16, st->q_inp, voice_factors_fx[0] ); #else - stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx[0] ); + stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, st->q_inp, voice_factors_fx[0] ); #endif #else stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index ac3305d74..12d820641 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1116,10 +1116,10 @@ void enc_prm_igf_mdct( *-------------------------------------------------------------------*/ void ivas_mdct_core_whitening_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/ #ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ + Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ #endif Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ @@ -1232,7 +1232,7 @@ void ivas_mdct_core_whitening_enc_fx( windowedSignal_fx[0] = orig_spectrum_long[0]; /* NOTE temporarily available */ windowedSignal_fx[1] = temp_buffer; /* orig_spectrum_long isn't long enough */ - + /*--------------------------------------------------------------* * TCX20/TCX10 switching decision *---------------------------------------------------------------*/ @@ -1823,12 +1823,12 @@ void ivas_mdct_core_whitening_enc_fx( } } TNSAnalysisStereo_fx( sts, mdst_spectrum_fx, 0, tnsSize, tnsBits, param_core, mct_on ); - + /*--------------------------------------------------------------* * Envelope Quantization and FDNS *---------------------------------------------------------------*/ - - /* Common q for spectrum and mdst */ + + /* Common q for spectrum and mdst */ q_min = 0; move16(); q_com = Q31; @@ -2328,7 +2328,7 @@ void ivas_mdct_core_whitening_enc_fx( /*--------------------------------------------------------------------------------* * SNS parameters *--------------------------------------------------------------------------------*/ - + test(); test(); test(); diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index d18a7ee49..86e662b57 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -622,11 +622,11 @@ void stereo_icBWE_enc_fx( #ifdef REMOVE_SCALING_SHB_SPEECH_BE const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ #else - const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/ + const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel shb_speech_ref_e*/ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ #endif #ifdef SCALING_SWB_SPEECH_32 - Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel Q15-shb_speech_nonref_e*/ + Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/ #else Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ #endif @@ -672,6 +672,7 @@ void stereo_icBWE_enc_fx( Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; Word32 voice_factors_fx[NB_SUBFR16k]; + shb_speech_nonref_e = Q15 - shb_speech_nonref_e; Copy_Scale_sig_16_32_no_sat( shb_speech_nonref_fx_16, shb_speech_nonref_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp Copy_Scale_sig_16_32_no_sat( voice_factors_fx16, voice_factors_fx, NB_SUBFR16k, Q16 ); // Q31 #endif diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 2c197ed0b..ce689dcd3 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -128,10 +128,10 @@ static void sync_tcx_mode_fx( *-------------------------------------------------------------------*/ void stereo_mdct_core_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q_new-1*/ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q_new-1*/ #ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ + Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ #endif Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 9d83d8df1..2aa707c11 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -184,7 +184,7 @@ void stereo_tcx_core_enc( /*Bits*/ Word16 nbits_start, - total_nbbits, nbits_header; + total_nbbits, nbits_header; Word16 target_bits[2], bitsAvailable; Word16 nbits_lpc[2]; Word16 tnsSize[2]; /* number of tns parameters put into prm */ @@ -703,7 +703,7 @@ void stereo_tcx_core_enc( /*--------------------------------------------------------------------------------* * Encode TCX20/10 parameters *--------------------------------------------------------------------------------*/ - + writeTCXparam_fx( st, hBstr, hm_cfg, param_core, nbits_header, nbits_start, add( nbits_lpc[0], nbits_lpc[1] ), NULL, NULL, NULL, -1 ); total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 4c6427b78..3425ceeec 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -636,7 +636,7 @@ void swb_bwe_enc_ivas_fx( const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ #ifdef REMOVE_SCALING_SHB_SPEECH_BE - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 Q_slb_speech #else Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ @@ -691,7 +691,7 @@ void swb_tbe_enc_fx( void swb_tbe_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb */ + Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2 * Q_new */ const Word16 voice_factors_fx[], /* i : voicing factors Q15 */ Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE Q_white_exc */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 763df2fa5..c288857c9 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -278,7 +278,7 @@ void swb_bwe_enc_ivas_fx( Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ Word16 Q_shb_speech, Word16 Q_slb_speech -#endif +#endif ) { Word16 i; diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index ebe37fae5..c0af2d1e5 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -2823,9 +2823,9 @@ void swb_tbe_enc_fx( /*======================================================================================*/ void swb_tbe_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ + Encoder_State *st_fx, /* i/o: encoder state structure */ STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb */ + Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2 * Q_new */ const Word16 voice_factors_fx[], /* i : voicing factors Q15 */ Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE Q_white_exc */ -- GitLab From a5d4aab0507a8596c8f2b9e81a6bbf83c89d0146 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 09:49:15 +0100 Subject: [PATCH 556/750] FIX_2367_REMOVE_CODE_ICBWE --- lib_com/ivas_prot_fx.h | 2 +- lib_com/options.h | 1 + lib_enc/ivas_core_enc_fx.c | 4 +- lib_enc/ivas_stereo_icbwe_enc_fx.c | 90 +++++++++++++++--------------- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 31dfb1ea2..a28bea6cd 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1357,7 +1357,7 @@ void stereo_tcx_init_dec_fx( const Word16 last_element_mode /* i : element mode of previous frame */ ); -void stereo_icBWE_enc_ivas_fx( +void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..b1a4e3c5a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2367_REMOVE_CODE_ICBWE /* VA: basop issue 2367: Remove IC-BWE obsolete code */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 3a19ad171..9ba980600 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -824,7 +824,8 @@ ivas_error ivas_core_enc_fx( Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 - stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); + stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); +#ifndef FIX_2367_REMOVE_CODE_ICBWE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { @@ -840,6 +841,7 @@ ivas_error ivas_core_enc_fx( move32(); } } +#endif } Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame ); diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 61a2f0490..7ae50b177 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -39,6 +39,7 @@ #include "ivas_rom_com.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * ic_bwe_enc_reset() * @@ -90,21 +91,24 @@ static void ic_bwe_enc_reset_fx( return; } + /*--------------------------------------------------------------------------* * ic_bwe_specMapping() * * Encode and apply the spectral shape mapping of ref to the non-ref channel *---------------------------------------------------------------------------*/ -static Word16 ic_bwe_enc_specMapping_ivas_fx( - const Word32 *shb_frame_target_fx, /* i : target shb Q31-shb_frame_target_e*/ - Word16 shb_frame_target_e, - Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth Q31-shb_synth_nonref_e*/ - Word16 *shb_synth_nonref_e, - Word32 *specMapping_fx, /* i/o: current frame's mapping Qx*/ - Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Q31-memShbSpecMapping_e*/ - Word16 *memShbSpecMapping_e, - Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/ - Word16 *memShbSpecXcorr_e ) + +static Word16 ic_bwe_enc_specMapping_fx( + const Word32 *shb_frame_target_fx, /* i : target shb Q31-shb_frame_target_e*/ + const Word16 shb_frame_target_e, /* i : Q value shb_frame_target_fx */ + Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth Q31-shb_synth_nonref_e*/ + Word16 *shb_synth_nonref_e, /* i/o: Q value shb_synth_nonref_fx */ + Word32 *specMapping_fx, /* i/o: current frame's mapping Qx*/ + Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Q31-memShbSpecMapping_e*/ + Word16 *memShbSpecMapping_e, /* i/o: Q value memShbSpecMapping_fx */ + Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/ + Word16 *memShbSpecXcorr_e /* i/o: Q value memShbSpecMapping_fx */ +) { Word16 idx; Word16 max_exp; @@ -129,7 +133,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( move16(); /* Calculate rxx(1)/rxx(0) of the non ref target */ - temp00_fx = dotp_fx_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp00_exp ); /* Q31-temp0_exp */ temp11_fx = dotp_fx_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp11_exp ); /* Q31-temp1_exp */ @@ -149,7 +152,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( temp3_fx = L_shr( temp3_fx, sub( exp, temp3_exp ) ); /* Smoothing */ - FOR( Word16 i = 0; i < 6; i++ ) { memShbSpecXcorr_fx[i] = L_shl( memShbSpecXcorr_fx[i], sub( *memShbSpecXcorr_e, exp ) ); @@ -175,7 +177,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( T_nonref_target_fx = BASOP_Util_Divide3232_Scale( temp11_fx, temp00_fx, &T_nonref_target_e ); } - memShbSpecXcorr_fx[0] = temp00_fx; move32(); memShbSpecXcorr_fx[1] = temp11_fx; @@ -189,7 +190,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( memShbSpecXcorr_fx[5] = temp3_fx; /* Q31-exp */ move32(); - IF( temp0_fx != 0 ) { Txx1_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &Txx1_e ); /* Q31-Txx1_e */ @@ -215,9 +215,7 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( u_fx = extract_l( *specMapping_fx ); - /* while performing (-32768)*(-32768), overflow occurs because the result comes out as 32768 after mult. This is the only case for mult where overflow happens. In order to avoid this scenario mult_sat is used */ - tmp = mult_sat( b_fx, b_fx ); // b_e + b_e; tmp1 = mult_sat( a_fx, c_fx ); // a_e + c_e + 2 @@ -314,14 +312,7 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( *-----------------------------------------------------------------------*/ /*! r: return quant. index value */ -/*----------------------------------------------------------------------* - * ic_bwe_gsMapping() - * - * Encode and apply the gain shape mapping of ref to the non-ref channel - *-----------------------------------------------------------------------*/ - -/*! r: return quant. index value */ -static Word16 ic_bwe_enc_gsMapping_ivas_fx( +static Word16 ic_bwe_enc_gsMapping_fx( const Word32 relG_targ_fx, /* i : gDes, rel gain target Q31-relG_targ_e*/ Word16 relG_targ_e, const Word16 *shbSynth_fx, /* i : ref synth signal Q15-shbSynth_e*/ @@ -416,8 +407,10 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx( move16(); idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS_DFT ) ); // Q12 } + *gsMapping_fx = L_deposit_h( gsMapping_fx16 ); // Q28 move32(); + Word16 e; L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q28 + Q13 - Q15 -> Q26 *gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e ); /* Q31-e */ @@ -425,15 +418,18 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx( *gsMapping_e = e; // Q31 move16(); + return idx; } + /*----------------------------------------------------------------------* * icbwe_dft_stereo_param() * * Estimate ICBWE parameters in DFT stereo *-----------------------------------------------------------------------*/ -static void icbwe_dft_stereo_param_ivas_fx( + +static void icbwe_dft_stereo_param_fx( STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: */ STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i : */ Encoder_State *st, /* i/o: */ @@ -486,7 +482,6 @@ static void icbwe_dft_stereo_param_ivas_fx( move16(); /* refChanIndex_bwe refinement */ - test(); test(); test(); @@ -563,7 +558,6 @@ static void icbwe_dft_stereo_param_ivas_fx( } /* gsMapping estimate */ - Word16 exp; IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX ) { @@ -592,7 +586,7 @@ static void icbwe_dft_stereo_param_ivas_fx( move32(); move16(); - gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */ + gsIndx = ic_bwe_enc_gsMapping_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */ hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx ); /* Q31-exp */ hStereoICBWE->gDes_pastFrame_e = exp; @@ -611,13 +605,20 @@ static void icbwe_dft_stereo_param_ivas_fx( return; } -void stereo_icBWE_enc_ivas_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/ - const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ - Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ - Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ - const Word32 *voice_factors_fx /* i : voicing factors Q31 */ + +/*-------------------------------------------------------------------* + * stereo_icBWE_enc() + * + * Encode the spatial mapping of reference to the non-reference channels in HB + *-------------------------------------------------------------------*/ + +void stereo_icBWE_enc_fx( + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/ + const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ + Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ + Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ + const Word32 *voice_factors_fx /* i : voicing factors Q31 */ ) { Word16 i, j, k, nbSubFr; @@ -641,7 +642,6 @@ void stereo_icBWE_enc_ivas_fx( Word32 temp1_fx, temp2_fx; Word16 temp1_e, temp2_e, shb_frame_ref_e, shb_frame_nonref_e, gDes_e, tmp, exp; - /* initialization */ hStereoDft = hCPE->hStereoDft; hStereoICBWE = hCPE->hStereoICBWE; @@ -702,7 +702,6 @@ void stereo_icBWE_enc_ivas_fx( move32(); /* SHB frame buffer offsets for TBE processing << re-adjust check >>*/ - max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e ); Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e @@ -722,7 +721,6 @@ void stereo_icBWE_enc_ivas_fx( Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) ); /* shb_speech_ref_e */ Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) - Q16 ); // mem_shb_speech_ref_e - test(); test(); IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) ) @@ -798,8 +796,8 @@ void stereo_icBWE_enc_ivas_fx( excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */ move32(); } - /* LP synthesis */ + /* LP synthesis */ Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ); @@ -820,11 +818,10 @@ void stereo_icBWE_enc_ivas_fx( move16(); } - icbwe_dft_stereo_param_ivas_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, &shb_synth_nonref_e ); + icbwe_dft_stereo_param_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, &shb_synth_nonref_e ); } ELSE { - max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e ); Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e @@ -900,7 +897,6 @@ void stereo_icBWE_enc_ivas_fx( /*temp1 = 0.8f*hStereoICBWE->prevNonRefEner + 0.2f*temp1;*/ /*temp2 = 0.8f*hStereoICBWE->prevRefEner + 0.2f*temp2;*/ - IF( temp2_fx == 0 ) { gDes_fx = 1073741824; /* 1.0 in Q30 */ @@ -1012,6 +1008,7 @@ void stereo_icBWE_enc_ivas_fx( excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */ move32(); } + /* LP synthesis */ Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ @@ -1039,7 +1036,7 @@ void stereo_icBWE_enc_ivas_fx( IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) ) { /* IC BWE spectral mapping */ - spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_e ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */ + spIndx = ic_bwe_enc_specMapping_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_e ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */ } ELSE { @@ -1063,7 +1060,7 @@ void stereo_icBWE_enc_ivas_fx( /* IC BWE GS mapping */ - gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */ + gsIndx = ic_bwe_enc_gsMapping_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */ hStereoICBWE->gDes_pastFrame_fx = gDes_fx; /* Q31-hStereoICBWE->gDes_pastFrame_e */ hStereoICBWE->gDes_pastFrame_e = gDes_e; @@ -1085,6 +1082,7 @@ void stereo_icBWE_enc_ivas_fx( * * Stereo (inter-channel) BWE mapping - encoder initialization *-------------------------------------------------------------------*/ + void stereo_icBWE_init_enc_fx( STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */ ) @@ -1173,11 +1171,14 @@ void stereo_icBWE_init_enc_fx( return; } + + /*-------------------------------------------------------------------* * findRefChanBWE() * * Inter-channel BWE pre-proc of the non-ref channel *-------------------------------------------------------------------*/ + static void findRefChanBWE_fx( const Word16 *input0_fx, /* i/o : input 0 Qx q_dataChan_fx*/ const Word16 *input1_fx, /* i/o : input 1 Qx q_dataChan_fx*/ @@ -1219,6 +1220,7 @@ static void findRefChanBWE_fx( * * Inter-channel BWE pre-proc of the non-ref channel *-------------------------------------------------------------------*/ + void stereo_icBWE_preproc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word16 input_frame, /* i : input frame length Q0*/ -- GitLab From f006922fd16f3b5264fc785e32fa2d527cd9586b Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 10:23:32 +0100 Subject: [PATCH 557/750] FIX_2367_REMOVE_CODE_ICBWE --- lib_dec/ivas_core_dec_fx.c | 2 ++ lib_dec/ivas_stereo_icbwe_dec_fx.c | 29 +++++++++++++++++++---------- lib_enc/ivas_core_enc_fx.c | 5 +++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index b71f0df7d..459d1b450 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1181,11 +1181,13 @@ ivas_error ivas_core_dec_fx( q = 11; move16(); +#ifndef FIX_2367_REMOVE_CODE_ICBWE if ( hCPE->hStereoDft != NULL ) { hCPE->hStereoDft->td_gain_fx[0] = 1; move32(); } +#endif stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); test(); test(); diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 0dc9e7886..1c51fc2d1 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -112,6 +112,12 @@ static Word16 FindScale( } +/*-------------------------------------------------------------------* + * stereo_icBWE_dec() + * + * Spatial mapping of reference to the non-reference channels in SHB + *-------------------------------------------------------------------*/ + void stereo_icBWE_dec_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 *synthRef_fx, /* i/o: Reference channel HB synthesis at output Fs Q11 */ @@ -150,6 +156,14 @@ void stereo_icBWE_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE = hCPE->hStereoICBWE; st = hCPE->hCoreCoder[0]; +#ifdef FIX_2367_REMOVE_CODE_ICBWE + if ( hCPE->hStereoDft != NULL ) + { + hCPE->hStereoDft->td_gain_fx[0] = 1; + move32(); + } + +#endif /*--------------------------------------------------------------------* * skip IC-BWE in case of mono DMX output * * -------------------------------------------------------------------*/ @@ -251,6 +265,7 @@ void stereo_icBWE_dec_fx( /*--------------------------------------------------------------------* * IC-BWE * * -------------------------------------------------------------------*/ + test(); test(); test(); @@ -265,7 +280,6 @@ void stereo_icBWE_dec_fx( return; } - set16_fx( fb_synth_nonref_fx, 0, L_FRAME48k ); /* core switching reset */ @@ -408,7 +422,6 @@ void stereo_icBWE_dec_fx( } // hStereoICBWE->prevgsMapping = powf( 10, hStereoICBWE->prevgsMapping ); - specMapping_fx = hStereoICBWE->prevSpecMapping_fx; // Q15 move16(); gsMapping_fx = hStereoICBWE->prevgsMapping_fx; // Q14 @@ -637,7 +650,6 @@ void stereo_icBWE_dec_fx( } /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ - tmp = 31; move16(); tmp = FindScale( shb_synth_nonref_fx, L_FRAME16k + L_SHB_LAHEAD, Q_syn_shb, tmp ); @@ -669,7 +681,6 @@ void stereo_icBWE_dec_fx( alpha_fx = winSlope_fx; /* Q15 */ move16(); - IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { ratio_L_fx = 16384; /* 0.5 in Q15 */ @@ -685,7 +696,6 @@ void stereo_icBWE_dec_fx( move16(); IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX ) { - IF( GE_16( ratio_L_fx, 3276 /* 0.1 in Q15 */ ) ) { tmp = mult_r( sub( 32767 /* 1.0 in Q15 */, ratio_L_fx ), sub( 32767 /* 1.0 in Q15 */, ratio_L_fx ) ); // Q15 @@ -775,8 +785,6 @@ void stereo_icBWE_dec_fx( } /* resample to output FS */ - - IF( EQ_32( st->output_Fs, 48000 /* Q0 */ ) ) { tmp = 31; @@ -829,7 +837,6 @@ void stereo_icBWE_dec_fx( } /* copy to outputHB and reset hb_synth values */ - IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { ratio_L_fx = 16384; /* 1.0 in Q15 */ @@ -926,6 +933,7 @@ void stereo_icBWE_dec_fx( return; } + /*-------------------------------------------------------------------* * stereo_icBWE_decproc() * @@ -1084,7 +1092,7 @@ void stereo_icBWE_decproc_fx( move32(); BREAK; } - // memOffset for 16K 32K 48K are 15 30 45 respectively.camera + // memOffset for 16K 32K 48K are 15 30 45 respectively } ELSE { @@ -1172,7 +1180,7 @@ void stereo_icBWE_decproc_fx( move16(); BREAK; } - // memOffset for 16K 32K 48K are 15 30 45 respectively.camera + // memOffset for 16K 32K 48K are 15 30 45 respectively } ELSE { @@ -1354,6 +1362,7 @@ void stereo_icBWE_decproc_fx( return; } + /*-------------------------------------------------------------------* * stereo_icBWE_init_dec() * diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 9ba980600..3a945295b 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -810,13 +810,18 @@ ivas_error ivas_core_enc_fx( * Inter-channel BWE encoding *-------------------------------------------------------------------*/ +#ifndef FIX_2367_REMOVE_CODE_ICBWE Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer ); +#endif test(); test(); IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL ) { +#ifdef FIX_2367_REMOVE_CODE_ICBWE + Word16 q_new_swb_speech_buffer = st->q_inp; +#endif Word32 voice_factors_fx32[CPE_CHANNELS][NB_SUBFR16k]; stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); -- GitLab From 5b2289a37c16443c5e9aabeb5f001bc76f6879f2 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 10:41:13 +0100 Subject: [PATCH 558/750] make sure exp_pPowerSpectrumParameter_fx is initialized in all cases --- lib_com/options.h | 1 + lib_enc/igf_enc_fx.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..181d4997f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 0adf23deb..1037fb6c4 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -3320,9 +3320,13 @@ static void IGF_Whitening_ivas_fx( FOR( sb = hGrid->tile[p]; sb < hGrid->tile[p + 1]; sb++ ) { IF( LT_32( powerSpectrum[sb], 1 ) ) - hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP=-125 )*/ + { + hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP=-125 )*/ + } ELSE + { hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( powerSpectrum_e[sb], Q25 ) ), Q25 ) ) ); + } move16(); } } @@ -4271,6 +4275,10 @@ void IGFEncApplyStereo_fx( { pPowerSpectrumParameter_fx[0] = NULL; pPowerSpectrumParameter_fx[1] = NULL; +#ifdef FIX_2355_IGF_EXP_POWERSPEC + exp_pPowerSpectrumParameter_fx[0] = NULL; + exp_pPowerSpectrumParameter_fx[1] = NULL; +#endif pPowerSpectrumParameterMsInv_fx[0] = NULL; pPowerSpectrumParameterMsInv_fx[1] = NULL; q_pPowerSpectrumParameterMsInv_fx[0] = NULL; @@ -4293,6 +4301,9 @@ void IGFEncApplyStereo_fx( ELSE { pPowerSpectrumParameter_fx[ch] = NULL; +#ifdef FIX_2355_IGF_EXP_POWERSPEC + exp_pPowerSpectrumParameter_fx[ch] = NULL; +#endif } IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrumParameter_fx[ch], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode ); -- GitLab From 63651f47cc4328432c6cd2cf4b8d7157dfca9152 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 23 Jan 2026 10:59:07 +0100 Subject: [PATCH 559/750] port fix for issue 1283 in BASOP --- lib_com/options.h | 1 + lib_enc/cod_tcx_fx.c | 12 ++++++++++++ lib_enc/lib_enc_fx.c | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..f51133d4f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,6 +119,7 @@ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 8e40d9530..3ca520e1c 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -621,7 +621,13 @@ void ShapeSpectrum_ivas_fx( } test(); + test(); + test(); +#ifndef FIX_1283_STEREO_DFT_COLLAPSE IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) ) +#else + IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) ) +#endif { max_low_pre = 0; move32(); @@ -697,7 +703,13 @@ void ShapeSpectrum_ivas_fx( /* reduce the peaks in the IGF region, to make life of the core-coder easier... */ test(); + test(); + test(); +#ifndef FIX_1283_STEREO_DFT_COLLAPSE IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) ) +#else + IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) ) +#endif { Word16 sf_width; Word16 dist_low, dist_high; diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 3c6baff39..b2f1cf529 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1475,6 +1475,10 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( { hCoreCoder->total_brate = hEncoderConfig->ivas_total_brate; /* needed in case of bitrate switching */ move32(); +#ifdef FIX_1283_STEREO_DFT_COLLAPSE + hCoreCoder->element_brate = hEncoderConfig->ivas_total_brate; /* needed in checks in core-coder functions other than mono*/ + move32(); +#endif IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) { -- GitLab From ce9b838672eeae32e45c4e3a8a5497dd4e1cb2c6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 13:01:49 +0100 Subject: [PATCH 560/750] disable two fixes --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 07c86b4c5..eeffebc4a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,8 +107,8 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ -#define SIMPLIFY_SCALING_OLD_INP -#define REMOVE_UNUSED_BUFFER_CORE_ENC +//#define SIMPLIFY_SCALING_OLD_INP +//#define REMOVE_UNUSED_BUFFER_CORE_ENC #define REMOVE_SCALING_SHB_SPEECH_BE #define SCALING_SWB_SPEECH_32 -- GitLab From 4c8bdbdf08320b90bb80848bf4dfa9122c84a58b Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 13:12:19 +0100 Subject: [PATCH 561/750] remove SIMPLIFY_SCALING_OLD_INP --- lib_com/ivas_prot_fx.h | 15 ------------- lib_com/options.h | 1 - lib_enc/ivas_core_enc_fx.c | 23 ------------------- lib_enc/ivas_mdct_core_enc_fx.c | 18 --------------- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 8 ------- lib_enc/ivas_tcx_core_enc_fx.c | 31 -------------------------- 6 files changed, 96 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b9aa238c0..fc849f2c7 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3077,24 +3077,15 @@ void InternalTCXDecoder_fx( void stereo_tcx_core_enc( Encoder_State *st, /* i/o: encoder state structure */ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new-1*/ - Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new-1*/ -#else const Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz */ const Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz */ -#endif const Word16 Aw_fx[], /* i : weighted A(z) unquant. for subframes,Q12*/ Word16 lsp_new_fx[], /* i : LSPs at the end of the frame, Q15 */ Word16 lsp_mid_fx[], /* i : LSPs in the middle of the frame, Q15 */ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : pitch for each subframe, Q6 */ const Word16 last_element_mode, /* i : last element mode, Q0 */ const Word16 vad_hover_flag, /* i : VAD hangover flag, Q0 */ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_inp /* i : Q factor of input buffer */ -#else Word16 Q_new -#endif ); Word16 transient_analysis_ivas_fx( @@ -6404,9 +6395,6 @@ UWord16 get_indice_st( void stereo_mdct_core_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ -#endif Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ ); @@ -6454,9 +6442,6 @@ void stereo_switching_dec( void ivas_mdct_core_whitening_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ -#endif Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ diff --git a/lib_com/options.h b/lib_com/options.h index eeffebc4a..ecfaaefe6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,7 +107,6 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ -//#define SIMPLIFY_SCALING_OLD_INP //#define REMOVE_UNUSED_BUFFER_CORE_ENC #define REMOVE_SCALING_SHB_SPEECH_BE #define SCALING_SWB_SPEECH_32 diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 0335cf845..a99a70913 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -359,10 +359,8 @@ ivas_error ivas_core_enc_fx( TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; Word16 Q_spec_old, L_spec; -#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0 Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 -#endif Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( negate( 1 ), st->hTcxEnc->q_Txnq ) ); /* Q(-1) */ st->hTcxEnc->q_Txnq = -Q1; move16(); @@ -370,14 +368,10 @@ ivas_error ivas_core_enc_fx( move16(); /* TCX core encoder */ -#ifdef SIMPLIFY_SCALING_OLD_INP - stereo_tcx_core_enc( st, old_inp_12k8_fx[n] + L_INP_MEM, old_inp_16k_fx[n] + L_INP_MEM, Aw_fx[n], lsp_new_fx[n], lsp_mid_fx[n], pitch_buf_fx[n], last_element_mode, vad_hover_flag[0], Q_new[n] ); -#else stereo_tcx_core_enc( st, old_inp_12k8_fx[n] + L_INP_MEM, old_inp_16k_fx[n] + L_INP_MEM, Aw_fx[n], lsp_new_fx[n], lsp_mid_fx[n], pitch_buf_fx[n], last_element_mode, vad_hover_flag[0], 0 ); Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q_new[n], Q1 ) ); // Q_new[n] - 1 Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q_new[n], Q1 ) ); // Q_new[n] - 1 -#endif Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( st->hTcxEnc->Q_old_out ) ); // scaling back to Q0 st->hTcxEnc->Q_old_out = 0; @@ -458,9 +452,7 @@ ivas_error ivas_core_enc_fx( FOR( n = 0; n < n_CoreChannels; n++ ) { st = sts[n]; -#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 -#endif IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc; @@ -473,22 +465,15 @@ ivas_error ivas_core_enc_fx( Q_spec_old[1] = hCPE->hCoreCoder[1]->hTcxEnc->spectrum_long_e; move16(); -#ifdef SIMPLIFY_SCALING_OLD_INP - ivas_mdct_core_whitening_enc_fx( hCPE, old_inp_16k_fx, Q_new, old_wsp_fx, pitch_buf_fx_new, hMCT->p_mdst_spectrum_long_fx[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long_fx[cpe_id], - hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, 1, hMCT->nchan_out_woLFE, mdst_spectrum_e, orig_spectrum_e ); -#else ivas_mdct_core_whitening_enc_fx( hCPE, old_inp_16k_fx, old_wsp_fx, pitch_buf_fx_new, hMCT->p_mdst_spectrum_long_fx[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long_fx[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, 1, hMCT->nchan_out_woLFE, mdst_spectrum_e, orig_spectrum_e ); -#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = sts[i]; Word16 nSubframes = NB_DIV; move16(); -#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q_new[i], Q1 ) ); // Q_new[n] - 1 -#endif if ( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) { nSubframes = 1; @@ -553,9 +538,7 @@ ivas_error ivas_core_enc_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = sts[i]; -#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q1, Q_new[i] ) ); // Q0 -#endif test(); IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { @@ -581,17 +564,11 @@ ivas_error ivas_core_enc_fx( Q_spec_old[1] = hCPE->hCoreCoder[1]->hTcxEnc->spectrum_long_e; move16(); -#ifdef SIMPLIFY_SCALING_OLD_INP - stereo_mdct_core_enc_fx( hCPE, old_inp_16k_fx, Q_new, old_wsp_fx, pitch_buf_fx ); -#else stereo_mdct_core_enc_fx( hCPE, old_inp_16k_fx, old_wsp_fx, pitch_buf_fx ); -#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { -#ifndef SIMPLIFY_SCALING_OLD_INP Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q_new[i], Q1 ) ); // Q_new[n] - 1 -#endif st = sts[i]; IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) { diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 12d820641..2bf2e3273 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1118,9 +1118,6 @@ void enc_prm_igf_mdct( void ivas_mdct_core_whitening_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ -#endif Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word32 *mdst_spectrum_long_fx[CPE_CHANNELS], /* o : buffer for MDST spectrum mdst_spectrum_e*/ @@ -1186,13 +1183,6 @@ void ivas_mdct_core_whitening_enc_fx( move16(); move16(); -#ifdef SIMPLIFY_SCALING_OLD_INP - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - Scale_sig( new_samples_fx[ch], L_INP, sub( Q1, Q_new_inp[ch] ) ); // Q0 - } -#endif - /*--------------------------------------------------------------* * Initialization *---------------------------------------------------------------*/ @@ -2490,14 +2480,6 @@ void ivas_mdct_core_whitening_enc_fx( } } -#ifdef SIMPLIFY_SCALING_OLD_INP - // scaling the input buffer back to Q_new-1 - actually not needed because the buffer is not used in the subsequent processing - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - Scale_sig( new_samples_fx[ch], L_INP, sub( Q_new_inp[ch], Q1 ) ); // Q0 - } -#endif - pop_wmops(); return; } diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index ce689dcd3..f085dd9c4 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -130,9 +130,6 @@ static void sync_tcx_mode_fx( void stereo_mdct_core_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q_new-1*/ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_inp[CPE_CHANNELS], /* i : Q factor of input buffer */ -#endif Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ ) @@ -288,13 +285,8 @@ void stereo_mdct_core_enc_fx( * - TNS *---------------------------------------------------------------*/ -#ifdef SIMPLIFY_SCALING_OLD_INP - ivas_mdct_core_whitening_enc_fx( hCPE, new_samples, Q_new_inp, old_wsp, pitch_buf_fx, p_mdst_spectrum_long_fx, - tnsBits, p_orig_spectrum_long_fx, tnsSize, p_param, hBstr, 0, CPE_CHANNELS, mdst_spectrum_e, orig_spectrum_e ); -#else ivas_mdct_core_whitening_enc_fx( hCPE, new_samples, old_wsp, pitch_buf_fx, p_mdst_spectrum_long_fx, tnsBits, p_orig_spectrum_long_fx, tnsSize, p_param, hBstr, 0, CPE_CHANNELS, mdst_spectrum_e, orig_spectrum_e ); -#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index ec0b95515..5dacc2474 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -152,24 +152,15 @@ void stereo_tcx_init_enc_fx( void stereo_tcx_core_enc( Encoder_State *st, /* i/o: encoder state structure */ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new-1*/ - Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new-1*/ -#else const Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new*/ const Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new*/ -#endif const Word16 Aw_fx[], /* i : weighted A(z) unquant. for subframes, Q12 */ Word16 lsp_new_fx[], /* i : LSPs at the end of the frame, Q15 */ Word16 lsp_mid_fx[], /* i : LSPs in the middle of the frame, Q15 */ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : pitch for each subframe, Q6 */ const Word16 last_element_mode, /* i : last element mode, Q0 */ const Word16 vad_hover_flag, /* i : VAD hangover flag, Q0 */ -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new /* i : Q factor of input buffer */ -#else Word16 Q_new -#endif ) { TCX_ENC_HANDLE hTcxEnc; @@ -308,16 +299,10 @@ void stereo_tcx_core_enc( IF( EQ_16( st->L_frame, L_FRAME ) ) { -#ifdef SIMPLIFY_SCALING_OLD_INP - Scale_sig( new_samples_12k8, L_INP_12k8, sub( Q1, Q_new ) ); // Q0 -#endif p_new_samples = new_samples_12k8; /* Q0 */ } ELSE { -#ifdef SIMPLIFY_SCALING_OLD_INP - Scale_sig( new_samples_16k, L_INP, sub( Q1, Q_new ) ); // Q0 -#endif p_new_samples = new_samples_16k; /* Q0 */ } @@ -386,10 +371,6 @@ void stereo_tcx_core_enc( st->prev_Q_new = 0; st->Q_old = 0; -#ifdef SIMPLIFY_SCALING_OLD_INP - Word16 Q_new_orig = Q_new; - move16(); -#endif Q_new = 0; move16(); @@ -731,18 +712,6 @@ void stereo_tcx_core_enc( move16(); } -#ifdef SIMPLIFY_SCALING_OLD_INP - // scaling the input buffer back to Q_new-1 - actually not needed because the buffer is not used in the subsequent processing - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - Scale_sig( new_samples_12k8, L_INP_12k8, sub( Q_new_orig, Q1 ) ); // Q_new-1 - } - ELSE - { - Scale_sig( new_samples_16k, L_INP, sub( Q_new_orig, Q1 ) ); // Q_new-1 - } -#endif - pop_wmops(); return; } -- GitLab From b951acfeff1ecde07b581578e85549cbba8a3f90 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 13:33:37 +0100 Subject: [PATCH 562/750] remove REMOVE_UNUSED_BUFFER_CORE_ENC --- lib_com/options.h | 1 - lib_enc/ivas_core_enc_fx.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ecfaaefe6..201bc7ade 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,7 +107,6 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ -//#define REMOVE_UNUSED_BUFFER_CORE_ENC #define REMOVE_SCALING_SHB_SPEECH_BE #define SCALING_SWB_SPEECH_32 diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index a99a70913..a75998961 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -636,9 +636,8 @@ ivas_error ivas_core_enc_fx( * Postprocessing, BWEs and Updates *---------------------------------------------------------------------*/ -#ifndef REMOVE_UNUSED_BUFFER_CORE_ENC Word16 tmp_input_fx[L_FRAME48k], tmp_old_input_fx[L_FRAME48k], q_inp[2]; -#endif + FOR( n = 0; n < n_CoreChannels; n++ ) { st = sts[n]; @@ -653,12 +652,10 @@ ivas_error ivas_core_enc_fx( move16(); } -#ifndef REMOVE_UNUSED_BUFFER_CORE_ENC Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame ); Copy( st->input_fx, tmp_input_fx, input_frame ); q_inp[0] = st->q_old_inp; q_inp[1] = st->q_inp; -#endif Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( -1, st->q_inp ) ); st->q_inp = -1; move16(); @@ -893,14 +890,12 @@ ivas_error ivas_core_enc_fx( } } -#ifndef REMOVE_UNUSED_BUFFER_CORE_ENC Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame ); Copy( tmp_input_fx, st->input_fx, input_frame ); st->q_old_inp = q_inp[0]; move16(); st->q_inp = q_inp[1]; move16(); -#endif /*---------------------------------------------------------------------* * Common updates -- GitLab From c7605ca33c7e9f963db3a568133a37f44afa192d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 13:47:20 +0100 Subject: [PATCH 563/750] correctly initialize exponents in getChannelEnergies_fx() --- lib_com/options.h | 1 + lib_enc/ivas_mct_enc_mct_fx.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..9fcf994e4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,6 +119,7 @@ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 5b2642030..5329e3c2f 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -92,15 +92,36 @@ void getChannelEnergies_fx( move16(); nrg[ch] = 0; move32(); + +#ifdef FIX_2356_GET_CHAN_ENERGIES + /* move first loop iteration outside of loop - we need a proper initialization of nrg_e[ch] based on sum2_e, which is calculated in first loop iteration */ + sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[0], L_subframe, &sum2_e, gb ); // 31 - sum2_e + + nrg_e[ch] = sum2_e; /* only needed in first iteration */ + move16(); + + nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); + move32(); + FOR( n = 0; n < nSubframes; n++ ) +#else + FOR( n = 1; n < nSubframes; n++ ) +#endif { +#ifdef FIX_2356_GET_CHAN_ENERGIES + sum2_e = st->hTcxEnc->spectrum_e[n]; + move16(); +#endif + sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb ); // 31 - sum2_e nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); move32(); +#ifndef FIX_2356_GET_CHAN_ENERGIES sum2_e = st->hTcxEnc->spectrum_e[0]; move16(); +#endif } nrg[ch] = Sqrt32( nrg[ch], &nrg_e[ch] ); // nrg_e -- GitLab From a23b682ce43e837a72a1ad90d8c428a3827e673c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 13:49:53 +0100 Subject: [PATCH 564/750] consolidate switches REMOVE_SCALING_SHB_SPEECH --- lib_com/ivas_prot_fx.h | 13 +++---- lib_com/options.h | 3 +- lib_com/prot_fx.h | 4 +-- lib_enc/ivas_core_enc_fx.c | 58 +++++++++++------------------- lib_enc/ivas_stereo_icbwe_enc_fx.c | 18 ++++------ lib_enc/prot_fx_enc.h | 2 +- lib_enc/swb_bwe_enc_fx.c | 6 ++-- lib_enc/swb_pre_proc_fx.c | 8 ++--- 8 files changed, 43 insertions(+), 69 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index fc849f2c7..c8da9fea1 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1359,23 +1359,20 @@ void stereo_tcx_init_dec_fx( void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ + Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/ #else const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ -#endif -#ifdef SCALING_SWB_SPEECH_32 - Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel Q15-shb_speech_nonref_e*/ -#else Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel */ #endif Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ -#ifdef SCALING_SWB_SPEECH_32 - const Word16 *voice_factors_fx /* i : voicing factors Q15 */ +#ifdef REMOVE_SCALING_SHB_SPEECH + const Word16 *voice_factors_fx /* i : voicing factors Q15 */ #else const Word32 *voice_factors_fx /* i : voicing factors Q31 */ - #endif +#endif ); void initMdctStereoDecData_fx( diff --git a/lib_com/options.h b/lib_com/options.h index 201bc7ade..0024e9b5b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,8 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ -#define REMOVE_SCALING_SHB_SPEECH_BE -#define SCALING_SWB_SPEECH_32 +#define REMOVE_SCALING_SHB_SPEECH /* VA: remove unnecessary scaling and 32-bit buffers from ivas_core_enc_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index b4d5b50da..d538fd111 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10338,11 +10338,11 @@ void Copy_Scale_sig32( void swb_pre_proc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ -#ifndef SCALING_SWB_SPEECH_32 +#ifndef REMOVE_SCALING_SHB_SPEECH Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ #endif Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/ -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Word16 *Q_shb_spch, #endif Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index a75998961..7cd893ec4 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -87,18 +87,14 @@ ivas_error ivas_core_enc_fx( STEREO_ICBWE_ENC_HANDLE hStereoICBWE; STEREO_TD_ENC_DATA_HANDLE hStereoTD; Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; /* Q15 */ -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Word32 shb_speech_fx32[L_FRAME16k]; -#endif -#ifndef SCALING_SWB_SPEECH_32 Word32 *new_swb_speech_fx; #endif Word16 *inp_fx[CPE_CHANNELS]; Word16 *shb_speech_fx; -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Word16 Q_shb_spch; -#endif -#ifndef SCALING_SWB_SPEECH_32 Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; #endif Word16 new_inp_resamp16k_fx[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ @@ -118,7 +114,7 @@ ivas_error ivas_core_enc_fx( Word16 max_num_indices_BWE; Word16 i, shift, Q_min; -#ifndef SCALING_SWB_SPEECH_32 +#ifndef REMOVE_SCALING_SHB_SPEECH set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); #endif FOR( i = 0; i < CPE_CHANNELS; i++ ) @@ -133,7 +129,7 @@ ivas_error ivas_core_enc_fx( error = IVAS_ERR_OK; move32(); -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Q_shb_spch = 0; move16(); #endif @@ -359,8 +355,8 @@ ivas_error ivas_core_enc_fx( TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; Word16 Q_spec_old, L_spec; - Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0 - Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 + Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0 + Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( negate( 1 ), st->hTcxEnc->q_Txnq ) ); /* Q(-1) */ st->hTcxEnc->q_Txnq = -Q1; move16(); @@ -701,7 +697,7 @@ ivas_error ivas_core_enc_fx( * SWB(FB) BWE encoding *---------------------------------------------------------------------*/ -#ifndef SCALING_SWB_SPEECH_32 +#ifndef REMOVE_SCALING_SHB_SPEECH new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; #endif new_swb_speech_fx_16 = new_swb_speech_buffer_fx_16 + STEREO_DFT_OVL_MAX; @@ -736,12 +732,8 @@ ivas_error ivas_core_enc_fx( st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 ); } -#ifdef SCALING_SWB_SPEECH_32 -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); -#else - swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); -#endif #else swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); #endif @@ -756,16 +748,14 @@ ivas_error ivas_core_enc_fx( } } -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Word16 Q_shb_spch_16 = Q_shb_spch; move16(); -#endif #ifdef FIX_2344_ALIGN_PREPROC IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become: // IF( st->tcxonly == 0 ) #endif { -#ifndef REMOVE_SCALING_SHB_SPEECH_BE shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch Q_shb_spch = add( Q_shb_spch, shift ); @@ -777,7 +767,9 @@ ivas_error ivas_core_enc_fx( move16(); Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda } +#ifndef REMOVE_SCALING_SHB_SPEECH } +#endif /* SWB TBE encoder */ test(); @@ -790,7 +782,7 @@ ivas_error ivas_core_enc_fx( Word16 Q_fb_exc; Word16 fb_exc_fx[L_FRAME16k]; -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], 0, st->voicing_fx, pitch_buf_fx[n] ); #else swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], Q_shb_spch_16, st->voicing_fx, pitch_buf_fx[n] ); @@ -805,11 +797,11 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 #endif /* SWB(FB) BWE encoder */ -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_new[n], 1 ) ); #else swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); @@ -828,7 +820,7 @@ ivas_error ivas_core_enc_fx( IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && ( GE_16( input_frame, L_FRAME32k ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) { /* SHB DTX/CNG encoder */ -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 #endif #ifdef HARM_NON_LINEARITY @@ -842,7 +834,7 @@ ivas_error ivas_core_enc_fx( * Inter-channel BWE encoding *-------------------------------------------------------------------*/ -#ifndef SCALING_SWB_SPEECH_32 +#ifndef REMOVE_SCALING_SHB_SPEECH Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer ); @@ -851,27 +843,19 @@ ivas_error ivas_core_enc_fx( test(); IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL ) { -#ifndef SCALING_SWB_SPEECH_32 +#ifndef REMOVE_SCALING_SHB_SPEECH Word32 voice_factors_fx32[CPE_CHANNELS][NB_SUBFR16k]; stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); -#else - stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, st->q_inp ); -#endif -#ifndef SCALING_SWB_SPEECH_32 q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, Q16 ); Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 -#endif -#ifdef SCALING_SWB_SPEECH_32 -#ifdef REMOVE_SCALING_SHB_SPEECH_BE - stereo_icBWE_enc_fx( hCPE, shb_speech_fx, new_swb_speech_buffer_fx_16, st->q_inp, voice_factors_fx[0] ); -#else - stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx_16, st->q_inp, voice_factors_fx[0] ); -#endif -#else stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); +#else + stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, st->q_inp ); + + stereo_icBWE_enc_fx( hCPE, shb_speech_fx, new_swb_speech_buffer_fx_16, st->q_inp, voice_factors_fx[0] ); #endif IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 86e662b57..0fd189e41 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -619,19 +619,16 @@ static void icbwe_dft_stereo_param_ivas_fx( void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ + Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/ #else const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel shb_speech_ref_e*/ const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ -#endif -#ifdef SCALING_SWB_SPEECH_32 - Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/ -#else Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ #endif Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ -#ifdef SCALING_SWB_SPEECH_32 +#ifdef REMOVE_SCALING_SHB_SPEECH const Word16 *voice_factors_fx16 /* i : voicing factors Q15 */ #else const Word32 *voice_factors_fx /* i : voicing factors Q31 */ @@ -659,18 +656,15 @@ void stereo_icBWE_enc_fx( Word32 temp1_fx, temp2_fx; Word16 temp1_e, temp2_e, shb_frame_ref_e, shb_frame_nonref_e, gDes_e, tmp, exp; -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH Word32 shb_speech_ref_fx[L_FRAME16k]; Word16 shb_speech_ref_e; + Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; + Word32 voice_factors_fx[NB_SUBFR16k]; shb_speech_ref_e = add( getScaleFactor16( shb_speech_ref_fx16, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_ref_fx16, shb_speech_ref_fx, L_FRAME16k, shb_speech_ref_e ); shb_speech_ref_e = Q31 - shb_speech_ref_e; -#endif - -#ifdef SCALING_SWB_SPEECH_32 - Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; - Word32 voice_factors_fx[NB_SUBFR16k]; shb_speech_nonref_e = Q15 - shb_speech_nonref_e; Copy_Scale_sig_16_32_no_sat( shb_speech_nonref_fx_16, shb_speech_nonref_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index ab07c7e80..b5c66c3db 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -599,7 +599,7 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 Q_slb_speech #else diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index c288857c9..e07f79777 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -271,7 +271,7 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 Q_slb_speech #else @@ -311,7 +311,7 @@ void swb_bwe_enc_ivas_fx( move16(); Word16 fb_band_begin; Word16 q_new_input_hp; -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH Word16 shb_speech_fx[L_FRAME16k]; Word16 Q_shb_speech; #endif @@ -319,7 +319,7 @@ void swb_bwe_enc_ivas_fx( FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; -#ifdef REMOVE_SCALING_SHB_SPEECH_BE +#ifdef REMOVE_SCALING_SHB_SPEECH Q_shb_speech = getScaleFactor16( shb_speech_fx_Q0, L_FRAME16k ); Copy_Scale_sig( shb_speech_fx_Q0, shb_speech_fx, L_FRAME16k, Q_shb_speech ); // Q0 -> Q_shb_spch #endif diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 0cccc621c..107d85ccd 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -774,11 +774,11 @@ void swb_pre_proc_fx( void swb_pre_proc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ -#ifndef SCALING_SWB_SPEECH_32 +#ifndef REMOVE_SCALING_SHB_SPEECH Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ #endif Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0 */ -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH Word16 *Q_shb_spch, #endif Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ @@ -1066,7 +1066,7 @@ void swb_pre_proc_ivas_fx( ELSE /* IVAS_CPE_DFT */ { Word16 out_start_ind, out_end_ind; -#ifdef SCALING_SWB_SPEECH_32 +#ifdef REMOVE_SCALING_SHB_SPEECH Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; Word32 *new_swb_speech_fx; set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); @@ -1282,7 +1282,7 @@ void swb_pre_proc_ivas_fx( cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); // Q0 -#ifndef REMOVE_SCALING_SHB_SPEECH_BE +#ifndef REMOVE_SCALING_SHB_SPEECH *Q_shb_spch = 0; move16(); #endif -- GitLab From 3b9b748ca81c571a1911e82aae93f5d1cf3caea7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 13:56:38 +0100 Subject: [PATCH 565/750] formatting --- lib_enc/ivas_core_enc_fx.c | 7 +++++-- lib_enc/ivas_mdct_core_enc_fx.c | 20 ++++---------------- lib_enc/ivas_tcx_core_enc_fx.c | 21 ++++++++++----------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 7cd893ec4..a8cfdfacf 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -355,8 +355,9 @@ ivas_error ivas_core_enc_fx( TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; Word16 Q_spec_old, L_spec; - Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0 - Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 + Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0 + Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0 + Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( negate( 1 ), st->hTcxEnc->q_Txnq ) ); /* Q(-1) */ st->hTcxEnc->q_Txnq = -Q1; move16(); @@ -535,6 +536,7 @@ ivas_error ivas_core_enc_fx( { st = sts[i]; Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q1, Q_new[i] ) ); // Q0 + test(); IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { @@ -652,6 +654,7 @@ ivas_error ivas_core_enc_fx( Copy( st->input_fx, tmp_input_fx, input_frame ); q_inp[0] = st->q_old_inp; q_inp[1] = st->q_inp; + Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( -1, st->q_inp ) ); st->q_inp = -1; move16(); diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 2bf2e3273..f4889bf5f 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1116,8 +1116,8 @@ void enc_prm_igf_mdct( *-------------------------------------------------------------------*/ void ivas_mdct_core_whitening_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word32 *mdst_spectrum_long_fx[CPE_CHANNELS], /* o : buffer for MDST spectrum mdst_spectrum_e*/ @@ -1222,7 +1222,6 @@ void ivas_mdct_core_whitening_enc_fx( windowedSignal_fx[0] = orig_spectrum_long[0]; /* NOTE temporarily available */ windowedSignal_fx[1] = temp_buffer; /* orig_spectrum_long isn't long enough */ - /*--------------------------------------------------------------* * TCX20/TCX10 switching decision *---------------------------------------------------------------*/ @@ -1322,7 +1321,6 @@ void ivas_mdct_core_whitening_enc_fx( move32(); } } - /*--------------------------------------------------------------* * Transform Kernel Switching, Stereo Pre-Processing, and TNS *---------------------------------------------------------------*/ @@ -1524,7 +1522,6 @@ void ivas_mdct_core_whitening_enc_fx( move16(); move16(); } - FOR( n = 0; n < nSubframes; n++ ) { test(); @@ -1711,6 +1708,7 @@ void ivas_mdct_core_whitening_enc_fx( init_tcx_enc_info_fx( sts[ch], &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); + nSubframes = NB_DIV; move16(); shift = 1; @@ -1760,7 +1758,6 @@ void ivas_mdct_core_whitening_enc_fx( } } } - TCX_ENC_HANDLE hTcxEnc = NULL; q_min = 0; move16(); @@ -1813,11 +1810,9 @@ void ivas_mdct_core_whitening_enc_fx( } } TNSAnalysisStereo_fx( sts, mdst_spectrum_fx, 0, tnsSize, tnsBits, param_core, mct_on ); - /*--------------------------------------------------------------* * Envelope Quantization and FDNS *---------------------------------------------------------------*/ - /* Common q for spectrum and mdst */ q_min = 0; move16(); @@ -2067,6 +2062,7 @@ void ivas_mdct_core_whitening_enc_fx( init_tcx_enc_info_fx( st, &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); + IF( NE_16( st->hTcxEnc->tcxMode, TCX_20 ) ) { /* nSubframes = NB_DIV = 2 */ @@ -2095,7 +2091,6 @@ void ivas_mdct_core_whitening_enc_fx( Scale_sig32( st->hTcxEnc->spectrum_fx[n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, st->hTcxEnc->spectrum_e[n] ) ); } } - /*--------------------------------------------------------------* * TNS *---------------------------------------------------------------*/ @@ -2318,7 +2313,6 @@ void ivas_mdct_core_whitening_enc_fx( /*--------------------------------------------------------------------------------* * SNS parameters *--------------------------------------------------------------------------------*/ - test(); test(); test(); @@ -2485,12 +2479,6 @@ void ivas_mdct_core_whitening_enc_fx( } -/*--------------------------------------------------------------* - * ivas_mdct_quant_coder() - * - * Spectrum quantization and coding - *---------------------------------------------------------------*/ - void ivas_mdct_quant_coder_fx( CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 5dacc2474..6bd3aca8c 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -151,17 +151,16 @@ void stereo_tcx_init_enc_fx( *-------------------------------------------------------------------*/ void stereo_tcx_core_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new*/ - const Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 new_samples_12k8[], /* i : buffer of input signal @12.8 kHz Q_new*/ + const Word16 new_samples_16k[], /* i : buffer of input signal @16 kHz Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquant. for subframes, Q12 */ Word16 lsp_new_fx[], /* i : LSPs at the end of the frame, Q15 */ Word16 lsp_mid_fx[], /* i : LSPs in the middle of the frame, Q15 */ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : pitch for each subframe, Q6 */ const Word16 last_element_mode, /* i : last element mode, Q0 */ const Word16 vad_hover_flag, /* i : VAD hangover flag, Q0 */ - Word16 Q_new -) + Word16 Q_new ) { TCX_ENC_HANDLE hTcxEnc; Word16 i, n; @@ -174,8 +173,7 @@ void stereo_tcx_core_enc( Word16 last_core_orig; /*Bits*/ - Word16 nbits_start, - total_nbbits, nbits_header; + Word16 nbits_start, total_nbbits, nbits_header; Word16 target_bits[2], bitsAvailable; Word16 nbits_lpc[2]; Word16 tnsSize[2]; /* number of tns parameters put into prm */ @@ -204,12 +202,15 @@ void stereo_tcx_core_enc( /*HM*/ Word16 indexBuffer[2 * ( ( N_MAX / 2 ) + 1 )]; + Word16 s; + CONTEXT_HM_CONFIG hm_cfg[2]; /* bitstream */ BSTR_ENC_HANDLE hBstr = st->hBstr; + push_wmops( "stereo_tcx_core_enc" ); /*Sanity check*/ @@ -299,11 +300,11 @@ void stereo_tcx_core_enc( IF( EQ_16( st->L_frame, L_FRAME ) ) { - p_new_samples = new_samples_12k8; /* Q0 */ + p_new_samples = new_samples_12k8; /* Q_new */ } ELSE { - p_new_samples = new_samples_16k; /* Q0 */ + p_new_samples = new_samples_16k; /* Q_new */ } /*--------------------------------------------------------------* @@ -679,7 +680,6 @@ void stereo_tcx_core_enc( /*--------------------------------------------------------------------------------* * Encode TCX20/10 parameters *--------------------------------------------------------------------------------*/ - writeTCXparam_fx( st, hBstr, hm_cfg, param_core, nbits_header, nbits_start, add( nbits_lpc[0], nbits_lpc[1] ), NULL, NULL, NULL, -1 ); total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); @@ -704,7 +704,6 @@ void stereo_tcx_core_enc( move16(); } } - Scale_sig( st->synth, st->L_frame, -Q_new ); IF( st->tcxonly == 0 ) { -- GitLab From ed41b0648c2a817011976004c27d6cf6b23b01a5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 14:14:14 +0100 Subject: [PATCH 566/750] clang-format --- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index f085dd9c4..4e4d0d92a 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -128,8 +128,8 @@ static void sync_tcx_mode_fx( *-------------------------------------------------------------------*/ void stereo_mdct_core_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q_new-1*/ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q_new-1*/ Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ ) -- GitLab From 5709d4ffc6007935549e0455890766cb131c9dc7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 14:26:35 +0100 Subject: [PATCH 567/750] revert comment --- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 4e4d0d92a..705635d88 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -126,10 +126,9 @@ static void sync_tcx_mode_fx( * * joint stereo mdct core encoder *-------------------------------------------------------------------*/ - void stereo_mdct_core_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q_new-1*/ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ ) -- GitLab From e4f6113a97298476dad19d4800c0f15dad757cbd Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 14:40:20 +0100 Subject: [PATCH 568/750] formatting --- lib_enc/multi_harm_fx.c | 7 ++- lib_enc/nois_est_fx.c | 108 ++++++++++++++++++++++------------------ 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index cfba37d19..a042bcbc4 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -48,6 +48,7 @@ Word16 multi_harm_fx( #ifdef FIX_2364_HARM_MULT_HARM Word32 tmp2_32; #endif + /*------------------------------------------------------------------* * initialization *------------------------------------------------------------------*/ @@ -124,6 +125,7 @@ Word16 multi_harm_fx( move16(); step = 0; move16(); + #ifdef FIX_2364_HARM_MULT_HARM IF( element_mode != EVS_MONO ) { @@ -214,6 +216,7 @@ Word16 multi_harm_fx( *cor_strong_limit = 1; move16(); } + test(); if ( LT_32( total_brate, ACELP_9k60 ) || GT_32( total_brate, ACELP_16k40 ) ) { @@ -329,6 +332,7 @@ Word16 multi_harm_fx( move16(); pt2 = cor_map; move16(); + #ifdef FIX_2364_HARM_MULT_HARM IF( element_mode != EVS_MONO ) { @@ -380,6 +384,7 @@ Word16 multi_harm_fx( pt2++; } } + IF( ( bwidth == NB ) ) { /* cor_map_LT_sum *= 1.53f; */ @@ -423,9 +428,9 @@ Word16 multi_harm_fx( { Copy( S, S_map, L ); } + return harm; } - #ifndef FIX_2364_HARM_MULT_HARM /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_ivas_fx( diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 4fa371533..67e7fbf35 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -62,10 +62,11 @@ * y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) *-----------------------------------------------------------------*/ -Word16 noise_est_AR1_Qx( /* o : Qx y(n) */ - Word16 x, /* i : Qx x(n) */ - Word16 y, /* i : Qx y(n-1) */ - Word16 alpha /*i : Q15 scaling of driving x(n) */ +/* o : Qx y(n) */ +Word16 noise_est_AR1_Qx( + Word16 x, /* i : Qx x(n) */ + Word16 y, /* i : Qx y(n-1) */ + Word16 alpha /*i : Q15 scaling of driving x(n) */ ) { Word16 alpham1; @@ -75,10 +76,11 @@ Word16 noise_est_AR1_Qx( /* o : Qx y(n) */ return mac_r( L_mult( y, alpham1 ), x, alpha ); } -Word32 noise_est_AR1_Qx_32( /* o : Qx y(n) */ - Word32 x, /* i : Qx x(n) */ - Word32 y, /* i : Qx y(n-1) */ - Word32 alpha /*i : Q15 scaling of driving x(n) */ +/* o : Qx y(n) */ +Word32 noise_est_AR1_Qx_32( + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /*i : Q15 scaling of driving x(n) */ ) { Word32 alpham1; @@ -89,6 +91,7 @@ Word32 noise_est_AR1_Qx_32( /* o : Qx y(n) */ return Madd_32_32( Mpy_32_32( y, alpham1 ), x, alpha ); } + /*-----------------------------------------------------------------* * noise_est_ln_q8_fx() * @@ -126,12 +129,13 @@ static Word16 noise_est_ln_q8_fx( * *-----------------------------------------------------------------*/ -static Word32 eps_quota_fx( /* o: eps_num/eps_den in q_out */ - Word16 eps_num_h, /* num high ,*/ - Word16 eps_num_l, /* num low (signed) ,*/ - Word16 eps_den_h, /* den low */ - Word16 eps_den_l, /* den low (signed),*/ - Word16 q_out /* range 15...0 , tested with 11 and 12 */ +/* o: eps_num/eps_den in q_out */ +static Word32 eps_quota_fx( + Word16 eps_num_h, /* num high ,*/ + Word16 eps_num_l, /* num low (signed) ,*/ + Word16 eps_den_h, /* den low */ + Word16 eps_den_l, /* den low (signed),*/ + Word16 q_out /* range 15...0 , tested with 11 and 12 */ ) { Word32 L_tmp_num, L_tmp_den; @@ -139,7 +143,6 @@ static Word32 eps_quota_fx( /* o: eps_num/eps_den in q_out Word16 m_num, m_den; Word16 num_shift; - L_tmp_num = L_Comp( eps_num_h, eps_num_l ); L_tmp_den = L_Comp( eps_den_h, eps_den_l ); @@ -166,11 +169,13 @@ static Word32 eps_quota_fx( /* o: eps_num/eps_den in q_out return L_shr( m_num, num_shift ); } + /*-----------------------------------------------------------------* * noise_est_init_fx() * * Initialization of Noise estimator *-----------------------------------------------------------------*/ + void noise_est_init_fx( NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ ) @@ -385,6 +390,8 @@ void noise_est_init_ivas_fx( return; } + + /*-----------------------------------------------------------------* * noise_est_pre_fx() * @@ -432,7 +439,6 @@ void noise_est_pre_fx( hNoiseEst->Etot_l_fx = add( hNoiseEst->Etot_l_fx, 20 ); move16(); /* 20 = .08 in Q8 */ - /* Could even be higher but it also delays first entry to DTX */ IF( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_FX ) ) { @@ -611,6 +617,8 @@ void noise_est_pre_32fx( return; } + + /*==================================================================================*/ /* FUNCTION : noise_est_down_fx() */ /*----------------------------------------------------------------------------------*/ @@ -638,7 +646,6 @@ void noise_est_pre_32fx( /* _ (Word32[]) tmpN_he1 : temporary noise update 1 Q_new+QSCALE */ /*----------------------------------------------------------------------------------*/ - void noise_est_down_fx( const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) */ Word32 bckr[], /* i/o: per band background noise energy estimate */ @@ -689,6 +696,7 @@ void noise_est_down_fx( Ltmp = Mpy_32_16( e_Noise, f_Noise, LG10 ); *totalNoise = round_fx( L_shl( Ltmp, 10 ) ); /*Q8*/ move16(); + /*-----------------------------------------------------------------* * Average energy per frame for each frequency band *-----------------------------------------------------------------*/ @@ -836,6 +844,7 @@ void noise_est_down_ivas_fx( /*-----------------------------------------------------------------* * Background noise energy update *-----------------------------------------------------------------*/ + FOR( i = 0; i < NB_BANDS; i++ ) { /* tmpN[i] = (1-ALPHA) * bckr[i] + ALPHA * enr[i]; */ @@ -896,9 +905,11 @@ void noise_est_down_ivas_fx( move16(); move16(); move16(); + /*------------------------------------------------------------------* * Energy variation update *------------------------------------------------------------------*/ + /*Etot_v = (float) fabs(*Etot_last - Etot);*/ L_Etot_v = L_abs( L_sub( L_Etot_last, L_Etot ) ); /* Q24 */ @@ -914,11 +925,13 @@ void noise_est_down_ivas_fx( return; } + /*-----------------------------------------------------------------* * noise_est_fx() * * Noise energy estimation (noise energy is updated in case of noise-only frame) *-----------------------------------------------------------------*/ + void noise_est_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 old_pitch1, /* i : previous frame OL pitch[1] */ @@ -995,6 +1008,7 @@ void noise_est_fx( /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ + vad_bwidth_fx = st_fx->input_bwidth; move16(); @@ -1109,6 +1123,7 @@ void noise_est_fx( *loc_harm = multi_harm_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); #else + test(); *loc_harm = multi_harm_fx( EVS_MONO, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); #endif @@ -1162,7 +1177,6 @@ void noise_est_fx( } Lsum_den = L_shr( Lsum_den, tmpExp ); - /* calculation of spectral diversity */ /* THR_SPDIV_FX = 5 , 1/5 Q15 = 6554 */ spec_div = 0; @@ -1224,7 +1238,6 @@ void noise_est_fx( /* *st_noise_char = M_ALPHA * *st_noise_char + (1-M_ALPHA) * noise_chartmp */ hNoiseEst->noise_char_fx = mac_r( L_mult( M_ALPHA_FX, hNoiseEst->noise_char_fx ), ONE_MINUS_M_ALPHA, noise_chartmp ); - nchar_thr = THR_NCHAR_WB_FX; move16(); /* 1.0 Q11 */ if ( vad_bwidth_fx == NB ) @@ -1263,6 +1276,7 @@ void noise_est_fx( /*if( alpha > 0.999f { alpha = 0.999f;} */ alpha = s_min( alpha, 32735 ); /*.999 in Q15*/ alpham1 = negate( add( -32768, alpha ) ); /* 1.0 - alpha */ + /*--------------------------------------------------------------* * during significant attacks, replace the LT energy by the * current energy this will cause non_sta2 failures to occur in @@ -1374,6 +1388,7 @@ void noise_est_fx( move16(); } } + test(); IF( GE_16( i, 2 ) && LE_16( i, 16 ) ) { @@ -1442,11 +1457,15 @@ void noise_est_fx( test(); *st_harm_cor_cnt = add( *st_harm_cor_cnt, 1 ); move16(); + + test(); + test(); if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_16( round_fx( Ltmp ), COR_MAX_NNE_FX ) ) ) ) { *st_harm_cor_cnt = 0; move16(); } + test(); test(); test(); @@ -1457,6 +1476,7 @@ void noise_est_fx( { *st_harm_cor_cnt = 1; } + test(); test(); if ( GT_16( *st_harm_cor_cnt, 1 ) && @@ -1470,10 +1490,10 @@ void noise_est_fx( move16(); } - /*-----------------------------------------------------------------* * Energy based pause length counter *-----------------------------------------------------------------*/ + test(); IF( ( *bg_cnt >= 0 ) && ( GT_16( sub( Etot, Etot_l_lp ), 1280 ) /*5.0 in Q8*/ ) ) { @@ -1491,6 +1511,7 @@ void noise_est_fx( move16(); } } + if ( *bg_cnt >= 0 ) { *bg_cnt = add( *bg_cnt, 1 ); @@ -1511,7 +1532,6 @@ void noise_est_fx( epsP_0_2 = s_max( 0, epsP_0_2 ); /* min value is 0 , Q12 */ - /* st->epsP_0_2_lp = 0.15f * epsP_0_2 + (1.0f-0.15f) * st->epsP_0_2_lp; */ alpha = 4915; move16(); /*0.15 in Q15 */ @@ -1536,7 +1556,6 @@ void noise_est_fx( /* epsP_0_2_ad_lp_max = max(epsP_0_2_ad,st->epsP_0_2_ad_lp);*/ epsP_0_2_ad_lp_max = s_max( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx ); /* Q12 */ - /*-----------------------------------------------------------------* * Linear predition efficiency 2 to 16 order *-----------------------------------------------------------------*/ @@ -1551,7 +1570,6 @@ void noise_est_fx( epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */ - /* if (epsP_2_16 > st->epsP_2_16_lp){ st->epsP_2_16_lp = 0.2f * epsP_2_16 + (1.0f-0.2f) * st->epsP_2_16_lp; } else { @@ -1573,7 +1591,6 @@ void noise_est_fx( move16(); epsP_2_16_dlp = sub( hNoiseEst->epsP_2_16_lp_fx, hNoiseEst->epsP_2_16_lp2_fx ); - /* if (epsP_2_16_dlp < st->epsP_2_16_dlp_lp2 ) { st->epsP_2_16_dlp_lp2 = 0.02f * epsP_2_16_dlp + (1.0f-0.02f) * st->epsP_2_16_dlp_lp2; } else { @@ -1644,7 +1661,6 @@ void noise_est_fx( hNoiseEst->low_tn_track_cnt = tmp; move16(); - /* update of the long-term non-stationarity measure (between 0 and 1) */ /* if ( (non_sta > th_sta) || (*loc_harm > 0) ) { st->act_pred = M_GAMMA * st->act_pred + (1-M_GAMMA) * 1; @@ -1662,10 +1678,10 @@ void noise_est_fx( hNoiseEst->act_pred_fx = tmp; move16(); - /*-----------------------------------------------------------------* * Background noise adaptation enable flag *-----------------------------------------------------------------*/ + Ltmp = L_mult( st_fx->voicing_fx[0], 16384 ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 ); cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); @@ -1729,17 +1745,14 @@ void noise_est_fx( } hNoiseEst->aEn = add( hNoiseEst->aEn, tmp ); - hNoiseEst->aEn = s_min( hNoiseEst->aEn, 6 ); hNoiseEst->aEn = s_max( hNoiseEst->aEn, 0 ); /* Additional NNE detectors */ - /* comb_ahc_epsP = max(max(st->act_pred, st->lt_haco_ev), epsP_2_16_dlp); */ /* Q15 Q15 Q12 */ comb_ahc_epsP = s_max( s_max( shr( hNoiseEst->act_pred_fx, 15 - 12 ), shr( hNoiseEst->lt_haco_ev_fx, 15 - 12 ) ), epsP_2_16_dlp ); /* Q12 */ - /* comb_hcm_epsP = max(max(st->lt_haco_ev,epsP_2_16_dlp_max),epsP_0_2_ad_lp_max); */ /* Q15 Q12 Q12 */ comb_hcm_epsP = s_max( s_max( shr( hNoiseEst->lt_haco_ev_fx, 15 - 12 ), epsP_2_16_dlp_max ), epsP_0_2_ad_lp_max ); /* Q12 */ @@ -1793,7 +1806,6 @@ void noise_est_fx( move16(); /* Q0 */ } - /* ns_mask = non_sta < 1e5f; */ ns_mask = 0; move16(); @@ -1803,7 +1815,6 @@ void noise_est_fx( move16(); /* Q0 */ } - /* lt_haco_mask = st->lt_haco_ev < 0.5f; */ lt_haco_mask = 0; move16(); @@ -1822,7 +1833,6 @@ void noise_est_fx( move16(); /* Q0 */ } - /* SD_1 = ( (epsP_0_2_ad > 0.5f) && (epsP_0_2 > 7.95f) ); */ SD_1 = 0; move16(); @@ -1922,7 +1932,6 @@ void noise_est_fx( tmp = s_and( tmp, SD_1_inv ); PAU = s_or( PAU, s_and( tmp, s_or( s_and( PD_3, s_or( PD_1, PD_2 ) ), s_or( PD_4, PD_5 ) ) ) ); - /* NEW_POS_BG = (PAU | BG_1) & bg_bgd3; note bitwise logic in float */ NEW_POS_BG = s_and( s_or( PAU, BG_1 ), bg_bgd3 ); @@ -1936,7 +1945,6 @@ void noise_est_fx( move16(); } - /* When the signal dynamics is high and the energy is close to the background estimate */ /* sd1_bgd = (st->sign_dyn_lp > 15) && (Etot - st->Etot_l_lp ) < 2*st->Etot_v_h2 @@ -2187,11 +2195,13 @@ void noise_est_fx( return; } + /*-----------------------------------------------------------------* * noise_est_fx() * * Noise energy estimation (noise energy is updated in case of noise-only frame) *-----------------------------------------------------------------*/ + void noise_est_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 old_pitch1, /* i : previous frame OL pitch[1] */ @@ -2284,10 +2294,10 @@ void noise_est_ivas_fx( /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ + vad_bwidth_fx = st_fx->input_bwidth; move16(); - /*st_fx->ener_RAT = 10.0f * (float)log10( mean(lf_E, 8));*/ temp = 0; move64(); @@ -2341,6 +2351,7 @@ void noise_est_ivas_fx( } } } + /*-----------------------------------------------------------------* * Set the threshold for eps & non_sta based on input sampling rate * The reason is that in case of 8kHz sampling input, there is nothing @@ -2394,11 +2405,10 @@ void noise_est_ivas_fx( move16(); /* low correlation -> probably inactive signal */ } - /* Update */ - /*-----------------------------------------------------------------* * Multi-harmonic analysis *-----------------------------------------------------------------*/ + IF( hFrontVad == NULL ) { IF( st_fx->hSpMusClas != NULL ) @@ -2415,9 +2425,11 @@ void noise_est_ivas_fx( move16(); } } + /*-----------------------------------------------------------------* * Detection of frames with non-stationary spectral content *-----------------------------------------------------------------*/ + /* weighted sum of spectral changes per critical bands */ w_sum_num = 0; move64(); @@ -2429,6 +2441,7 @@ void noise_est_ivas_fx( Word16 exp, exp2; w_sum_den = 0; move64(); + FOR( i = 10; i <= st_fx->max_band; i++ ) { Lnum = L_max( *pt1, *pt2 ); @@ -2441,7 +2454,6 @@ void noise_est_ivas_fx( num = extract_h( Mpy_32_32( Lnum, Lnum ) ); // 2*(q_fr_bands+exp)-31-16 ExpNum = add( sub( shl( q_fr_bands, 1 ), 47 ), shl( exp, 1 ) ); - den = E_MIN_FXQ31 >> 8; // 29360, 0.0035f in Q23 ExpDen = Q23; move32(); @@ -2606,6 +2618,7 @@ void noise_est_ivas_fx( /*if( alpha > 0.999f { alpha = 0.999f;} */ alpha = s_min( alpha, 32735 ); /*.999 in Q15*/ alpham1 = negate( add( -32768, alpha ) ); /* 1.0 - alpha */ + /*--------------------------------------------------------------* * during significant attacks, replace the LT energy by the * current energy this will cause non_sta2 failures to occur in @@ -2780,7 +2793,8 @@ void noise_est_ivas_fx( } } - } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */ + } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */ + *non_staX = L_shl( *non_staX, 12 ); // Q20 move32(); IF( LT_16( Etot, -1280 /* -5.0f in Q8 */ ) ) @@ -2814,6 +2828,7 @@ void noise_est_ivas_fx( Word16 exp_tmp; st_E_var_est_fx = BASOP_Util_Add_Mant32Exp( hNoiseEst->L_Etot_sq_st_est_fx, Q15, L_negate( Mpy_32_32( hNoiseEst->L_Etot_st_est_fx, hNoiseEst->L_Etot_st_est_fx ) ), Q16, &exp_tmp ); // exp(exp_tmp) + /*-----------------------------------------------------------------* * Count frames since last correlation or harmonic event *-----------------------------------------------------------------*/ @@ -2823,6 +2838,7 @@ void noise_est_ivas_fx( *st_harm_cor_cnt = add( *st_harm_cor_cnt, 1 ); move16(); + test(); test(); if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_32( Ltmp, 1825361101 /* 0.85 in Q31 */ ) ) ) ) @@ -2841,6 +2857,7 @@ void noise_est_ivas_fx( *st_harm_cor_cnt = 1; move16(); } + test(); test(); IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && EQ_16( BASOP_Util_Cmp_Mant32Exp( st_E_var_est_fx, exp_tmp, 524288 /* 8.0f in Q16 */, Q15 ), 1 ) ) @@ -2850,7 +2867,6 @@ void noise_est_ivas_fx( move16(); } - /*-----------------------------------------------------------------* * Energy based pause length counter *-----------------------------------------------------------------*/ @@ -3003,7 +3019,6 @@ void noise_est_ivas_fx( hNoiseEst->lt_Ellp_dist_fx = mac_r( L_mult( tmp, 983 /* 0.03 in Q15*/ ), hNoiseEst->lt_Ellp_dist_fx, 31785 /* 0.97 in Q15*/ ); // Q8 move16(); - /* if (st->harm_cor_cnt == 0) { st->lt_haco_ev = 0.03f*1.0 + 0.97f*st->lt_haco_ev; } else { @@ -3057,6 +3072,7 @@ void noise_est_ivas_fx( /*-----------------------------------------------------------------* * Background noise adaptation enable flag *-----------------------------------------------------------------*/ + /* if( ( (*st_harm_cor_cnt < 3*HC_CNT_SLOW ) && ( ( non_sta > th_sta ) || @@ -3088,7 +3104,6 @@ void noise_est_ivas_fx( LepsP = extract_l( div_s( num, den ) ); // Q15+exp-exp2 LepsP = L_shr( LepsP, add( sub( exp, exp2 ), 4 ) ); // Q11 - test(); test(); test(); @@ -3128,9 +3143,11 @@ void noise_est_ivas_fx( move16(); move16(); } + /*-----------------------------------------------------------------* * Stereo classifier - save raw aEn *-----------------------------------------------------------------*/ + IF( hStereoClassif != NULL ) { /* @@ -3161,14 +3178,11 @@ void noise_est_ivas_fx( move16(); } - /* Additional NNE detectors */ - /* comb_ahc_epsP = max(max(st->act_pred, st->lt_haco_ev), epsP_2_16_dlp); */ /* Q15 Q15 Q12 */ comb_ahc_epsP = s_max( shr( s_max( hNoiseEst->act_pred_fx, hNoiseEst->lt_haco_ev_fx ), 15 - 12 ), epsP_2_16_dlp ); /* Q12 */ - /* comb_hcm_epsP = max(max(st->lt_haco_ev,epsP_2_16_dlp_max),epsP_0_2_ad_lp_max); */ /* Q15 Q12 Q12 */ comb_hcm_epsP = s_max( s_max( shr( hNoiseEst->lt_haco_ev_fx, 15 - 12 ), epsP_2_16_dlp_max ), epsP_0_2_ad_lp_max ); /* Q12 */ @@ -3222,7 +3236,6 @@ void noise_est_ivas_fx( move16(); /* Q0 */ } - /* ns_mask = non_sta < 1e5f; */ ns_mask = 0; move16(); @@ -3232,7 +3245,6 @@ void noise_est_ivas_fx( move16(); /* Q0 */ } - /* lt_haco_mask = st->lt_haco_ev < 0.5f; */ lt_haco_mask = 0; move16(); @@ -3251,7 +3263,6 @@ void noise_est_ivas_fx( move16(); /* Q0 */ } - /* SD_1 = ( (epsP_0_2_ad > 0.5f) && (epsP_0_2 > 7.95f) ); */ SD_1 = 0; move16(); @@ -3588,6 +3599,7 @@ void noise_est_ivas_fx( } } } + /*st->lt_aEn_zero = 0.2f * (st->aEn==0) + (1-0.2f) *st->lt_aEn_zero;*/ /* y(n+1)= alpha*tmp + (1-alpha)*y(n) */ L_tmp = 0; -- GitLab From f6f64fbe9a1ce2b0a87488baac48deda103335cb Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 23 Jan 2026 14:43:37 +0100 Subject: [PATCH 569/750] Change to num_src for scaling, since it includes LFE channel --- lib_rend/ivas_objectRenderer_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index bd638a9cb..8ba74dad8 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -435,7 +435,7 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( Word16 i; #ifdef FIX_BASOP_2358_SCALING_OOB - FOR( i = 0; i < hBinRendererTd->NumOfSrcs; ++i ) + FOR( i = 0; i < num_src; ++i ) #else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) #endif @@ -453,7 +453,7 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( } #ifdef FIX_BASOP_2358_SCALING_OOB - FOR( i = 0; i < hBinRendererTd->NumOfSrcs; ++i ) + FOR( i = 0; i < num_src; ++i ) #else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) #endif -- GitLab From 956a9c1ed38c089127eac88995a192eafa25b2e0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 14:46:22 +0100 Subject: [PATCH 570/750] formatting --- lib_com/prot_fx.h | 1 + lib_enc/ivas_core_pre_proc_front_fx.c | 2 ++ lib_enc/ivas_core_pre_proc_fx.c | 1 + lib_enc/ivas_front_vad_fx.c | 2 ++ 4 files changed, 6 insertions(+) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index d4e49bdf1..7b27a5233 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -11041,6 +11041,7 @@ void ivas_find_wsp_fx( const Word16 L_look /* i : look-ahead Q0*/ ); #endif + Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( Word16 *x, /* Q0 */ const Word16 nt, /* Q0 */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 147340d38..57e473239 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1085,11 +1085,13 @@ ivas_error pre_proc_front_ivas_fx( st->mem_wsp_q = *Q_new; move16(); move16(); + #ifndef FIX_2363_FIND_WSP ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 ); #else find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR ); #endif + Word16 Q_wsp = *Q_new; move16(); IF( st->vad_flag == 0 ) diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index bee6b73eb..7c1b8fe61 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1251,6 +1251,7 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ + #ifndef FIX_2363_FIND_WSP ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); #else diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index c2b31b87a..80aca8fb8 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -634,11 +634,13 @@ ivas_error front_vad_spar_fx( st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */ st->mem_wsp_q = Q_inp_12k8; move16(); + #ifndef FIX_2363_FIND_WSP ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 ); #else find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR ); #endif + IF( st->vad_flag == 0 ) { /* reset the OL pitch tracker memories during inactive frames */ -- GitLab From 2fb35a6e14375665f6c01d6375d376f4939843ec Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 23 Jan 2026 15:50:52 +0200 Subject: [PATCH 571/750] Fix basop issue 2357 by adding missing init to zero. --- lib_com/options.h | 1 + lib_dec/ivas_omasa_dec_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..ec51e47ff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index f06e1ec85..1659d4912 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -344,8 +344,16 @@ ivas_error ivas_omasa_data_open_fx( move16(); hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; move32(); +#ifdef FIX_BASOP_2357_OBJECT_EDIT_MSAN + hMasaIsmData->preprocEneTarget_e[band_idx] = 0; + move16(); +#endif hMasaIsmData->preprocEneRealized_fx[band_idx] = 0; move32(); +#ifdef FIX_BASOP_2357_OBJECT_EDIT_MSAN + hMasaIsmData->preprocEneRealized_e[band_idx] = 0; + move16(); +#endif } hMasaIsmData->objectsEdited = 0; -- GitLab From 9a69085215e70cc3697c60c34058e48fa252c7af Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 14:59:34 +0100 Subject: [PATCH 572/750] FIX_BASOP_2350_HARM_0B_BWE_2 --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_fx.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..16566b275 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,6 +106,7 @@ #define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ +#define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index a11a25b1b..bdb8c5d85 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -74,7 +74,9 @@ ivas_error acelp_core_dec_fx( const Word16 read_sid_info /* i : read SID info flag */ ) { +#ifndef FIX_BASOP_2350_HARM_0B_BWE_2 Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; +#endif Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ Word16 output_frame; /* frame length at output sampling freq. */ @@ -1896,6 +1898,9 @@ ivas_error acelp_core_dec_fx( st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); } +#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 + Word32 synth_fx[L_FRAME48k]; +#endif Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); syn_32_fx = syn_tmp_32_fx + L_SUBFR; @@ -2049,7 +2054,11 @@ ivas_error acelp_core_dec_fx( } } - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*tmp buffer for save_hb_synth_fx[] */, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); + +#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 + Copy_Scale_sig_32_16( synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0 +#endif /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) @@ -2197,6 +2206,9 @@ ivas_error acelp_core_dec_fx( Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ } +#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 + Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 +#endif st->Q_syn2 = 0; move16(); } @@ -2217,6 +2229,9 @@ ivas_error acelp_core_dec_fx( IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { +#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 + hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); +#else IF( EQ_16( st->element_mode, EVS_MONO ) ) { #ifndef FIX_BASOP_2350_HARM_0B_BWE @@ -2235,6 +2250,7 @@ ivas_error acelp_core_dec_fx( #endif Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); } +#endif } ELSE { @@ -2352,6 +2368,7 @@ ivas_error acelp_core_dec_fx( } } +#ifndef FIX_BASOP_2350_HARM_0B_BWE_2 IF( NE_16( st->element_mode, EVS_MONO ) ) { IF( save_hb_synth_fx16 != NULL ) @@ -2360,7 +2377,7 @@ ivas_error acelp_core_dec_fx( } Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 } - +#endif pop_wmops(); return error; } -- GitLab From e672c51d6f075ec360238fba5685bc01434bea2b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 15:22:30 +0100 Subject: [PATCH 573/750] fix loop initialization --- lib_enc/ivas_mct_enc_mct_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 5329e3c2f..40882b1eb 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -103,9 +103,9 @@ void getChannelEnergies_fx( nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); move32(); - FOR( n = 0; n < nSubframes; n++ ) -#else FOR( n = 1; n < nSubframes; n++ ) +#else + FOR( n = 0; n < nSubframes; n++ ) #endif { #ifdef FIX_2356_GET_CHAN_ENERGIES -- GitLab From f21565c8cb0a93d023872d837b4763de7489cb72 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 15:37:55 +0100 Subject: [PATCH 574/750] simplify patch --- lib_enc/ivas_mct_enc_mct_fx.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 40882b1eb..84bc74dd9 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -88,31 +88,24 @@ void getChannelEnergies_fx( gb = find_guarded_bits_fx( (Word32) L_subframe ); +#ifndef FIX_2356_GET_CHAN_ENERGIES sum2_e = st->hTcxEnc->spectrum_e[0]; move16(); +#endif nrg[ch] = 0; move32(); - #ifdef FIX_2356_GET_CHAN_ENERGIES - /* move first loop iteration outside of loop - we need a proper initialization of nrg_e[ch] based on sum2_e, which is calculated in first loop iteration */ - sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[0], L_subframe, &sum2_e, gb ); // 31 - sum2_e - - nrg_e[ch] = sum2_e; /* only needed in first iteration */ + nrg_e[ch] = 0; /* if the mantissa is 0, the exponent gets set to sum2_e inside BASOP_Util_Add_Mant32Exp() */ move16(); +#endif - nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); - move32(); - - FOR( n = 1; n < nSubframes; n++ ) -#else FOR( n = 0; n < nSubframes; n++ ) -#endif { #ifdef FIX_2356_GET_CHAN_ENERGIES sum2_e = st->hTcxEnc->spectrum_e[n]; move16(); -#endif +#endif sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb ); // 31 - sum2_e nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); -- GitLab From 5344aa05738e9156945178bb5335124620efd8ac Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 17:13:07 +0100 Subject: [PATCH 575/750] initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 --- lib_com/options.h | 1 + lib_dec/dec_tcx_fx.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..e0dc54043 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2353_PTR_INIT /* FhG: basop issue 2353: initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 13cf9e9eb..e48affb21 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4021,6 +4021,9 @@ void decoder_tcx_ivas_fx( move16(); fUseTns = 0; /* flag that is set if TNS data is present */ move16(); +#ifdef FIX_2353_PTR_INIT + prm_sqQ = NULL; +#endif set16_fx( xn_buf_fx, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); -- GitLab From 037f0bc0aa581295b3ea8df2b7e3a50b112da58c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Jan 2026 18:51:08 +0100 Subject: [PATCH 576/750] FIX_2370_UNUSED_BUFFERS_CORE_ENC --- lib_com/options.h | 1 + lib_enc/ivas_core_enc_fx.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..f1f5baa53 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 3a19ad171..402d4085b 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -628,8 +628,9 @@ ivas_error ivas_core_enc_fx( * Postprocessing, BWEs and Updates *---------------------------------------------------------------------*/ +#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC Word16 tmp_input_fx[L_FRAME48k], tmp_old_input_fx[L_FRAME48k], q_inp[2]; - +#endif FOR( n = 0; n < n_CoreChannels; n++ ) { st = sts[n]; @@ -644,6 +645,7 @@ ivas_error ivas_core_enc_fx( move16(); } +#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame ); Copy( st->input_fx, tmp_input_fx, input_frame ); q_inp[0] = st->q_old_inp; @@ -654,6 +656,7 @@ ivas_error ivas_core_enc_fx( move16(); st->q_old_inp = -1; move16(); +#endif /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching @@ -694,6 +697,21 @@ ivas_error ivas_core_enc_fx( * SWB(FB) BWE encoding *---------------------------------------------------------------------*/ +#ifdef FIX_2370_UNUSED_BUFFERS_CORE_ENC + Word16 q_inp_orig; + q_inp_orig = st->q_inp; + move16(); + test(); + IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL ) + { + st->q_inp = -1; + st->q_old_inp = -1; + move16(); + move16(); + Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( st->q_inp, q_inp_orig ) ); + } +#endif + new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; new_swb_speech_fx_16 = new_swb_speech_buffer_fx_16 + STEREO_DFT_OVL_MAX; set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); @@ -788,6 +806,15 @@ ivas_error ivas_core_enc_fx( Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 +#ifdef FIX_2370_UNUSED_BUFFERS_CORE_ENC + IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL ) + { + Scale_sig( st->input_fx, input_frame, sub( q_inp_orig, st->q_inp ) ); + st->q_inp = q_inp_orig; + move16(); + } + +#endif /*---------------------------------------------------------------------* * SWB DTX/CNG encoding *---------------------------------------------------------------------*/ @@ -842,6 +869,7 @@ ivas_error ivas_core_enc_fx( } } +#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame ); Copy( tmp_input_fx, st->input_fx, input_frame ); st->q_old_inp = q_inp[0]; @@ -849,6 +877,7 @@ ivas_error ivas_core_enc_fx( st->q_inp = q_inp[1]; move16(); +#endif /*---------------------------------------------------------------------* * Common updates *---------------------------------------------------------------------*/ -- GitLab From 368bc9b742ed9499a1a9f12bc493f5db506189c3 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 23 Jan 2026 20:11:24 +0200 Subject: [PATCH 577/750] Fix basop issue 2354 by initializing diffusenesss Q-value to Q30. --- lib_com/options.h | 1 + lib_rend/ivas_dirac_rend_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..7b216f4eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 7eb2f83d6..024fa63a1 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -253,6 +253,10 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( move16(); hSpatParamRendCom->numIsmDirections = 0; move16(); +#ifdef FIX_2354_MSAN_DIFF_Q_VALUE + hSpatParamRendCom->q_diffuseness_vector = Q30; + move16(); +#endif } /*-----------------------------------------------------------------* -- GitLab From 0487aa5e1cb0d966df3da0b97391c5632567bbbb Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 26 Jan 2026 09:34:51 +0100 Subject: [PATCH 578/750] remove obsolete unused ISAR-related fcns --- lib_com/options.h | 1 + lib_isar/isar_PerceptualModel.c | 11 ++++++++++- lib_isar/isar_lcld_prot.h | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..b60412396 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolvy: basop issue 2371: remove unused ISAR-related functions */ /* #################### End BE switches ################################## */ diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index bed0d5630..aa0e8bd09 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -112,7 +112,6 @@ static inline Word32 LogAdd( return iRetVal; } - /*------------------------------------------------------------------------------------------* * Function PerceptualModel() * @@ -175,6 +174,9 @@ void PerceptualModel_fx( return; } + +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS + /*------------------------------------------------------------------------------------------* * Function PerceptualModel() * @@ -232,6 +234,8 @@ void PerceptualModel( return; } +#endif + /*------------------------------------------------------------------------------------------* * Function PerceptualModelStereo() @@ -239,6 +243,8 @@ void PerceptualModel( * *------------------------------------------------------------------------------------------*/ +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS + void PerceptualModelStereo( const Word32 iMaxQuantBands, const Word32 *piMSFlags, @@ -348,6 +354,9 @@ void PerceptualModelStereo( return; } + +#endif + void PerceptualModelStereo_fx( const Word32 iMaxQuantBands, const Word32 *piMSFlags, diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index 56dd08f6b..fdb4d840a 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -175,12 +175,14 @@ Word32 CountMSBits( * PereptualModel prototypes *----------------------------------------------------------------------------------*/ +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS extern void PerceptualModel( const Word32 iMaxQuantBands, const Word32 *piRMSEnvelope, Word32 *piExcitation, Word32 *piSMR ); +#endif extern void PerceptualModel_fx( const Word32 iMaxQuantBands, @@ -200,6 +202,7 @@ extern void PerceptualModelStereo_fx( Word32 *piSMR1 ); +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS extern void PerceptualModelStereo( const Word32 iMaxQuantBands, const Word32 *piMSFlags, @@ -210,7 +213,7 @@ extern void PerceptualModelStereo( Word32 *piSMR0, Word32 *piSMR1 ); - +#endif /*----------------------------------------------------------------------------------* * PredEncoder/PredDecoder prototypes -- GitLab From 5b684737087d82df8839aa2d2c75f20916af30d4 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 26 Jan 2026 10:10:03 +0100 Subject: [PATCH 579/750] improve warning and error messages --- lib_isar/isar_RMSEnvGrouping.c | 8 ++++---- lib_isar/isar_lcld_encoder.c | 12 ++++++------ lib_isar/isar_lcld_prot.h | 3 ++- lib_isar/lib_isar_post_rend.c | 2 -- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index c5a3b1ded..371f34230 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -867,8 +867,8 @@ static void LimitRMSEnvelope( IF( GT_32( iDelta, iRMSDeltaMax ) ) { -#ifdef DEBUG_VERBOSE - printf( "WARNING RMS envelope delta limited\n" ); +#ifdef DEBUGGING + printf( "Warning: RMS envelope delta limited!\n" ); #endif piRMSEnvelope[iBand] = L_add( L_sub( iDelta, iRMSDeltaMax ), piRMSEnvelope[iBand] ); } @@ -887,8 +887,8 @@ static void LimitRMSEnvelope( IF( LT_32( iDelta, iRMSDeltaMin ) ) { -#ifdef DEBUG_VERBOSE - printf( "WARNING RMS envelope delta limited\n" ); +#ifdef DEBUGGING + printf( "Warning: RMS envelope delta limited!\n" ); #endif piRMSEnvelope[iBand] = L_add( piRMSEnvelope[iBand], L_sub( iRMSDeltaMin, iDelta ) ); } diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 13dbb1a83..18a1a6650 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -135,6 +135,7 @@ static Word32 UnQuantize_fx( } return fVal_fx; } + static void PackReal( const Word32 iChannels, const Word32 iNumBlocks, @@ -159,6 +160,7 @@ static void PackReal( } } } + /*------------------------------------------------------------------------------------------* * Function CreateLCLDEncoder() * @@ -770,6 +772,7 @@ Word32 EncodeLCLDFrame( return 0; } +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS /*------------------------------------------------------------------------------------------* * Function GetNumGroups() * @@ -780,7 +783,7 @@ Word32 GetNumGroups( LCLDEncoder *psLCLDEncoder ) { return psLCLDEncoder->piNumGroups[0]; } - +#endif /*------------------------------------------------------------------------------------------* * Local functions @@ -1850,7 +1853,7 @@ static Word32 WriteAllocInformation( IF( LT_32( iAllocOffset, MIN_ALLOC_OFFSET ) || GT_32( iAllocOffset, MAX_ALLOC_OFFSET ) ) { - printf( "Serious error\n" ); + printf( "Error in WriteAllocInformation() - iAllocOffset has incorrect value: %d!\n", iAllocOffset ); } ISAR_SPLIT_REND_BITStream_write_int32( pBits, L_sub( iAllocOffset, MIN_ALLOC_OFFSET ), ALLOC_OFFSET_BITS ); @@ -2090,10 +2093,7 @@ static Word32 ComputeAllocation( IF( LE_32( *piAllocOffset, MIN_ALLOC_OFFSET ) && GT_32( iBitsUsed, iAvailableBits ) ) { -#ifdef DEBUG_VERBOSE - printf( "Frame can not be coded with the number of bits available\n" ); -#endif - // iLastError = ENC_ERROR_STREAM_FAILURE; + printf( "Error in ComputeAllocation() - frame can not be coded with the number of bits available!\n" ); return -1; } ELSE IF( GE_32( *piAllocOffset, MAX_ALLOC_OFFSET ) && LT_32( iBitsUsed, iAvailableBits ) ) diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index fdb4d840a..073838f33 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -65,10 +65,11 @@ Word32 EncodeLCLDFrame( Word16 *q_final ); +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS Word32 GetNumGroups( LCLDEncoder *psLCLDEncoder ); - +#endif typedef struct LCLD_DECODER LCLDDecoder; diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 7292f1a66..544ff25ca 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1062,7 +1062,6 @@ ivas_error ISAR_POST_REND_FeedInputAudio( IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { - printf( "Foo\n" ); return error; } @@ -1185,7 +1184,6 @@ ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream( IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { - printf( "Goo\n" ); return error; } -- GitLab From 4bb07b2e7f53890298dbdd4c5a6b7e5ee94adf8f Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 26 Jan 2026 10:21:57 +0100 Subject: [PATCH 580/750] improve formatting, name conventions --- lib_isar/isar_RMSEnvGrouping.c | 2 +- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/isar_lcld_encoder.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 371f34230..ab6237a53 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -49,7 +49,7 @@ * *-------------------------------------------------------------------*/ -Word32 Inv_grp_length[17] = { +static const Word32 Inv_grp_length[17] = { // Q31 0, 2147483647, diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 5f41dd707..d4d6074f8 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1563,7 +1563,7 @@ static Word32 ReadMSInformation( } ELSE { - printf( "ERROR UNSUPPORTED MS MODE\n" ); + printf( "Error in ReadMSInformation() - unsupported MS mode information!\n" ); } return iBitsRead; diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 18a1a6650..8f6ed3983 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -136,7 +136,7 @@ static Word32 UnQuantize_fx( return fVal_fx; } -static void PackReal( +static void PackReal_fx( const Word32 iChannels, const Word32 iNumBlocks, Word32 ***pppfReal, @@ -591,7 +591,7 @@ Word32 EncodeLCLDFrame( assert( available_bits <= pBits->buf_len * 8 ); IF( EQ_32( psLCLDEncoder->iRealOnlyOut, 1 ) ) { - PackReal( psLCLDEncoder->iChannels, psLCLDEncoder->iNumBlocks * 2, pppfLCLDReal_fx, pppfLCLDImag_fx ); + PackReal_fx( psLCLDEncoder->iChannels, psLCLDEncoder->iNumBlocks * 2, pppfLCLDReal_fx, pppfLCLDImag_fx ); } /* Do MS calc here */ IF( EQ_32( psLCLDEncoder->iChannels, 2 ) ) -- GitLab From 73b0e0f5ed0404f2093f9334790ca8a9b9da0b19 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 26 Jan 2026 10:22:44 +0100 Subject: [PATCH 581/750] remove unused functions --- lib_isar/isar_PredDecoder.c | 3 ++- lib_isar/isar_lcld_prot.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index 0f8ac0f0a..9023009ef 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -359,7 +359,7 @@ Word16 ReadPredictors_fx( return iBitsRead; } - +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* PLC_IMPROVEMENT */ void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ) @@ -376,6 +376,7 @@ void SetDecodingPassed( return; } +#endif Word32 AnyDecodingUnresolved( diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index 073838f33..16acd9716 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -346,9 +346,11 @@ Word32 **GetDecodingFailedPrevStatus( LCLDDecoder *psLCLDDecoder ); +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ); +#endif void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder -- GitLab From 82c404f64eae736aaaacb3fa3c09545df4182183 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 26 Jan 2026 10:34:14 +0100 Subject: [PATCH 582/750] clear debugging message --- lib_isar/lib_isar_post_rend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 544ff25ca..04e80dc61 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -773,7 +773,6 @@ ivas_error ISAR_POST_REND_SetInputGain( IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { - printf( "Hoo\n" ); return error; } -- GitLab From df08d1a47022bf77489d024230b7143681cdcdd3 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 26 Jan 2026 12:37:33 +0100 Subject: [PATCH 583/750] remove LogAdd() - duplicate --- lib_isar/isar_PerceptualModel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index aa0e8bd09..cbc878b7c 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -83,6 +83,7 @@ static inline Word16 LogAdd_fx( return iRetVal; } +#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS /*------------------------------------------------------------------------------------------* * Function LogAdd() @@ -112,6 +113,8 @@ static inline Word32 LogAdd( return iRetVal; } +#endif + /*------------------------------------------------------------------------------------------* * Function PerceptualModel() * -- GitLab From a45433772b0ff40ac1f9cfb14859a8935b96af12 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Mon, 26 Jan 2026 12:37:59 +0100 Subject: [PATCH 584/750] typo --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b60412396..f92f8221a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,7 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ -#define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolvy: basop issue 2371: remove unused ISAR-related functions */ +#define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */ /* #################### End BE switches ################################## */ -- GitLab From a154fc29fc3216833b7d91a5d650ebc281a3a0fb Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 26 Jan 2026 13:31:11 +0100 Subject: [PATCH 585/750] issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX --- lib_com/options.h | 1 + lib_dec/ivas_stereo_mdct_core_dec_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..455ba816d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2352_COPY_AQ_IN_TCX /* FhG: basop issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index c1dc964af..118baa38b 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -371,9 +371,17 @@ void stereo_mdct_core_dec_fx( } } +#ifdef FIX_2352_COPY_AQ_IN_TCX + FOR( ch = 0; ch < nChannels; ch++ ) +#else FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) +#endif { +#ifdef FIX_2352_COPY_AQ_IN_TCX + Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], nSubframes[ch] * M, sub( Q16, Q12 ) ); /* Q16 */ +#else Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ +#endif } /*--------------------------------------------------------------------------------* -- GitLab From bbfd08781df8d9f3845607e73c4a91025abb8406 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 13:50:27 +0100 Subject: [PATCH 586/750] FIX_2376_FIX_USAN_PRE_PROC --- lib_com/options.h | 1 + lib_enc/ivas_core_pre_proc_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..fe2316038 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2376_FIX_USAN_PRE_PROC /* VA: basop issue 2376: Resolve "USAN: SEGV in ivas_compute_core_buffers_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index a6e8966df..142931191 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -786,7 +786,11 @@ ivas_error ivas_compute_core_buffers_fx( #endif Word16 *preemp_start_idx = NULL; #ifdef FIX_2344_ALIGN_PREPROC +#ifdef FIX_2376_FIX_USAN_PRE_PROC + Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k + L_FILT16k], max_32; +#else Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; +#endif #else Word32 sig_out[960], max_32; #endif -- GitLab From 53cc344bae42154f64d02b5b4f73447b9c9f9cbc Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 14:50:34 +0100 Subject: [PATCH 587/750] FIX_2379_REMOVE_previoussynth_fx_32 --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_fx.c | 4 ++++ lib_dec/core_switching_dec_fx.c | 10 +++++++++- lib_dec/init_dec_fx.c | 2 ++ lib_dec/ivas_core_dec_fx.c | 6 ++++-- lib_dec/stat_dec.h | 2 ++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..02a324541 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,6 +119,7 @@ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index a11a25b1b..a0eb8e629 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2103,7 +2103,11 @@ ivas_error acelp_core_dec_fx( } /* save synthesis - needed in case of core switching */ +#ifdef FIX_2379_REMOVE_previoussynth_fx_32 + Copy_Scale_sig_32_16( synth_fx, st->previoussynth_fx, output_frame, 0 ); // Q0 +#else Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 +#endif } ELSE { diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 3bfcb453d..165822a27 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1596,9 +1596,13 @@ ivas_error core_switching_pre_dec_fx( move16(); } } - ELSE + ELSE { +#ifdef FIX_2379_REMOVE_previoussynth_fx_32 + frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); /*Q-0*/ +#else fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ +#endif st->lp_gainp_fx = 0; move16(); st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ @@ -1681,7 +1685,11 @@ ivas_error core_switching_pre_dec_fx( set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); st->last_coder_type = GENERIC; move16(); +#ifdef FIX_2379_REMOVE_previoussynth_fx_32 + frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); /*Q-0*/ +#else fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ +#endif st->lp_gainp_fx = 0; move16(); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index e031fd696..a3e2c48e3 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -436,7 +436,9 @@ ivas_error init_decoder_fx( set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); +#ifndef FIX_2379_REMOVE_previoussynth_fx_32 set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k ); +#endif IF( st_fx->element_mode == EVS_MONO ) { diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index b71f0df7d..6bd91a2f7 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -446,8 +446,9 @@ ivas_error ivas_core_dec_fx( move16(); move16(); +#ifndef FIX_2379_REMOVE_previoussynth_fx_32 Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 - +#endif IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) { return error; @@ -557,8 +558,9 @@ ivas_error ivas_core_dec_fx( } } +#ifndef FIX_2379_REMOVE_previoussynth_fx_32 Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0 - +#endif test(); test(); IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 429070d85..a1646e82e 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1258,7 +1258,9 @@ typedef struct Decoder_State Word16 last_L_frame_ori; Word16 previoussynth_fx[L_FRAME48k]; +#ifndef FIX_2379_REMOVE_previoussynth_fx_32 Word32 previoussynth_fx_32[L_FRAME48k]; +#endif Word16 old_synth_sw_fx[NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS )]; Word16 delay_buf_out_fx[HQ_DELTA_MAX * HQ_DELAY_COMP]; /*Q0*/ Word32 delay_buf_out32_fx[HQ_DELTA_MAX * HQ_DELAY_COMP]; /*Q11*/ -- GitLab From 8b9c3c909276ec0143a02b684a503c41e0590880 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 14:56:26 +0100 Subject: [PATCH 588/750] clang-format --- lib_dec/core_switching_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 165822a27..b8fad90c6 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1596,7 +1596,7 @@ ivas_error core_switching_pre_dec_fx( move16(); } } - ELSE + ELSE { #ifdef FIX_2379_REMOVE_previoussynth_fx_32 frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); /*Q-0*/ @@ -1688,7 +1688,7 @@ ivas_error core_switching_pre_dec_fx( #ifdef FIX_2379_REMOVE_previoussynth_fx_32 frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); /*Q-0*/ #else - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif st->lp_gainp_fx = 0; -- GitLab From d36fbf2011e4546fc6cd4925156d31359a764d98 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 16:15:48 +0100 Subject: [PATCH 589/750] updt --- lib_com/ivas_prot_fx.h | 8 +++++++ lib_com/prot_fx.h | 14 ++++++++----- lib_dec/acelp_core_dec_fx.c | 22 +++++++++++++++----- lib_dec/hq_core_dec_fx.c | 38 ++++++++++++++++++++++++++++++++-- lib_dec/ivas_core_dec_fx.c | 16 ++++++++++++-- lib_dec/ivas_tcx_core_dec_fx.c | 20 +++++++++++++++--- 6 files changed, 101 insertions(+), 17 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 31dfb1ea2..9f2eb0d4a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1588,8 +1588,12 @@ void ivas_hq_core_dec_fx( const Word16 output_frame, /* i : output frame length */ const Word16 hq_core_type, /* i : HQ core type */ const Word16 core_switching_flag, /* i : ACELP->HQ switching frame flag */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_32_fx /* o : synthesis @internal_Fs, Q11 */ +#else Word16 output[], Word16 *Q_output +#endif ); void ivas_HQ_FEC_Mem_update_fx( @@ -2068,7 +2072,11 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( void stereo_tcx_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ const FRAME_MODE frameMode, /* i : Decoder frame mode */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *signal_out_32_fx, /* o : synthesis @internal_Fs, Q11 */ +#else Word16 *signal_out, /* o : synthesis @internal_Fs, Q0 */ +#endif Word16 *signal_outFB, /* o : synthesis @output_Fs, Q0 */ Word16 pitch_buf[], /* o : floating pitch for each subframe, Q6 */ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9e56f4868..66349adcc 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10199,13 +10199,17 @@ Word16 swb_bwe_dec_fx32( ); ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs */ - Word16 synth_fx16[], /* o : synthesis */ + Decoder_State *st, /* i/o: decoder state structure */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ #else - Word16 save_hb_synth_fx16[], /* o : HB synthesis */ + Word16 output_fx[], /* o : synthesis @internal Fs */ +#endif + Word16 synth_fx16[], /* o : synthesis */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else + Word16 save_hb_synth_fx16[], /* o : HB synthesis */ #endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ Word16 *voice_factors_fx, /* o : voicing factors */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 7d6ac254d..366480956 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -52,13 +52,17 @@ *-------------------------------------------------------------------*/ ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ - Word16 synth_fx16[], /* o : synthesis Q_syn2*/ + Decoder_State *st, /* i/o: decoder state structure */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ #else - Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ + Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ +#endif + Word16 synth_fx16[], /* o : synthesis Q_syn2*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else + Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ #endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ @@ -214,7 +218,11 @@ ivas_error acelp_core_dec_fx( Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/ } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + set32_fx( output_fx32, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ +#else set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ +#endif set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ /* CN generation done in DFT domain */ @@ -2209,7 +2217,11 @@ ivas_error acelp_core_dec_fx( Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 IF( st->element_mode > EVS_MONO ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig_16_32_no_sat( psyn_fx, output_fx32, L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 +#else Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ +#endif } st->Q_syn2 = 0; diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index e34527da0..f9dac288e 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -468,8 +468,13 @@ void ivas_hq_core_dec_fx( const Word16 output_frame, /* i : output frame length Q0*/ const Word16 hq_core_type, /* i : HQ core type Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching frame flag Q0*/ - Word16 output[], /* Q_ouput */ - Word16 *Q_output ) +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_32_fx /* o : synthesis @internal_Fs, Q11 */ +#else + Word16 output[], /* Q_ouput */ + Word16 *Q_output +#endif +) { Word16 num_bits, is_transient, hqswb_clas, inner_frame; Word16 i, j, flag_uv, num_Sb, nb_sfm; @@ -504,7 +509,19 @@ void ivas_hq_core_dec_fx( Word16 mdctWindowLength; Word16 mdctWindowLengthFB; Word16 tmp_e; +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 tmp_out[L_FRAME48k]; +#else + Word16 output[L_FRAME48k]; + Word16 Q_output; + + Q_output = 0; + move16(); + *Q_synth = 0; + move16(); + st_fx->Q_syn_factor = 0; + move16(); +#endif /*-------------------------------------------------------------------------- * Initializations @@ -886,7 +903,11 @@ void ivas_hq_core_dec_fx( move16(); Inverse_Transform( t_audio_q, &Q_audio, wtda_audio_LB, is_transient, st_fx->L_frame, inner_frame, st_fx->element_mode ); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Q_output = Q_audio; +#else *Q_output = Q_audio; +#endif move16(); } @@ -912,7 +933,11 @@ void ivas_hq_core_dec_fx( IF( st_fx->element_mode > EVS_MONO ) { /* LB synthesis for potential switch to ACELP */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + window_ola_fx( wtda_audio_LB, output, &Q_output, hHQ_core->old_out_LB_fx, &hHQ_core->Q_old_wtda_LB, L_FRAME16k, st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx ); +#else window_ola_fx( wtda_audio_LB, output, Q_output, hHQ_core->old_out_LB_fx, &hHQ_core->Q_old_wtda_LB, L_FRAME16k, st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx ); +#endif } test(); test(); @@ -974,12 +999,21 @@ void ivas_hq_core_dec_fx( Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[nbsubfr + 2], nbsubfr ); /* Q14 */ set16_fx( &st_fx->mem_pitch_gain[2], 0, nbsubfr ); } + /* Move LB excitation to old_exc memory in case of switch HQ->ACELP */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig( output, st_fx->old_exc_fx + sub( L_EXC_MEM_DEC, st_fx->L_frame ), st_fx->L_frame, negate( Q_output ) ); /* Q0 */ + + Copy_Scale_sig_16_32_DEPREC( output, output_32_fx, L_FRAME48k, sub( Q11, Q_output ) ); // Q11 + st_fx->Q_syn_factor = s_min( 0, s_min( *Q_synth, Q_output ) ); +#else IF( st_fx->element_mode > EVS_MONO ) { Copy_Scale_sig( output, tmp_out, st_fx->L_frame, negate( *Q_output ) ); /* Q0 */ Copy( tmp_out, st_fx->old_exc_fx + sub( L_EXC_MEM_DEC, st_fx->L_frame ), st_fx->L_frame ); /* Q0 */ } +#endif + return; } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index b1cb8a071..37d9520cd 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -524,7 +524,7 @@ ivas_error ivas_core_dec_fx( move16(); #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_32_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = acelp_core_dec_fx( st, output_32_fx[n], synth_16_fx[n], save_hb_synth_32_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) #endif @@ -532,8 +532,10 @@ ivas_error ivas_core_dec_fx( return error; } +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 Scale_sig( output_16_fx[n], L_FRAME48k, negate( st->Q_syn2 ) ); // Q0 +#endif IF( st->cldfbAna ) { scale_sig32( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, Q10 - Q11 ); /* 9 * (Word16)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f) , Q10 */ @@ -603,9 +605,13 @@ ivas_error ivas_core_dec_fx( move32(); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + stereo_tcx_core_dec_fx( st, frameMode[n], output_32_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); +#else stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], output_frame, sub( Q11, st->Q_syn_factor ) ); // Q11 +#endif IF( st->hTcxDec ) { @@ -623,6 +629,11 @@ ivas_error ivas_core_dec_fx( IF( EQ_16( st->core, HQ_CORE ) ) { /* HQ core decoder */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + ivas_hq_core_dec_fx( st, synth_16_fx[n], &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_32_fx[n] ); + + Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor +#else Word16 Q_output; Q_output = 0; @@ -638,6 +649,7 @@ ivas_error ivas_core_dec_fx( st->Q_syn_factor = s_min( 0, s_min( Q_synth, Q_output ) ); Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor Scale_sig( output_16_fx[n], L_FRAME48k, sub( st->Q_syn_factor, Q_output ) ); // st->Q_syn_factor +#endif } /*---------------------------------------------------------------------* @@ -1153,7 +1165,7 @@ ivas_error ivas_core_dec_fx( #ifdef HARM_NON_LINEARITY Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 45588e7cc..3c917978c 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -188,9 +188,13 @@ void stereo_tcx_init_dec_fx( *-------------------------------------------------------------------*/ void stereo_tcx_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const FRAME_MODE frameMode, /* i : Decoder frame mode */ - Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const FRAME_MODE frameMode, /* i : Decoder frame mode */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *signal_out_32_fx, /* o : synthesis @internal_Fs, Q11*/ +#else + Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0*/ +#endif Word16 *signal_outFB_fx, /* o : synthesis @output_Fs, Q0*/ Word16 pitch_buf_fx[], /* o : Word16 pitch for each subframe, Q6*/ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ @@ -232,6 +236,9 @@ void stereo_tcx_core_dec_fx( Word32 psd_fx[L_FRAME16k]; Word32 psd_part_fx[NPART_SHAPING]; Word16 psd_part_e; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 signal_out_fx[L_FRAME48k]; +#endif TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; @@ -877,7 +884,9 @@ void stereo_tcx_core_dec_fx( } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word32 signal_out_32_fx[L_FRAME48k]; +#endif Word16 exp; Copy_Scale_sig_16_32_no_sat( signal_out_fx, signal_out_32_fx, st->hFdCngDec->hFdCngCom->frameSize, Q6 ); generate_masking_noise_ivas_fx( signal_out_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); @@ -893,6 +902,11 @@ void stereo_tcx_core_dec_fx( } } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 output_frame = extract_l( Mpy_32_16_1( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); + Copy_Scale_sig_16_32_DEPREC( signal_out_fx, signal_out_32_fx, output_frame, sub( Q11, st->Q_syn_factor ) ); +#endif + pop_wmops(); return; } -- GitLab From 2f5af4899fa03e66ac47fdf1c50959d6d70bd4d8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 16:33:24 +0100 Subject: [PATCH 590/750] remove buffer output_16_fx[][] --- lib_com/ivas_prot_fx.h | 4 ++++ lib_com/options.h | 1 + lib_dec/ivas_core_dec_fx.c | 19 +++++++++++++++---- lib_dec/swb_bwe_dec_fx.c | 30 +++++++++++++++++++++++++++--- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 9f2eb0d4a..281599664 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1892,7 +1892,11 @@ void GenShapedWBExcitation_ivas_fx( /* o : Q_syn_hb*/ Word16 ivas_wb_bwe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ +#else const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ + #endif Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ diff --git a/lib_com/options.h b/lib_com/options.h index 1852ffa6d..414eaaa40 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,6 +108,7 @@ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ +//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 37d9520cd..c4ecdffcd 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -93,7 +93,9 @@ ivas_error ivas_core_dec_fx( ivas_error error; Word32 L_tmp; Word16 Q_synth; +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Word16 output_16_fx[CPE_CHANNELS][L_FRAME48k]; +#endif Word16 hb_synth_16_fx[CPE_CHANNELS][L_FRAME48k]; Word16 synth_16_fx[CPE_CHANNELS][L_FRAME48k]; Word32 synth_32_fx[CPE_CHANNELS][L_FRAME48k]; @@ -467,8 +469,9 @@ ivas_error ivas_core_dec_fx( * HQ core decoding *---------------------------------------------------------------------*/ +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE set16_fx( output_16_fx[n], 0, L_FRAME48k ); /* this is needed for instances like L_norm_arr( p_output_fx[i], L_FRAME48k ) */ - +#endif IF( st->core == ACELP_CORE ) { /* ACELP core decoder */ @@ -1023,8 +1026,10 @@ ivas_error ivas_core_dec_fx( Q_synth_fx = Q_synth; move16(); +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 +#endif + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 test(); test(); test(); @@ -1043,7 +1048,11 @@ ivas_error ivas_core_dec_fx( ELSE IF( EQ_16( st->extl, WB_BWE ) && st->bws_cnt == 0 ) { /* WB BWE decoder */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_32_fx[n], synth_16_fx[n], hb_synth_16_fx[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); +#else Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_16_fx[n], synth_16_fx[n], hb_synth_16_fx[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); +#endif } /* Memories Re-Scaling */ @@ -1051,7 +1060,9 @@ ivas_error ivas_core_dec_fx( { Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 } - Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE + Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 +#endif Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11 IF( hBWE_FD != NULL ) @@ -1165,7 +1176,7 @@ ivas_error ivas_core_dec_fx( #ifdef HARM_NON_LINEARITY Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 1845b32e4..c1cb1ed5f 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -355,8 +355,12 @@ Word16 WB_BWE_gain_deq_fx( /* o : Q_syn_hb */ Word16 ivas_wb_bwe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ + Decoder_State *st_fx, /* i/o: decoder state structure */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ +#else + const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ +#endif Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ @@ -370,6 +374,10 @@ Word16 ivas_wb_bwe_dec_fx( Word16 ysynth_fx[L_FRAME48k]; Word16 Q_syn, exp, Q_syn_hb; Word32 L_wtda_synth_fx[2 * L_FRAME48k], ysynth_32[L_FRAME48k], t_audio32_tmp[L_FRAME48k]; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 output[L_FRAME48k]; + Word16 Q_input, sf; +#endif Word16 scl, new_input_fx_exp; Word16 i; FD_BWE_DEC_HANDLE hBWE_FD; @@ -379,8 +387,20 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD = st_fx->hBWE_FD; - /* MDCT of the core synthesis signal */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + sf = getScaleFactor32( output_fx32, L_FRAME48k ); + + Q_input = 0; + move16(); + if ( LT_16( sf, 5 ) ) + { + Q_input = sub( sf, 5 ); + } + + Copy_Scale_sig_32_16( output_fx32, output, L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input +#endif + /* MDCT of the core synthesis signal */ new_input_fx_exp = *Qpost; move16(); test(); @@ -512,6 +532,10 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD->prev_Q_synth = Q_syn; move16(); +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig_16_32_no_sat( output, output_fx32, L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 + +#endif return Q_syn_hb; } -- GitLab From bd3b498ec72b503a18ec1d7e839e34cb05ace6ae Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 16:51:31 +0100 Subject: [PATCH 591/750] clang-format --- lib_com/prot_fx.h | 2 +- lib_dec/acelp_core_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 66349adcc..c956b584d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10201,7 +10201,7 @@ Word16 swb_bwe_dec_fx32( ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ #else Word16 output_fx[], /* o : synthesis @internal Fs */ #endif diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 366480956..1dc3fc087 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -221,7 +221,7 @@ ivas_error acelp_core_dec_fx( #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING set32_fx( output_fx32, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #else - set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ + set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #endif set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ -- GitLab From 7be3ae7388cff6e63e37a6fc35eec17649a971d0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 17:29:41 +0100 Subject: [PATCH 592/750] fix buffer length --- lib_dec/acelp_core_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 1dc3fc087..f6fd79257 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2215,14 +2215,14 @@ ivas_error acelp_core_dec_fx( /* Copy output signal */ Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 - IF( st->element_mode > EVS_MONO ) - { #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Copy_Scale_sig_16_32_no_sat( psyn_fx, output_fx32, L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 + Copy_Scale_sig_16_32_no_sat( psyn_fx, output_fx32, st->L_frame, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 #else + IF( st->element_mode > EVS_MONO ) + { Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ -#endif } +#endif st->Q_syn2 = 0; move16(); -- GitLab From a46f371a962d0db7886b7c66acd56cc49fd25fb6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 17:37:04 +0100 Subject: [PATCH 593/750] cleaning --- lib_dec/swb_bwe_dec_fx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index c1cb1ed5f..025129585 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -532,10 +532,6 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD->prev_Q_synth = Q_syn; move16(); -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Copy_Scale_sig_16_32_no_sat( output, output_fx32, L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 - -#endif return Q_syn_hb; } -- GitLab From 72ef7fda3ec164adad14a4b507c4272329ec5b35 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 26 Jan 2026 17:38:55 +0100 Subject: [PATCH 594/750] init hs->flags during openCldfb(), to avoid reading of uninitialized memory --- lib_com/cldfb_evs_fx.c | 5 +++++ lib_com/options.h | 1 + 2 files changed, 6 insertions(+) diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c index a471d8f91..8e8b6565f 100644 --- a/lib_com/cldfb_evs_fx.c +++ b/lib_com/cldfb_evs_fx.c @@ -996,6 +996,11 @@ ivas_error openCldfb( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } +#ifdef FIX_2319_CLDFB_INIT_FLAGS + hs->flags = 0; + move16(); +#endif + hs->type = type; move16(); diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..d2da294f3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ +#define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ /* #################### End BE switches ################################## */ -- GitLab From ce6f0d99ec65011a307618ca9dd8b54bae8b6923 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:08:44 +0100 Subject: [PATCH 595/750] optimization --- lib_dec/ivas_core_dec_fx.c | 21 ++++++++++++++++----- lib_dec/swb_bwe_dec_fx.c | 28 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index c4ecdffcd..595d8b062 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -284,6 +284,9 @@ ivas_error ivas_core_dec_fx( } set16_fx( voice_factors_fx[n], 0, NB_SUBFR16k ); +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + set32_fx( output_32_fx[n], 0, L_FRAME48k ); +#endif set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k ); set16_fx( hb_synth_16_fx[n], 0, L_FRAME48k ); bwe_exc_extended_fx[n] = hb_synth_32_fx[n]; /* note: reuse the buffer */ @@ -848,7 +851,11 @@ ivas_error ivas_core_dec_fx( set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } - Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], output_frame, Q4 - Q11 ); // Q4 +#else + Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 +#endif /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ @@ -953,7 +960,11 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( st->delay_buf_out_fx, st->delay_buf_out32_fx, ( HQ_DELTA_MAX * HQ_DELAY_COMP ), sub( Q11, st->hHQ_core->Q_old_postdec ) ); // Q11 } - Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], output_frame, ( Q11 - Q4 ) ); // Q11 +#else + Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 +#endif /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -1029,7 +1040,7 @@ ivas_error ivas_core_dec_fx( #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input #endif - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 test(); test(); test(); @@ -1061,7 +1072,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 } #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE - Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 + Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 #endif Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11 @@ -1174,7 +1185,7 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); #ifdef HARM_NON_LINEARITY - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 025129585..61d5b3451 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -375,7 +375,7 @@ Word16 ivas_wb_bwe_dec_fx( Word16 Q_syn, exp, Q_syn_hb; Word32 L_wtda_synth_fx[2 * L_FRAME48k], ysynth_32[L_FRAME48k], t_audio32_tmp[L_FRAME48k]; #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word16 output[L_FRAME48k]; + Word16 output[L_FRAME16k]; Word16 Q_input, sf; #endif Word16 scl, new_input_fx_exp; @@ -387,25 +387,25 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD = st_fx->hBWE_FD; -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - sf = getScaleFactor32( output_fx32, L_FRAME48k ); - - Q_input = 0; - move16(); - if ( LT_16( sf, 5 ) ) - { - Q_input = sub( sf, 5 ); - } - - Copy_Scale_sig_32_16( output_fx32, output, L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input -#endif - /* MDCT of the core synthesis signal */ new_input_fx_exp = *Qpost; move16(); test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + sf = getScaleFactor32( output_fx32, st_fx->L_frame ); + + Q_input = 0; + move16(); + if ( LT_16( sf, 5 ) ) + { + Q_input = sub( sf, 5 ); + } + + Copy_Scale_sig_32_16( output_fx32, output, st_fx->L_frame, sub( Q_input, Q11 ) ); // Q_input + +#endif /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ /* IVAS_fmToDo: delay output[] by 1.25ms ? */ lerp( output, ysynth_fx, L_FRAME16k, st_fx->L_frame ); -- GitLab From f20a898e278157cc2e14f8b18701d241bdeb7ec3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:27:41 +0100 Subject: [PATCH 596/750] updt --- lib_com/prot_fx.h | 10 +++++++--- lib_dec/core_switching_dec_fx.c | 24 ++++++++++++++++++++---- lib_dec/ivas_core_dec_fx.c | 29 ++++++++++++++++++++--------- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c956b584d..f48e092a5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7654,9 +7654,13 @@ ivas_error core_switching_pre_dec_fx( Word16 *Q_olapBufferSynth2 ); ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ +#else + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ +#endif Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 3bfcb453d..cd30683fd 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -208,9 +208,13 @@ void bw_switching_pre_proc_fx( ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ +#else + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ +#endif Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ @@ -433,7 +437,11 @@ ivas_error core_switching_post_dec_fx( test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { - Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_fx, output_frame, Q10 - Q11 ); /* Q10 */ +#else + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#endif core_switch_lb_upsamp_fx( st_fx, output_fx ); } @@ -491,7 +499,11 @@ ivas_error core_switching_post_dec_fx( FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ +#else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ +#endif move32(); IF( LT_16( alpha, sub( 32767, tmp ) ) ) { @@ -540,7 +552,11 @@ ivas_error core_switching_post_dec_fx( FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ +#else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ +#endif move32(); IF( LT_16( alpha, sub( 32767, tmp ) ) ) { diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 595d8b062..4014d3ab2 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -851,12 +851,10 @@ ivas_error ivas_core_dec_fx( set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_32_fx[n], output_frame, Q4 - Q11 ); // Q4 -#else - Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 -#endif +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 +#endif /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ @@ -961,7 +959,10 @@ ivas_error ivas_core_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE + Scale_sig32( output_32_fx[n], output_frame, ( Q4 - Q11 ) ); // Q4 Scale_sig32( output_32_fx[n], output_frame, ( Q11 - Q4 ) ); // Q11 +#endif #else Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 #endif @@ -1005,8 +1006,18 @@ ivas_error ivas_core_dec_fx( * WB BWE decoding *---------------------------------------------------------------------*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE + Word16 Q_hb_synth_fx, Q_synth_fx; + Word16 Q_syn_hb; + + Q_hb_synth_fx = 0; + move16(); + Q_synth_fx = Q_synth; + move16(); +#else Word16 Q_input, Q_hb_synth_fx, Q_synth_fx; Word16 Q_syn_hb, sf; +#endif flaf_swb_tbe = 0; move16(); @@ -1024,6 +1035,7 @@ ivas_error ivas_core_dec_fx( move16(); } +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE sf = getScaleFactor32( output_32_fx[n], L_FRAME48k ); Q_input = 0; @@ -1037,10 +1049,9 @@ ivas_error ivas_core_dec_fx( Q_synth_fx = Q_synth; move16(); -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input #endif - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 test(); test(); test(); @@ -1072,7 +1083,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 } #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE - Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 + Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 #endif Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11 @@ -1185,7 +1196,7 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); #ifdef HARM_NON_LINEARITY - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif -- GitLab From e792d0e25d832dcda81284b39d4114146ef80ab0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:41:18 +0100 Subject: [PATCH 597/750] FIX_2280_REDUCTION_UNNECESSARY_SCALING2 --- lib_com/options.h | 1 + lib_com/prot_fx.h | 6 +++++- lib_dec/core_switching_dec_fx.c | 19 ++++++++++++++++++- lib_dec/ivas_core_dec_fx.c | 12 +++++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 414eaaa40..3286878a2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +109,7 @@ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ //#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f48e092a5..bb9ee20ac 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7661,7 +7661,11 @@ ivas_error core_switching_post_dec_fx( #else Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ #endif - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#else + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#endif const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index cd30683fd..ae7299d5e 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -207,6 +207,12 @@ void bw_switching_pre_proc_fx( } +/*---------------------------------------------------------------------* + * core_switching_post_dec() + * + * Postprocessing for ACELP/HQ core switching + *---------------------------------------------------------------------*/ + ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ @@ -215,7 +221,11 @@ ivas_error core_switching_post_dec_fx( #else Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ #endif - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#else + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#endif const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ @@ -618,10 +628,17 @@ ivas_error core_switching_post_dec_fx( hHQ_core->Q_old_wtda = Qtmp; move16(); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; + + Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) + Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ +#else IF( output_mem_fx != NULL ) { Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ } +#endif *Qsynth = Qtmp; move16(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 4014d3ab2..db08b8feb 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -835,6 +835,7 @@ ivas_error ivas_core_dec_fx( /*core_switching_post_dec*/ Q_synth = add( sub( 15, e_sig[0] ), st->Q_syn_factor ); +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /*------------------fix-to-fix-end-----------------------*/ Word16 output_mem_16_fx[L_FRAME48k]; @@ -850,14 +851,15 @@ ivas_error ivas_core_dec_fx( p_output_mem_16 = NULL; set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } - +#endif #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 #endif +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ - +#endif IF( st->cldfbSyn != NULL ) { scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q4 - Q11 ); // Q4 @@ -917,7 +919,11 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_fx, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -964,7 +970,7 @@ ivas_error ivas_core_dec_fx( Scale_sig32( output_32_fx[n], output_frame, ( Q11 - Q4 ) ); // Q11 #endif #else - Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 + Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 #endif /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ -- GitLab From e3555e5ee9a9a33adcd0c9d21dad39eb08e37e25 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:54:18 +0100 Subject: [PATCH 598/750] fix --- lib_dec/ivas_mct_dec_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index d44ebdb3f..6deeef90d 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -340,6 +340,7 @@ ivas_error ivas_mct_dec_fx( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 Word16 output_mem_fx[L_FRAME48k]; IF( hCPE->output_mem_fx[1] != NULL ) { @@ -349,7 +350,7 @@ ivas_error ivas_mct_dec_fx( { set16_fx( output_mem_fx, 0, NS2SA_FX2( sts[n]->output_Fs, 3125000 ) ); } - +#endif Word16 Q_synth = sub( 15, e_sig[n] ); move16(); @@ -364,7 +365,11 @@ ivas_error ivas_mct_dec_fx( dirac_stereo_flag = 0; } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], hCPE->output_mem_fx[1], 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#endif { return error; } -- GitLab From 980f808b214f5a51f0fc35524a1371b173c425b8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 08:01:22 +0100 Subject: [PATCH 599/750] fix MSAN errors --- lib_dec/core_switching_dec_fx.c | 8 +++++--- lib_dec/ivas_tcx_core_dec_fx.c | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ae7299d5e..ab0fd31da 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -630,9 +630,11 @@ ivas_error core_switching_post_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; - - Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) - Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + IF( output_mem_fx32 != NULL ) + { + Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) + Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + } #else IF( output_mem_fx != NULL ) { diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 3c917978c..b85150251 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -903,8 +903,7 @@ void stereo_tcx_core_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word16 output_frame = extract_l( Mpy_32_16_1( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); - Copy_Scale_sig_16_32_DEPREC( signal_out_fx, signal_out_32_fx, output_frame, sub( Q11, st->Q_syn_factor ) ); + Copy_Scale_sig_16_32_DEPREC( signal_out_fx, signal_out_32_fx, st->L_frame, sub( Q11, st->Q_syn_factor ) ); #endif pop_wmops(); -- GitLab From d7746898df8fe78b9ae50daed37dfbe482030882 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 08:40:00 +0100 Subject: [PATCH 600/750] fix MSAN errors --- lib_dec/hq_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index f9dac288e..8d1f4c966 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1004,7 +1004,7 @@ void ivas_hq_core_dec_fx( #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig( output, st_fx->old_exc_fx + sub( L_EXC_MEM_DEC, st_fx->L_frame ), st_fx->L_frame, negate( Q_output ) ); /* Q0 */ - Copy_Scale_sig_16_32_DEPREC( output, output_32_fx, L_FRAME48k, sub( Q11, Q_output ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( output, output_32_fx, L_FRAME16k, sub( Q11, Q_output ) ); // Q11 st_fx->Q_syn_factor = s_min( 0, s_min( *Q_synth, Q_output ) ); #else IF( st_fx->element_mode > EVS_MONO ) -- GitLab From 058e89a02dad8c503570ce7c2d7e6940fa486cef Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 09:34:15 +0100 Subject: [PATCH 601/750] disable FIX_2280_REDUCTION_UNNECESSARY_SCALING2 --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3286878a2..e2c7b3a96 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ //#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ -- GitLab From 44a87dd7cce4c8ad5af2149d90f922c5d469ad1c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 27 Jan 2026 10:17:13 +0100 Subject: [PATCH 602/750] fix ifdef in ivas_dirac_rend_fx.c --- lib_rend/ivas_dirac_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 024fa63a1..e7df45b6c 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -253,7 +253,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( move16(); hSpatParamRendCom->numIsmDirections = 0; move16(); -#ifdef FIX_2354_MSAN_DIFF_Q_VALUE +#ifdef FIX_BASOP_2354_MSAN_DIFF_Q_VALUE hSpatParamRendCom->q_diffuseness_vector = Q30; move16(); #endif -- GitLab From acecaca6246af12d9c307fb578e8f996814a2bd1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 12:31:52 +0100 Subject: [PATCH 603/750] fix --- lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/core_switching_dec_fx.c | 11 ++++++++--- lib_dec/hq_core_dec_fx.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index f6fd79257..f4e2bf5f3 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -219,7 +219,7 @@ ivas_error acelp_core_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - set32_fx( output_fx32, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ + set32_fx( output_fx32, 0, st->L_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #else set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #endif diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ab0fd31da..58e4a606e 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -247,6 +247,10 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; Word16 offset; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 q_output_fx = Q11; + move16(); +#endif L_tmp = 0; move32(); @@ -448,7 +452,8 @@ ivas_error core_switching_post_dec_fx( IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_fx, output_frame, Q10 - Q11 ); /* Q10 */ + Scale_sig32( output_fx, st_fx->L_frame, Q10 - Q11 ); /* Q10 */ + q_output_fx = Q4; #else Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif @@ -510,7 +515,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif @@ -563,7 +568,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 8d1f4c966..dcc99bbdc 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -512,7 +512,7 @@ void ivas_hq_core_dec_fx( #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 tmp_out[L_FRAME48k]; #else - Word16 output[L_FRAME48k]; + Word16 output[L_FRAME16k]; Word16 Q_output; Q_output = 0; -- GitLab From 8ae38f57e11db4463449e7aecf392f383a448993 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 12:37:14 +0100 Subject: [PATCH 604/750] enable FIX_2280_REDUCTION_UNNECESSARY_SCALING2 --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index e2c7b3a96..3286878a2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ //#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE -//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ -- GitLab From eb82bc34fc852ebc2cc9af5e332fc5975d72a9bd Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 18:44:11 +0100 Subject: [PATCH 605/750] fix + activate FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE --- lib_com/options.h | 2 +- lib_dec/core_switching_dec_fx.c | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 108f4c993..6bdf247c7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE #define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 58e4a606e..c50fabdc2 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -172,7 +172,6 @@ void bw_switching_pre_proc_fx( } } - test(); test(); test(); @@ -835,7 +834,6 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); - IF( ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || EQ_16( st_fx->extl, SWB_CNG ) ) && ( NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) || EQ_16( st_fx->last_core, HQ_CORE ) ) ) || ( LT_16( st_fx->bwidth, st_fx->last_bwidth ) && NE_16( st_fx->last_extl, SWB_TBE ) ) || st_fx->old_ppp_mode || ( ( EQ_16( st_fx->prev_coder_type, AUDIO ) || EQ_16( st_fx->prev_coder_type, INACTIVE ) ) && st_fx->bws_cnt > 0 ) || ( st_fx->bws_cnt == 0 && EQ_16( st_fx->prev_bws_cnt, N_WS2N_FRAMES ) ) ) @@ -911,6 +909,7 @@ ivas_error core_switching_post_dec_fx( return error; } + /*---------------------------------------------------------------------* * core_switching_hq_prepare_dec() * @@ -994,9 +993,17 @@ void core_switching_hq_prepare_dec_fx( /* reset state of old_out if switching */ set16_fx( st_fx->hHQ_core->old_out_fx, 0, output_frame ); + return; } + +/*---------------------------------------------------------------------* + * core_switch_lb_upsamp() + * + * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) + *---------------------------------------------------------------------*/ + static void core_switch_lb_upsamp_fx( Decoder_State *st, /* i/o: Decoder state */ Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ @@ -1072,17 +1079,28 @@ static void core_switch_lb_upsamp_fx( no_col = s_min( no_col, temp ); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( st->hTcxDec->L_frameTCX, imult1616( no_col, st->cldfbSyn->no_channels ) ), Q4 - Q10 ); /* Q4 */ +#else Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( L_FRAME48k, imult1616( no_col, st->cldfbSyn->no_channels ) ), 4 - 10 ); /* Q4 */ +#endif /* save synthesis - needed in case of core switching */ IF( st->hTcxDec != NULL ) { - Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -4 ); /* Q0 */ + Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -Q4 ); /* Q0 */ } return; } + +/*---------------------------------------------------------------------* + * smoothTransitionDtxToTcx() + * + * apply smoothing to the transition part for inactive to active transitions in DTX + *---------------------------------------------------------------------*/ + #define TRANSITION_SMOOTHING_LEN_16k 15 #define TRANSITION_SMOOTHING_LEN_32k 31 #define TRANSITION_SMOOTHING_LEN_48k 47 -- GitLab From 5da447265f7312c6250253de833e7aa8cc7f1d10 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 18:57:23 +0100 Subject: [PATCH 606/750] simplification --- lib_dec/core_switching_dec_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index c50fabdc2..f352a3f30 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -636,8 +636,7 @@ ivas_error core_switching_post_dec_fx( Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; IF( output_mem_fx32 != NULL ) { - Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) - Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Qtmp, Q11 ) ); // Qtmp } #else IF( output_mem_fx != NULL ) -- GitLab From 3ac7ee7885f50409366d2264ccc395e69d8ea8fc Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 19:43:53 +0100 Subject: [PATCH 607/750] clang-format --- lib_dec/core_switching_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 1d02014f3..24d9efda9 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1687,7 +1687,7 @@ ivas_error core_switching_pre_dec_fx( move16(); #ifdef FIX_2379_REMOVE_previoussynth_fx_32 frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); /*Q-0*/ - st->enr_old_fx--; // just to keep the value identical + st->enr_old_fx--; // just to keep the value identical #else fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif -- GitLab From 526491a6a12bb5cbc0c0149f76edf334f8185b57 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 20:38:56 +0100 Subject: [PATCH 608/750] disable FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE --- lib_com/options.h | 2 +- lib_dec/acelp_core_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6d09f8e0e..9fddaf3a6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -120,7 +120,7 @@ #define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ #define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE #define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index d8c2cd7bc..6d37d4486 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2073,7 +2073,7 @@ ivas_error acelp_core_dec_fx( #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx32, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); #else - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*tmp buffer for save_hb_synth_fx[] */, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); #ifdef FIX_BASOP_2350_HARM_0B_BWE_2 Copy_Scale_sig_32_16( synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0 -- GitLab From 526131890e15d723365289984f60bf3ab84e6675 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 28 Jan 2026 09:41:57 +0100 Subject: [PATCH 609/750] simplification --- lib_dec/core_switching_dec_fx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index f352a3f30..41b42c6b0 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -246,10 +246,6 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; Word16 offset; -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word16 q_output_fx = Q11; - move16(); -#endif L_tmp = 0; move32(); @@ -452,7 +448,6 @@ ivas_error core_switching_post_dec_fx( { #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Scale_sig32( output_fx, st_fx->L_frame, Q10 - Q11 ); /* Q10 */ - q_output_fx = Q4; #else Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif @@ -514,7 +509,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif @@ -567,7 +562,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif @@ -1079,7 +1074,7 @@ static void core_switch_lb_upsamp_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( st->hTcxDec->L_frameTCX, imult1616( no_col, st->cldfbSyn->no_channels ) ), Q4 - Q10 ); /* Q4 */ + Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( st->hTcxDec->L_frameTCX, imult1616( no_col, st->cldfbSyn->no_channels ) ), Q11 - Q10 ); /* Q11 */ #else Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( L_FRAME48k, imult1616( no_col, st->cldfbSyn->no_channels ) ), 4 - 10 ); /* Q4 */ #endif @@ -1087,7 +1082,11 @@ static void core_switch_lb_upsamp_fx( /* save synthesis - needed in case of core switching */ IF( st->hTcxDec != NULL ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -Q4 ); /* Q0 */ +#else + Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -Q4 ); /* Q0 */ +#endif } return; -- GitLab From 3e191ba3f946f43b0a770e284d7d43f0b6e97411 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 28 Jan 2026 10:43:50 +0100 Subject: [PATCH 610/750] fix to prevent saturations --- lib_dec/core_switching_dec_fx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 24d9efda9..9d36d2c5e 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1599,7 +1599,9 @@ ivas_error core_switching_pre_dec_fx( ELSE { #ifdef FIX_2379_REMOVE_previoussynth_fx_32 - frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); /*Q-0*/ + Word32 previoussynth_fx_32[L_FRAME48k]; + Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); + fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ #else fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif @@ -1686,8 +1688,9 @@ ivas_error core_switching_pre_dec_fx( st->last_coder_type = GENERIC; move16(); #ifdef FIX_2379_REMOVE_previoussynth_fx_32 - frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); /*Q-0*/ - st->enr_old_fx--; // just to keep the value identical + Word32 previoussynth_fx_32[L_FRAME48k]; + Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); + fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ #else fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif -- GitLab From 3ff2c9f618c13a5864804a38f85be18fbace1e3b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:32:25 +0100 Subject: [PATCH 611/750] [cleanup] accept FIX_2318_CLANG_DECODER --- apps/decoder.c | 2 -- lib_com/options.h | 1 - 2 files changed, 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 12f6b1786..eadb854f3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -911,9 +911,7 @@ static bool parseCmdlIVAS_dec( arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->non_diegetic_pan_enabled = false; arg->non_diegetic_pan_gain = 0.f; -#ifdef FIX_2318_CLANG_DECODER arg->non_diegetic_pan_gain_fx = 0; -#endif arg->tsmEnabled = false; arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; arg->aeSequence.count = 0; diff --git a/lib_com/options.h b/lib_com/options.h index 929c05624..d4d7a8213 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ #define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ #define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ -- GitLab From ad4f0ee37332c16cdf63cd206510b5cfbdcf270d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:33:23 +0100 Subject: [PATCH 612/750] [cleanup] accept HARM_NON_LINEARITY --- lib_com/cng_exc_fx.c | 283 ------ lib_com/options.h | 1 - lib_com/prot_fx.h | 61 -- lib_com/swb_tbe_com_fx.c | 267 ------ lib_dec/acelp_core_dec_fx.c | 22 - lib_dec/cng_dec_fx.c | 347 ------- lib_dec/dec_LPD_fx.c | 13 - lib_dec/dec_acelp_tcx_main_fx.c | 4 - lib_dec/ivas_core_dec_fx.c | 12 - lib_dec/ivas_tcx_core_dec_fx.c | 8 - lib_enc/acelp_core_enc_fx.c | 44 - lib_enc/amr_wb_enc_fx.c | 4 - lib_enc/cng_enc_fx.c | 1542 ------------------------------- lib_enc/cod_tcx_fx.c | 4 - lib_enc/core_enc_ol_fx.c | 15 - lib_enc/enc_acelp_tcx_main_fx.c | 4 - lib_enc/hq_hr_enc_fx.c | 4 - lib_enc/igf_enc_fx.c | 4 - lib_enc/ivas_core_enc_fx.c | 4 - lib_enc/ivas_tcx_core_enc_fx.c | 12 - lib_enc/prot_fx_enc.h | 22 - 21 files changed, 2677 deletions(-) diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 4d2d76baa..3ce3e518f 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -602,112 +602,6 @@ return; *-------------------------------------------------------*/ void cng_params_postupd_fx( -#ifndef HARM_NON_LINEARITY - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer Q6 */ -) -{ - Word16 i, j; - Word16 Q_exc; - const Word16 *exc2; - Word16 fft_io[L_FFT]; - Word32 sp[129]; - Word16 *ptR, *ptI; - Word32 env[NUM_ENV_CNG]; - Word32 L_tmp; - Word16 tmp; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - Word16 exp1; - Word16 CNG_mode; - Word16 ptr; - Word32 last_active_brate; - - ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 ); - IF( ptr < 0 ) - { - ptr = add( ptr, HO_HIST_SIZE ); - } - - FOR( j = 0; j < *cng_buf_cnt; j++ ) - { - exc2 = &cng_exc2_buf[ptr * L_FFT]; - Q_exc = cng_Qexc_buf[ptr]; - move16(); - last_active_brate = cng_brate_buf[ptr]; - move32(); - - /* calculate the spectrum of residual signal */ - Copy( exc2, fft_io, L_FFT ); - - fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); - - ptR = &fft_io[1]; - ptI = &fft_io[L_FFT - 1]; - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_exc+1 */ - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_exc+1 */ - tmp = add( add( Q_exc, Q_exc ), 1 ); - sp[i] = L_shr( L_tmp, sub( tmp, 6 ) ); - move32(); /* Q6 */ - - ptR++; - ptI--; - } - - Copy32( sp, env, NUM_ENV_CNG ); - { - - CNG_mode = get_cng_mode( last_active_brate ); - - /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */ - L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - - exp_pow = sub( 14, temp_hi_fx ); - L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ - L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */ - tmp = extract_l( L_tmp ); /* Q13 */ - - exp1 = norm_s( tmp ); - tmp = shl( tmp, exp1 ); /*Q(exp1+13) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp1-13) */ - tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */ - } - - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - env[i] = Mult_32_16( env[i], tmp ); - move32(); - } - - /* update the circular buffer of old residual envelope */ - Copy32( env, &( ho_env_circ[(ptr) *NUM_ENV_CNG] ), NUM_ENV_CNG ); - - ptr = add( ptr, 1 ); - if ( EQ_16( ptr, HO_HIST_SIZE ) ) - { - ptr = 0; - move16(); - } - } - - *cng_buf_cnt = 0; - move16(); - - return; -} - -void cng_params_postupd_ivas_fx( -#endif const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ @@ -833,183 +727,8 @@ void cng_params_postupd_ivas_fx( * * update CNG parameters *-------------------------------------------------------*/ -#ifndef HARM_NON_LINEARITY -void cng_params_upd_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer Q6 */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ -) -{ - Word32 L_ener, L_tmp; - Word16 i, j; - const Word16 *pt_exc2; - Word16 tmpv, maxv, scale; - Word16 fft_io[L_FRAME16k]; - Word32 sp[129]; - Word16 *ptR, *ptI; - Word32 env[NUM_ENV_CNG]; - Word16 exp1; - Word16 CNG_mode; - Word16 tmp; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - - /* update the pointer to circular buffer of old LSP vectors */ - *ho_circ_ptr = add( *ho_circ_ptr, 1 ); - move16(); - - if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) ) - { - *ho_circ_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &( ho_lsp_circ[( *ho_circ_ptr ) * M] ), M ); - - /* calculate the residual signal energy */ - /*enr = dotp( exc2, exc2, L_frame ) / L_frame; */ - - maxv = 0; - move16(); - FOR( i = 0; i < L_frame; i++ ) - { - maxv = s_max( maxv, abs_s( exc2[i] ) ); - } - scale = norm_s( maxv ); - - pt_exc2 = exc2; - L_ener = 0; - move32(); - IF( EQ_16( L_frame, L_FRAME ) ) - { - FOR( j = 0; j < 128; j++ ) - { - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ - pt_exc2++; - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); - pt_exc2++; - L_ener = L_add_sat( L_ener, L_shr_sat( L_tmp, 7 ) ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ - } - } - ELSE /* L_FRAME16k */ - { - FOR( j = 0; j < 160; j++ ) - { - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ - pt_exc2++; - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); - pt_exc2++; - L_ener = L_add_sat( L_ener, L_shr_sat( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ - } - } - L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ - - /* update the circular buffer of old energies */ - ho_ener_circ[*ho_circ_ptr] = L_ener; - move32(); - - IF( enc_dec_flag == ENC ) - { - /* Store residual signal for postponed FFT-processing*/ - *cng_buf_cnt = add( *cng_buf_cnt, 1 ); - move16(); - if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) ) - { - *cng_buf_cnt = HO_HIST_SIZE; - move16(); - } - Copy( exc2, &( cng_exc2_buf[( *ho_circ_ptr ) * L_FFT] ), L_FFT ); - cng_Qexc_buf[*ho_circ_ptr] = Q_exc; - move16(); - cng_brate_buf[*ho_circ_ptr] = last_active_brate; - move32(); - } - ELSE - { - /* calculate the spectrum of residual signal */ - Copy( exc2, fft_io, L_frame ); - - fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); - - ptR = &fft_io[1]; - ptI = &fft_io[L_FFT - 1]; - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_exc+1 */ - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_exc+1 */ - tmp = add( add( Q_exc, Q_exc ), 1 ); - sp[i] = L_shr( L_tmp, sub( tmp, 6 ) ); - move32(); /* Q6 */ - - ptR++; - ptI--; - } - - Copy32( sp, env, NUM_ENV_CNG ); - { - CNG_mode = get_cng_mode( last_active_brate ); - /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */ - L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - - exp_pow = sub( 14, temp_hi_fx ); - L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ - L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */ - tmp = extract_l( L_tmp ); /* Q13 */ - - exp1 = norm_s( tmp ); - tmp = shl( tmp, exp1 ); /*Q(exp1+13) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp1-13) */ - tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */ - } - - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - env[i] = Mult_32_16( env[i], tmp ); - move32(); - } - - /* update the circular buffer of old residual envelope */ - /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */ - Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); - } - *ho_circ_size = add( *ho_circ_size, 1 ); - move16(); - if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) ) - { - *ho_circ_size = HO_HIST_SIZE; - move16(); - } - - return; -} -#endif -#ifdef HARM_NON_LINEARITY void cng_params_upd_fx( -#else -void cng_params_upd_ivas_fx( -#endif const Word16 lsp_new[], /* i : LSP aprameters Q15 */ const Word16 exc2[], /* i : current enhanced excitation Q_exc */ const Word16 L_frame, /* i : frame length Q0 */ @@ -1187,9 +906,7 @@ void cng_params_upd_ivas_fx( /* update the circular buffer of old residual envelope */ /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */ Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); -#ifdef HARM_NON_LINEARITY IF( NE_16( element_mode, EVS_MONO ) ) -#endif { scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); // Q(6+shift) } diff --git a/lib_com/options.h b/lib_com/options.h index d4d7a8213..0d06acdff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ #define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ #define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ #define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6c3d24ce4..78652dc7c 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3103,9 +3103,7 @@ void ScaleShapedWB_fx( ); void non_linearity_fx( -#ifdef HARM_NON_LINEARITY const Word16 element_mode, /* i : element mode */ -#endif const Word16 i[], /* i : i signal Q_inp */ Word32 output[], /* o : output signal 2*Q_inp */ const Word16 length, /* i : i length */ @@ -3116,18 +3114,6 @@ void non_linearity_fx( const Word16 L_frame /* i : ACELP frame length */ ); -#ifndef HARM_NON_LINEARITY -void non_linearity_ivas_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ -); -#endif void interp_code_5over2_fx( const Word16 inp_code[], /* i : i vector */ Word16 interp_code[], /* o : output vector */ @@ -3919,17 +3905,6 @@ void CNG_exc_fx( ); void cng_params_postupd_fx( -#ifndef HARM_NON_LINEARITY - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer */ -); - -void cng_params_postupd_ivas_fx( -#endif const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ @@ -3941,26 +3916,6 @@ void cng_params_postupd_ivas_fx( ); void cng_params_upd_fx( -#ifndef HARM_NON_LINEARITY - const Word16 lsp_new[], /* i : LSP parameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ -); - -void cng_params_upd_ivas_fx( -#endif const Word16 lsp_new[], /* i : LSP aprameters Q15 */ const Word16 exc2[], /* i : current enhanced excitation Q_exc */ const Word16 L_frame, /* i : frame length Q0 */ @@ -6070,15 +6025,6 @@ void swb_CNG_dec_fx( const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ); -#ifndef HARM_NON_LINEARITY -void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -); -#endif void td_cng_dec_init_fx( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ); @@ -10569,13 +10515,6 @@ void writeTCXparam_fx( const Word16 target_bitsTCX10[2], const Word16 pre_past_flag ); -#ifndef HARM_NON_LINEARITY -void calculate_hangover_attenuation_gain_ivas_fx( - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -); -#endif void init_coder_ace_plus_ivas_fx( Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 9b4db81b7..e54fff446 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -5534,9 +5534,7 @@ static Word32 non_linearity_scaled_copy_ivas( /*==========================================================================*/ void non_linearity_fx( -#ifdef HARM_NON_LINEARITY const Word16 element_mode, /* i : element mode */ -#endif const Word16 input[], /* i : input signal Q_inp */ Word32 output[], /* o : output signal 2*Q_inp */ const Word16 length, /* i : input length */ @@ -5546,248 +5544,6 @@ void non_linearity_fx( Word16 *voice_factors, /* i : Voice Factors */ const Word16 L_frame /* i : ACELP frame length */ ) -#ifndef HARM_NON_LINEARITY -{ - Word16 i, j; - Word16 max_val = 0; - move16(); - Word32 scale; - Word16 scale_step; - Word16 exp, tmp; - Word16 e_tmp, f_tmp; - Word16 frac; - Word32 L_tmp; - Word32 L_tmp1; - - Word16 en_abs = 0; - Word16 v_fac = 0; - move16(); - move16(); - Word16 ths; - Word16 nframes; - Word32 prev_scale; - Word16 length_half; - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - nframes = 5; - move16(); - ths = 17817; - move16(); /* 0.87*5 in Q12 */ - } - ELSE - { - nframes = 4; - move16(); - ths = 15400; - move16(); /* 0.94*4 in Q12 */ - } - - - FOR( i = 0; i < nframes; i++ ) - { - v_fac = add( v_fac, shr( voice_factors[i], 3 ) ); /* Q12 */ - } - - test(); - if ( EQ_16( coder_type, VOICED ) && GT_16( v_fac, ths ) ) - { - en_abs = 1; - move16(); - } - - length_half = shr( length, 1 ); - prev_scale = *pPrevScale; - move32(); - - - /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */ - - FOR( i = j = 0; i < length_half; i++ ) - { - tmp = abs_s( input[i] ); - if ( GT_16( tmp, max_val ) ) - { - j = i; - move16(); - } - max_val = s_max( max_val, tmp ); - } - - - IF( GT_16( max_val, shl( 1, Q_inp ) ) ) - { - exp = norm_s( max_val ); - tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ - scale = L_shl( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */ - } - ELSE - { - scale = 1438814044; - move32(); /* Q31; 0.67 in Q31 */ - } - - test(); - IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) - { - scale_step = 16384; - move16(); /* Q14 */ - prev_scale = L_shr( scale, 1 ); /* Q30 */ - } - ELSE - { - - /* Computing log2(scale) */ - IF( j == 0 ) - { - scale_step = 32767; - move16(); - } - ELSE - { - e_tmp = norm_l( scale ); - f_tmp = Log2_norm_lc( L_shl( scale, e_tmp ) ); - e_tmp = sub( -1, e_tmp ); - L_tmp = Mpy_32_16( e_tmp, f_tmp, MAX_16 ); /* Q16 */ - - /* Computing log2(prev_scale) */ - e_tmp = norm_l( prev_scale ); - f_tmp = Log2_norm_lc( L_shl( prev_scale, e_tmp ) ); - e_tmp = negate( e_tmp ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, MAX_16 ); /* Q16 */ - - /* log2(scale / prev_scale) = log2(scale) - log2(prev_scale) */ - L_tmp = L_sub( L_tmp, L_tmp1 ); /* Q16 */ - - /* Computing 1/j */ - exp = norm_s( j ); - tmp = div_s( shl( 1, sub( 14, exp ) ), j ); /* Q(29-exp) */ - - /* (log2(scale / prev_scale))/length */ - L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ - tmp = extract_l( Pow2( 14, frac ) ); - scale_step = shl_sat( tmp, exp ); /* Q14 */ - } - } - - prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs ); - - max_val = 0; - move16(); - j = shr( length, 1 ); - FOR( i = length_half; i < length; i++ ) - { - tmp = abs_s( input[i] ); - if ( GT_16( tmp, max_val ) ) - { - j = i; - move16(); - } - max_val = s_max( max_val, tmp ); - } - - IF( GT_16( max_val, shl( 1, Q_inp ) ) ) - { - exp = norm_s( max_val ); - tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ - scale = L_shl_sat( L_mult( 21955 /* 0.67 in Q15 */, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */ - } - ELSE - { - scale = 1438814044; - move32(); /* Q31; 0.67 in Q31 */ - } - - test(); - IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) - { - scale_step = 16384; - move16(); /*Q14 */ - prev_scale = L_shr( scale, 1 ); /*Q30 */ - } - ELSE - { - /*scale_step = (float) exp(1.0f / (float) (j - length/2) * (float) log(scale / prev_scale)); */ - /* Computing log2(scale) */ - IF( EQ_16( j, length_half ) ) - { - scale_step = 32767; - move16(); /*Q14 */ - } - ELSE - { - e_tmp = norm_l( scale ); - f_tmp = Log2_norm_lc( L_shl( scale, e_tmp ) ); - e_tmp = sub( -e_tmp, 1 ); - L_tmp = Mpy_32_16( e_tmp, f_tmp, 32767 ); /* Q16 */ - - /* Computing log2(prev_scale) */ - e_tmp = norm_l( prev_scale ); - f_tmp = Log2_norm_lc( L_shl( prev_scale, e_tmp ) ); - e_tmp = negate( e_tmp ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 32767 ); /* Q16 */ - - /* log2(scale / prev_scale) = log2(scale) - log2(prev_scale) */ - L_tmp = L_sub( L_tmp, L_tmp1 ); /* Q16 */ - - /* Computing 1/(j - length/2) */ - tmp = sub( j, length_half ); - exp = norm_s( tmp ); - tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* Q(29-exp) */ - - /* (log2(scale / prev_scale))/length */ - L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ - tmp = extract_l( Pow2( 14, frac ) ); - scale_step = shl_sat( tmp, exp ); /*Q14 */ - } - } - - prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); - - *pPrevScale = prev_scale; - move32(); - - /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */ - - return; -} - - -/*==========================================================================*/ -/* FUNCTION : void non_linearity_ivas_fx() */ -/*--------------------------------------------------------------------------*/ -/* PURPOSE : Apply a non linearity to the SHB excitation */ -/*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word16 input[] i : input signal Q_inp */ -/* Word16 length i : input length */ -/*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* Word32 output[] o : output signal 2*Q_inp */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Word32 *prev_scale i/o: memory Q30 */ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ -/*==========================================================================*/ - -void non_linearity_ivas_fx( - const Word16 input[], /* i : input signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : input length */ - Word32 *pPrevScale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ - -) -#endif { Word16 i, j; Word16 max_val = 0; @@ -5809,9 +5565,7 @@ void non_linearity_ivas_fx( Word32 prev_scale; Word16 length_half; Word16 sc_factor; -#ifdef HARM_NON_LINEARITY Word32 prev_scale_factor; -#endif IF( EQ_16( L_frame, L_FRAME16k ) ) { @@ -5869,7 +5623,6 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale_factor = Mult_32_16( prev_scale, 32 ); @@ -5883,13 +5636,6 @@ void non_linearity_ivas_fx( test(); IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) ) -#else - sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ - - test(); - IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ -#endif { scale_step = 16384; move16(); /* Q14 */ @@ -5933,13 +5679,11 @@ void non_linearity_ivas_fx( } } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs ); } ELSE -#endif { prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs ); } @@ -5970,7 +5714,6 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale_factor = Mult_32_16( prev_scale, 32 ); @@ -5984,14 +5727,6 @@ void non_linearity_ivas_fx( test(); IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) ) -#else - /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ - sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */ - sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ - - test(); - IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ -#endif { scale_step = 16384; move16(); /*Q14 */ @@ -6035,13 +5770,11 @@ void non_linearity_ivas_fx( } } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); } ELSE -#endif { prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); } diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index bdb8c5d85..373e2ea54 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2301,20 +2301,12 @@ ivas_error acelp_core_dec_fx( { IF( EQ_16( st->element_mode, EVS_MONO ) ) { -#ifdef HARM_NON_LINEARITY non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#else - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#endif } ELSE { Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_exc) */ -#ifdef HARM_NON_LINEARITY non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#else - non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#endif exp = sub( L_norm_arr( bwe_exc_extended_fx + L_FRAME32k, NL_BUFF_OFFSET ), 16 ); Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, exp ); /* Q(2 * Q_exc) -> Q(q_old_bwe_exc_extended_fx) */ st->hBWE_TD->q_old_bwe_exc_extended_fx = add( shl( st->Q_exc, 1 ), exp ); @@ -2341,22 +2333,8 @@ ivas_error acelp_core_dec_fx( IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#else - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, - st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); - } - ELSE - { - cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, - st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, - st->hFdCngDec->hFdCngCom->CngBandwidth ); - } -#endif /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 27c528b24..e35c13c79 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -9,11 +9,6 @@ #include "prot_fx.h" #include "ivas_cnst.h" -#ifndef HARM_NON_LINEARITY -/*Temporary location to be move in prot* when merge is done*/ -void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); -void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); -#endif /*-----------------------------------------------------------------* * Local function prototypes @@ -21,9 +16,6 @@ void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); -#ifndef HARM_NON_LINEARITY -static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); -#endif /*-----------------------------------------------------------------* @@ -728,11 +720,7 @@ void swb_CNG_dec_fx( { st_fx->last_vad_fx = 1; move16(); -#ifdef HARM_NON_LINEARITY st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 ); -#else - st_fx->hTdCngDec->burst_cnt_fx = add( st_fx->hTdCngDec->burst_cnt_fx, 1 ); -#endif move16(); if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) ) { @@ -744,45 +732,6 @@ void swb_CNG_dec_fx( return; } -#ifndef HARM_NON_LINEARITY -void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -) -{ - test(); - IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - /* SHB SID decoding and CNG */ - test(); - IF( EQ_16( st_fx->cng_type, LP_CNG ) && EQ_16( st_fx->extl, SWB_CNG ) ) - { - shb_CNG_decod_ivas_fx( st_fx, synth_fx, shb_synth_fx, sid_bw, Qsyn ); - } - st_fx->last_vad_fx = 0; - move16(); - st_fx->hTdCngDec->burst_cnt_fx = 0; - move16(); - } - ELSE - { - st_fx->last_vad_fx = 1; - move16(); - st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 ); // saturation reached? - move16(); - if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) ) - { - st_fx->hTdCngDec->burst_cnt_fx = 0; - move16(); - } - } - - return; -} -#endif /*---------------------------------------------------------------------* * shb_CNG_decod() @@ -791,284 +740,12 @@ void swb_CNG_dec_ivas_fx( *---------------------------------------------------------------------*/ static void shb_CNG_decod_fx( -#ifdef HARM_NON_LINEARITY Decoder_State *st, /* i/o: State structure */ -#else - Decoder_State *st_fx, /* i/o: State structure */ -#endif const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ) -#ifndef HARM_NON_LINEARITY -{ - Word16 i; - Word16 idx_ener_fx; - TD_CNG_DEC_HANDLE hTdCngDec; - Word16 shb_lpcCNG_fx[LPC_SHB_ORDER + 1]; - Word16 shb_lspCNG_fx[LPC_SHB_ORDER]; - Word16 excTmp_fx[L_FRAME16k]; - Word16 excSHB_fx[L_FRAME16k]; - Word16 tmp_lsp[LPC_SHB_ORDER]; - Word16 ener_excSHB_fx; - Word32 wb_ener_fx; - Word16 wb_ener16_fx; - Word32 L_gain_fx; - Word16 gain_fx; - Word16 shb_syn16k_fx[L_FRAME16k]; - Word16 tmp; - Word16 step_fx; - Word16 interp_fx; - Word16 ener_fx; - Word16 exp, exp1; - Word16 fra; - Word32 L_tmp; - Word16 tmp2; - Word16 allow_cn_step_fx = 0; - move16(); - Word16 q; - TD_BWE_DEC_HANDLE hBWE_TD; - - hBWE_TD = st_fx->hBWE_TD; - hTdCngDec = st_fx->hTdCngDec; - - IF( st_fx->bfi == 0 ) - { - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) ) - { - idx_ener_fx = get_next_indice_fx( st_fx, 4 ); - - if ( !idx_ener_fx ) - { - idx_ener_fx = -15; - move16(); - } - IF( st_fx->element_mode == EVS_MONO ) - { - /* de-quantization of SHB CNG parameters */ - L_tmp = L_mult( idx_ener_fx, 27400 ); /*Q14 */ - hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */ - move16(); - } - ELSE - { - } - } - } - - /* SHB spectrum estimation */ - - - interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 ); - interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tmp2 = mult( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ); /*Q14*/ - tmp = mult( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ); /*Q14*/ - shb_lspCNG_fx[i] = add( tmp2, tmp ); - move16(); /*Q14*/ - } - - IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - if ( LT_16( hTdCngDec->shb_dtx_count_fx, 1000 ) ) - { - hTdCngDec->shb_dtx_count_fx = add( hTdCngDec->shb_dtx_count_fx, 1 ); - move16(); - } - } - E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/ - E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER ); - - Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ - - /* SHB energy estimation */ - wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ - FOR( i = 0; i < L_FRAME32k; i++ ) - { - wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */ - } - exp = norm_l( wb_ener_fx ); - fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); - exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) ); - wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */ - if ( !st_fx->first_CNG ) - { - hTdCngDec->wb_cng_ener_fx = wb_ener16_fx; - move16(); /*Q8 */ - } - if ( GT_16( abs_s( sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ) ), 3072 ) ) - { - allow_cn_step_fx = 1; - move16(); - } - - IF( EQ_16( allow_cn_step_fx, 1 ) ) - { - hTdCngDec->wb_cng_ener_fx = wb_ener16_fx; - move16(); /*Q8 */ - } - ELSE - { - tmp = sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ); /*Q8 */ - tmp = mult_r( tmp, 29491 ); /*Q8 */ - hTdCngDec->wb_cng_ener_fx = add( hTdCngDec->wb_cng_ener_fx, tmp ); /*Q8 */ - move16(); - } - test(); - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && ( st_fx->bfi == 0 ) ) - { - hTdCngDec->last_wb_cng_ener_fx = hTdCngDec->wb_cng_ener_fx; - move16(); - - if ( !st_fx->first_CNG ) - { - hTdCngDec->shb_cng_ener_fx = hTdCngDec->last_shb_cng_ener_fx; - move16(); - } - } - - gain_fx = sub( hTdCngDec->wb_cng_ener_fx, hTdCngDec->last_wb_cng_ener_fx ); /* Q8 */ - if ( GT_16( gain_fx, 15 ) ) - { - gain_fx = 15; - move16(); - } - step_fx = sub( add( gain_fx, hTdCngDec->last_shb_cng_ener_fx ), hTdCngDec->shb_cng_ener_fx ); /*Q8 */ - test(); - IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st_fx->last_core_brate, SID_2k40 ) ) - { - hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, step_fx ); /* Q8 */ - move16(); - } - ELSE - { - hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, mult( 8192, step_fx ) ); /*Q8 */ - move16(); - } - /* generate white noise excitation */ - FOR( i = 0; i < L_FRAME16k; i++ ) - { - excTmp_fx[i] = shr_r( Random( &hTdCngDec->swb_cng_seed ), 8 ); - move16(); /*Q-8*/ - } - - /* synthesis filtering */ - Syn_filt_s( 0, shb_lpcCNG_fx, LPC_SHB_ORDER, excTmp_fx, excSHB_fx, L_FRAME16k, hBWE_TD->state_lpc_syn_fx, 1 ); - - - /* synthesis signal gain shaping */ - L_tmp = 0; - move32(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - L_tmp = L_add( L_tmp, Mpy_32_16_1( L_mult0( excSHB_fx[i], excSHB_fx[i] ), 102 ) ); /*Q-16*/ - } - q = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, q ); - q = sub( q, 32 ); - ener_excSHB_fx = round_fx( L_tmp ); /*Qq */ - IF( EQ_16( st_fx->last_vad_fx, 1 ) ) - { - hTdCngDec->trans_cnt_fx = 0; - move16(); - test(); - IF( GT_16( hTdCngDec->burst_cnt_fx, 3 ) && NE_16( st_fx->last_core, HQ_CORE ) ) - { - hTdCngDec->trans_cnt_fx = 5; - move16(); - } - } - - ener_fx = hTdCngDec->shb_cng_ener_fx; - move16(); /*Q8 */ - IF( hTdCngDec->trans_cnt_fx > 0 ) - { - i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */ - ener_fx = add_sat( hTdCngDec->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( hTdCngDec->last_shb_ener_fx, hTdCngDec->shb_cng_ener_fx ) ) ); /*Q8 */ - hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 ); - move16(); - } - - tmp = mult( 3277, ener_fx ); /*Q8 */ - L_tmp = L_mult( 27213, tmp ); /*Q22, 27213=3.321928 in Q13 */ - L_tmp = L_shr( L_tmp, 6 ); /*Q16 */ - L_tmp = L_add( L_tmp, 10 << 16 ); - if ( L_tmp < 0 ) - { - L_tmp = 0; - move32(); - } - fra = L_Extract_lc( L_tmp, &exp ); - L_tmp = L_shl_sat( Pow2( exp, fra ), 5 ); /*Q5 */ - L_tmp = L_shr( L_tmp, 10 ); - if ( !L_tmp ) - { - L_tmp = 1; /*Q5 */ - } - exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q31*/ - tmp = extract_h( L_tmp ); /*Q15*/ - exp = sub( exp, 16 ); - exp1 = norm_s( ener_excSHB_fx ); - fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/ - - IF( GT_16( fra, tmp ) ) - { - fra = shr( fra, 1 ); /*Q15*/ - exp1 = sub( exp1, 1 ); - } - tmp = div_s( fra, tmp ); /*Q15*/ - - L_tmp = L_deposit_h( tmp ); /*Q31 */ - tmp = sub( add( 5, exp ), add( q, exp1 ) ); - L_gain_fx = Isqrt_lc( L_tmp, &tmp ); /*Q31-Qtmp */ - - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */ - move16(); - } - - test(); - IF( EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) - { - /* rescale the Hilbert memories to Q0 */ - FOR( i = 0; i < HILBERT_MEM_SIZE; i++ ) - { - hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = L_shr( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */ - move32(); - } - - FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ ) - { - hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */ - move16(); - } - } - GenSHBSynth_fx( shb_syn16k_fx, shb_synth_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st_fx->L_frame, &( hBWE_TD->syn_dm_phase ) ); - - IF( EQ_32( st_fx->output_Fs, 48000 ) ) - { - interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); - } - - ResetSHBbuffer_Dec_fx( st_fx->hBWE_TD, st_fx->extl ); - - return; -} - -static void shb_CNG_decod_ivas_fx( - Decoder_State *st, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn ) -#endif { Word16 i; Word16 idx_ener; @@ -1091,9 +768,7 @@ static void shb_CNG_decod_ivas_fx( Word16 exp, exp1; Word16 fra; Word32 L_tmp; -#ifdef HARM_NON_LINEARITY Word16 tmp_16, tmp_16_2, step_fx16, gain_fx16, ener_fx16; -#endif Word16 allow_cn_step_fx; Word16 q; TD_BWE_DEC_HANDLE hBWE_TD; @@ -1119,14 +794,9 @@ static void shb_CNG_decod_ivas_fx( /* de-quantization of SHB CNG parameters */ IF( st->element_mode == EVS_MONO ) { -#ifdef HARM_NON_LINEARITY L_tmp = L_mult( idx_ener, 27400 ); /*Q14 */ hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */ move16(); -#else - hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11 - move32(); -#endif } ELSE { @@ -1140,7 +810,6 @@ static void shb_CNG_decod_ivas_fx( interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 ); interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/ -#ifdef HARM_NON_LINEARITY IF( st->element_mode == EVS_MONO ) { FOR( i = 0; i < LPC_SHB_ORDER; i++ ) @@ -1152,7 +821,6 @@ static void shb_CNG_decod_ivas_fx( } } ELSE -#endif { FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -1170,16 +838,13 @@ static void shb_CNG_decod_ivas_fx( E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/ E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER ); -#ifdef HARM_NON_LINEARITY IF( st->element_mode != EVS_MONO ) -#endif { Copy_Scale_sig( shb_lpcCNG_fx, hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */ } Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ /* SHB energy estimation */ -#ifdef HARM_NON_LINEARITY IF( st->element_mode == EVS_MONO ) { wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ @@ -1251,7 +916,6 @@ static void shb_CNG_decod_ivas_fx( } } ELSE -#endif { wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) @@ -1360,7 +1024,6 @@ static void shb_CNG_decod_ivas_fx( } } -#ifdef HARM_NON_LINEARITY IF( st->element_mode == EVS_MONO ) { ener_fx16 = hTdCngDec->shb_cng_ener_fx; @@ -1409,7 +1072,6 @@ static void shb_CNG_decod_ivas_fx( } ELSE { -#endif ener_fx = hTdCngDec->shb_cng_ener_fx_32; move32(); /*Q11 */ IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) ) @@ -1423,9 +1085,6 @@ static void shb_CNG_decod_ivas_fx( tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */ IF( GT_32( tmp, 32767 ) ) abort(); -#ifndef HARM_NON_LINEARITY - Word16 tmp_16; -#endif tmp_16 = (Word16) tmp; move16(); L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */ @@ -1462,9 +1121,7 @@ static void shb_CNG_decod_ivas_fx( L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */ hTdCngDec->shb_cng_gain_fx_32 = ener_fx; move32(); -#ifdef HARM_NON_LINEARITY } -#endif FOR( i = 0; i < L_FRAME16k; i++ ) { @@ -1495,7 +1152,6 @@ static void shb_CNG_decod_ivas_fx( interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); } -#ifdef HARM_NON_LINEARITY IF( st->element_mode != EVS_MONO ) { IF( EQ_32( st->output_Fs, 32000 ) ) @@ -1507,9 +1163,6 @@ static void shb_CNG_decod_ivas_fx( Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ } } -#else - Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ -#endif ResetSHBbuffer_Dec_fx( st->hBWE_TD, st->extl ); diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index c24d338cb..00ff81afe 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -931,26 +931,13 @@ void decoder_LPD_fx( E_LPC_a_lsp_conversion( A, lsptmp, &xspnew_uw[0], M ); Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 ); -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, - st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, - Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); -#endif } ELSE { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, - st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, - &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, - st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); -#endif } /* Set 16k LSP flag for CNG buffer */ diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index b475a31d7..1eccbfeab 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -479,11 +479,7 @@ Word16 dec_acelp_tcx_frame_fx( test(); IF( st->core == ACELP_CORE && st->igf != 0 && st->con_tcx == 0 ) { -#ifdef HARM_NON_LINEARITY non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame ); -#else - non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame ); -#endif /* update the old BWE exe memory */ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 459d1b450..eba1cbad6 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1141,29 +1141,17 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); -#ifdef HARM_NON_LINEARITY Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 -#else - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 -#endif Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 -#ifdef HARM_NON_LINEARITY swb_CNG_dec_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); -#else - swb_CNG_dec_ivas_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); -#endif test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { -#ifdef HARM_NON_LINEARITY Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], output_frame, ( Q11 ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, ( Q11 ) ); // Q11 -#endif } Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, negate( sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ) ); // Q0 diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 45588e7cc..a3feb62ff 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -753,22 +753,14 @@ void stereo_tcx_core_dec_fx( IF( st->hTdCngDec != NULL ) { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#endif } } ELSE IF( st->hTdCngDec != NULL ) { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#endif } /* Set 16k LSP flag for CNG buffer */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ad0ca1346..baf8fad41 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -97,9 +97,7 @@ ivas_error acelp_core_enc_fx( error = IVAS_ERR_OK; (void) hStereoTD; -#ifdef HARM_NON_LINEARITY (void) ener_fx; -#endif /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -277,20 +275,11 @@ ivas_error acelp_core_enc_fx( IF( EQ_16( st_fx->cng_type, LP_CNG ) ) { /* Run CNG post parameter update */ -#ifdef HARM_NON_LINEARITY cng_params_postupd_fx( hTdCngEnc->ho_circ_ptr, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx, EVS_MONO, -1 ); -#else - cng_params_postupd_fx( hTdCngEnc->ho_circ_ptr, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, - hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx ); -#endif /* encode CNG parameters */ -#ifdef HARM_NON_LINEARITY CNG_enc_fx( st_fx, Aq_fx, inp_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw ); -#else - CNG_enc_fx( st_fx, Aq_fx, inp_fx, ener_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw ); -#endif /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc_fx, exc2_fx, &hTdCngEnc->lp_ener_fx, st_fx->last_core_brate, @@ -625,11 +614,7 @@ ivas_error acelp_core_enc_fx( IF( !st_fx->Opt_SC_VBR ) { /* Apply a non linearity to the SHB excitation */ -#ifdef HARM_NON_LINEARITY non_linearity_fx( st_fx->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame ); -#else - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame ); -#endif } test(); if ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, FRAME_NO_DATA ) ) @@ -647,14 +632,8 @@ ivas_error acelp_core_enc_fx( IF( hTdCngEnc != NULL && ( st_fx->Opt_DTX_ON != 0 ) && ( GT_32( st_fx->core_brate, SID_2k40 ) ) ) { /* update CNG parameters in active frames */ -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, - &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, - hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate ); -#endif IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { @@ -974,18 +953,10 @@ ivas_error acelp_core_enc_ivas_fx( IF( st->cng_type == LP_CNG ) { /* Run CNG post parameter update */ -#ifdef HARM_NON_LINEARITY cng_params_postupd_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif /* encode CNG parameters */ -#ifdef HARM_NON_LINEARITY CNG_enc_fx( st, Aq, inp, lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw ); -#else - CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw ); -#endif /* comfort noise generation */ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate, @@ -1233,11 +1204,7 @@ ivas_error acelp_core_enc_ivas_fx( calc_residu_fx( st, inp, res_fx, Aq ); -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) ) { @@ -1440,11 +1407,7 @@ ivas_error acelp_core_enc_ivas_fx( { /* Apply a non linearity to the SHB excitation */ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc -#ifdef HARM_NON_LINEARITY non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); -#else - non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); -#endif Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc } @@ -1491,15 +1454,8 @@ ivas_error acelp_core_enc_ivas_fx( move16(); } -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, - &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, - st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, - st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif IF( EQ_16( st->L_frame, L_FRAME ) ) { diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 985c2852b..876cc94fd 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -459,11 +459,7 @@ void amr_wb_enc_fx( IF( EQ_32( st->core_brate, SID_1k75 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) { /* encode CNG parameters */ -#ifdef HARM_NON_LINEARITY CNG_enc_fx( st, Aq, inp, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw ); -#else - CNG_enc_fx( st, Aq, inp, ener, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw ); -#endif /* comfort noise generation */ CNG_exc_fx( st->core_brate, L_FRAME, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc, exc2, &hTdCngEnc->lp_ener_fx, diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 7e63dc139..e622c9857 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -28,10 +28,6 @@ static void shb_CNG_encod_fx( Encoder_State *st_fx, const Word16 update_fx ); static Word16 shb_DTX_fx( Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k ); -#ifndef HARM_NON_LINEARITY -static Word16 shb_DTX_ivas_fx( Encoder_State *st, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k_fx ); -static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); -#endif /*---------------------------------------------------------------------* @@ -40,1143 +36,7 @@ static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); * Confort noise generation for the coder *---------------------------------------------------------------------*/ -#ifndef HARM_NON_LINEARITY void CNG_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - Word16 Aq[], /* o : LP coefficients Q12 */ - const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ - Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */ - const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */ - Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ - Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 Q_new, /* i : Q value of speech */ - Word32 *q_env, - Word16 *sid_bw ) -{ - Word16 enr_index; - Word16 i, j, ptr; - Word16 m1; - Word16 res[L_FRAME16k]; - Word16 step_inv = 0; - move16(); - Word16 hi, lo; - Word16 maxl = 0; - move16(); - Word16 num_bits = 0; - move16(); - Word16 step = 0; - move16(); - Word16 *pt_res; - const Word16 *pt_sp; - Word16 enr; - Word32 L_tmp, L_ener; - Word16 k, tmp1; - Word16 weights; - Word16 sp_enr; - Word32 L_tmp1; - Word16 exp; - Word16 m = 0; - move16(); - Word16 tmp[HO_HIST_SIZE * M]; - Word16 ll, s_ptr; - Word16 tmpv, maxv, scale, att = 1; - move16(); - Word16 lsf_tmp[M]; - Word32 C[M]; - Word32 max_val[2]; - Word16 max_idx[2]; - Word16 ftmp_fx; - Word16 lsp_tmp[M]; - Word16 dev; - Word16 max_dev; - Word16 dist; - Word16 max_idx1[2] = { 0, 0 }; - move16(); - move16(); - Word16 fft_io[L_FRAME16k]; - Word16 *ptR, *ptI; - Word32 enr1 = 0; - move32(); - Word32 env[NUM_ENV_CNG]; - Word32 min1; - Word16 min1_idx; - Word32 d; - Word16 res1[L_FRAME16k]; - Word32 tmp_env[HO_HIST_SIZE * NUM_ENV_CNG]; - Word16 fra; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - Word16 force_cn_step = 0; - move16(); - Word16 tmp_loop; - Word16 st_lp_sp_enr; - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx; - move16(); - Word16 lp_ener_thr_scale; - - lp_ener_thr_scale = 8; /* 4.0f*/ /*IVAS_CODE Q2 */ - move16(); - if ( st_fx->element_mode != EVS_MONO ) - { - lp_ener_thr_scale = 7; /* 3.5f;*/ - move16(); - } - /*sp_enr = (float) log10( sum2_f( speech, L_frame )/L_frame + 0.1f )/ (float)log10(2.0f);*/ /*9.1 */ - pt_sp = speech; - L_ener = L_deposit_l( 1 ); - /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/ - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - FOR( j = 0; j < 128; j++ ) - { - L_tmp = L_mult0( *pt_sp, *pt_sp ); - pt_sp++; - L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); - pt_sp++; - L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ - } - } - ELSE /* L_FRAME16k */ - { - FOR( i = 0; i < 2; i++ ) - { - FOR( j = 0; j < 80; j++ ) - { - L_tmp = L_mult0( *pt_sp, *pt_sp ); - pt_sp++; - L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); - pt_sp++; - L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ - } - } - } - - hi = norm_l( L_ener ); - lo = Log2_norm_lc( L_shl( L_ener, hi ) ); - hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */ - hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */ - L_tmp = L_Comp( hi, lo ); /* Q16 */ - sp_enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ - - if ( sp_enr < 0 ) - { - sp_enr = 0; - move16(); - } - test(); - IF( hDtxEnc->first_CNG == 0 || hTdCngEnc->old_enr_index < 0 ) - { - hTdCngEnc->lp_sp_enr_fx = sp_enr; - move16(); /* Q8 */ - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /*6.0f in Q8*/ ) && - GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 /*4.0f in Q8*/ ) && GT_16( sp_enr, 1536 /*6.0f in Q8*/ ) ) - { - hTdCngEnc->lp_sp_enr_fx = sp_enr; - move16(); - force_cn_step = 1; - move16(); - } - ELSE - { - hTdCngEnc->lp_sp_enr_fx = round_fx( L_mac( L_mult( 29491 /* 0.9, Q15 */, hTdCngEnc->lp_sp_enr_fx ), 3277 /* 0.1, Q15 */, sp_enr ) ); /* Q8 (8+15+1-16) */ - move16(); - } - } - /* update the pointer to circular buffer of old LSP vectors */ - hTdCngEnc->cng_hist_ptr = add( hTdCngEnc->cng_hist_ptr, 1 ); - move16(); - if ( EQ_16( hTdCngEnc->cng_hist_ptr, DTX_HIST_SIZE ) ) - { - hTdCngEnc->cng_hist_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &( hTdCngEnc->cng_lsp_hist_fx[( hTdCngEnc->cng_hist_ptr ) * M] ), M ); - - /*-----------------------------------------------------------------* - * Find CNG spectral envelope - * Find LSP median - *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) && GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) ) - { - set32_fx( max_val, 0, 2 ); - set16_fx( max_idx, 0, 2 ); - - FOR( i = 0; i < hDtxEnc->cng_hist_size; i++ ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; /*(6400/(M+1))X2.56 */ - move16(); /*QX2.56 */ - tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - ELSE - { - lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_16k ); - ftmp_fx = 1205; /*(8000/(M+1))X2.56*/ - move16(); /*QX2.56 */ - tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - - tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - FOR( j = 0; j < M - 1; j++ ) - { - tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - } - - C[i] = Mpy_32_16_1( L_tmp, 1928 /*.0588235f Q15*/ ); - move32(); /*QX6.5536 */ - - IF( GT_32( C[i], max_val[0] ) ) - { - max_val[1] = max_val[0]; - move32(); - max_idx[1] = max_idx[0]; - move16(); - max_val[0] = C[i]; - move32(); - max_idx[0] = i; - move16(); - } - ELSE IF( GT_32( C[i], max_val[1] ) ) - { - max_val[1] = C[i]; - move32(); - max_idx[1] = i; - move16(); - } - } - - FOR( i = 0; i < M; i++ ) - { - L_tmp = 0; - move32(); - FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[j * M + i] ) ); /*Q15 */ - } - - L_tmp = L_sub( L_tmp, L_add( L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[0] * M + i] ), L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[1] * M + i] ) ) ); /*Q15 */ - tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */ - L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_new[i] = extract_l( L_tmp ); /*Q15 */ - move16(); - } - max_idx1[0] = max_idx[0]; - move16(); - max_idx1[1] = max_idx[1]; - move16(); - } - - /*-----------------------------------------------------------------* - * Quantize CNG spectral envelope (only in SID frame) - * Quantize the LSF vector - *-----------------------------------------------------------------*/ - *allow_cn_step = 0; - move16(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( hDtxEnc->cng_cnt == 0 ) && - GT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /* 6.0, Q8 */ ) && - ( LT_16( add( st_lp_sp_enr, 1024 /* 4.0, Q8 */ ), sp_enr ) ) && - ( hDtxEnc->first_CNG != 0 ) && - ( hTdCngEnc->old_enr_index >= 0 ) && - ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) ) || - EQ_16( force_cn_step, 1 ) ) - { - *allow_cn_step = 1; - move16(); - } - - /* Initialize the CNG spectral envelope in case of the very first CNG frame */ - IF( hDtxEnc->first_CNG == 0 ) - { - Copy( st_fx->lsp_old_fx, hDtxEnc->lspCNG_fx, M ); - - /* Average the CNG spectral envelope in case of the very first CNG frame */ - IF( st_fx->element_mode != EVS_MONO ) - { - FOR( i = 0; i < M; i++ ) - { - /*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/ - lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 /*.5 Q15*/ ); - move16(); - } - } - } - - - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - /* LSF quantization */ - IF( st_fx->Opt_AMR_WB != 0 ) - { - isf_enc_amr_wb_fx( st_fx, lsf_new, lsp_new, 0 ); - } - ELSE - { - lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); - } - - /* Reset CNG history if CNG frame length is changed */ - test(); - test(); - if ( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->first_CNG != 0 && NE_16( st_fx->L_frame, hDtxEnc->last_CNG_L_frame ) ) - { - hTdCngEnc->ho_hist_size = 0; - move16(); - } - } - ELSE - { - /* Use old LSP vector */ - Copy( st_fx->lsp_old_fx, lsp_new, M ); - Copy( st_fx->lsf_old_fx, lsf_new, M ); - } - - /*---------------------------------------------------------------------* - * CNG spectral envelope update - * Find A(z) coefficients - *---------------------------------------------------------------------*/ - - IF( LE_32( st_fx->last_core_brate, SID_2k40 ) ) - { - /* Reset hangover counter if not first SID period */ - if ( GT_32( st_fx->core_brate, FRAME_NO_DATA ) ) - { - hTdCngEnc->num_ho = 0; - move16(); - } - /* Update LSPs if last SID energy not outlier or insufficient number of hangover frames */ - test(); - IF( LT_16( hTdCngEnc->num_ho, 3 ) || LT_32( Mult_32_16( hTdCngEnc->Enew_fx, 21845 /*1/1.5f, Q15*/ ), hTdCngEnc->lp_ener_fx ) ) - { - FOR( i = 0; i < M; i++ ) - { - /* AR low-pass filter */ - hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] ); - move16(); /* Q15 (15+15+1-16) */ - } - } - } - ELSE - { - /* Update CNG_mode if allowed */ - test(); - test(); - test(); - test(); - IF( st_fx->element_mode == EVS_MONO && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) ) - { - IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) ) - { - hDtxEnc->CNG_mode = -1; - move16(); - } - ELSE - { - hDtxEnc->CNG_mode = get_cng_mode( hDtxEnc->last_active_brate ); - move16(); - } - } - - /* If first sid after active burst update LSF history from circ buffer */ - hTdCngEnc->burst_ho_cnt = s_min( hTdCngEnc->burst_ho_cnt, hTdCngEnc->ho_circ_size ); - move16(); - hTdCngEnc->act_cnt = 0; - move16(); - s_ptr = add( sub( hTdCngEnc->ho_circ_ptr, hTdCngEnc->burst_ho_cnt ), 1 ); - - if ( s_ptr < 0 ) - { - s_ptr = add( s_ptr, hTdCngEnc->ho_circ_size ); - } - - FOR( ll = hTdCngEnc->burst_ho_cnt; ll > 0; ll-- ) - { - hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 ); - move16(); - if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_ptr = 0; - move16(); - } - - /* Conversion between 12.8k and 16k LSPs */ - test(); - test(); - IF( EQ_16( st_fx->L_frame, L_FRAME ) && EQ_16( hTdCngEnc->ho_16k_lsp[s_ptr], 1 ) ) - { - /* Conversion from 16k LPSs to 12k8 */ - lsp_convert_poly_fx( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), st_fx->L_frame, 0 ); - } - ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && hTdCngEnc->ho_16k_lsp[s_ptr] == 0 ) - { - /* 16k LSPs already converted and stored, just copy to the other buffer */ - Copy( &( hTdCngEnc->ho_lsp_circ2_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), M ); - } - /* update the circular buffers */ - Copy( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_hist_fx[hTdCngEnc->ho_hist_ptr * M] ), M ); - Copy32( &( hTdCngEnc->ho_ener_circ_fx[s_ptr] ), &( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 1 ); - hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - move32(); - Copy32( &( hTdCngEnc->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngEnc->ho_env_hist_fx[hTdCngEnc->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); - - hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 ); - move16(); - if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_size = HO_HIST_SIZE; - move16(); - } - - s_ptr = add( s_ptr, 1 ); - - if ( EQ_16( s_ptr, hTdCngEnc->ho_circ_size ) ) - { - s_ptr = 0; - move16(); - } - } - - IF( hTdCngEnc->burst_ho_cnt > 0 ) - { - /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ - /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/ - /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */ - L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 ); - IF( NE_16( lp_ener_thr_scale, 8 ) ) - { - L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) ); - } - L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx ); - test(); - test(); - IF( ( hDtxEnc->first_CNG > 0 || st_fx->element_mode == EVS_MONO ) && L_tmp1 > 0 ) - { - *allow_cn_step = s_or( *allow_cn_step, 1 ); - move16(); - } - } - test(); - IF( *allow_cn_step == 0 && hTdCngEnc->ho_hist_size > 0 ) - { - /* Use average of energies below last energy */ - ptr = hTdCngEnc->ho_hist_ptr; - move16(); - Copy( &( hTdCngEnc->ho_lsp_hist_fx[ptr * M] ), tmp, M ); - m1 = 0; - move16(); - IF( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x1 ) == 0 ) - { - Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], tmp_env, NUM_ENV_CNG ); - m1 = 1; - move16(); - } - L_enr = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */ - - weights = W_DTX_HO_FX[0]; /* Q15 */ - move16(); - m = 1; - move16(); - FOR( k = 1; k < hTdCngEnc->ho_hist_size; k++ ) - { - ptr = sub( ptr, 1 ); - if ( ptr < 0 ) - { - ptr = HO_HIST_SIZE - 1; - move16(); - } - - test(); - IF( LT_32( Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], ONE_OVER_BUF_H_NRG_FX ), hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ) && - GT_32( hTdCngEnc->ho_ener_hist_fx[ptr], Mult_32_16( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], BUF_L_NRG_FX ) ) ) - { - /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr]; */ - L_tmp1 = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[k] ); /* Q6+15-15->Q6 */ - L_enr = L_add( L_enr, L_tmp1 ); /* Q6 */ - - /*weights += W_DTX_HO[k]; */ - weights = add( weights, W_DTX_HO_FX[k] ); /* Q15 */ - - Copy( &hTdCngEnc->ho_lsp_hist_fx[ptr * M], &tmp[m * M], M ); - IF( L_and( hTdCngEnc->ho_sid_bw, L_shl( (Word32) 0x1, k ) ) == 0 ) - { - Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], &tmp_env[m1 * NUM_ENV_CNG], NUM_ENV_CNG ); - m1 = add( m1, 1 ); - } - m = add( m, 1 ); - } - } - - /*enr /= weights; */ - exp = norm_s( weights ); - tmp1 = div_s( shl( 1, sub( 14, exp ) ), weights ); /* Q(15+14-exp-15) */ - L_tmp1 = Mult_32_16( L_enr, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */ - L_enr = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */ - - hTdCngEnc->lp_ener_fx = L_enr; - move32(); /* Q6 */ - - set32_fx( max_val, 0, 2 ); - set16_fx( max_idx, 0, 2 ); - - FOR( i = 0; i < m; i++ ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; /*(6400/(M+1))X2.56*/ - move16(); /*QX2.56 */ - tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - ELSE - { - lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k ); - ftmp_fx = 1205; /*(8000/(M+1))X2.56*/ - move16(); /*QX2.56 */ - tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - - tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - FOR( j = 0; j < M - 1; j++ ) - { - tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - } - - C[i] = Mpy_32_16_1( L_tmp, 1928 ); - move32(); /*QX6.5536 */ - - IF( GT_32( C[i], max_val[0] ) ) - { - max_val[1] = max_val[0]; - move32(); - max_idx[1] = max_idx[0]; - move16(); - max_val[0] = C[i]; - move32(); - max_idx[0] = i; - move16(); - } - ELSE IF( GT_32( C[i], max_val[1] ) ) - { - max_val[1] = C[i]; - move32(); - max_idx[1] = i; - move16(); - } - } - - IF( EQ_16( m, 1 ) ) - { - Copy( tmp, lsp_tmp, M ); - } - ELSE IF( LT_16( m, 4 ) ) - { - FOR( i = 0; i < M; i++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < m; j++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( tmp[j * M + i] ) ); - } - - L_tmp = L_sub( L_tmp, L_deposit_l( tmp[max_idx[0] * M + i] ) ); - tmpv = div_s( 1, sub( m, 1 ) ); /*Q15 */ - L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ - } - } - ELSE - { - FOR( i = 0; i < M; i++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < m; j++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( tmp[j * M + i] ) ); - } - - L_tmp = L_sub( L_tmp, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15 */ - tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */ - L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ - } - } - - dist = 0; /*Q15 */ - max_dev = 0; /*Q15 */ - move16(); - move16(); - FOR( i = 0; i < M; i++ ) - { - dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ - dist = add_sat( dist, dev ); /*Q15 */ - if ( GT_16( dev, max_dev ) ) - { - max_dev = dev; - move16(); - } - } - - test(); - IF( GT_16( dist, 13107 ) || GT_16( max_dev, 3277 ) ) - { - FOR( i = 0; i < M; i++ ) - { - hDtxEnc->lspCNG_fx[i] = lsp_tmp[i]; - move16(); /*Q15 */ - } - } - ELSE - { - FOR( i = 0; i < M; i++ ) - { - /* AR low-pass filter */ - hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) ); - move16(); - } - } - IF( m1 > 0 ) - { - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < m1; j++ ) - { - /* env[i] += tmp_env[j*NUM_ENV_CNG+i]; */ - L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); - } - /* env[i] /= (float)m1; */ - /* env[i] = env[i] - 2*hTdCngEnc->lp_ener_fx; */ - IF( EQ_16( m1, 1 ) ) - { - L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); - } - ELSE - { - tmp1 = div_s( 1, m1 ); - L_tmp = Mult_32_16( L_tmp, tmp1 ); - L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); - } - - env[i] = L_tmp; - move32(); - } - Copy32( env, hTdCngEnc->lp_env_fx, NUM_ENV_CNG ); - } - } - ELSE - { - Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */ - } - } - IF( st_fx->Opt_AMR_WB != 0 ) - { - E_LPC_f_isp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); - } - ELSE - { - E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); /* Find A(z) (not interpolated) */ - } - - tmp_loop = shr( st_fx->L_frame, 6 ); - FOR( i = 1; i < tmp_loop; i++ ) - { - Copy( Aq, &Aq[i * ( M + 1 )], M + 1 ); - } - /*-----------------------------------------------------------------* - * Find residual signal - * Calculate residual signal energy per sample - *-----------------------------------------------------------------*/ - - /* calculate the residual signal */ - Residu3_fx( Aq, speech, res, st_fx->L_frame, 0 ); - Copy( res, res1, st_fx->L_frame ); - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - } - ELSE IF( NE_16( st_fx->bwidth, NB ) ) - { - test(); - IF( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->CNG_mode >= 0 ) - { - ftmp_fx = HO_ATT_FX[hDtxEnc->CNG_mode]; - move16(); - } - ELSE - { - ftmp_fx = 19661; /*0.6f in Q15*/ - move16(); - } - - att = mult( ftmp_fx, 5461 /*1/6f in Q15*/ ); /* Q15 */ - L_tmp = L_mult( att, 8 ); /* Q16 */ - tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */ - tmp1 = add( 16384, tmp1 ); - att = div_s( 16374, tmp1 ); /* Q15 */ - - att = s_max( att, ftmp_fx ); - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - /*res1[i] *= att;*/ - res1[i] = mult( res1[i], att ); - move16(); /* Q_new */ - } - att = shr( att, 7 ); /* Q8 */ - } - - /* calculate the spectrum of residual signal */ - Copy( res1, fft_io, st_fx->L_frame ); - - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, hTdCngEnc->exc_mem2_fx, 0 ); - } - - fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); - ptR = &fft_io[1]; - ptI = &fft_io[L_FFT - 1]; - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ - tmp1 = add( add( Q_new, Q_new ), 1 ); - env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); - move32(); /* Q6 */ - ptR++; - ptI--; - } - - Copy32( env, &( hTdCngEnc->cng_res_env_fx[( hTdCngEnc->cng_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); - - /* calculate the residual signal energy */ - /*enr = dotp( res, res, L_frame ) / L_frame; */ - maxv = 0; - move16(); - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - maxv = s_max( maxv, abs_s( res[i] ) ); - } - scale = norm_s( maxv ); - pt_res = res; - L_ener = L_deposit_l( 1 ); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - FOR( j = 0; j < 128; j++ ) - { - tmpv = shl( *pt_res, scale ); - L_tmp = L_mult0( tmpv, tmpv ); - pt_res++; - tmpv = shl( *pt_res, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ - pt_res++; - L_ener = L_add_sat( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */ - } - } - ELSE /* L_FRAME16k */ - { - FOR( j = 0; j < 160; j++ ) - { - tmpv = shl( *pt_res, scale ); - L_tmp = L_mult0( tmpv, tmpv ); - pt_res++; - tmpv = shl( *pt_res, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ - pt_res++; - L_ener = L_add_sat( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */ - } - } - /* convert log2 of residual signal energy */ - /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ - hi = norm_l( L_ener ); - lo = Log2_norm_lc( L_shl( L_ener, hi ) ); - hi = sub( 29, hi ); /* log2 exp in Q2*(Q_new+scale) */ - hi = sub( hi, shl( add( Q_new, scale ), 1 ) ); /* Q0 */ - L_tmp = L_Comp( hi, lo ); /* Q16 */ - enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ - - /* update the circular buffer of old energies */ - hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr; - move16(); /* Q8 */ - - /*-----------------------------------------------------------------* - * Quantize residual signal energy (only in SID frame) - *-----------------------------------------------------------------*/ - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - IF( GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) ) - { - /* average the envelope except outliers */ - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - L_tmp1 = L_add( env[i], 0 ); - FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ ) - { - L_tmp1 = L_add_sat( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] ); - } - L_tmp = L_add( hTdCngEnc->cng_res_env_fx[max_idx1[0] * NUM_ENV_CNG + i], hTdCngEnc->cng_res_env_fx[max_idx1[1] * NUM_ENV_CNG + i] ); - L_tmp1 = L_sub( L_tmp1, L_tmp ); - - /* env[i] /= (float)(st_fx->cng_hist_size - 2); */ - tmp1 = sub( hDtxEnc->cng_hist_size, 2 ); - IF( GT_16( tmp1, 1 ) ) - { - tmp1 = div_s( 1, tmp1 ); - L_tmp1 = Mult_32_16( L_tmp1, tmp1 ); - } - - env[i] = L_tmp1; - move32(); - } - /* compute average excitation energy */ - L_tmp = L_deposit_l( 0 ); - ptr = hTdCngEnc->cng_hist_ptr; - move16(); - - FOR( k = 0; k < hDtxEnc->cng_hist_size; k++ ) - { - /* enr += W_HIST[k]*cng_ener_hist[ptr] */ - L_tmp = L_mac0( L_tmp, W_HIST_FX[k], hTdCngEnc->cng_ener_hist_fx[ptr] ); /* Q24 (8+16) */ - ptr = sub( ptr, 1 ); - if ( ptr < 0 ) /* check for circular pointer */ - { - ptr = DTX_HIST_SIZE - 1; - move16(); - } - } - /*----------------------------------------------------------- - * here we want to divide L_tmp by the sum - * of all the coefs used W_HIST[0..cng_hist_size-1] - * The table W_HIST_S already contains the inverted sum. - * That is - * W_HIST_S[k] 1 - * ------------- = --------------------------- - * 4096 W_HIST[0] + ... + W_HIST[k] - * - * 1 / Sum(W_HIST[0..k]) is always > 1 since the sum - * of the coefs 0..k is always < 1 but > 0 - * enr is in Q8 since the history buffer constains Q8 energies - *-----------------------------------------------------------*/ - /*L_tmp = Mpy_32_16_1(L_tmp, W_HIST_S_FX[k-1]); */ /* normalize average value */ - L_tmp = Mult_32_16( L_tmp, W_HIST_S_FX[k - 1] ); /* Q21 (24+12+1-16) */ - L_tmp = L_shl( L_tmp, 3 ); /* Q24 */ - enr = round_fx( L_tmp ); /* Q8 */ - } - /* decrease the energy in case of WB input */ - test(); - IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - } - ELSE IF( NE_16( st_fx->bwidth, NB ) ) - { - IF( EQ_16( st_fx->bwidth, WB ) ) - { - IF( hDtxEnc->CNG_mode >= 0 ) - { - /* Bitrate adapted attenuation */ - att = ENR_ATT_fx[hDtxEnc->CNG_mode]; - move16(); - } - ELSE - { - /* Use least attenuation for higher bitrates */ - att = ENR_ATT_fx[4]; - move16(); - } - } - ELSE - { - att = 384; - move16(); /*Q8*/ - } - enr = sub( enr, att ); - } - /* intialize the energy quantization parameters */ - IF( st_fx->Opt_AMR_WB == 0 ) - { - step = STEP_SID_FX; - move16(); - step_inv = ISTEP_SID_FX; - move16(); - maxl = 127; - move16(); - num_bits = 7; - move16(); - } - ELSE - { - step = STEP_AMR_WB_SID_FX; - move16(); - step_inv = ISTEP_AMR_WB_SID_FX; - move16(); - maxl = 63; - move16(); - num_bits = 6; - move16(); - } - - /* calculate the energy quantization index */ - enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ - enr_index = extract_l( L_shr( L_mult0( enr_index, step ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ - - /* limit the energy quantization index */ - enr_index = s_min( enr_index, maxl ); - enr_index = s_max( enr_index, 0 ); - - /* allow only slow energy increase */ - test(); - IF( hTdCngEnc->old_enr_index >= 0 && GT_16( enr_index, add( hTdCngEnc->old_enr_index, MAX_DELTA ) ) ) - { - IF( *allow_cn_step != 0 ) - { - tmp1 = mult( 27853 /* Q15(0.85) */, sub( enr_index, hTdCngEnc->old_enr_index ) ); - enr_index = add( hTdCngEnc->old_enr_index, tmp1 ); - } - ELSE - { - enr_index = add( hTdCngEnc->old_enr_index, MAX_DELTA ); - } - } - hTdCngEnc->old_enr_index = enr_index; - move16(); - - push_indice( hBstr, IND_ENERGY, enr_index, num_bits ); - if ( enr_index == 0 ) - { - enr_index = -5; - move16(); - } - /* Find quantized energy */ - /* *Enew = (float)enr_index / step - 2.0 */ - /* *Enew = (float)pow(2.0, *Enew) */ - L_tmp = L_mult( enr_index, step_inv ); /* Q16(0+15+1) */ - /* substract by 2 not done to leave Energy in Q2 */ - lo = L_Extract_lc( L_tmp, &hi ); - hTdCngEnc->Enew_fx = Pow2( add( hi, 4 ), lo ); /* Q6 */ - move32(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/ - exp = norm_l( hTdCngEnc->Enew_fx ); - L_tmp = L_shl( hTdCngEnc->Enew_fx, exp ); /*Q(exp+6) */ - L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /* Q(exp+6+5-15=exp-4) */ - - L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /* Q6 */ - - exp = norm_l( L_tmp ); - fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); - enr1 = L_shr( L_tmp, 10 ); /* Q6 */ - - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* env[i] -= 2 * st->Enew;*/ - L_tmp1 = L_add( env[i], 0 ); - L_tmp = L_add( hTdCngEnc->Enew_fx, hTdCngEnc->Enew_fx ); - L_tmp1 = L_sub( L_tmp1, L_tmp ); /*Q6*/ - - IF( L_tmp1 < 0 ) - { - L_tmp1 = L_deposit_l( 6 ); /* (0.1)Q6 */ - } - /* env[i] = (float)log10( env[i] + 0.1f ) / (float)log10( 2.0f ); */ - exp = norm_l( L_tmp1 ); - fra = Log2_norm_lc( L_shl( L_tmp1, exp ) ); - exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); - L_tmp1 = L_shr( L_tmp, 10 ); /* Q6 */ - - L_tmp = L_shr( L_deposit_l( att ), 2 ); /* Q6 */ - L_tmp1 = L_sub( L_tmp1, L_tmp ); - - IF( L_tmp1 < 0 ) - { - L_tmp1 = L_deposit_l( 0 ); - } - - L_tmp1 = L_sub( enr1, L_tmp1 ); - - env[i] = L_tmp1; - move32(); - } - - /* codebook search */ - min1 = L_add( 1310588928, 0 ); /* Q17 */ - min1_idx = 0; - move16(); - - FOR( i = 0; i < 64; i++ ) - { - d = L_deposit_l( 0 ); - FOR( j = 0; j < NUM_ENV_CNG; j++ ) - { - /* d += (env[j] - CNG_details_codebook_fx[i][j]) * (env[j] - CNG_details_codebook_fx[i][j]);*/ - L_tmp = L_sub( env[j], L_deposit_l( CNG_details_codebook_fx[i][j] ) ); /* Q6 */ - exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ - tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ - L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ - d = L_add( d, L_tmp ); - } - - IF( LT_32( d, min1 ) ) - { - min1 = L_add( d, 0 ); - min1_idx = i; - move16(); - } - } - push_indice( hBstr, IND_CNG_ENV1, min1_idx, 6 ); - /* get quantized res_env_details */ - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - q_env[i] = L_deposit_l( CNG_details_codebook_fx[min1_idx][i] ); - move32(); - } - } - /* Update hangover memory during CNG */ - test(); - IF( *allow_cn_step == 0 && LT_32( Mult_32_16( hTdCngEnc->Enew_fx, 21845 /*1/1.5f, Q15*/ ), hTdCngEnc->lp_ener_fx ) ) - { - /* update the pointer to circular buffer of old LSP vectors */ - hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 ); - move16(); - if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &( hTdCngEnc->ho_lsp_hist_fx[( hTdCngEnc->ho_hist_ptr ) * M] ), M ); - - /* update the hangover energy buffer */ - hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] = hTdCngEnc->Enew_fx; - move32(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* get quantized envelope */ - /* env[i] = pow(2.0f,(enr1 - q_env[i])) + 2*st->Enew;*/ - L_tmp = L_sub( enr1, q_env[i] ); /* Q6 */ - L_tmp = L_shl( L_tmp, 10 ); /* 16 */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - - exp_pow = sub( 14, temp_hi_fx ); - L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ - env[i] = L_shl( L_tmp, sub( 6, exp_pow ) ); - move32(); /* Q6 */ - L_tmp = L_add( hTdCngEnc->Enew_fx, hTdCngEnc->Enew_fx ); - env[i] = L_add( env[i], L_tmp ); - move32(); /* Q6 */ - } - Copy32( env, &( hTdCngEnc->ho_env_hist_fx[( hTdCngEnc->ho_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); - } - hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 ); - move16(); - if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_size = HO_HIST_SIZE; - move16(); - } - } - } - /* dithering bit for AMR-WB IO mode is always set to 0 */ - IF( EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - push_indice( hBstr, IND_DITHERING, 0, 1 ); - } - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - push_indice( hBstr, IND_ACELP_16KHZ, 1, 1 ); - } - ELSE - { - push_indice( hBstr, IND_ACELP_16KHZ, 0, 1 ); - } - - push_indice( hBstr, IND_CNG_HO, s_min( hTdCngEnc->burst_ho_cnt, 7 ), 3 ); - hTdCngEnc->num_ho = m; - move16(); - push_indice( hBstr, IND_SID_TYPE, 0, 1 ); - - test(); - IF( LT_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - push_indice( hBstr, IND_SID_BW, 0, 1 ); - *sid_bw = 0; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Updates - *-----------------------------------------------------------------*/ - /* update the SID frames counter */ - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - hDtxEnc->cng_cnt = 0; - move16(); - hTdCngEnc->cng_hist_ptr = -1; - move16(); - /* update frame length memory */ - hDtxEnc->last_CNG_L_frame = st_fx->L_frame; - move16(); - } - ELSE - { - hDtxEnc->cng_cnt = add( hDtxEnc->cng_cnt, 1 ); - move16(); - } - - return; -} - -void CNG_enc_ivas_fx( -#else -void CNG_enc_fx( -#endif Encoder_State *st_fx, /* i/o: State structure */ Word16 Aq[], /* o : LP coefficients Q12 */ const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ @@ -1214,14 +74,8 @@ void CNG_enc_fx( Word16 max_idx[2]; Word16 ftmp_fx; Word16 lsp_tmp[M]; -#ifdef HARM_NON_LINEARITY Word32 dev, max_dev, dist; Word16 dev16, max_dev16, dist16; -#else - Word32 dev; - Word32 max_dev; - Word32 dist; -#endif Word16 max_idx1[2]; Word16 fft_io[L_FRAME16k]; Word16 *ptR, *ptI; @@ -1245,10 +99,8 @@ void CNG_enc_fx( Word64 w_temp; Word32 inv_frame_len; Word32 L_ener; -#ifdef HARM_NON_LINEARITY Word16 *pt_res; const Word16 *pt_sp; -#endif step_inv = 0; move16(); @@ -1281,7 +133,6 @@ void CNG_enc_fx( move16(); } -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { pt_sp = speech; @@ -1314,7 +165,6 @@ void CNG_enc_fx( } } ELSE -#endif { w_temp = 1; move64(); @@ -1685,7 +535,6 @@ void CNG_enc_fx( IF( hTdCngEnc->burst_ho_cnt > 0 ) { -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ @@ -1700,7 +549,6 @@ void CNG_enc_fx( w_temp = W_deposit32_l( L_tmp1 ); } ELSE -#endif { /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ @@ -1867,7 +715,6 @@ void CNG_enc_fx( } } -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { dist16 = 0; /*Q15 */ @@ -1889,7 +736,6 @@ void CNG_enc_fx( max_dev = L_deposit_l( max_dev16 ); } ELSE -#endif { dist = 0; /*Q15 */ move32(); @@ -1967,9 +813,7 @@ void CNG_enc_fx( ELSE { E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode != EVS_MONO ) -#endif { exp = sub( Q14, norm_s( Aq[0] ) ); Scale_sig( Aq, M + 1, sub( Q12, exp ) ); // Q12 @@ -2057,7 +901,6 @@ void CNG_enc_fx( /* calculate the residual signal energy */ /*enr = dotp( res, res, L_frame ) / L_frame; */ -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { Word16 maxv, scale; @@ -2108,7 +951,6 @@ void CNG_enc_fx( enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ } ELSE -#endif { w_temp = 1; move64(); @@ -2527,310 +1369,6 @@ void CNG_enc_fx( return; } -#ifndef HARM_NON_LINEARITY -/*---------------------------------------------------------------------* - * swb_CNG_enc() - * - * SWB DTX/CNG encoding - *---------------------------------------------------------------------*/ -void swb_CNG_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ -) -{ - Word16 shb_SID_updt_fx = 0; - move16(); - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || st_fx->core_brate == FRAME_NO_DATA ) - { - IF( EQ_16( st_fx->cng_type, LP_CNG ) ) - { - IF( GE_32( st_fx->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) - { - /* decide if SHB SID encoding or not */ - shb_SID_updt_fx = shb_DTX_fx( st_fx, shb_speech_fx, syn_12k8_16k_fx ); - - /* SHB CNG encoding */ - shb_CNG_encod_fx( st_fx, shb_SID_updt_fx ); - } - ELSE IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - } - } - hTdCngEnc->last_vad = 0; - move16(); - } - ELSE - { - hTdCngEnc->last_vad = 1; - move16(); - } - - return; -} - -/*---------------------------------------------------------------------* - * shb_CNG_encod() - * - * SID parameters encoding for SHB signal - *---------------------------------------------------------------------*/ -static void shb_CNG_encod_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 update_fx /* i : SID update flag */ -) -{ - Word16 idx_ener_fx; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - - idx_ener_fx = 0; - move16(); - IF( EQ_16( update_fx, 1 ) ) - { - /* SHB energy quantization */ - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - idx_ener_fx = shr( add( mult( hTdCngEnc->mov_shb_cng_ener_fx, 9797 ), 1510 ), 8 ); /* Q0 */ - } - ELSE - { - } - - if ( LT_16( st_fx->bwidth, SWB ) ) - { - idx_ener_fx = 0; - move16(); - } - - IF( GT_16( idx_ener_fx, 15 ) ) - { - idx_ener_fx = 15; - move16(); - } - ELSE - { - idx_ener_fx = s_max( idx_ener_fx, 0 ); - } - - push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); - push_indice( hBstr, IND_SID_BW, 1, 1 ); - delete_indice( hBstr, IND_CNG_ENV1 ); - move16(); - move16(); - - if ( st_fx->element_mode == IVAS_CPE_DFT ) - { - } - else - { - push_indice( hBstr, IND_UNUSED, 0, 2 ); - } - hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - hTdCngEnc->ho_sid_bw = L_or( hTdCngEnc->ho_sid_bw, 0x1L ); - move32(); - move32(); - } - ELSE - { - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - push_indice( hBstr, IND_SID_BW, 0, 1 ); - } - } - - return; -} - -/*---------------------------------------------------------------------* - * shb_DTX() - * - * Decide if encoding SHB SID or not - *---------------------------------------------------------------------*/ - -static Word16 shb_DTX_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ - const Word16 *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ -) -{ - Word16 i; - Word16 update_fx; - Word16 shb_old_speech_fx[( ACELP_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 4]; - Word16 *shb_new_speech_fx; - Word32 wb_ener_fx; - Word32 shb_ener_fx; - Word16 log_wb_ener_fx; - Word16 log_shb_ener_fx; - Word16 tmp; - Word16 exp; - Word16 fra; - Word16 att; /*Q8*/ - Word16 allow_cn_step_fx = 0; - move16(); - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - - shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; - Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); - Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); - Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); - - shb_ener_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); - } - - shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* 102 in Q15, shb_ener_fx in Q1 */ - - wb_ener_fx = L_deposit_l( 0 ); - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); - } - - wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ - - exp = norm_l( wb_ener_fx ); - fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); - exp = sub( 30 - 1, exp ); - wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ - exp = norm_l( shb_ener_fx ); - fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); - exp = sub( 30 - 1, exp ); - shb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - - test(); - IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - att = 0; - move16(); - } - ELSE - { - att = 1664; /*6.5 in Q8*/ - move16(); - } - - log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */ - IF( hDtxEnc->first_CNG == 0 ) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - } - - if ( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12.0f Q8*/ ) ) - { - allow_cn_step_fx = 1; - move16(); - } - - IF( EQ_16( allow_cn_step_fx, 1 ) ) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - } - ELSE - { - tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */ - tmp = mult( tmp, 29491 /*.9f in Q15*/ ); /* Q8 */ - hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */ - move16(); - tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ); - tmp = mult( tmp, 8192 /*.25f in Q15*/ ); /* Q8 */ - hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */ - move16(); - } - hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 ); - move16(); - update_fx = 0; - move16(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - test(); - test(); - IF( hDtxEnc->first_CNG == 0 || EQ_16( hTdCngEnc->last_vad, 1 ) || GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) - { - update_fx = 1; - move16(); - } - ELSE - { - IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) - { - update_fx = 1; - move16(); - hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); - move16(); - } - ELSE - { - IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 /*3.0f in Q8*/ ) ) - { - update_fx = 1; - move16(); - } - ELSE - { - test(); - IF( GE_16( st_fx->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) - { - update_fx = 1; - move16(); - } - ELSE - { - test(); - IF( LT_16( st_fx->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) - { - update_fx = 1; - move16(); - } - } - } - } - } - - hTdCngEnc->last_SID_bwidth = st_fx->bwidth; - move16(); - } - /* LF-boost not yet implemented in decoder which means that the specific wb_sid information is not used */ - test(); - test(); - if ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - update_fx = 1; - move16(); - } - - IF( EQ_16( update_fx, 1 ) ) - { - hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; - move16(); - hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; - move16(); - hTdCngEnc->shb_NO_DATA_cnt = 0; - move16(); - } - - - return ( update_fx ); -} -#endif /*---------------------------------------------------------------------* * calculate_hangover_attenuation_gain_fx() @@ -2839,50 +1377,6 @@ static Word16 shb_DTX_fx( *---------------------------------------------------------------------*/ void calculate_hangover_attenuation_gain_fx( -#ifndef HARM_NON_LINEARITY - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor Q15 */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -) -{ - Word16 offset; - TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; - - *att = 32767; // 1.0f in Q15 - - move16(); - /* smoothing in case of CNG */ - IF( hTdCngEnc != NULL ) - { - test(); - test(); - test(); - IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */ - { - if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) - { - } - else - { - offset = 5; - move16(); - test(); - if ( EQ_16( st->bwidth, WB ) && st->hDtxEnc->CNG_mode >= 0 ) - { - offset = st->hDtxEnc->CNG_mode; - move16(); - } - assert( hTdCngEnc->burst_ho_cnt > 0 ); - *att = CNG_burst_att_fx[offset][hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/ - move16(); - } - } - } - return; -} - -void calculate_hangover_attenuation_gain_ivas_fx( -#endif Encoder_State *st, /* i : encoder state structure */ Word16 *att, /* o : attenuation factor Q15 */ const Word16 vad_hover_flag /* i : VAD hangover flag */ @@ -2907,7 +1401,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( *att = extract_h( L_shl_sat( L_tmp, result_e ) ); move16(); } -#ifdef HARM_NON_LINEARITY ELSE IF( st->element_mode == EVS_MONO ) { Word16 offset = 5; @@ -2922,7 +1415,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( *att = CNG_burst_att_fx[offset][st->hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/ move16(); } -#endif ELSE { test(); @@ -2953,7 +1445,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( } -#ifdef HARM_NON_LINEARITY /*---------------------------------------------------------------------* * swb_CNG_enc() * @@ -2961,9 +1452,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( *---------------------------------------------------------------------*/ void swb_CNG_enc_fx( -#else -void swb_CNG_enc_ivas_fx( -#endif Encoder_State *st, /* i/o: State structure */ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ @@ -2980,18 +1468,10 @@ void swb_CNG_enc_ivas_fx( IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) { /* decide if SHB SID encoding or not */ -#ifdef HARM_NON_LINEARITY shb_SID_updt = shb_DTX_fx( st, shb_speech_fx, syn_12k8_16k_fx ); -#else - shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx ); -#endif /* SHB CNG encoding */ -#ifdef HARM_NON_LINEARITY shb_CNG_encod_fx( st, shb_SID_updt ); -#else - shb_CNG_encod_ivas_fx( st, shb_SID_updt ); -#endif } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) ) { @@ -3021,11 +1501,7 @@ void swb_CNG_enc_ivas_fx( * SID parameters encoding for SHB signal *---------------------------------------------------------------------*/ -#ifdef HARM_NON_LINEARITY static void shb_CNG_encod_fx( -#else -static void shb_CNG_encod_ivas_fx( -#endif Encoder_State *st, /* i/o: State structure */ const Word16 update /* i : SID update flag */ ) @@ -3039,11 +1515,7 @@ static void shb_CNG_encod_ivas_fx( { IF( st->element_mode == EVS_MONO ) { -#ifdef HARM_NON_LINEARITY idx_ener = shr( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 9797 ), 1510 ), 8 ); /* Q0 */ -#else - idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */ -#endif } ELSE { @@ -3146,11 +1618,7 @@ static void shb_CNG_encod_ivas_fx( * Decide if encoding SHB SID or not *---------------------------------------------------------------------*/ -#ifdef HARM_NON_LINEARITY static Word16 shb_DTX_fx( -#else -static Word16 shb_DTX_ivas_fx( -#endif Encoder_State *st, /* i/o: State structure */ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ @@ -3219,11 +1687,7 @@ static Word16 shb_DTX_ivas_fx( } ELSE { -#ifdef HARM_NON_LINEARITY att_fx = 1664; /*6.5 in Q8*/ -#else - att_fx = -1664; // Q8 -#endif move16(); } @@ -3291,11 +1755,7 @@ static Word16 shb_DTX_ivas_fx( update = 1; move16(); } -#ifdef HARM_NON_LINEARITY ELSE IF( st->element_mode != EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 ) -#else - ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) -#endif { hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); update = 1; @@ -3312,7 +1772,6 @@ static Word16 shb_DTX_ivas_fx( update = 1; move16(); } -#ifdef HARM_NON_LINEARITY ELSE IF( st->element_mode == EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 ) { hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); @@ -3320,7 +1779,6 @@ static Word16 shb_DTX_ivas_fx( move16(); move16(); } -#endif ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) { update = 1; diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 8e40d9530..6c2f6100b 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3617,11 +3617,7 @@ void QuantizeTCXSpectrum_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif *gain_tcx_fx = mult( *gain_tcx_fx, att_fx ); move16(); } diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index ce0a8f23e..2cbbd5c9a 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -461,28 +461,13 @@ void core_encode_openloop_fx( E_LPC_a_lsp_conversion( A, lsptmp, lsp_new, M ); Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 ); -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr, - hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, - Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, - hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate ); -#endif } ELSE { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, - st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, - &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, - &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, - hDtxEnc->last_active_brate ); -#endif } IF( EQ_16( st->L_frame, L_FRAME ) ) diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c index 5e3c9241b..b3bd7d112 100644 --- a/lib_enc/enc_acelp_tcx_main_fx.c +++ b/lib_enc/enc_acelp_tcx_main_fx.c @@ -71,11 +71,7 @@ void enc_acelp_tcx_main_fx( test(); IF( EQ_16( st->core, ACELP_CORE ) && st->igf != 0 ) { -#ifdef HARM_NON_LINEARITY non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame ); -#else - non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame ); -#endif /* update the old BWE exe memory */ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/ diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 8f70a5b36..7c5a7884c 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -337,11 +337,7 @@ void hq_hr_enc_ivas_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */ } diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 1037fb6c4..deed347b3 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -4141,11 +4141,7 @@ void IGFEncApplyMono_ivas_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif } IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 35d7f45b3..96c61e38a 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -852,11 +852,7 @@ ivas_error ivas_core_enc_fx( #ifndef REMOVE_SCALING_SHB_SPEECH Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 #endif -#ifdef HARM_NON_LINEARITY swb_CNG_enc_fx( st, shb_speech_fx, old_syn_12k8_16k_fx[n] ); -#else - swb_CNG_enc_ivas_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); -#endif } /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 6bd3aca8c..709e17ef7 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -629,27 +629,15 @@ void stereo_tcx_core_enc( E_LPC_a_lsp_conversion( A_fx, lsptmp_fx, lsp_new_fx, M ); Residu3_fx( A_fx, buf_fx + L_LP - L_FRAME, res_fx, L_FRAME, 0 ); -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, - st->hTdCngEnc->ho_lsp_circ_fx, Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, - st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif Q_exc = Q_r; move16(); } ELSE { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, - st->hTdCngEnc->ho_lsp_circ_fx, st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, - st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif } IF( EQ_16( st->L_frame, L_FRAME ) ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index fc5fa2eeb..dd3060a48 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -615,13 +615,6 @@ void swb_CNG_enc_fx( const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */ ); -#ifndef HARM_NON_LINEARITY -void swb_CNG_enc_ivas_fx( - Encoder_State *st, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ -); -#endif void swb_pre_proc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *input_fx, /* i : original i signal */ @@ -1709,21 +1702,6 @@ void reset_rf_indices_fx( ); void CNG_enc_fx( -#ifndef HARM_NON_LINEARITY - Encoder_State *st_fx, /* i/o: State structure */ - Word16 Aq[], /* o : LP coefficients Q12 */ - const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */ - Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */ - const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */ - Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ - Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 Q_new, /* i : Q value of speech */ - Word32 *q_env, - Word16 *sid_bw ); - -void CNG_enc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: State structure */ Word16 Aq[], /* o : LP coefficients Q12 */ const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */ -- GitLab From 50437ededadc40ac14cfd88e2131ed46fce3dcb6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:34:19 +0100 Subject: [PATCH 613/750] [cleanup] accept FIX_2344_ALIGN_PREPROC --- lib_com/ivas_prot_fx.h | 12 -- lib_com/options.h | 1 - lib_enc/ivas_core_enc_fx.c | 25 ---- lib_enc/ivas_core_pre_proc_front_fx.c | 41 ------ lib_enc/ivas_core_pre_proc_fx.c | 171 -------------------------- lib_enc/ivas_cpe_enc_fx.c | 9 -- lib_enc/ivas_ism_enc_fx.c | 9 -- lib_enc/ivas_sce_enc_fx.c | 12 -- 8 files changed, 280 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c8da9fea1..4e380b17c 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5827,11 +5827,7 @@ ivas_error ivas_mct_enc_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ); -#ifdef FIX_2344_ALIGN_PREPROC void ivas_compute_core_buffers_fx( -#else -ivas_error ivas_compute_core_buffers_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */ @@ -5936,11 +5932,7 @@ void ivas_mct_enc_close_fx( MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ ); -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_front_ivas_fx( -#else -ivas_error pre_proc_front_ivas_fx( -#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -5996,11 +5988,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 *Q_new /* i/o : Q factor of speech buffers */ ); -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_ivas_fx( -#else -ivas_error pre_proc_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ diff --git a/lib_com/options.h b/lib_com/options.h index 0d06acdff..970e684b1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ #define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ #define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ #define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT /* Nokia/FhG: basop issue 2323: Use correct init size */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 96c61e38a..14230d021 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -232,7 +232,6 @@ ivas_error ivas_core_enc_fx( Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } -#ifdef FIX_2344_ALIGN_PREPROC Word32 last_element_brate_tmp = element_brate; move32(); IF( EQ_32( ivas_format, SBA_FORMAT ) ) @@ -244,28 +243,6 @@ ivas_error ivas_core_enc_fx( pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ); -#else - IF( EQ_32( ivas_format, SBA_FORMAT ) ) - { - IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), - IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE - { - IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), - IVAS_ERR_OK ) ) - { - return error; - } - } -#endif test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || EQ_16( st->element_mode, IVAS_SCE ) ) @@ -771,10 +748,8 @@ ivas_error ivas_core_enc_fx( #ifndef REMOVE_SCALING_SHB_SPEECH Word16 Q_shb_spch_16 = Q_shb_spch; move16(); -#ifdef FIX_2344_ALIGN_PREPROC IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become: // IF( st->tcxonly == 0 ) -#endif { shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index b8d10c06f..66dad5732 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -76,11 +76,7 @@ static Word16 get_zero_flag( const Word32 arr[], const Word16 len ) * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) *--------------------------------------------------------------------*/ -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_front_ivas_fx( -#else -ivas_error pre_proc_front_ivas_fx( -#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -161,9 +157,6 @@ ivas_error pre_proc_front_ivas_fx( STEREO_CLASSIF_HANDLE hStereoClassif; Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */ Word16 LR_localVAD; -#ifndef FIX_2344_ALIGN_PREPROC - ivas_error error; -#endif Word16 *signal_in_fx; Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ @@ -214,30 +207,15 @@ ivas_error pre_proc_front_ivas_fx( Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; Word16 Q_inp_const = -1; move16(); -#ifdef FIX_2344_ALIGN_PREPROC Word16 headroom, preemp_len, inp_max; -#else - Word16 headroom = 0, preemp_len = 0, inp_max = 0; - move16(); - move16(); - move16(); -#endif Word16 *preemp_start_idx = NULL; -#ifdef FIX_2344_ALIGN_PREPROC Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; -#else - Word32 sig_out[960], max_32; -#endif push_wmops( "pre_proc_front" ); /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ -#ifndef FIX_2344_ALIGN_PREPROC - error = IVAS_ERR_OK; - move32(); -#endif cldfbScale.lb_scale = Q31; cldfbScale.hb_scale = Q31; move16(); @@ -542,17 +520,10 @@ ivas_error pre_proc_front_ivas_fx( * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1 *-----------------------------------------------------------------*/ -#ifndef FIX_2344_ALIGN_PREPROC - *Q_new = 0; - move16(); - set32_fx( sig_out, 0, 960 ); -#endif headroom = 2; move16(); -#ifdef FIX_2344_ALIGN_PREPROC preemp_len = 0; move16(); -#endif st->mem_preemph_fx_q_inp = shl_sat( st->mem_preemph_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/ move16(); @@ -1477,15 +1448,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Compute core-coder buffers at internal sampling rate */ -#ifdef FIX_2344_ALIGN_PREPROC ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); -#else - error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); - IF( NE_32( error, IVAS_ERR_OK ) ) - { - return error; - } -#endif *epsP_fx_q = add( Q_r[0], 1 ); move16(); @@ -1572,11 +1535,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); pop_wmops(); -#ifdef FIX_2344_ALIGN_PREPROC return; -#else - return error; -#endif } diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index e6dc79e2f..e83973437 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -46,11 +46,7 @@ * Decision matrix, Preprocessing at other Fs, core switching decision, ...) *--------------------------------------------------------------------*/ -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_ivas_fx( -#else -ivas_error pre_proc_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ @@ -86,16 +82,9 @@ ivas_error pre_proc_ivas_fx( Word16 *inp_16k_fx, *new_inp_12k8_fx, *inp_12k8_fx; /* pointers to current frame and new data */ Word16 *wsp_fx; /* weighted input signal buffer */ Word32 sr_core_tmp, total_brate_tmp; -#ifndef FIX_2344_ALIGN_PREPROC - ivas_error error; -#endif push_wmops( "pre_proc" ); -#ifndef FIX_2344_ALIGN_PREPROC - error = IVAS_ERR_OK; - move32(); -#endif /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ @@ -173,7 +162,6 @@ ivas_error pre_proc_ivas_fx( move16(); } -#ifdef FIX_2344_ALIGN_PREPROC IF( EQ_16( st->L_frame, L_FRAME16k ) ) { total_brate_tmp = ACELP_16k40; @@ -192,27 +180,6 @@ ivas_error pre_proc_ivas_fx( { configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp ); } -#else - test(); - test(); - test(); - Word16 flag_1 = 0; - move16(); - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - flag_1 = ACELP_16k40; - move16(); - } - ELSE - { - flag_1 = ACELP_9k60; - move16(); - } - IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) ) - { - configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 ); - } -#endif if ( st->ini_frame == 0 ) { @@ -503,16 +470,6 @@ ivas_error pre_proc_ivas_fx( } } -#ifndef FIX_2344_ALIGN_PREPROC - /* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */ - test(); - test(); - if ( st->rf_mode && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) ) - { - st->sharpFlag = 1; - move16(); - } -#endif /* TD stereo, secondary channel - due to lack of signaling bits, sharpFlag is always 1 */ test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) @@ -601,28 +558,14 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); -#ifndef FIX_2344_ALIGN_PREPROC - Word16 Q_inp_12k8 = *Q_new; - move16(); - Word16 Q_inp_16k = *Q_new; - move16(); -#endif IF( !flag_16k_smc ) { -#ifdef FIX_2344_ALIGN_PREPROC Word16 Q_inp_12k8 = *Q_new; move16(); Word16 Q_inp_16k; ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); -#else - error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, - A_fx, Aw_fx, - epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); - -#endif IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) { @@ -636,12 +579,6 @@ ivas_error pre_proc_ivas_fx( } move16(); -#ifndef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return error; - } -#endif test(); IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -727,11 +664,7 @@ ivas_error pre_proc_ivas_fx( } pop_wmops(); -#ifdef FIX_2344_ALIGN_PREPROC return; -#else - return error; -#endif } @@ -741,11 +674,7 @@ ivas_error pre_proc_ivas_fx( * Compute core-coder buffers at internal sampling rate *--------------------------------------------------------------------*/ -#ifdef FIX_2344_ALIGN_PREPROC void ivas_compute_core_buffers_fx( -#else -ivas_error ivas_compute_core_buffers_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/ @@ -775,32 +704,15 @@ ivas_error ivas_compute_core_buffers_fx( Word16 Q_tmp, mem_decim16k_size, size_modified; Word16 epsP_h[M + 1]; Word16 epsP_l[M + 1]; -#ifdef FIX_2344_ALIGN_PREPROC Word16 i, shift, Q_min; Word16 preemp_len, inp_max; -#else - Word16 headroom = 1, preemp_len = 0, inp_max = 0; - move16(); - move16(); - move16(); -#endif Word16 *preemp_start_idx = NULL; -#ifdef FIX_2344_ALIGN_PREPROC #ifdef FIX_2376_FIX_USAN_PRE_PROC Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k + L_FILT16k], max_32; #else Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; #endif -#else - Word32 sig_out[960], max_32; -#endif -#ifndef FIX_2344_ALIGN_PREPROC - set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k ); - set16_fx( epsP_h, 0, M + 1 ); - set16_fx( epsP_l, 0, M + 1 ); - set16_fx( input_buf_fx, 0, L_FRAME48k * 2 ); -#endif Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) ); Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) ); @@ -917,23 +829,14 @@ ivas_error ivas_compute_core_buffers_fx( Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } -#ifdef FIX_2344_ALIGN_PREPROC size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - lMemRecalc_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#else - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#endif Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); IF( lMemRecalc > 0 ) { -#ifdef FIX_2344_ALIGN_PREPROC size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#else - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ -#endif } set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); @@ -1017,37 +920,14 @@ ivas_error ivas_compute_core_buffers_fx( move16(); } -#ifdef FIX_2344_ALIGN_PREPROC *Q_new = 0; move16(); -#else - test(); - test(); - *Q_new = 0; - move16(); - set32_fx( sig_out, 0, 960 ); test(); - test(); - if ( ( ( st->bwidth == NB ) || ( st->max_bwidth == NB ) ) && ( GT_32( st->input_Fs, 8000 ) ) ) - { - headroom = add( headroom, 1 ); - } - -#endif - - test(); -#ifdef FIX_2344_ALIGN_PREPROC IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) -#else - test(); - IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) -#endif { -#ifdef FIX_2344_ALIGN_PREPROC preemp_len = 0; move16(); -#endif IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1134,12 +1014,7 @@ ivas_error ivas_compute_core_buffers_fx( maximum_abs_32_fx( sig_out, preemp_len, &max_32 ); inp_max = s_max( extract_h( max_32 ), 1 ); -#ifdef FIX_2344_ALIGN_PREPROC shift = sub( norm_s( inp_max ), 1 /* headroom */ ); -#else - Word16 shift = sub( norm_s( inp_max ), headroom ); - Word16 Q_min, i; -#endif shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min ); @@ -1164,25 +1039,8 @@ ivas_error ivas_compute_core_buffers_fx( Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new ); } -#ifdef FIX_2344_ALIGN_PREPROC ELSE /* keep memory up-to-date in case of bitrate switching */ -#else - ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */ -#endif { -#ifndef FIX_2344_ALIGN_PREPROC - IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) - { - st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */ - move16(); - } - ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) - { - st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */ - move16(); - } - ELSE -#endif IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { st->mem_preemph16k_fx = 0; @@ -1206,9 +1064,6 @@ ivas_error ivas_compute_core_buffers_fx( IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { /* update signal buffers */ -#ifndef FIX_2344_ALIGN_PREPROC - Word16 shift; -#endif shift = negate( *Q_new ); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -1244,14 +1099,12 @@ ivas_error ivas_compute_core_buffers_fx( analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); } -#ifdef FIX_2344_ALIGN_PREPROC FOR( i = 0; i < M + 1; i++ ) { epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); move32(); } -#endif /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ @@ -1270,30 +1123,19 @@ ivas_error ivas_compute_core_buffers_fx( /* update old input signal @16kHz buffer */ test(); test(); -#ifndef FIX_2344_ALIGN_PREPROC - test(); -#endif IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); st->exp_old_inp_16k = 0; move16(); } -#ifdef FIX_2344_ALIGN_PREPROC ELSE IF( EQ_32( sr_core, INT_FS_16k ) ) -#else - ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) ) -#endif { Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM ); st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1) move16(); } -#ifdef FIX_2344_ALIGN_PREPROC ELSE -#else - ELSE IF( GT_32( input_Fs, 8000 ) ) -#endif { lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) ); @@ -1311,18 +1153,5 @@ ivas_error ivas_compute_core_buffers_fx( Copy( new_inp_resamp16k_fx, new_inp_resamp16k_out_fx, L_FRAME16k ); } -#ifndef FIX_2344_ALIGN_PREPROC - test(); - IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) - { - FOR( Word16 i = 0; i < M + 1; i++ ) - { - epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); - move32(); - } - } - return IVAS_ERR_OK; -#else return; -#endif } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 6e7455d63..eaf460fce 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -957,21 +957,12 @@ ivas_error ivas_cpe_enc_fx( } move16(); -#ifndef FIX_2344_ALIGN_PREPROC - error = -#endif pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); -#ifndef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return error; - } -#endif e_old_wsp[n] = sub( Q15, q_old_wsp ); move16(); } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 40f683925..75c1c3340 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -244,19 +244,10 @@ ivas_error ivas_ism_enc_fx( move16(); Word16 q_fr_bands[2]; -#ifndef FIX_2344_ALIGN_PREPROC - error = -#endif pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); -#ifndef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return error; - } -#endif e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); move16(); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 4d639c961..001af150c 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -251,7 +251,6 @@ ivas_error ivas_sce_enc_fx( move16(); Word16 q_fr_bands[2]; -#ifdef FIX_2344_ALIGN_PREPROC Word16 front_vad_flag, force_front_vad, front_vad_dtx_flag; IF( st_ivas->hSpar != NULL ) { @@ -274,17 +273,6 @@ ivas_error ivas_sce_enc_fx( realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, front_vad_flag, force_front_vad, front_vad_dtx_flag, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); -#else - error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0], - &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], - realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], - fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); - IF( NE_32( error, IVAS_ERR_OK ) ) - { - return error; - } -#endif e_old_wsp[0] = sub( Q15, q_old_wsp ); move16(); -- GitLab From 5a8cff59997b3411e137da2fbf24413e0ba96dd3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:35:08 +0100 Subject: [PATCH 614/750] [cleanup] accept FIX_2334_HARM_CODER_MODIF --- lib_com/options.h | 1 - lib_enc/ivas_cpe_enc_fx.c | 4 -- lib_enc/ivas_ism_enc_fx.c | 4 -- lib_enc/ivas_sce_enc_fx.c | 4 -- lib_enc/prot_fx_enc.h | 6 -- lib_enc/sig_clas_fx.c | 148 -------------------------------------- lib_enc/vad_fx.c | 4 -- 7 files changed, 171 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 970e684b1..34fcbe051 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ #define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ #define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT /* Nokia/FhG: basop issue 2323: Use correct init size */ #define FIX_BASOP_2324_MISSING_SET_TO_ZERO /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index eaf460fce..3be57e782 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1132,11 +1132,7 @@ ivas_error ivas_cpe_enc_fx( IF( ( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->element_mode, IVAS_CPE_TD ) ) || n == 0 ) /* modify coder_type of primary channel */ { /* limit coder_type depending on the bitrate */ -#ifndef FIX_2334_HARM_CODER_MODIF - coder_type_modif_ivas_fx( sts[n], relE_fx[n] ); -#else coder_type_modif_fx( sts[n], relE_fx[n] ); -#endif } } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 75c1c3340..a6ce92a18 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -438,11 +438,7 @@ ivas_error ivas_ism_enc_fx( } /* modify the coder_type depending on the total_brate per channel */ -#ifndef FIX_2334_HARM_CODER_MODIF - coder_type_modif_ivas_fx( st, relE_fx[sce_id][0] ); -#else coder_type_modif_fx( st, relE_fx[sce_id][0] ); -#endif /*----------------------------------------------------------------* * Encoder *----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 001af150c..ec539b738 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -352,11 +352,7 @@ ivas_error ivas_sce_enc_fx( move16(); /* modify the coder_type depending on the total_brate per channel */ -#ifndef FIX_2334_HARM_CODER_MODIF - coder_type_modif_ivas_fx( st, relE_fx[0] ); -#else coder_type_modif_fx( st, relE_fx[0] ); -#endif /*----------------------------------------------------------------* * Encoder *----------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index dd3060a48..0e1b7d7a6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1152,12 +1152,6 @@ void coder_type_modif_fx( const Word16 relE /* i : frame relative E to the long term average */ ); -#ifndef FIX_2334_HARM_CODER_MODIF -void coder_type_modif_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 relE /* i : frame relative E to the long term average */ -); -#endif void speech_music_clas_init_fx( SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ); diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index b4d41c405..ccc1e38e9 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -545,151 +545,7 @@ void select_TC_fx( * * Coder type modification *-------------------------------------------------------------------*/ -#ifndef FIX_2334_HARM_CODER_MODIF void coder_type_modif_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 relE /* i : frame relative E to the long term average Q8*/ -) -{ - Word16 unmod_coder_type, vbr_generic_ho; - - SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR; - - - IF( st->Opt_SC_VBR ) - { - vbr_generic_ho = hSC_VBR->vbr_generic_ho; - move16(); - } - ELSE - { - vbr_generic_ho = -1; - move16(); - } - - IF( EQ_16( st->codec_mode, MODE1 ) ) - { - /*---------------------------------------------------------------------* - * Coder type modification - * - * Prevent UC coder type in certain conditions - * Prevent VC coder type in certain conditions - * Select TC coder type in appropriate frames - *---------------------------------------------------------------------*/ - - /* At higher rates, use GC coding instead of UC coding to improve quality */ - test(); - test(); - test(); - test(); - test(); - if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || - ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) - { - st->coder_type = GENERIC; - move16(); - } - - /* Prevent UC coding on mixed content at 9.6 kb/s */ - test(); - test(); - if ( GE_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) && st->audio_frame_cnt != 0 ) - { - st->coder_type = GENERIC; - move16(); - } - - unmod_coder_type = st->coder_type; - move16(); - - /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( st->localVAD == 0 && ( ( - EQ_16( st->coder_type, UNVOICED ) && ( ( st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->Opt_SC_VBR, 1 ) ) && vbr_generic_ho == 0 && GT_16( st->last_coder_type, UNVOICED ) ) ) ) || - EQ_16( st->coder_type, TRANSITION ) || EQ_16( st->coder_type, VOICED ) ) - - ) - { - st->coder_type = GENERIC; - move16(); - } - - test(); - test(); - IF( EQ_16( st->Opt_SC_VBR, 1 ) ) - { - test(); - if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) ) - { - hSC_VBR->vbr_generic_ho = 1; - move16(); - } - - if ( GT_16( st->coder_type, UNVOICED ) ) - { - hSC_VBR->vbr_generic_ho = 0; - move16(); - } - } - hSC_VBR->last_7k2_coder_type = st->coder_type; - move16(); - test(); - if ( st->localVAD == 0 && EQ_16( st->coder_type, UNVOICED ) ) - { - hSC_VBR->last_7k2_coder_type = GENERIC; - move16(); - } - - IF( st->element_mode == 0 ) - { - /* At higher rates and with 16kHz core, allow only GC and TC coder type */ - test(); - test(); - // test(); - if ( GT_32( st->total_brate, ACELP_16k40 ) && NE_16( st->coder_type, GENERIC ) && NE_16( st->coder_type, TRANSITION ) ) - { - /* onset/transition frame is always coded using GC mode */ - st->coder_type = GENERIC; - move16(); - } - } - ELSE /*IVAS*/ - { - /* At higher bitrates, disable UC and VC coder type; note that IC coder type is classified later */ - test(); - test(); - test(); - if ( ( GT_32( st->total_brate, MAX_VOICED_BRATE ) && EQ_16( st->coder_type, VOICED ) ) || - ( GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) - { - st->coder_type = GENERIC; - move16(); - } - } - - /* Patch for certain low-level signals for which the gain quantizer sometimes goes out of its dynamic range */ - test(); - test(); - test(); - if ( EQ_16( st->coder_type, VOICED ) && st->input_bwidth == 0 && LT_16( relE, -2560 ) && LE_32( st->total_brate, ACELP_8k00 ) ) - { - st->coder_type = GENERIC; - move16(); - } - } - - return; -} -void coder_type_modif_ivas_fx( -#else -void coder_type_modif_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 relE /* i : frame relative E to the long term average */ ) @@ -777,7 +633,6 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } -#ifdef FIX_2334_HARM_CODER_MODIF IF( NE_16( st->element_mode, EVS_MONO ) ) { hSC_VBR->last_7k2_coder_type = st->coder_type; @@ -789,9 +644,7 @@ void coder_type_modif_fx( move16(); } } -#endif } -#ifdef FIX_2334_HARM_CODER_MODIF IF( EQ_16( st->element_mode, EVS_MONO ) ) { hSC_VBR->last_7k2_coder_type = st->coder_type; @@ -803,7 +656,6 @@ void coder_type_modif_fx( move16(); } } -#endif IF( st->element_mode == 0 ) { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 5f1356def..7c5414780 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -562,11 +562,7 @@ Word16 wb_vad_fx( st_fx->max_band = 19; move16(); } -#ifdef FIX_2334_HARM_CODER_MODIF IF( st_fx->Opt_SC_VBR || ( !st_fx->Opt_SC_VBR && st_fx->element_mode == EVS_MONO ) ) /* this keep 26.444 BE */ -#else - IF( 1 ) // st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ -#endif { last_7k2_coder_type = st_fx->hSC_VBR->last_7k2_coder_type; move16(); -- GitLab From c7156d5baf6742d4187c0282b49a7cbe1dc0d90f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:35:48 +0100 Subject: [PATCH 615/750] [cleanup] accept FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA --- lib_com/options.h | 1 - lib_enc/ivas_masa_enc_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 34fcbe051..964f21a46 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ #define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT /* Nokia/FhG: basop issue 2323: Use correct init size */ #define FIX_BASOP_2324_MISSING_SET_TO_ZERO /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */ #define FIX_BASOP_2326_WRONG_SIG_LENGTH /* Nokia: basop issue 2326: Fix issue by using correct signal length in multiple places */ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 0cdad4d92..6bfea1f19 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1800,10 +1800,8 @@ void ivas_masa_combine_directions_fx( } } -#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA IF( GT_16( hMasa->config.numTwoDirBands, 0 ) ) { -#endif /* Estimate the importance of having two directions instead of one */ /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */ FOR( i = 0; i < numCodingBands; i++ ) @@ -1831,10 +1829,8 @@ void ivas_masa_combine_directions_fx( /* Determine bands where to use two directions */ find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands ); -#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA } -#endif FOR( i = 0; i < numCodingBands; i++ ) { -- GitLab From 689a8e6878af368a593dd2acc9b146bf3028d07c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:36:23 +0100 Subject: [PATCH 616/750] [cleanup] accept FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT --- lib_com/options.h | 1 - lib_enc/ivas_dirac_enc_fx.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 964f21a46..c6e0d3676 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT /* Nokia/FhG: basop issue 2323: Use correct init size */ #define FIX_BASOP_2324_MISSING_SET_TO_ZERO /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */ #define FIX_BASOP_2326_WRONG_SIG_LENGTH /* Nokia: basop issue 2326: Fix issue by using correct signal length in multiple places */ #define FIX_BASOP_2327_WRONG_LOOP_END /* Nokia: basop inssue 2327: Correct loop end to solve MSAN error */ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 7a2823b7a..169348225 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -1574,17 +1574,9 @@ void computeDiffuseness_mdft_fx( set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) ); set16_fx( intensity_slow_e, 0, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) ); set_zero_fx( intensity_slow_abs, MASA_FREQUENCY_BANDS ); -#ifdef FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT set16_fx( intensity_slow_abs_e, 0, MASA_FREQUENCY_BANDS ); -#else - set16_fx( intensity_slow_abs_e, 0, no_col_avg_diff ); -#endif set_zero_fx( energy_slow, MASA_FREQUENCY_BANDS ); -#ifdef FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT set16_fx( energy_slow_e, 0, MASA_FREQUENCY_BANDS ); -#else - set16_fx( energy_slow_e, 0, no_col_avg_diff ); -#endif FOR( i = 0; i < no_col_avg_diff; ++i ) { -- GitLab From cd6e098663e79fcdc7e2550199fed2aa0b57a389 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:37:09 +0100 Subject: [PATCH 617/750] [cleanup] accept FIX_BASOP_2324_MISSING_SET_TO_ZERO --- lib_com/options.h | 1 - lib_enc/ivas_mcmasa_enc_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c6e0d3676..69846834f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2324_MISSING_SET_TO_ZERO /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */ #define FIX_BASOP_2326_WRONG_SIG_LENGTH /* Nokia: basop issue 2326: Fix issue by using correct signal length in multiple places */ #define FIX_BASOP_2327_WRONG_LOOP_END /* Nokia: basop inssue 2327: Correct loop end to solve MSAN error */ #define FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT /* Nokia: basop issue 2328: Fix MSAN error by correcting the variable assignment */ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 4d611915a..2507d6a0d 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1021,14 +1021,12 @@ void ivas_mcmasa_param_est_enc_fx( move32(); hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0; move32(); -#ifdef FIX_BASOP_2324_MISSING_SET_TO_ZERO hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] = 0; move16(); hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] = 0; move16(); hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] = 0; move16(); -#endif } /* Reset variable */ -- GitLab From f8201b4c3d304848b99a5b97113c83578873ff60 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:38:01 +0100 Subject: [PATCH 618/750] [cleanup] accept FIX_BASOP_2326_WRONG_SIG_LENGTH --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 69846834f..a84ab6eaa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2326_WRONG_SIG_LENGTH /* Nokia: basop issue 2326: Fix issue by using correct signal length in multiple places */ #define FIX_BASOP_2327_WRONG_LOOP_END /* Nokia: basop inssue 2327: Correct loop end to solve MSAN error */ #define FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT /* Nokia: basop issue 2328: Fix MSAN error by correcting the variable assignment */ #define FIX_BASOP_2329_UNINIT_VALUE /* Nokia: basop issue 2329: Fix issue by checking for structure instead of length */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b497bceb7..c57522674 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9175,15 +9175,10 @@ static ivas_error renderInputMasa( } copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ } -#else - Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ - Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ -#endif // scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); @@ -9207,17 +9202,10 @@ static ivas_error renderInputMasa( masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; move16(); } -#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ } -#else - FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) - { - Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ - } -#endif scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ @@ -9241,15 +9229,10 @@ static ivas_error renderInputMasa( copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ } -#else - Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ - Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ -#endif scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); -- GitLab From 70c080ef1a18fec2b166776077fcd42b37792b1d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:38:49 +0100 Subject: [PATCH 619/750] [cleanup] accept FIX_BASOP_2327_WRONG_LOOP_END --- lib_com/options.h | 1 - lib_rend/ivas_omasa_ana_fx.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a84ab6eaa..b3de062f4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2327_WRONG_LOOP_END /* Nokia: basop inssue 2327: Correct loop end to solve MSAN error */ #define FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT /* Nokia: basop issue 2328: Fix MSAN error by correcting the variable assignment */ #define FIX_BASOP_2329_UNINIT_VALUE /* Nokia: basop issue 2329: Fix issue by checking for structure instead of length */ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index edffafe45..02af0f7fd 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -719,11 +719,7 @@ static void ivas_omasa_dmx_fx( } max_e = in_e[0]; move16(); -#ifdef FIX_BASOP_2327_WRONG_LOOP_END FOR( l = 1; l < input_frame; l++ ) -#else - FOR( l = 1; l < L_FRAME48k; l++ ) -#endif { IF( LT_16( max_e, in_e[l] ) ) { @@ -732,11 +728,7 @@ static void ivas_omasa_dmx_fx( } } -#ifdef FIX_BASOP_2327_WRONG_LOOP_END FOR( l = 0; l < input_frame; l++ ) -#else - FOR( l = 0; l < L_FRAME48k; l++ ) -#endif { data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) move32(); -- GitLab From 1dd43b19c25f3608b8d2a77bf268b608e7764aa5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:39:33 +0100 Subject: [PATCH 620/750] [cleanup] accept FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT --- lib_com/options.h | 1 - lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b3de062f4..6c5207eca 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT /* Nokia: basop issue 2328: Fix MSAN error by correcting the variable assignment */ #define FIX_BASOP_2329_UNINIT_VALUE /* Nokia: basop issue 2329: Fix issue by checking for structure instead of length */ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 7121cbe2c..f2a225de3 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -211,11 +211,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } -#ifdef FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT dirac_output_synthesis_state->cy_auto_diff_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); -#else - dirac_output_synthesis_state->cy_auto_dir_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); -#endif move16(); } ELSE -- GitLab From 27abfbb556894196db2400a01a327407eca3f699 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:40:32 +0100 Subject: [PATCH 621/750] [cleanup] accept FIX_BASOP_2329_UNINIT_VALUE --- lib_com/options.h | 1 - lib_rend/ivas_dirac_rend_fx.c | 2 -- lib_rend/lib_rend_fx.c | 4 ---- 3 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6c5207eca..c40e6c47e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2329_UNINIT_VALUE /* Nokia: basop issue 2329: Fix issue by checking for structure instead of length */ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index e7df45b6c..e242c9c08 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -860,11 +860,9 @@ ivas_error ivas_dirac_alloc_mem_fx( /* Prototypes */ hDirAC_mem->proto_direct_buffer_f_fx = NULL; hDirAC_mem->proto_diffuse_buffer_f_fx = NULL; -#ifdef FIX_BASOP_2329_UNINIT_VALUE hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len = 0; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len = 0; hDirAC_mem->proto_diffuse_buffer_f_len = 0; -#endif test(); test(); IF( NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_32( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c57522674..143e49c82 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11265,11 +11265,7 @@ static void intermidiate_ext_dirac_render( move16(); } -#ifdef FIX_BASOP_2329_UNINIT_VALUE IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx ) -#else - IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) -#endif { Word16 shift, norm1, norm2; Word32 tmp1, tmp2; -- GitLab From 7cdaee3181d771bfb0d08430052128e54ebefe13 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:41:11 +0100 Subject: [PATCH 622/750] [cleanup] accept FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 22 ---------------------- 2 files changed, 23 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c40e6c47e..cbc6887e3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 143e49c82..2f94d5213 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11199,33 +11199,15 @@ static void intermidiate_ext_dirac_render( IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) { -#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); -#else - Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ) ); -#endif scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, shift ); move16(); } -#ifndef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND - Word16 num_channels_dir = hDirACRend->num_outputs_dir; - move16(); - - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) ) - { - num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; - move16(); - } -#endif IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { -#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len ); -#else - tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); -#endif scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); /* Q(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth + tmp) */ h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp ); move16(); @@ -11247,11 +11229,7 @@ static void intermidiate_ext_dirac_render( move16(); IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) { -#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len ); -#else - Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); -#endif scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift ); move16(); -- GitLab From 837906830e4ca5c45a906feededa9842ef5c46eb Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:42:05 +0100 Subject: [PATCH 623/750] [cleanup] accept FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK --- lib_com/options.h | 1 - lib_rend/ivas_mcmasa_ana_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index cbc6887e3..a9a308292 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ #define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 05d65ecec..8f4149171 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -425,7 +425,6 @@ void ivas_mcmasa_ana_close( free( ( *hMcMasa )->direction_vector_m_fx[i] ); ( *hMcMasa )->direction_vector_m_fx[i] = NULL; -#ifdef FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { @@ -435,7 +434,6 @@ void ivas_mcmasa_ana_close( free( ( *hMcMasa )->direction_vector_e[i] ); ( *hMcMasa )->direction_vector_e[i] = NULL; -#endif FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { -- GitLab From a53bb94cf0612a19b53526862be656fd62118d7c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:42:54 +0100 Subject: [PATCH 624/750] [cleanup] accept HARM_COREDECODER_FUNCTIONS --- lib_com/options.h | 1 - lib_com/parameter_bitmaping_fx.c | 89 ---------- lib_com/prot_fx.h | 46 ----- lib_dec/core_dec_init_fx.c | 4 - lib_dec/dec_post_fx.c | 164 ------------------ lib_dec/dec_prm_fx.c | 8 - lib_dec/dec_tran_fx.c | 11 -- lib_dec/dlpc_avq_fx.c | 141 --------------- lib_dec/gain_dec_fx.c | 138 --------------- lib_dec/waveadjust_fec_dec_fx.c | 60 ------- lib_enc/enc_prm_fx.c | 16 -- lib_enc/ivas_mdct_core_enc_fx.c | 4 - lib_enc/lsf_msvq_ma_enc_fx.c | 97 ----------- lib_enc/prot_fx_enc.h | 70 -------- lib_enc/qlpc_avq_fx.c | 289 ------------------------------- lib_enc/tns_base_enc_fx.c | 20 --- 16 files changed, 1158 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a9a308292..338a68553 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ #define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ #define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 412ab4647..4225879e6 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -25,26 +25,6 @@ static Word16 PutIntoBitstream_fx( return value; } -#ifndef HARM_COREDECODER_FUNCTIONS -static Word16 PutIntoBitstream_ivas_fx( - const Word16 **pStream, - TEncodeValue EncodeValue, - Word16 index, - BSTR_ENC_HANDLE hBstr, - const Word16 nBits ) -{ - Word16 value; - Word16 codedValue; - - move16(); - value = *( *pStream )++; - codedValue = EncodeValue( value, index ); - - push_next_indice( hBstr, codedValue, nBits ); - - return value; -} -#endif static Word16 FixedWidthEncoding( Word16 value, Word16 index ) { @@ -327,75 +307,6 @@ void WriteToBitstream_fx( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ) -{ - Word16 index; - Word16 iParam, nParams; - - - assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( hBstr != NULL ) && ( pnBits != NULL ) ); - nParams = paramsBitMap->nParams; - move16(); - - FOR( index = 0; index < nArrayLength; index++ ) - { - - FOR( iParam = 0; iParam < nParams; iParam++ ) - { - ParamBitMap const *param; - Word16 nBits; - /* If a function for encoding/decoding value is defined than it should take care of 0 */ - Word16 fShiftValue; - TEncodeValue EncodeValue; - Word16 value; - - move16(); - param = ¶msBitMap->params[iParam]; - - move16(); - nBits = param->nBits; - IF( param->nBits == 0 ) - { -#define WMC_TOOL_SKIP - nBits = param->GetNumberOfBits( **pStream, index ); -#undef WMC_TOOL_SKIP - } - - fShiftValue = s_and( param->fZeroAllowed == 0, param->EncodeValue == NULL ); - - EncodeValue = param->EncodeValue; - if ( param->EncodeValue == NULL ) - { - move16(); - EncodeValue = &FixedWidthEncoding; - } - value = PutIntoBitstream_ivas_fx( pStream, EncodeValue, index, hBstr, nBits ); - IF( fShiftValue ) - { - value = add( value, 1 ); - } - - move16(); - *pnSize = add( *pnSize, 1 ); - move16(); - *pnBits = add( *pnBits, nBits ); - - test(); - IF( ( param->pSubParamBitMap != NULL ) && ( value > 0 ) ) - { - WriteToBitstream_ivas_fx( param->pSubParamBitMap, value, pStream, pnSize, hBstr, pnBits ); - } - } - } -} -#endif /** Get nBits long value from bitstream into *pStream. */ static Word16 GetFromBitstream( diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 78652dc7c..78ff2fc72 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6038,11 +6038,9 @@ void concealment_init_x( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); -#ifdef HARM_COREDECODER_FUNCTIONS void concealment_init_ivas_fx( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); -#endif void concealment_update_x( const Word16 bfi, const Word16 core, @@ -6438,21 +6436,6 @@ void formant_post_filt_fx( const Word16 off_flag /* i : off flag */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -void Filt_mu_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr /* i : the length of subframe */ -); - -void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ); -#endif void scale_st_fx( const Word16 *sig_in, /* i : postfilter i signal */ Word16 *sig_out, /* i/o: postfilter o signal */ @@ -6639,18 +6622,6 @@ void gain_dec_tc_fx( Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -void gain_dec_tc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -); -#endif void gain_dec_mless_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ @@ -8606,14 +8577,6 @@ Word16 dlpc_avq_fx( Word32 sr_core ); Word16 decode_lpc_avq_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ -); - -Word16 decode_lpc_avq_ivas_fx( -#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ @@ -10656,15 +10619,6 @@ void WriteToBitstream_fx( BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); -#ifndef HARM_COREDECODER_FUNCTIONS -void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); -#endif /*===========================================================================================*/ /*----------------------------------------------------------------------------------* diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 2ff4ce84f..79b75b02f 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1978,11 +1978,7 @@ void open_decoder_LPD_ivas_fx( IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) { -#ifdef HARM_COREDECODER_FUNCTIONS concealment_init_x( st->hTcxDec->L_frameTCX, st->hPlcInfo ); -#else - concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo ); -#endif } } ELSE diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 596b8574c..1a568cbf9 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -35,11 +35,7 @@ static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); -#ifdef HARM_COREDECODER_FUNCTIONS static void Filt_mu_fx( Word16 *sig_in, Word16 *sig_out, Word16 parcor0, Word16 L_subfr ); -#else -static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); -#endif /*-------------------------------------------------------------------------- @@ -448,11 +444,7 @@ static void Dec_formant_postfilt_fx( } /* Controls short term pst filter gain and compute parcor0 */ -#ifdef HARM_COREDECODER_FUNCTIONS calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero ); -#else - calc_st_filt_ivas_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero, -1 ); -#endif /* 1/A(gamma1) filtering, mem_stp is updated */ resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) ); @@ -470,11 +462,7 @@ static void Dec_formant_postfilt_fx( } /* Tilt filtering */ -#ifdef HARM_COREDECODER_FUNCTIONS Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR ); -#else - Filt_mu_ivas_fx( resynth, sig_out, parcor0, L_SUBFR, -1 ); -#endif IF( scale_down ) { @@ -1345,62 +1333,6 @@ static void calc_st_filt_local_fx( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -static void calc_st_filt_ivas_fx( - Word16 *apond2, /* i : coefficients of numerator Q12 */ - Word16 *apond1, /* i : coefficients of denominator Q12 */ - Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15 */ - Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx*/ - Word16 *mem_zero, /* i : All zero memory */ - const Word16 extl /* i : extension layer info */ -) -{ - Word32 L_g0; - - Word16 h[LONG_H_ST]; // Q12 - - Word16 g0, temp; - Word16 i; - - - temp = sub( 2, norm_s( apond2[0] ) ); - - /* compute i.r. of composed filter apond2 / apond1 */ - IF( EQ_16( extl, SWB_TBE ) ) - { - E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, LPC_SHB_ORDER ); - } - ELSE - { - E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, M ); - } - - /* compute 1st parcor */ - Calc_rc0_h( h, parcor0 ); - - /* compute g0 */ - L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12 - FOR( i = 1; i < LONG_H_ST; i++ ) - { - L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); // Q12 - } - g0 = extract_h( L_shl( L_g0, 14 ) ); // Q10 - - /* Scale signal i of 1/A(gamma1) */ - IF( GT_16( g0, 1024 ) ) /*1024 = 1.Q10*/ - { - temp = div_s( 1024, g0 ); /* temp => Q15 / gain0 */ /*1024 = 1.Q10*/ - FOR( i = 0; i < L_SUBFR; i++ ) - { - sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); // Qx - move16(); - } - } - - - return; -} -#endif /*---------------------------------------------------------------------------- * filt_mu @@ -1409,11 +1341,7 @@ static void calc_st_filt_ivas_fx( * computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1]) *---------------------------------------------------------------------------*/ -#ifdef HARM_COREDECODER_FUNCTIONS static void Filt_mu_fx( -#else -void Filt_mu_fx( -#endif Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -1474,98 +1402,6 @@ void Filt_mu_fx( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) Q15 */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ) -{ - Word32 L_acc, L_temp, L_fact; - - Word16 *ptrs; - - Word16 n; - Word16 mu, mu2, ga, temp; - Word16 fact, sh_fact; - - IF( EQ_16( extl, SWB_TBE ) ) - { - IF( parcor0 > 0 ) - { - mu = mult_r( parcor0, GAMMA3_PLUS_WB_FX ); // Q15 - /* GAMMA3_PLUS_FX < 0.5 */ - sh_fact = 14; - move16(); /* sh_fact */ - fact = (Word16) 0x4000; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */ - } - ELSE - { - mu = mult_r( parcor0, GAMMA3_MINUS_WB_FX ); // Q15 - /* GAMMA3_MINUS_FX < 0.9375 */ - sh_fact = 11; - move16(); /* sh_fact */ - fact = (Word16) 0x0800; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */ - } - } - ELSE - { - IF( parcor0 > 0 ) - { - mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15 - /* GAMMA3_PLUS_FX < 0.5 */ - sh_fact = 14; - move16(); /* sh_fact */ - fact = (Word16) 0x4000; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */ - } - ELSE - { - mu = mult_r( parcor0, GAMMA3_MINUS_FX ); // Q15 - /* GAMMA3_MINUS_FX < 0.9375 */ - sh_fact = 11; - move16(); /* sh_fact */ - fact = (Word16) 0x0800; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */ - } - } - - temp = sub( 1, abs_s( mu ) ); - BASOP_SATURATE_WARNING_OFF_EVS; - mu2 = add_sat( 32767, temp ); /* Q15 (1 - |mu|) */ - BASOP_SATURATE_WARNING_ON_EVS; - ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ - - ptrs = sig_in; /* points on sig_in(-1) */ - - sh_fact = sub( sh_fact, 16 ); /* to remove the saturate(), should shl by 16 before rounding */ - - FOR( n = 0; n < L_subfr; n++ ) - { - L_acc = L_mult0( mu, *ptrs++ ); - L_temp = L_mac( L_acc, 16384, *ptrs ); /* sig_in(n) * 2**15 */ - - L_temp = Madd_32_16( L_fact, L_temp, ga ); - L_temp = L_shr( L_temp, sh_fact ); /* mult. temp x ga */ - - BASOP_SATURATE_WARNING_OFF_EVS; - /*sig_out[n] = saturate(L_temp); move16();*/ - sig_out[n] = round_fx_sat( L_temp ); - BASOP_SATURATE_WARNING_ON_EVS; - } - - - return; -} - -#endif /*---------------------------------------------------------------------------- * scale_st_fx() diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 91a5a671f..41a2e9842 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -52,11 +52,7 @@ void getLPCparam_fx( { IF( st->lpcQuantization == 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS decode_lpc_avq_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); -#else - decode_lpc_avq_ivas_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); -#endif } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) { @@ -1007,11 +1003,7 @@ void dec_prm_fx( { IF( st->lpcQuantization == 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS decode_lpc_avq_fx( st, st->numlpc, param_lpc, 0, EVS_MONO, 0 ); -#else - decode_lpc_avq_fx( st, st->numlpc, param_lpc ); -#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 93a9cf8ca..20d5f4b22 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -145,18 +145,7 @@ void decod_tran_fx( IF( Jopt_flag == 0 ) { /* 2/3-bit decoding */ -#ifdef HARM_COREDECODER_FUNCTIONS gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); -#else - IF( st_fx->element_mode == EVS_MONO ) - { - gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - } - ELSE - { - gain_dec_tc_ivas_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - } -#endif } ELSE { diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c index 2b1264218..9080fd5aa 100644 --- a/lib_dec/dlpc_avq_fx.c +++ b/lib_dec/dlpc_avq_fx.c @@ -146,147 +146,6 @@ static Word16 pack4bits_fx( } Word16 decode_lpc_avq_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ -) -{ - Word16 k, j; - Word16 nb, qn1, qn2, avqBits, q_type; - Word16 start_bit_pos; - move16(); - move16(); - move16(); - j = 0; - start_bit_pos = st->next_bit_pos; - - FOR( k = 0; k < numlpc; k++ ) - { - /* Decode quantizer type */ - - IF( k == 0 ) - { - move16(); - move16(); - q_type = 0; - nb = 0; - } - ELSE - { - move16(); - nb = 1; - q_type = get_next_indice_fx( st, nb ); - move16(); - param_lpc[j] = q_type; - j = add( j, 1 ); - } - /* Decode quantization indices */ - - IF( q_type == 0 ) - { - /* Absolute quantizer with 1st stage stochastic codebook */ - { - move16(); - param_lpc[j] = get_next_indice_fx( st, 8 ); - } - j = add( j, 1 ); - } - /* - * 2nd stage decoding is skipped if: - * - we are in low bitrate mode and no joint SNS coding is used - * - OR the side-SNS-is-zero flag is set for joint SNS - */ - { - /* 2 bits to specify Q2,Q3,Q4,ext */ - qn1 = add( 2, get_next_indice_fx( st, 2 ) ); - qn2 = add( 2, get_next_indice_fx( st, 2 ) ); - - /* Unary code */ - /* Q5 = 0, Q6=10, Q0=110, Q7=1110, ... */ - - IF( GT_16( qn1, 4 ) ) - { - nb = unary_decode_fx( st, &qn1 ); - - if ( EQ_16( nb, 1 ) ) - { - qn1 = add( qn1, 5 ); - } - if ( EQ_16( nb, 2 ) ) - { - qn1 = add( qn1, 4 ); - } - if ( EQ_16( nb, 3 ) ) - { - move16(); - qn1 = 0; - } - if ( GT_16( nb, 3 ) ) - { - qn1 = add( qn1, 3 ); - } - } - - IF( GT_16( qn2, 4 ) ) - { - nb = unary_decode_fx( st, &qn2 ); - - if ( EQ_16( nb, 1 ) ) - { - qn2 = add( qn2, 5 ); - } - if ( EQ_16( nb, 2 ) ) - { - qn2 = add( qn2, 4 ); - } - if ( EQ_16( nb, 3 ) ) - { - move16(); - qn2 = 0; - } - if ( GT_16( nb, 3 ) ) - { - qn2 = add( qn2, 3 ); - } - } - - /* check for potential bit errors */ - test(); - IF( ( GT_16( qn1, NB_SPHERE ) ) || ( GT_16( qn2, NB_SPHERE ) ) ) - { - qn1 = 0; - move16(); - qn2 = 0; - move16(); - st->BER_detect = 1; - move16(); - } - - move16(); - param_lpc[j] = qn1; - j = add( j, 1 ); - move16(); - param_lpc[j] = qn2; - j = add( j, 1 ); - - /* Decode Split-by-2 algebraic VQ */ - avqBits = shl( qn1, 2 ); - - pack4bits_fx( avqBits, st, ¶m_lpc[j] ); - j = add( j, qn1 ); - - avqBits = shl( qn2, 2 ); - pack4bits_fx( avqBits, st, ¶m_lpc[j] ); - j = add( j, qn2 ); - } - } - - return sub( st->next_bit_pos, start_bit_pos ); -} - -Word16 decode_lpc_avq_ivas_fx( -#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 3ac75b9c7..551e04205 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -90,140 +90,6 @@ void Es_pred_dec_fx( /*======================================================================================*/ void gain_dec_tc_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -) -{ - Word16 index, nBits; - Word16 gcode0_fx; - Word16 Ei_fx; - Word16 expg, expg2, e_tmp, f_tmp, exp_gcode0, tmp_fx, frac; - Word32 L_tmp, L_tmp1; - Word16 wgain_code = 0; - move16(); - *gain_pit_fx = 0; - move16(); - - /*----------------------------------------------------------------* - * find number of bits for gain dequantization - *----------------------------------------------------------------*/ - nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / 64 )]; - move16(); - /*-----------------------------------------------------------------* - * calculate the predicted gain code - *-----------------------------------------------------------------*/ - - /*Ecode = (dotp( code, code, L_SUBFR) + 0.01f) / L_SUBFR; - *gain_inov = 1.0f / (float)sqrt( Ecode );*/ - L_tmp = Dot_product12( code_fx, code_fx, L_SUBFR, &expg ); /*Q31 - expg*/ - expg = sub( expg, 18 + 6 ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ - expg2 = expg; - move16(); - L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ - move32(); - L_tmp = Isqrt_lc( L_tmp, &expg ); /*Q31 - expg*/ - - *gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); - move16(); /* gain_inov in Q12 */ - - - /* Ei = 10 * (float)log10( Ecode );*/ - e_tmp = norm_l( L_tmp1 ); - f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/ - e_tmp = sub( expg2, add( 1, e_tmp ) ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ - Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ - /* gcode0 = (float) pow(10, 0.05 * (Es_pred - Ei));*/ - gcode0_fx = sub( Es_pred_fx, Ei_fx ); /* Q8 */ - - /*-----------------------------------------------------------------* - * gcode0 = pow(10.0, gcode0/20) - * = pow(2, 3.321928*gcode0/20) - * = pow(2, 0.166096*gcode0) - *-----------------------------------------------------------------*/ - L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ - L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ - gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ - exp_gcode0 = sub( exp_gcode0, 14 ); - /*------------------------------------------------------------------------------------------* - * Select the gain quantization table and dequantize the gain - *------------------------------------------------------------------------------------------*/ - - /* index = (Word16)get_indice( st_fx,"gain_code", i_subfr_fx, ACELP_CORE);move16();*/ - index = (Word16) get_next_indice_fx( st_fx, nBits ); - move16(); - - - IF( GT_16( nBits, 3 ) ) - { - wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); - wgain_code = shl_sat( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/ - } - ELSE /* nBits == 3 */ - { - wgain_code = tbl_gain_code_tc_fx[index]; /*Q13*/ - move16(); - } - - /*-----------------------------------------------------------------* - * decode normalized codebook gain - *-----------------------------------------------------------------*/ - - /* *gain_code *= gcode0;*/ - L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/ - move32(); - - /**norm_gain_code = *gain_code / *gain_inov;*/ - expg = sub( norm_s( *gain_inov_fx ), 1 ); - expg = s_max( expg, 0 ); - - tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx ); - *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); /*Q16*/ - move32(); - - return; -} - -/*======================================================================================*/ -/* FUNCTION : void gain_dec_tc_ivas_fx () */ -/*--------------------------------------------------------------------------------------*/ -/* PURPOSE : Decoding of pitch and codebook gains and updating long term energies */ -/*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word32 core_brate_fx i : core bitrate */ -/* Word16 *code_fx i : algebraic code excitation */ -/* Word16 L_frame_fx i : length of the frame */ -/* Word16 i_subfr_fx i : subframe number */ -/* Word16 tc_subfr_fx i : TC subframe index */ -/* Word16 Es_pred_fx i : predicted scaled innov. energy Q8 */ -/*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* Word16 *gain_pit_fx o : pitch gain Q14 */ -/* Word32 *gain_code_fx o : Quantized codeebook gain Q16 */ -/* Word16 *gain_inov_fx o : unscaled innovation gain Q12 */ -/* Word32 *norm_gain_code_fx o : norm. gain of the codebook excit. Q16 */ -/*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*--------------------------------------------------------------------------------------*/ -/* CALLED FROM : */ -/*======================================================================================*/ - -void gain_dec_tc_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 i_subfr_fx, /* i : subframe number */ @@ -297,7 +163,6 @@ void gain_dec_tc_ivas_fx( index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/ -#ifdef HARM_COREDECODER_FUNCTIONS IF( st_fx->element_mode == EVS_MONO ) { IF( GT_16( nBits, 3 ) ) @@ -312,7 +177,6 @@ void gain_dec_tc_ivas_fx( } } ELSE -#endif { IF( GT_16( nBits, 3 ) ) { @@ -331,14 +195,12 @@ void gain_dec_tc_ivas_fx( *-----------------------------------------------------------------*/ /* *gain_code *= gcode0;*/ -#ifdef HARM_COREDECODER_FUNCTIONS IF( st_fx->element_mode == EVS_MONO ) { L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/ } ELSE -#endif { L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */ *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */ diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index c6b658a2d..1776d31a2 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -839,66 +839,6 @@ void concealment_init_x( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -void concealment_init_ivas_fx( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ) -{ - Word16 i; - - hPlcInfo->L_frameTCX = L_frameTCX; - move16(); - hPlcInfo->Pitch_fx = 0; - move16(); - hPlcInfo->T_bfi_fx = 0; - move16(); - hPlcInfo->outx_new_n1_fx = 0; - move16(); - hPlcInfo->nsapp_gain_fx = 0; - move16(); - hPlcInfo->nsapp_gain_n_fx = 0; - move16(); - hPlcInfo->ener_mean_fx = L_deposit_l( 15213 ); - hPlcInfo->ener_fx = L_deposit_l( 0 ); - hPlcInfo->zp_fx = L_frameTCX; - move16(); - hPlcInfo->recovery_gain = 0; - move16(); - hPlcInfo->step_concealgain_fx = 0; - move16(); - hPlcInfo->concealment_method = TCX_NONTONAL; - move16(); - hPlcInfo->subframe_fx = 0; - move16(); - hPlcInfo->nbLostCmpt = (Word16) L_deposit_l( 0 ); - move16(); - hPlcInfo->seed = RANDOM_INITSEED; - move16(); - - FOR( i = 0; i < TCX_TONALITY_INIT_CNT; i++ ) - { - hPlcInfo->TCX_Tonality[i] = 1; - move16(); - } - FOR( i = TCX_TONALITY_INIT_CNT; i < DEC_STATE_LEN; i++ ) - { - hPlcInfo->TCX_Tonality[i] = 0; - move16(); - } - FOR( i = 0; i < MAX_POST_LEN; i++ ) - { - hPlcInfo->Transient[i] = 1; - move16(); - } - - FOR( i = 0; i < L_FRAME_MAX; i++ ) - { - hPlcInfo->data_reci2_fx[i] = L_deposit_l( 0 ); - move32(); - } - return; -} -#endif static Word16 own_random_fix( /* o : output random value */ Word16 *seed /* i/o: random seed Q0 */ diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index dae4570cc..e28dd0bf9 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -975,11 +975,7 @@ void writeLPCparam_fx( IF( st->enableTcxLpc && st->core != ACELP_CORE ) { /* Encode the indices */ -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr ); /* Q0 */ -#else - *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */ -#endif move16(); } ELSE @@ -998,11 +994,7 @@ void writeLPCparam_fx( move16(); } -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ -#else - *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ -#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) @@ -1012,20 +1004,12 @@ void writeLPCparam_fx( IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->coder_type, VOICED ) && EQ_16( st->core, ACELP_CORE ) ) { assert( st->element_mode == EVS_MONO ); -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#else - *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#endif move16(); } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#else - *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#endif move16(); } } diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index f4889bf5f..560cd81bd 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2445,11 +2445,7 @@ void ivas_mdct_core_whitening_enc_fx( } } -#ifdef HARM_COREDECODER_FUNCTIONS encode_lpc_avq_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); -#else - encode_lpc_avq_ivas_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); -#endif st->side_bits_frame_channel = add( st->side_bits_frame_channel, sub( hBstr->nb_bits_tot, nbits_start_sns ) ); move16(); diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index bf2b1a704..2f9f2b7c7 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1512,45 +1512,6 @@ Word16 lsf_msvq_ma_encprm_fx( return nbits_lpc; } -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 lsf_msvq_ma_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, // Q0 - const Word16 core, - const Word16 acelp_mode, - const Word16 acelp_midLpc, - const Word16 *bits_param_lpc, - const Word16 no_indices ) -{ - Word16 i, nbits_lpc; - Word16 bits_midlpc; - - bits_midlpc = MIDLSF_NBITS; - move16(); - nbits_lpc = 0; - move16(); - - FOR( i = 0; i < no_indices; i++ ) - { - - push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); - param_lpc++; - nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); - } - IF( NE_16( acelp_mode, VOICED ) ) - { - test(); - IF( ( core == ACELP_CORE ) && acelp_midLpc ) - { - - push_next_indice( hBstr, *param_lpc, bits_midlpc ); - nbits_lpc = add( nbits_lpc, bits_midlpc ); - } - } - - return nbits_lpc; -} -#endif /*--------------------------------------------------------------------------* * midlsf_enc_fx() @@ -1992,41 +1953,6 @@ Word16 enc_lsf_tcxlpc_fx( return NumBits; } -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 enc_lsf_tcxlpc_ivas_fx( - const Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -) -{ - Word16 i, NumBits; - - Word16 flag; - - /* Read flag */ - flag = ( *indices )[0]; - move16(); - ++*indices; - - NumBits = TCXLPC_NUMBITS; - move16(); - FOR( i = 0; i < TCXLPC_NUMSTAGES; ++i ) - { - push_next_indice( hBstr, **indices, lsf_numbits[i] ); - ++*indices; - } - - IF( flag ) - { - NumBits = add( NumBits, TCXLPC_IND_NUMBITS ); - FOR( i = 0; i < TCXLPC_IND_NUMSTAGES; ++i ) - { - push_next_indice( hBstr, **indices, lsf_ind_numbits[i] ); - ++*indices; - } - } - return NumBits; -} -#endif /*--------------------------------------------------------------------------* * lsf_bctcvq_encprm_fx() @@ -2053,26 +1979,3 @@ Word16 lsf_bctcvq_encprm_fx( return nbits_lpc; } -#ifndef HARM_COREDECODER_FUNCTIONS - -Word16 lsf_bctcvq_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, // Q0 - const Word16 *bits_param_lpc, - const Word16 no_indices ) -{ - Word16 i, nbits_lpc; - - nbits_lpc = 0; - move16(); - - FOR( i = 0; i < no_indices; i++ ) - { - push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); - param_lpc++; - nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); - } - - return nbits_lpc; -} -#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0e1b7d7a6..2e20d7494 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2686,13 +2686,6 @@ Word16 enc_lsf_tcxlpc_fx( BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -/* Returns: number of bits written */ -Word16 enc_lsf_tcxlpc_ivas_fx( - const Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); -#endif Word16 encode_lpc_avq_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ @@ -2701,28 +2694,12 @@ Word16 encode_lpc_avq_fx( const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 encode_lpc_avq_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 numlpc, /* i : Number of sets of lpc Q0*/ - const Word16 *param_lpc, /* i : lpc parameters Q0*/ - const Word16 core, /* i : core Q0*/ - const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ -); -#endif Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, const Word16 *bits_param_lpc, const Word16 no_indices ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 lsf_bctcvq_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, - const Word16 *bits_param_lpc, - const Word16 no_indices ); -#endif Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, @@ -2732,16 +2709,6 @@ Word16 lsf_msvq_ma_encprm_fx( const Word16 *bits_param_lpc, const Word16 no_indices ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 lsf_msvq_ma_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, - const Word16 core, - const Word16 acelp_mode, - const Word16 acelp_midLpc, - const Word16 *bits_param_lpc, - const Word16 no_indices ); -#endif /* o: number of bits written per frame */ Word16 IGFEncWriteBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ @@ -3611,22 +3578,6 @@ void gain_enc_tc_fx( const Word16 Q_xn /* i : xn and y1 scaling */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -void gain_enc_tc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); -#endif Word16 gaus_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -3647,27 +3598,6 @@ Word16 gaus_encode_fx( Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 gaus_encode_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ -); -#endif void pre_proc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 input_frame, /* i : frame length */ diff --git a/lib_enc/qlpc_avq_fx.c b/lib_enc/qlpc_avq_fx.c index 0b28d1b77..5d4d93fdf 100644 --- a/lib_enc/qlpc_avq_fx.c +++ b/lib_enc/qlpc_avq_fx.c @@ -130,38 +130,9 @@ void qlpc_avq_fx( * *--------------------------------------------------------------------*/ -#ifdef HARM_COREDECODER_FUNCTIONS static Word16 unary_code_fx( -#else -static Word16 unary_code( -#endif Word16 ind, /* Q0 */ BSTR_ENC_HANDLE hBstr ) -#ifndef HARM_COREDECODER_FUNCTIONS -{ - Word16 nb_bits; - - move16(); - nb_bits = 1; - - /* Index bits */ - ind = sub( ind, 1 ); - - FOR( ; ind > 0; ind-- ) - { - push_next_indice( hBstr, 1, 1 ); - nb_bits = add( nb_bits, 1 ); // Q0 - } - - /* Stop bit */ - push_next_indice( hBstr, 0, 1 ); - - return ( nb_bits ); -} -static Word16 unary_code_ivas_fx( - Word16 ind, /* Q0 */ - BSTR_ENC_HANDLE hBstr ) -#endif { Word16 nb_bits; @@ -195,11 +166,7 @@ static Word16 unary_code_ivas_fx( * *--------------------------------------------------------------------*/ -#ifdef HARM_COREDECODER_FUNCTIONS static Word16 unpack4bits_fx( -#else -static Word16 unpack4bits( -#endif Word16 nbits, /* Q0 */ const Word16 *prm, /* Q0 */ BSTR_ENC_HANDLE hBstr ) @@ -228,37 +195,6 @@ static Word16 unpack4bits( return ( i ); } -#ifndef HARM_COREDECODER_FUNCTIONS -static Word16 unpack4bits_ivas_fx( - Word16 nbits, /* Q0 */ - const Word16 *prm, /* Q0 */ - BSTR_ENC_HANDLE hBstr ) -{ - Word16 i; - - IF( nbits == 0 ) - { - push_next_indice( hBstr, 0, 0 ); - i = 1; - move16(); - } - ELSE - { - move16(); - i = 0; - - FOR( ; nbits > 4; nbits -= 4 ) - { - push_next_indice( hBstr, prm[i], 4 ); - i = add( i, 1 ); - } - push_next_indice( hBstr, prm[i], nbits ); - i = add( i, 1 ); - } - - return ( i ); -} -#endif /*-------------------------------------------------------------------* * encode_lpc_avq_fx() * @@ -266,215 +202,6 @@ static Word16 unpack4bits_ivas_fx( *--------------------------------------------------------------------*/ Word16 encode_lpc_avq_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 numlpc, /* i : Number of sets of lpc Q0*/ - const Word16 *param_lpc, /* i : lpc parameters Q0*/ - const Word16 core, /* i : core Q0*/ - const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ -) -{ - Word16 k, j; - Word16 q_type, nb_ind; - Word16 i, qn1, qn2, nb, avqBits, st1; - Word16 nb_bits; - Word16 stereo_mode, bits_for_abs_quant; - - stereo_mode = 0; - move16(); - bits_for_abs_quant = LPC_ABS_QUANT_BITS; - move16(); - if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) - { - bits_for_abs_quant = SNS_ABS_QUANT_BITS; - move16(); - } - - move16(); - move16(); - move16(); - st1 = 0; - j = 0; - nb_bits = 0; - - FOR( k = 0; k < numlpc; k++ ) - { - /* Retrieve quantizer type */ - - - move16(); - q_type = 0; - if ( k != 0 ) - { - move16(); - q_type = param_lpc[j]; // Q0 - j = add( j, 1 ); - } - test(); - if ( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 ) - { - stereo_mode = param_lpc[j]; // Q0 - move16(); - j = add( j, 1 ); - } - /* Determine number of AVQ indices */ - move16(); - nb_ind = 0; - - if ( q_type == 0 ) - { - move16(); - st1 = param_lpc[j++]; // Q0 - } - move16(); - move16(); - qn1 = param_lpc[j++]; // Q0 - qn2 = param_lpc[j++]; // Q0 - IF( EQ_16( qn1, SNS_LOW_BR_MODE ) ) - { - nb_ind = add( qn1, qn2 ); - } - - test(); - test(); - IF( k == 0 || ( EQ_16( k, 1 ) && NE_16( core, TCX_20_CORE ) ) ) - { - /* Encode quantizer type */ - move16(); - nb = 0; - IF( k != 0 ) - { - nb = 1; - move16(); - push_next_indice( hBstr, q_type, nb ); - } - nb_bits = add( nb_bits, nb ); // Q0 - - /* Encode quantizer data */ - test(); - test(); - test(); - test(); - IF( ( ( q_type == 0 ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) || ( ( q_type == 0 ) && ( GE_16( st1, 0 ) ) && EQ_16( element_mode, IVAS_CPE_MDCT ) ) ) - { - /* Absolute quantizer with 1st stage stochastic codebook */ - push_next_indice( hBstr, st1, bits_for_abs_quant ); - nb_bits = add( nb_bits, bits_for_abs_quant ); // Q0 - } - - test(); - test(); - IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && EQ_16( stereo_mode, 3 ) && st1 < 0 ) - { - push_next_indice( hBstr, add( st1, 2 ), 1 ); - nb_bits = add( nb_bits, 1 ); // Q0 - } - - test(); - test(); - IF( NE_16( element_mode, IVAS_CPE_MDCT ) || ( NE_16( st1, -2 ) && NE_16( qn1, SNS_LOW_BR_MODE ) ) ) - { - - /* 2 bits to specify Q2,Q3,Q4,ext */ - nb_bits = add( nb_bits, 4 ); // Q0 - i = sub( qn1, 2 ); - - if ( s_or( i < 0, (Word16) GT_16( i, 3 ) ) ) - { - move16(); - i = 3; - } - push_next_indice( hBstr, i, 2 ); - - i = sub( qn2, 2 ); - - if ( s_or( i < 0, (Word16) GT_16( i, 3 ) ) ) - { - move16(); - i = 3; - } - push_next_indice( hBstr, i, 2 ); - - /* Unary code for abs and rel LPC0/LPC2 */ - /* Q5 = 0, Q6=10, Q0=110, Q7=1110, ... */ - move16(); - nb = qn1; - - IF( GT_16( nb, 6 ) ) - { - nb = sub( nb, 3 ); - } - ELSE IF( GT_16( nb, 4 ) ) - { - nb = sub( nb, 4 ); - } - ELSE IF( nb == 0 ) - { - move16(); - nb = 3; - } - ELSE - { - move16(); - nb = 0; - } - - IF( nb > 0 ) - { - unary_code( nb, hBstr ); - } - nb_bits = add( nb_bits, nb ); // Q0 - - move16(); - nb = qn2; - - IF( GT_16( nb, 6 ) ) - { - nb = sub( nb, 3 ); // Q0 - } - ELSE IF( GT_16( nb, 4 ) ) - { - nb = sub( nb, 4 ); // Q0 - } - ELSE IF( nb == 0 ) - { - move16(); - nb = 3; - } - ELSE - { - move16(); - nb = 0; - } - - IF( nb > 0 ) - { - unary_code( nb, hBstr ); - } - nb_bits = add( nb_bits, nb ); // Q0 - - avqBits = shl( qn1, 2 ); - unpack4bits( avqBits, ¶m_lpc[j], hBstr ); - j = add( j, qn1 ); - nb_bits = add( nb_bits, avqBits ); // Q0 - - avqBits = shl( qn2, 2 ); - unpack4bits( avqBits, ¶m_lpc[j], hBstr ); - j = add( j, qn2 ); - nb_bits = add( nb_bits, avqBits ); // Q0 - } - } - ELSE - { - j = add( j, nb_ind ); - } - } - - return ( nb_bits ); -} - -Word16 encode_lpc_avq_ivas_fx( -#endif BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ const Word16 *param_lpc, /* i : lpc parameters Q0*/ @@ -631,11 +358,7 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS unary_code_fx( nb, hBstr ); -#else - unary_code_ivas_fx( nb, hBstr ); -#endif } nb_bits = add( nb_bits, nb ); @@ -663,29 +386,17 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS unary_code_fx( nb, hBstr ); -#else - unary_code_ivas_fx( nb, hBstr ); -#endif } nb_bits = add( nb_bits, nb ); avqBits = shl( qn1, 2 ); -#ifdef HARM_COREDECODER_FUNCTIONS unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); -#else - unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); -#endif j = add( j, qn1 ); nb_bits = add( nb_bits, avqBits ); // Q0 avqBits = shl( qn2, 2 ); -#ifdef HARM_COREDECODER_FUNCTIONS unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); -#else - unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); -#endif j = add( j, qn2 ); nb_bits = add( nb_bits, avqBits ); // Q0 } diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 08f3e5033..30def3e2e 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -791,48 +791,28 @@ Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, Word16 const *stream, { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } } ELSE { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } } } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } return TNS_NO_ERROR; -- GitLab From ca7fe75aeead95f1cc175d85a9417c847805ca43 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:43:41 +0100 Subject: [PATCH 625/750] [cleanup] accept FIX_BASOP_2351_EXTREND_SCALE --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 88 ------------------------------------------ 2 files changed, 89 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 338a68553..fac99f95b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ -#define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ #define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ #define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 2f94d5213..890e38ca0 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6487,17 +6487,9 @@ static ivas_error renderIsmToBinaural( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpTDRendBuffer[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, @@ -6507,17 +6499,9 @@ static ivas_error renderIsmToBinaural( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpTDRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } IF( ismInput->hReverb != NULL ) @@ -6780,17 +6764,9 @@ static ivas_error renderIsmToBinauralReverb( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), IVAS_ERR_OK ) ) @@ -6798,17 +6774,9 @@ static ivas_error renderIsmToBinauralReverb( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( 11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( 11, exp ) ) ); /* Q(exp) */ -#endif } IF( ismInput->hReverb != NULL ) @@ -7111,17 +7079,9 @@ static ivas_error renderIsmToSplitBinaural( } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_NUM_OBJECTS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } /* Render */ @@ -7133,11 +7093,7 @@ static ivas_error renderIsmToSplitBinaural( FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpProcessing[i], output_frame, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } IF( ismInput->hReverb != NULL ) @@ -7540,17 +7496,9 @@ static ivas_error renderMcToBinaural( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer_fx ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), @@ -7559,17 +7507,9 @@ static ivas_error renderMcToBinaural( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } } ELSE @@ -7679,17 +7619,9 @@ static ivas_error renderMcToBinauralRoom( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, @@ -7699,17 +7631,9 @@ static ivas_error renderMcToBinauralRoom( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } } ELSE @@ -8052,17 +7976,9 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } /* Render */ IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer, &exp ) ) != IVAS_ERR_OK ) @@ -8071,11 +7987,7 @@ static ivas_error renderMcToSplitBinaural( } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } /* Copy rendered audio to tmp storage buffer. Copying directly to output would -- GitLab From f1a278196884c7e12f83a571d06fa994c4568060 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:45:22 +0100 Subject: [PATCH 626/750] [cleanup] accept FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fac99f95b..ab4a52097 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ -#define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ #define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 890e38ca0..860fb7512 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6928,9 +6928,7 @@ static ivas_error renderIsmToSba( error = IVAS_ERR_OK; move32(); -#ifdef FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE set32_fx( currentPanGains_fx, 0, MAX_OUTPUT_CHANNELS ); -#endif ismInput->currentPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->currentPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 ); ismInput->currentPos.elevation_fx = L_shl( L_shr( L_add( ismInput->currentPos.elevation_fx, ONE_IN_Q21 ), Q22 ), Q22 ); -- GitLab From 565bdd4c1ab38b2666d97369b51750ab1fbd82c7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:46:05 +0100 Subject: [PATCH 627/750] [cleanup] accept FIX_2362_TOTAL_BRATE_CALCULATION --- lib_com/options.h | 1 - lib_enc/ivas_cpe_enc_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ab4a52097..bcd18d49b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ -#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 3be57e782..659c03e52 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -630,7 +630,6 @@ ivas_error ivas_cpe_enc_fx( { sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */ sts[n]->bits_frame_channel = idiv1616( extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), n_CoreChannels ); /* Q0 */ -#ifdef FIX_2362_TOTAL_BRATE_CALCULATION /* sts[n]->total_brate = hCPE->element_brate / n_CoreChannels; */ assert( n_CoreChannels == 1 || n_CoreChannels == 2 ); sts[n]->total_brate = hCPE->element_brate; @@ -638,9 +637,6 @@ ivas_error ivas_cpe_enc_fx( { sts[n]->total_brate = L_shr( hCPE->element_brate, 1 ); } -#else - sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */ -#endif move32(); move16(); move16(); -- GitLab From 4f6ad9462b17bcf7f414ebbf19d4bb5a8cc8fa27 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:47:05 +0100 Subject: [PATCH 628/750] [cleanup] accept FIX_2330_CLANG_18_WARNINGS_REND --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index bcd18d49b..015ab6f61 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ -#define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 860fb7512..527a1b564 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11198,10 +11198,6 @@ static void intermidiate_ext_dirac_render( move16(); } } -#ifndef FIX_2330_CLANG_18_WARNINGS_REND - hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); - move16(); -#endif IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { -- GitLab From e23393cbfa60ee26a282ede7fc1385132521f7cc Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:48:43 +0100 Subject: [PATCH 629/750] [cleanup] accept FIX_BASOP_2350_HARM_0B_BWE --- lib_com/options.h | 1 - lib_com/prot_fx.h | 27 ----- lib_dec/acelp_core_dec_fx.c | 8 -- lib_dec/hf_synth_fx.c | 226 ------------------------------------ 4 files changed, 262 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 015ab6f61..bad7e0785 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ -#define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 78ff2fc72..1557bb6d8 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6339,35 +6339,9 @@ void hf_synth_reset_fx( ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ ); -#ifndef FIX_BASOP_2350_HARM_0B_BWE void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); -void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); -#else -void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ -#ifdef FIX_BASOP_2350_HARM_0B_BWE const Word16 element_mode, /* i : element mode Q0*/ -#endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ const Word16 *Aq, /* i : quantized Az Q12*/ @@ -6378,7 +6352,6 @@ void hf_synth_fx( const Word16 Q_syn2 /* i : synthesis scaling */ ); -#endif void hf_synth_amr_wb_init_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 373e2ea54..bbf4a8514 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2234,20 +2234,12 @@ ivas_error acelp_core_dec_fx( #else IF( EQ_16( st->element_mode, EVS_MONO ) ) { -#ifndef FIX_BASOP_2350_HARM_0B_BWE - hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#else hf_synth_fx( st->hBWE_zero, EVS_MONO, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#endif } ELSE { Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 -#ifndef FIX_BASOP_2350_HARM_0B_BWE - hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#else hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#endif Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); } #endif diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index a2dc8803b..a2dbba4aa 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -20,12 +20,7 @@ *---------------------------------------------------------------------*/ static void filt_6k_7k_scale_fx( Word16 signal[], Word16 lg, Word16 mem[], Word16 fact, Word16 exp ); -#ifdef FIX_BASOP_2350_HARM_0B_BWE static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word16 element_mode, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); -#else -static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); -static void hf_synthesis_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); -#endif static void hf_synthesis_amr_wb_fx( const Word32 core_brate, const Word16 output_subfr, const Word16 Ap[], Word16 exc16k[], Word16 synth_out[], Word16 *mem_syn_hf, Word16 *delay_syn_hf, Word16 *mem_hp_interp, Word16 p_r, Word16 HF_corr_gain, Word16 til, Word16 voice_factors, const Word16 exc[], const Word16 Q_exc, const Word16 Q_out, Word16 qhf ); static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, const Word32 core_brate, const Word16 Aq[], Word16 Ap[], Word16 *r, Word16 tilt0, Word16 tilt, Word16 voice_factor ); static void AdaptiveStartBand_fx( Word16 *start_band, const Word32 rate, const Word16 *lsf, const Word16 voicing_fac, const Word16 clas, Word16 *voicing_flag, Word16 *start_band_old, Word32 *OptCrit_old ); @@ -84,9 +79,7 @@ void hf_synth_reset_fx( void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ -#ifdef FIX_BASOP_2350_HARM_0B_BWE const Word16 element_mode, /* i : element mode Q0*/ -#endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ const Word16 *Aq, /* i : quantized Az Q12*/ @@ -106,11 +99,7 @@ void hf_synth_fx( p_Aq = Aq; /* Q12 */ FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { -#ifdef FIX_BASOP_2350_HARM_0B_BWE hf_synthesis_fx( hBWE_zero, element_mode, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); -#else - hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); -#endif p_Aq += ( M + 1 ); /* Q12 */ } @@ -130,9 +119,7 @@ void hf_synth_fx( static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, -#ifdef FIX_BASOP_2350_HARM_0B_BWE const Word16 element_mode, /* i : element mode Q0*/ -#endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_subfr, /* i : output sub-frame length Q0*/ const Word16 Aq[], /* i : quantized Az Q12*/ @@ -148,11 +135,9 @@ static void hf_synthesis_fx( Word16 HF_exc[L_SUBFR16k]; Word16 tmp, ener, exp1, exp2, scale; Word32 L_tmp; -#ifdef FIX_BASOP_2350_HARM_0B_BWE Word16 Q_tmp, Q_ener, sft; Word32 ONE, P_ONE; Word64 prod; -#endif Word16 Ap[M16k + 1]; /*-----------------------------------------------------------------* @@ -176,10 +161,8 @@ static void hf_synthesis_fx( L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 ); tmp = round_fx( L_tmp ); /* Q15 */ -#ifdef FIX_BASOP_2350_HARM_0B_BWE IF( element_mode == EVS_MONO ) { -#endif /* tmp = (float)(sqrt(ener/tmp)) */ /* scale is -1 if tmp > ener */ scale = shr( sub( ener, tmp ), 15 ); /* Q0 */ @@ -243,7 +226,6 @@ static void hf_synthesis_fx( /*scale *= fac;*/ tmp = mult_r( scale, tmp ); -#ifdef FIX_BASOP_2350_HARM_0B_BWE } ELSE { @@ -319,7 +301,6 @@ static void hf_synthesis_fx( tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */ Q_tmp = sub( Q_tmp, exp1 ); } -#endif /*-----------------------------------------------------------------* * modify HF excitation according to both calculated scaling factors @@ -386,213 +367,6 @@ static void hf_synthesis_fx( return; } -#ifndef FIX_BASOP_2350_HARM_0B_BWE -void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -) -{ - const Word16 *p_Aq; - Word16 i_subfr, output_subfr; - - output_subfr = shr( output_frame, 2 ); - - p_Aq = Aq; /* Q12 */ - FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) - { - hf_synthesis_ivas_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); - - p_Aq += ( M + 1 ); /* Q12 */ - } - - return; -} -static void hf_synthesis_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_subfr, /* i : output sub-frame length Q0*/ - const Word16 Aq[], /* i : quantized Az Q12*/ - const Word16 exc[], /* i : excitation at 12.8 kHz Q_exc*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 synth[], /* i : 12.8kHz synthesis signal Q_syn*/ - Word16 synth16k[], /* i/o: 16kHz synthesis signal Q_syn*/ - const Word16 Q_syn /* i : synthesis scaling */ -) -{ - Word16 i, s; - Word16 HF_syn[L_SUBFR16k], upsampled_HF_syn[L_FRAME48k / NB_SUBFR]; - Word16 HF_exc[L_SUBFR16k]; - Word16 exp1, exp2, scale, tmp, ener, Q_tmp, Q_ener, sft; - Word32 L_tmp, ONE, P_ONE; - Word16 Ap[M16k + 1]; - Word64 prod; - - /*-----------------------------------------------------------------* - * generate white noise vector - *-----------------------------------------------------------------*/ - - Random_Fill( &hBWE_zero->seed2, L_SUBFR16k, HF_exc, 3 ); /* 3 = Shift Right by 3 */ - - /* o: HF_exc in Q(-3) */ - - /*-----------------------------------------------------------------* - * calculate energy scaling factor so that white noise would have the - * same energy as exc12k8 - *-----------------------------------------------------------------*/ - - /*ener = sum2_f( exc, L_SUBFR ) + 0.01f*/ - ener = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp2 ) ); - exp2 = sub( exp2, add( Q_exc, Q_exc ) ); // ener exponent - - /*tmp = round_fx(Dot_product12(HF_exc, HF_exc, output_subfr, &exp1)); */ - L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 ); - tmp = round_fx( L_tmp ); - exp1 = add( exp1, 6 ); /* tmp exponent */ - - ener = shr( ener, 1 ); /* to avoid the assertion in div_s() further*/ - exp2 = add( exp2, 1 ); - - tmp = div_s( ener, tmp ); - exp1 = sub( exp2, exp1 ); - - scale = Sqrt16( tmp, &exp1 ); /* scale exponent = exp1 */ - - /*-----------------------------------------------------------------* - * calculate energy scaling factor to respect tilt of synth12k8 - * (tilt: 1=voiced, -1=unvoiced) - *-----------------------------------------------------------------*/ - - hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx ); - - /* i: mem_hp400 in Q_syn */ - /* i: synth in Q_syn */ - /* o: synth in Q_syn-3 */ - prod = W_mac0_16_16( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3) */ - FOR( i = 1; i < L_SUBFR; i++ ) - { - prod = W_mac0_16_16( prod, synth[i], synth[i] ); /* 2*(Q_syn-3) */ - } - sft = W_norm( prod ); - ener = extract_h( W_extract_h( W_shl( prod, sft ) ) ); - Q_ener = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 ); - - prod = W_mac0_16_16( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3) */ - FOR( i = 2; i < L_SUBFR; i++ ) - { - prod = W_mac0_16_16( prod, synth[i], synth[i - 1] ); /* 2*(Q_syn-3) */ - } - sft = sub( W_norm( prod ), 1 ); - tmp = extract_h( W_extract_h( W_shl( prod, sft ) ) ); - Q_tmp = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 ); - - tmp = s_max( 0, tmp ); - IF( tmp > 0 ) - { - tmp = div_s( tmp, ener ); - Q_tmp = add( 15, sub( Q_tmp, Q_ener ) ); - } - - /*-----------------------------------------------------------------* - * modify energy of white noise according to synthesis tilt - *-----------------------------------------------------------------*/ - /* tmp = 1.0 - fac */ - ONE = L_shl( 1, Q_tmp ); - P_ONE = L_shl( 3277 /* 0.1 in Q15 */, sub( Q_tmp, 15 ) ); - L_tmp = L_msu0( ONE, tmp, 1 ); - test(); - if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) ) - { - /* emphasize HF noise in CNG */ - /*fac *= 2.0f;*/ - L_tmp = L_add( L_tmp, L_tmp ); - } - L_tmp = L_max( L_tmp, P_ONE ); - L_tmp = L_min( L_tmp, ONE ); - - sft = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, sft ); - - tmp = round_fx( L_tmp ); - Q_tmp = sub( add( Q_tmp, sft ), 16 ); - - /*scale *= fac;*/ - tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */ - Q_tmp = sub( Q_tmp, exp1 ); - /*-----------------------------------------------------------------* - * modify HF excitation according to both calculated scaling factors - * high pass filtering (0.94ms of delay) - *-----------------------------------------------------------------*/ - - exp2 = sub( hBWE_zero->memExp1, exp1 ); - hBWE_zero->memExp1 = exp1; - move16(); - - filt_6k_7k_scale_fx( HF_exc, L_SUBFR16k, hBWE_zero->mem_hf_fx, tmp, exp2 ); - /* i: HF_exc in Q(-3) */ - /* o: HF_exc in ((-3) + Q_tmp - 17) */ - /* o: hBWE_zero->mem_hf_fx in Q(HF_exc)-2 */ - - /*-----------------------------------------------------------------* - * synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz - *-----------------------------------------------------------------*/ - - /*weight_a( Aq, Ap, 0.6f, M );*/ - weight_a_lc_fx( Aq, Ap, Gamma_19661_Tbl_fx, M ); - /* o: Ap in Q14 */ - - Syn_filt_s( 0, Ap, M, HF_exc, HF_syn, L_SUBFR16k, hBWE_zero->mem_syn_hf_fx, 1 ); - /* o: HF_syn in same Q as HF_exc */ - /* o: mem_syn_hf_fx same Q as HF_syn */ - - Scale_sig( HF_syn, L_SUBFR16k, ( add( Q_syn, exp1 ) ) ); /* bring HF_syn to (Q_syn+exp1) */ - - /*-----------------------------------------------------------------* - * add filtered HF noise to speech synthesis - *-----------------------------------------------------------------*/ - - /* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */ - delay_signal_fx( HF_syn, L_SUBFR16k, hBWE_zero->delay_syn_hf_fx, NS2SA_FX2( 16000, DELAY_CLDFB_NS ) - 15 ); - - /* interpolate the HF synthesis */ - IF( EQ_16( output_subfr, L_SUBFR48k ) ) /* 48kHz sampled output */ - { - s = s_max( s_min( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN - 3 ) ), 3 ), - sub( Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx + INTERP_3_1_MEM_LEN - 3, 3 ), 1 ) ), - 0 ); - Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, s ); /* Qx + s */ - interpolate_3_over_1_allpass_fx( HF_syn, L_SUBFR16k, upsampled_HF_syn, hBWE_zero->mem_hp_interp_fx ); - Scale_sig( upsampled_HF_syn, 3 * L_SUBFR16k, -s ); /* Q_syn + exp1 + s */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, -s ); /* Qx */ - Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */ - Scale_sig( upsampled_HF_syn, L_SUBFR48k, -1 ); - } - ELSE IF( EQ_16( output_subfr, L_SUBFR32k ) ) /* 32kHz sampled output */ - { - s = s_max( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP ) ), 2 ), 0 ); - Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, s ); /* Qx + s */ - Interpolate_allpass_steep_fx( HF_syn, hBWE_zero->mem_hp_interp_fx, L_SUBFR16k, upsampled_HF_syn ); - Scale_sig( upsampled_HF_syn, 2 * L_SUBFR16k, -s ); /* Q_syn + exp1 */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, -s ); /* Qx */ - Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */ - } - ELSE /* 16kHz sampled output */ - { - Copy( HF_syn, upsampled_HF_syn, L_SUBFR16k ); /* Q_syn */ - } - Vr_add( synth16k, upsampled_HF_syn, synth16k, output_subfr ); - - return; -} -#endif /*-------------------------------------------------------------------* * filt_6k_7k: -- GitLab From 9b3acce219afbbd74c40e0d5e3f035f4a2448d54 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:49:20 +0100 Subject: [PATCH 630/750] [cleanup] accept FIX_2349_HARM_FIND_UV --- lib_com/options.h | 1 - lib_enc/find_uv_fx.c | 513 -------------------------- lib_enc/ivas_core_pre_proc_front_fx.c | 5 - lib_enc/pre_proc_fx.c | 5 - lib_enc/prot_fx_enc.h | 25 -- 5 files changed, 549 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index bad7e0785..a3964e6a1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +89,6 @@ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ #define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ -#define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ #define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ #define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 66b5eac77..e2c342c19 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -85,501 +85,8 @@ static Word16 find_ener_decrease_fx( * Decision about coder type *-------------------------------------------------------------------*/ -#ifndef FIX_2349_HARM_FIND_UV -Word16 find_uv_fx( /* o : coding type */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ - const Word16 Q_new, - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 shift, - const Word16 last_core_orig /* i : original last core Q0*/ -) -{ - Word16 coder_type, i; - Word32 mean_ee, dE1, fac_32; - const Word16 *pt_speech; - Word32 L_tmp, enr_ssf[2 * NB_SSF + 2 * NB_SSF + 2], E_min_th; - Word16 dE2; - Word16 ind_deltaMax, tmp_offset_flag; - Word32 Ltmp0, *pt_enr_ssf, *pt_enr_ssf1, dE2_th; - Word16 exp0, exp1, Q_in; - Word16 wtmp0, wtmp1; - Word16 fac, mean_voi3, dE3; - Word16 relE_thres; - Word16 mean_voi3_offset; - Word16 voicing_m, dpit1, dpit2, dpit3; - Word16 ee0_th, ee1_th, voi_th, nb_cond, flag_low_relE; - NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - Word16 Last_Resort; - Word16 vadnoise; - - IF( hSC_VBR != NULL ) - { - Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ - vadnoise = hSC_VBR->vadnoise_fx; - move16(); - move16(); - } - ELSE - { - Last_Resort = 0; - vadnoise = 0; - move16(); - move16(); - } - - Q_in = sub( Q_new, 1 ); - - /*-----------------------------------------------------------------* - * Detect sudden energy increases to catch voice and music - * temporal events (dE1) - * - * - Find maximum energy per short subblocks. - * Two subblock sets are used shifted by half the subblock length - * - Find maximum energy ratio between adjacent subblocks - *-----------------------------------------------------------------*/ - - /* Find maximum energy per short subblocks */ - pt_speech = speech - SSF; /* Q_new */ - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) - { - emaximum_fx( Q_in, pt_speech, SSF, pt_enr_ssf ); - pt_speech += ( SSF / 2 ); - pt_enr_ssf++; - } - - dE1 = 0; - move16(); - ind_deltaMax = 0; - move16(); - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - pt_enr_ssf1 = pt_enr_ssf + 2; - - /* Test on energy increase between adjacent sub-subframes */ - exp1 = 0; - move16(); - FOR( i = 0; i < 2 * NB_SSF; i++ ) - { - /*fac = *pt_enr_ssf1 / (*pt_enr_ssf + 1);*/ - Ltmp0 = L_max( *pt_enr_ssf, 1 ); - exp0 = norm_l( Ltmp0 ); - wtmp0 = extract_h( L_shl( Ltmp0, exp0 ) ); - exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); - wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); - fac = div_s( wtmp1, wtmp0 ); - fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ - - if ( GT_32( fac_32, dE1 ) ) - { - ind_deltaMax = i; - move16(); - } - - dE1 = L_max( dE1, fac_32 ); /* Q13 */ - - pt_enr_ssf++; - pt_enr_ssf1++; - } - - /*-----------------------------------------------------------------* - * Average spectral tilt - * Average voicing (normalized correlation) - *-----------------------------------------------------------------*/ - - /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ - mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/ - - /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ - Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ - Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */ - mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ - /*-----------------------------------------------------------------* - * Total frame energy difference (dE3) - *-----------------------------------------------------------------*/ - - dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ - - /*-----------------------------------------------------------------* - * Energy decrease after spike (dE2) - *-----------------------------------------------------------------*/ - - /* set different thresholds and conditions for NB and WB input */ - dE2_th = 30 << 10; - move32(); - nb_cond = 1; - move16(); /* no additional condition for WB input */ - IF( EQ_16( st_fx->input_bwidth, NB ) ) - { - dE2_th = 21 << 10; - move32(); - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ - { - nb_cond = 0; - move16(); - } - } - - /* calcualte maximum energy decrease */ - dE2 = 0; - move16(); /* Test on energy decrease after an energy spike */ - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - - test(); - IF( GT_32( dE1, 30 << 13 ) && nb_cond ) /*>30 Q13*/ - { - IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) ) - { - st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */ - move16(); - Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */ - } - ELSE - { - st_fx->old_ind_deltaMax = -1; - move16(); - dE2 = find_ener_decrease_fx( ind_deltaMax, pt_enr_ssf ); /*Q10*/ - - if ( GT_32( dE2, dE2_th ) ) - { - st_fx->spike_hyst = 0; - move16(); - } - } - } - ELSE - { - IF( st_fx->old_ind_deltaMax >= 0 ) - { - Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */ - dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */ - - if ( GT_32( dE2, dE2_th ) ) - { - st_fx->spike_hyst = 1; - move16(); - } - } - - st_fx->old_ind_deltaMax = -1; - move16(); - } - - /*-----------------------------------------------------------------* - * Detection of voiced offsets (tmp_offset_flag) - *-----------------------------------------------------------------*/ - - tmp_offset_flag = 1; - move16(); - - IF( NE_16( st_fx->input_bwidth, NB ) ) - { - ee0_th = 154; /*2.4 in Q6 */ - move16(); - voi_th = 24248; /*0.74f Q15 */ - move16(); - } - ELSE - { - ee0_th = 627; /*9.8f Q6 */ - move16(); - voi_th = 24904; /*0.76f Q15*/ - move16(); - } - - test(); - test(); - test(); - if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ - ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ - { - tmp_offset_flag = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * Decision about UC - *-----------------------------------------------------------------*/ - - /* SC-VBR - set additional parameters and thresholds for SC-VBR */ - mean_voi3_offset = 0; - move16(); - flag_low_relE = 0; - move16(); - ee1_th = 608; /*9.5 Q6*/ - move16(); - IF( st_fx->Opt_SC_VBR || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) /* Allow the low energy flag for the secondary channel */ - { - ee1_th = 544; /*8.5f Q6*/ - move16(); - - /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ - IF( NE_16( st_fx->input_bwidth, NB ) ) - { - /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24 - if ( Last_Resort == 0 ) - { - /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24 - } - relE_thres = round_fx( L_tmp ); - } - ELSE - { - - /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24 - relE_thres = round_fx( L_tmp ); - } - relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */ - - /* SC-VBR = set flag on low relative energy */ - if ( LT_16( relE, relE_thres ) ) - { - flag_low_relE = 1; - move16(); - } - - /* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */ - test(); - if ( EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */ - { - mean_voi3_offset = 1638; /*0.05f Q15*/ - move16(); - } - } - - /* make decision whether frame is unvoiced */ - E_min_th = L_shl( E_MIN_FX, Q_new ); - coder_type = GENERIC; - move16(); - IF( EQ_16( st_fx->input_bwidth, NB ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ - { - coder_type = UNVOICED; - move16(); - } - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ - { - coder_type = UNVOICED; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Decision about VC - *-----------------------------------------------------------------*/ - if ( st_fx->Opt_SC_VBR ) - { - hSC_VBR->set_ppp_generic = 0; - } - move16(); - - test(); - test(); - IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) ) - { - dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); // Q6 - dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); // Q6 - dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); // Q6 - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */ - ( LT_16( dpit1, 3 << 6 ) ) && - ( LT_16( dpit2, 3 << 6 ) ) && - ( LT_16( dpit3, 3 << 6 ) ) ) - { - coder_type = VOICED; - move16(); - } - ELSE IF( st_fx->Opt_SC_VBR && EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */ - ( LT_16( dpit1, 5 << 6 ) ) && - ( LT_16( dpit2, 5 << 6 ) ) && - ( LT_16( dpit3, 5 << 6 ) ) ) - { - hSC_VBR->set_ppp_generic = 1; - move16(); - coder_type = VOICED; - move16(); - } - } - - /* set VOICED mode for frames with very stable pitch and high correlation - and avoid to switch to AUDIO/MUSIC later */ - voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ ); - test(); - test(); - test(); - test(); - test(); - IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) && - GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) ) - { - coder_type = VOICED; - move16(); - *flag_spitch = 1; - move16(); /*to avoid switch to AUDIO/MUSIC later*/ - } - } - - /*-----------------------------------------------------------------* - * Channel-aware mode - set RF mode and total bitrate - *-----------------------------------------------------------------*/ - - st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */ - move16(); - - IF( EQ_16( coder_type, GENERIC ) ) - { - test(); - test(); - test(); - test(); - IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */ - ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */ - ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */ - - { - st_fx->rf_mode = 0; - move16(); - /* Current frame cannot be compressed to pack the partial redundancy;*/ - - if ( st_fx->rf_mode != st_fx->Opt_RF_ON ) - { - core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift ); - } - } - } - - /*-----------------------------------------------------------------* - * Updates - *-----------------------------------------------------------------*/ - - /* update spike hysteresis parameters */ - test(); - if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) ) - { - st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */ - } - - /* reset spike hysteresis */ - test(); - test(); - test(); - if ( ( GT_16( st_fx->spike_hyst, 1 ) ) && - ( GT_16( dE3, 5 << 8 ) || /* energy increases */ - ( GT_16( relE, -3328 ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */ - { - st_fx->spike_hyst = -1; - move16(); - } - - /* update tilt parameters */ - st_fx->ee_old_fx = ee[1]; - move32(); /*Q6*/ - st_fx->old_dE1_fx = dE1; - move32(); /*Q13*/ - - /* save the raw coder_type for various modules later in the codec (the reason is that e.g. UNVOICED is lost at higher rates) */ - st_fx->coder_type_raw = coder_type; - move16(); - - return coder_type; -} - -/*-------------------------------------------------------------------* - * find_uv() - * - * Decision about coder type - *-------------------------------------------------------------------*/ -Word16 find_uv_ivas_fx( /* o : coding type */ -#else /*! r: coder type */ Word16 find_uv_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ @@ -594,9 +101,7 @@ Word16 find_uv_fx( const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, -#ifdef FIX_2349_HARM_FIND_UV const Word16 shift, -#endif const Word16 q_hp_E ) { Word16 coder_type, i; @@ -622,12 +127,10 @@ Word16 find_uv_fx( Q_in = Q_new; move16(); -#ifdef FIX_2349_HARM_FIND_UV if ( st_fx->element_mode == EVS_MONO ) { Q_in = sub( Q_new, 1 ); } -#endif IF( hSC_VBR != NULL ) { @@ -738,7 +241,6 @@ Word16 find_uv_fx( * Total frame energy difference (dE3) *-----------------------------------------------------------------*/ -#ifdef FIX_2349_HARM_FIND_UV IF( st_fx->element_mode == EVS_MONO ) /* Overwrite dE3 in case of EVS */ { dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ @@ -747,9 +249,6 @@ Word16 find_uv_fx( { dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ } -#else - dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ -#endif /*-----------------------------------------------------------------* * Energy decrease after spike (dE2) @@ -839,12 +338,10 @@ Word16 find_uv_fx( } E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); -#ifdef FIX_2349_HARM_FIND_UV if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ { E_min_th = L_shl( E_MIN_FX, Q_new ); } -#endif test(); test(); @@ -877,7 +374,6 @@ Word16 find_uv_fx( ee1_th = 544; /*8.5f Q6*/ move16(); -#ifdef FIX_2349_HARM_FIND_UV IF( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ { loc_lp_noise = st_fx->lp_noise_fx; @@ -886,9 +382,6 @@ Word16 find_uv_fx( { loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); } -#else - loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); -#endif /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ IF( st_fx->input_bwidth != NB ) @@ -958,7 +451,6 @@ Word16 find_uv_fx( move16(); } } -#ifdef FIX_2349_HARM_FIND_UV ELSE IF( st_fx->element_mode == EVS_MONO ) { if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ @@ -976,7 +468,6 @@ Word16 find_uv_fx( move16(); } } -#endif ELSE { test(); @@ -1112,11 +603,7 @@ Word16 find_uv_fx( /* Current frame cannot be compressed to pack the partial redundancy */ IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) /* can happen only for EVS format */ { -#ifdef FIX_2349_HARM_FIND_UV core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift ); -#else - core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); -#endif } } } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 66dad5732..8541b3fd9 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1239,13 +1239,8 @@ void pre_proc_front_ivas_fx( find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx, corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); -#ifdef FIX_2349_HARM_FIND_UV st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new, 0, fr_bands_fx_q ); // Q0 -#else - st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, - &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 -#endif Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 3e7207d07..479df45be 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -507,13 +507,8 @@ void pre_proc_fx( find_tilt_fx( fr_bands, hNoiseEst->bckr_fx, ee, st->pitch, st->voicing_fx, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); -#ifdef FIX_2349_HARM_FIND_UV st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0L, corr_shift, relE, *Etot, hp_E, &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 31 ); // Q0 -#else - st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, - corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); -#endif /*-----------------------------------------------------------------* * channel aware mode configuration * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2e20d7494..30aa1498b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -217,13 +217,8 @@ void find_tilt_fx( Word16 Opt_vbr_mode /* Q0 */ ); -#ifndef FIX_2349_HARM_FIND_UV -/* o : coding type */ -Word16 find_uv_ivas_fx( -#else /*! r: coder type */ Word16 find_uv_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ @@ -238,29 +233,9 @@ Word16 find_uv_fx( const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, -#ifdef FIX_2349_HARM_FIND_UV const Word16 shift, -#endif const Word16 q_hp_E ); -#ifndef FIX_2349_HARM_FIND_UV -/* o : coding type */ -Word16 find_uv_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ - const Word16 Q_new, - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 shift, - const Word16 last_core_orig /* i : original last core Q0*/ -); -#endif void fine_gain_quant_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order */ -- GitLab From 4956faabcf86562890fcd43c8e51b78d66c5e5d9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:51:13 +0100 Subject: [PATCH 631/750] [cleanup] accept FIX_2320_OOB_SCE_SWITCHING --- lib_com/options.h | 1 - lib_enc/ivas_corecoder_enc_reconfig_fx.c | 36 ------------------------ lib_enc/ivas_cpe_enc_fx.c | 31 -------------------- 3 files changed, 68 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a3964e6a1..0634301eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 04bf8c197..9c845eb40 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -236,13 +236,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame ), Q1 ); scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#else - shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ); @@ -252,13 +247,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32, shift ); move16(); q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame ), Q1 ); scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#else - shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32, shift ); move16(); q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 ); @@ -277,13 +267,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame ), Q1 ); scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#else - shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ); @@ -293,13 +278,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32, shift ); move16(); q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame ), Q1 ); scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#else - shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32, shift ); move16(); q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 ); @@ -314,18 +294,10 @@ ivas_error ivas_corecoder_enc_reconfig_fx( scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ -#else - scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */ -#else - Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com ); st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( Q6, q_com ); move16(); @@ -342,18 +314,10 @@ ivas_error ivas_corecoder_enc_reconfig_fx( scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ -#else - scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */ -#else - Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com ); st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( Q6, q_com ); move16(); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 659c03e52..201e49508 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -130,9 +130,7 @@ ivas_error ivas_cpe_enc_fx( Word16 NFFT_inner; move16(); move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING Word16 input_frame_2; -#endif Word16 i, j, q_com, shift, q_min, gb; error = IVAS_ERR_OK; @@ -159,9 +157,7 @@ ivas_error ivas_cpe_enc_fx( * Initialization - general *-----------------------------------------------------------------*/ -#ifdef FIX_2320_OOB_SCE_SWITCHING input_frame_2 = shl( input_frame, 1 ); -#endif set16_fx( q_re_im_buf, 0, CPE_CHANNELS ); tdm_SM_or_LRTD_Pri = 0; @@ -412,13 +408,8 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = L_norm_arr( sts[1]->old_input_signal32_fx, input_frame_2 ); shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, input_frame_2 ) ); -#else - shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) ); - shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) ); -#endif IF( LT_16( shift, gb ) ) { @@ -444,17 +435,10 @@ ivas_error ivas_cpe_enc_fx( * Temporal inter-channel alignment, stereo adjustment *----------------------------------------------------------------*/ -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); scale_sig32( sts[1]->input_buff32_fx, input_frame_2, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ scale_sig32( sts[0]->input_buff32_fx, input_frame_2, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ -#else - shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); - q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); - scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ - scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ -#endif sts[0]->q_inp32 = sts[1]->q_inp32 = sts[0]->q_old_inp32 = sts[1]->q_old_inp32 = q_min; move16(); move16(); @@ -463,17 +447,10 @@ ivas_error ivas_cpe_enc_fx( stereo_tca_enc_fx( hCPE, input_frame ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ), sts[1]->q_inp32 ), 16 ) ); Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift -#else - shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ); - shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) ); - Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift - Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift -#endif sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = shift; move16(); move16(); @@ -867,19 +844,11 @@ ivas_error ivas_cpe_enc_fx( // Normalise the input buffer from Q15 Word16 input_norm, q_inp; //, common_q, fir_delay_len; -#ifdef FIX_2320_OOB_SCE_SWITCHING input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, input_frame_2 ); -#else - input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) ); -#endif q_inp = sub( add( Q15, input_norm ), 16 ); // Rescale the old input, input and FIR delay section of input buffer -#ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, input_frame_2, sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp -#else - Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp -#endif // Update the Q-factors sts[0]->q_inp = q_inp; -- GitLab From 6dbda37fd672717211fd2417ba81c7b6b0385329 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:52:21 +0100 Subject: [PATCH 632/750] [cleanup] accept FIX_2302_LSF_CDBK_THRESHOLD --- lib_com/options.h | 1 - lib_enc/lsf_enc_fx.c | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0634301eb..e04df8c12 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index b423a7ae6..bc1f4cb3a 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -653,24 +653,11 @@ void lsf_end_enc_fx( IF( st->bwidth == NB ) { -#ifdef FIX_2302_LSF_CDBK_THRESHOLD abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); -#else - abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); -#endif } ELSE { -#ifdef FIX_2302_LSF_CDBK_THRESHOLD abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); -#else - abs_threshold = SFNETLOWLIMIT_WB / 2; - move32(); - if ( flag_1bit_gran == 0 ) - { - abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); - } -#endif } /* Calculate LSF weighting coefficients */ -- GitLab From 9b79821cb776228e23630f4b30b3a2eec3d95d77 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:53:30 +0100 Subject: [PATCH 633/750] [cleanup] accept FIX_1500_ISM_MD_DTX --- lib_com/options.h | 1 - lib_dec/ivas_ism_metadata_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e04df8c12..41059c09a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ #define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 063f089d0..e937b9dfe 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -129,11 +129,7 @@ static void ism_metadata_smooth_fx( diff_fx = L_sub( hIsmMetaData->last_true_elevation_fx, hIsmMetaData->last_elevation_fx ); test(); -#ifdef FIX_1500_ISM_MD_DTX IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION_FX ) ) -#else - IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( diff_fx, IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION_FX ) ) -#endif { /* skip the smoothing */ } -- GitLab From 181dd3b5450ebd53b3cb6941cb5c90643ac6a38c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:54:10 +0100 Subject: [PATCH 634/750] [cleanup] accept FIX_2348_REPLACE_FEC_ENC --- lib_com/options.h | 1 - lib_com/prot_fx.h | 15 ---- lib_enc/FEC_enc_fx.c | 173 ------------------------------------ lib_enc/acelp_core_enc_fx.c | 6 -- 4 files changed, 195 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 41059c09a..e11d5dffa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ #define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1557bb6d8..334afc86b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10550,21 +10550,6 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ); -#ifndef FIX_2348_REPLACE_FEC_ENC -void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ -); -#endif ivas_error IGF_Reconfig_fx( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index 2cbb7da22..3be0ff74c 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -299,176 +299,3 @@ void FEC_lsf_estim_enc_fx( return; } -#ifndef FIX_2348_REPLACE_FEC_ENC -/*-------------------------------------------------------------------* - * FEC_encode() - * - * Encoder supplementary information for FEC - *-------------------------------------------------------------------*/ - -void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ -) -{ - Word16 tmpS, index; - Word16 maxi, sign, tmp_FER_pitch; - Word32 enr_q, Ltmp; - Word16 exp_enrq; - - tmpS = 0; - move16(); - enr_q = 1; - move16(); - sign = 0; - move16(); - test(); - test(); - IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 ) - { - /*-----------------------------------------------------------------* - * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits) - *-----------------------------------------------------------------*/ - IF( NE_16( coder_type, VOICED ) ) - { - /* encode signal clas with 2 bits */ - test(); - IF( clas == UNVOICED_CLAS ) - { - index = 0; - move16(); - } - ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) ) - { - index = 1; - move16(); - } - ELSE IF( EQ_16( clas, VOICED_CLAS ) ) - { - index = 2; - move16(); - } - ELSE - { - index = 3; - move16(); - } - push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS ); - } - - /*-----------------------------------------------------------------* - * encode frame energy (5 bits) - *-----------------------------------------------------------------*/ - IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */ - { - /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */ - /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/ - Word32 synth32[L_FRAME16k]; - Copy_Scale_sig_16_32_DEPREC( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */ - fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame ); - exp_enrq = sub( 31, shl( Q_synth, 1 ) ); - - test(); - test(); - if ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */ - { - exp_enrq = 31; - move16(); - } - /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */ - /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/ - - Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22 - IF( Ltmp < 0 ) - { - tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) ); /* Q0 */ - } - ELSE - { - tmpS = extract_l( L_shr( Ltmp, Q22 ) ); /* Q0 */ - } - - tmpS = s_min( tmpS, FEC_ENR_QLIMIT ); - tmpS = s_max( tmpS, 0 ); - - push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR ); - } - /*-----------------------------------------------------------------* - * Encode last glottal pulse position (8 bits) - *-----------------------------------------------------------------*/ - - IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */ - { - /* retrieve the last glottal pulse position of the previous frame */ - /* use the current pitch information to scale or not the quantization */ - tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */ - sign = 0; - move16(); - maxi = *last_pulse_pos; /* Q0 */ - move16(); - IF( maxi < 0 ) - { - sign = 1; - move16(); - /*maxi = -maxi; */ - maxi = negate( maxi ); - } - - if ( GE_16( tmp_FER_pitch, 128 ) ) - { - maxi = shr( maxi, 1 ); - } - - if ( GT_16( maxi, 127 ) ) - { - /* better not use the glottal pulse position at all instead of using a wrong pulse */ - /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */ - maxi = 0; - move16(); - } - - if ( EQ_16( sign, 1 ) ) - { - maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/ - } - - push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS ); - } - maxi = 0; - move16(); - - /* If bitrate < 24k4, then the pitch - is not represented in the same domain (12.k instead of 16k) */ - test(); - IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) ) - { - /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */ - maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign ); - if ( EQ_16( sign, 1 ) ) - { - /*maxi = -maxi;*/ - maxi = negate( maxi ); - } - } - - *last_pulse_pos = maxi; /* Q0 */ - move16(); - } - ELSE - { - *last_pulse_pos = 0; - move16(); - } - - return; -} -#endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index baf8fad41..c5dc5e511 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1336,13 +1336,7 @@ ivas_error acelp_core_enc_ivas_fx( * Encode supplementary information for Frame Error Concealment *-----------------------------------------------------------------*/ -#ifndef FIX_2348_REPLACE_FEC_ENC - Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new ) - Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new ) - FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) ); -#else FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1 ), 0 ); -#endif IF( st->hBWE_TD != NULL ) { -- GitLab From bc02bc556741c68ced9030dff08e9989fac26a22 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 11:56:27 +0100 Subject: [PATCH 635/750] formatting --- lib_com/prot_fx.h | 16 ++++++++-------- lib_com/swb_tbe_com_fx.c | 18 +++++++++--------- lib_dec/cng_dec_fx.c | 3 +-- lib_dec/hf_synth_fx.c | 18 +++++++++--------- lib_dec/ivas_core_dec_fx.c | 2 +- lib_enc/find_uv_fx.c | 32 ++++++++++++++++---------------- lib_enc/ivas_cpe_enc_fx.c | 10 +++++----- lib_enc/ivas_ism_enc_fx.c | 8 ++++---- 8 files changed, 53 insertions(+), 54 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 334afc86b..3b93fda3b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3104,14 +3104,14 @@ void ScaleShapedWB_fx( void non_linearity_fx( const Word16 element_mode, /* i : element mode */ - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - const Word16 Q_inp, /* i : scaling of input */ - const Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + const Word16 Q_inp, /* i : scaling of input */ + const Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ ); void interp_code_5over2_fx( diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e54fff446..e06c8c4f6 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -5535,14 +5535,14 @@ static Word32 non_linearity_scaled_copy_ivas( void non_linearity_fx( const Word16 element_mode, /* i : element mode */ - const Word16 input[], /* i : input signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : input length */ - Word32 *pPrevScale, /* i/o: memory Q30 */ - const Word16 Q_inp, /* i : scaling of input */ - const Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ + const Word16 input[], /* i : input signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : input length */ + Word32 *pPrevScale, /* i/o: memory Q30 */ + const Word16 Q_inp, /* i : scaling of input */ + const Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ ) { Word16 i, j; @@ -5825,7 +5825,7 @@ void create_random_vector_fx( j = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ j = extract_l( L_shr( L_tmp, 23 ) ); #endif j = s_and( j, 0xff ); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index e35c13c79..56d2bd29c 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -17,7 +17,6 @@ static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); - /*-----------------------------------------------------------------* * CNG_dec_fx() * @@ -740,7 +739,7 @@ void swb_CNG_dec_fx( *---------------------------------------------------------------------*/ static void shb_CNG_decod_fx( - Decoder_State *st, /* i/o: State structure */ + Decoder_State *st, /* i/o: State structure */ const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index a2dbba4aa..153b76080 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -79,15 +79,15 @@ void hf_synth_reset_fx( void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ ) { const Word16 *p_Aq; diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index eba1cbad6..9838195cc 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1141,7 +1141,7 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index e2c342c19..063989aff 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -87,22 +87,22 @@ static Word16 find_ener_decrease_fx( /*! r: coder type */ Word16 find_uv_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF q_hp_E*/ - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 last_core_orig, /* i : original last core Q0*/ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const Word16 Q_new, - const Word16 shift, - const Word16 q_hp_E ) + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ + const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ + const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ + Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF q_hp_E*/ + Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ + const Word16 last_core_orig, /* i : original last core Q0*/ + STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ + const Word16 Q_new, + const Word16 shift, + const Word16 q_hp_E ) { Word16 coder_type, i; Word32 mean_ee, dE1, fac_32; diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 201e49508..be1caae83 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -922,11 +922,11 @@ ivas_error ivas_cpe_enc_fx( } move16(); - pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], - &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], - realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], - fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, - band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); + pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], + &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], + realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], + fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, + band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); e_old_wsp[n] = sub( Q15, q_old_wsp ); move16(); diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index a6ce92a18..94548ad2f 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -244,10 +244,10 @@ ivas_error ivas_ism_enc_fx( move16(); Word16 q_fr_bands[2]; - pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], - &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], - realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); + pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], + &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], + realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); move16(); -- GitLab From f394632c919b894a80d0dd4dc7e1bd4fc99b815d Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 28 Jan 2026 12:28:38 +0100 Subject: [PATCH 636/750] move st->element_brate initialization --- lib_enc/ivas_sce_enc_fx.c | 4 ++++ lib_enc/lib_enc_fx.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 4d639c961..bff27b1ec 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -489,6 +489,10 @@ ivas_error create_sce_enc_fx( } st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ +#ifdef FIX_1283_STEREO_DFT_COLLAPSE + st->element_brate = -1; + move32(); +#endif st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move32(); move32(); diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index b2f1cf529..3c6baff39 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1475,10 +1475,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( { hCoreCoder->total_brate = hEncoderConfig->ivas_total_brate; /* needed in case of bitrate switching */ move32(); -#ifdef FIX_1283_STEREO_DFT_COLLAPSE - hCoreCoder->element_brate = hEncoderConfig->ivas_total_brate; /* needed in checks in core-coder functions other than mono*/ - move32(); -#endif IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) { -- GitLab From 0f48cf1825f0d8228c4f92f9362139d1f9eb21dc Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 28 Jan 2026 14:45:26 +0100 Subject: [PATCH 637/750] fix in core_switch_lb_upsamp_fx() --- lib_dec/core_switching_dec_fx.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 41b42c6b0..9cba3af81 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -446,10 +446,8 @@ ivas_error core_switching_post_dec_fx( test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_fx, st_fx->L_frame, Q10 - Q11 ); /* Q10 */ -#else - Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif core_switch_lb_upsamp_fx( st_fx, output_fx ); } @@ -1000,7 +998,11 @@ void core_switching_hq_prepare_dec_fx( static void core_switch_lb_upsamp_fx( Decoder_State *st, /* i/o: Decoder state */ - Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output /* i/o: LB synth/upsampled LB synth Q11*/ +#else + Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ +#endif ) { Word16 i, no_col; @@ -1008,6 +1010,13 @@ static void core_switch_lb_upsamp_fx( Word32 realBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 output_tmp[L_FRAME16k]; + + Copy32( output, output_tmp, s_min( st->L_frame, L_FRAME16k ) ); + Scale_sig32( output, st->L_frame, Q10 - Q11 ); /* Q10 */ +#endif + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ FOR( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) { @@ -1089,6 +1098,10 @@ static void core_switch_lb_upsamp_fx( #endif } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy32( output_tmp, output, imult1616( no_col, st->cldfbSyn->no_channels ) ); /* Q11 */ +#endif + return; } -- GitLab From eba73d93e577e0cee6f2159e05d67921907532ad Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 28 Jan 2026 15:43:40 +0100 Subject: [PATCH 638/750] move functions --- Workspace_msvc/lib_dec.vcxproj | 3 +- Workspace_msvc/lib_dec.vcxproj.filters | 12 +- lib_dec/ivas_dec_fx.c | 1565 +++++++ ...ivas_jbm_dec_fx.c => ivas_dec_render_fx.c} | 3883 +++++------------ 4 files changed, 2755 insertions(+), 2708 deletions(-) create mode 100644 lib_dec/ivas_dec_fx.c rename lib_dec/{ivas_jbm_dec_fx.c => ivas_dec_render_fx.c} (64%) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 81461f72d..ef31eea68 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -213,6 +213,8 @@ + + @@ -222,7 +224,6 @@ - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 170eada9a..59e2aa52d 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -326,9 +326,6 @@ decoder_all_c - - decoder_ivas_c - decoder_ivas_c @@ -362,9 +359,6 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -509,6 +503,12 @@ decoder_all_c + + decoder_ivas_c + + + decoder_ivas_c + diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c new file mode 100644 index 000000000..bd3eab3e4 --- /dev/null +++ b/lib_dec/ivas_dec_fx.c @@ -0,0 +1,1565 @@ +/****************************************************************************************************** + + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "ivas_cnst.h" +#include "prot_fx.h" +#include "ivas_prot_fx.h" +#include "ivas_prot_rend_fx.h" +#include "ivas_rom_com.h" +#include "wmc_auto.h" +#ifdef DEBUGGING +#include "debug.h" +#endif + + +/*--------------------------------------------------------------------------* + * ivas_dec() + * + * Principal IVAS decoder routine, decoding of metadata and transport channels + *--------------------------------------------------------------------------*/ + +ivas_error ivas_dec_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + Word16 ch, n, output_frame, nchan_out, i, s; + Decoder_State *st; /* used for bitstream handling */ + Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */ + Word16 nchan_remapped; + Word16 nb_bits_metadata[MAX_SCE + 1]; + Word32 output_Fs, ivas_total_brate; + AUDIO_CONFIG output_config; + ivas_error error; + Word16 num_md_sub_frames; + Word32 ism_total_brate; + + push_wmops( "ivas_dec" ); + /*----------------------------------------------------------------* + * Initialization of local vars after struct has been set + *----------------------------------------------------------------*/ + + output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); + nchan_out = st_ivas->hTcBuffer->nchan_transport_rend; + move16(); + output_config = st_ivas->hDecoderConfig->output_config; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); + + output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) /* output_Fs / FRAMES_PER_SEC */; + + /* set pointers to transport channels audio */ + FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) + { + p_output_fx[n] = st_ivas->p_output_fx[n]; + IF( p_output_fx[n] != NULL ) + { + set32_fx( p_output_fx[n], 0, L_FRAME48k ); + } + } + + /*----------------------------------------------------------------* + * Decoding + pre-rendering + *----------------------------------------------------------------*/ + + test(); + IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + move32(); + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* HP filtering */ + FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* Metadata decoding and configuration */ + test(); + IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) + { + ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); + + IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); + + ivas_param_ism_dec_dequant_md_fx( st_ivas ); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + ivas_param_ism_dec_dequant_md_fx( st_ivas ); + } + ELSE /* ISM_MODE_DISC */ + { + IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + { + /* for DTX frames, dominant object has already been decoded before */ + test(); + test(); + IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) ) + { + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + /* HP filtering */ + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + + test(); + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) + { + ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); + + Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame ); /*returns Q-1*/ + + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q + } + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) + { + set16_fx( nb_bits_metadata, 0, MAX_SCE ); + + /* read parameters from the bitstream */ + test(); + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hQMetaData != NULL ) + { + // st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + IF( st_ivas->nSCE > 0 ) + { + st = st_ivas->hSCE[0]->hCoreCoder[0]; + } + ELSE + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + } + + IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + test(); + IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) + { + st_ivas->hCPE[0]->brate_surplus = 0; + move32(); + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + move32(); + } + + /* core-decoding of transport channels */ + IF( EQ_16( st_ivas->nSCE, 1 ) ) + { + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + /* TCs remapping */ + nchan_remapped = st_ivas->nchan_transport; + move16(); + + test(); + test(); + test(); + test(); + test(); + IF( st_ivas->sba_dirac_stereo_flag ) + { + nchan_remapped = nchan_out; + move16(); + + IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) + { + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14 + } + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + Word16 nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); + nchan_out = nchan_transport; + move16(); + + ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + + IF( st_ivas->hSpar->hPCA != NULL ) + { + ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output_fx ); + } + + ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + } + + ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); + } + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) + { + nchan_remapped = 1; /* Only one channel transported */ + move16(); + } + + /* HP filtering */ + FOR( n = 0; n < nchan_remapped; n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + + IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame ); + + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + Word16 Q_p_output = MAX_16, temp_min; + move16(); + Word16 nchan_transport; + + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); + nchan_out = nchan_transport; + move16(); + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + temp_min = L_norm_arr( p_output_fx[ch], output_frame ); + Q_p_output = s_min( Q_p_output, temp_min ); + } + Q_p_output = sub( Q_p_output, 2 ); + if ( GT_16( Q_p_output, 20 ) ) + { + Q_p_output = 20; + move16(); + } + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + Scale_sig32( p_output_fx[ch], output_frame, Q_p_output ); // Q(11+Q_p_output) + } + + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, Q_p_output ); + FOR( Word16 c = 0; c < nchan_transport; c++ ) + { + Scale_sig32( p_output_fx[c], output_frame, 11 ); // Q11 + } + } + ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) + { + Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); + if ( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) ) + size = add( size, 1 ); + + FOR( i = 0; i < size; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14 + } + + ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame ); + } + } + + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) + { + Word16 q_shift = 0; + move16(); + + ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); + + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); + } + + test(); + /* external output */ + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + { + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) + { + set_zero_fx( p_output_fx[add( st_ivas->nchan_transport, n )], output_frame ); + } + + ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, output_frame ); + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, nchan_remapped, output_frame ); + + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q + } + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + { + Word16 nchan_ism, nchan_transport_ism; + Word16 dirac_bs_md_write_idx; + + set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); + + /* Set the number of objects for the parametric rendering */ + dirac_bs_md_write_idx = 0; + move16(); + IF( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->numIsmDirections = 0; + move16(); + test(); + if ( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + { + st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism; + move16(); + } + + dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ + move16(); + } + + /* MASA metadata decoding */ + IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* Configuration of combined-format bit-budget distribution */ + ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); + + st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); + + IF( NE_32( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + FOR( n = 0; n < nchan_transport_ism; n++ ) + { + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + /* decode MASA channels */ + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) + { + Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ + } + + FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + + Word16 output_q = Q11; + move16(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) + { + ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); + + output_q = Q8; + move16(); + } + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame ); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + { + /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */ + ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame ); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */ + ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q ); + } + } + + IF( NE_16( output_q, Q11 ) ) + { + FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) + { + Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11 + } + st_ivas->hCPE[0]->q_output_mem_fx[0] = output_q; + st_ivas->hCPE[0]->q_output_mem_fx[1] = output_q; + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + Word16 nchan_ism, sba_ch_idx; + + set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); + nchan_ism = st_ivas->nchan_ism; + move16(); + IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + /* set ISM parameters and decode ISM metadata in OSBA format */ + IF( NE_32( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + { + return error; + } + sba_ch_idx = st_ivas->nchan_ism; + move16(); + } + ELSE + { + nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ ); + sba_ch_idx = 0; + move16(); + move16(); + } + + /* SBA metadata decoding */ + IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) + { + return error; + } + + test(); + IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + move32(); + } + + /* core-decoding of transport channels */ + IF( EQ_16( st_ivas->nSCE, 1 ) ) + { + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + IF( st_ivas->sba_dirac_stereo_flag ) + { + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) + { + Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, Q14 - Q11 ); // Q14 + } + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + Word16 nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); + nchan_out = nchan_transport; + move16(); + ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + + IF( st_ivas->hSpar->hPCA != NULL ) + { + ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] ); + } + + ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + + ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); + } + + /* HP filtering */ + FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + + nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); + + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + Word16 nchan_transport; + // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); + nchan_out = nchan_transport; + move16(); + Word16 Q_p_output; + Word16 min_norm = 31; + move16(); + + FOR( ch = 0; ch < nchan_transport; ++ch ) + { + Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel + min_norm = s_min( norm, min_norm ); + } + + Q_p_output = s_max( 3, sub( min_norm, 1 ) ); + + Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30 + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11 + } + Q_p_output = add( Q11, Q_p_output ); + hSpar->hMdDec->Q_mixer_mat = 31; + move16(); + + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, sub( Q_p_output, Q11 ) ); + FOR( Word16 c = 0; c < nchan_transport; c++ ) + { + Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); // Q11 + } + } + ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 ) + { + Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx ); + if ( EQ_16( size, 3 ) ) + { + size = add( size, 1 ); + } + + FOR( i = sba_ch_idx; i < size; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, ( Q14 - Q11 ) ); // Q14 + } + + ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); + } + + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/ + + FOR( i = 0; i < nchan_remapped; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q + } + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); + + Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); // Q11 + + /* add W */ + FOR( n = 0; n < nchan_out; n++ ) + { + v_add_32( p_output_fx[n], p_output_fx[n + s_max( nchan_out, nchan_ism )], p_output_fx[n], output_frame ); + } + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) + { + IF( st_ivas->nSCE > 0 ) + { + st = st_ivas->hSCE[0]->hCoreCoder[0]; + } + ELSE + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + } + + IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) + { + /* LFE channel decoder */ + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); + + Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 + + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* HP filtering */ + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + { + IF( NE_16( n, LFE_CHANNEL ) ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + } + + test(); + test(); + test(); + IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + { + IF( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) + { + ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); + } + } + + test(); + test(); + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) + { + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) + { + s = Q16 - Q11; + move16(); + s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + { + Scale_sig32( p_output_fx[i], output_frame, s ); // Q(11+s) + } + ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + { + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); // Q11 + } + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + { + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 ); + } + } + } + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + { + /* LFE channel decoder */ + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); + + Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 + + ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); + + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* HP filtering */ + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + { + IF( NE_16( n, LFE_CHANNEL ) ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + } + + /* Rendering */ + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + { + /* Compensate loudness for not doing full upmix */ + FOR( n = 4; n < 8; n++ ) + { + Scale_sig32( p_output_fx[n], output_frame, 1 ); + } + + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + { + s = Q16 - Q11; + move16(); + Word16 nchan_transport; + nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); + s = sub( s, find_guarded_bits_fx( nchan_transport ) ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) + { + Scale_sig32( p_output_fx[i], output_frame, s ); + } + + ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); + + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) + { + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); + } + } + } + } + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) + { + /* read Parametric MC parameters from the bitstream */ + ivas_param_mc_dec_read_BS_fx( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] ); + + IF( EQ_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + /* HP filtering */ + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + + /* Rendering */ + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + { + ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); + } + } + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + { + IF( st_ivas->hOutSetup.separateChannelEnabled ) + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */ + } + + /* read McMASA parameters from the bitstream */ + IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + IF( st_ivas->hOutSetup.separateChannelEnabled ) + { + /* Decode the transport audio signals */ + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ + n = LFE_CHANNEL - 1; + move16(); + + /* Decode the separated channel to output[n] to be combined with the synthesized channels */ + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL ); + } + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) + { + /* Delay the separated channel to sync with the DirAC rendering */ + delay_signal32_fx( p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + } + } + ELSE + { + IF( EQ_16( st_ivas->nSCE, 1 ) ) + { + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + } + + IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ + { + ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); + } + + /* HP filtering */ + FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + + IF( EQ_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) + { + ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame ); + } + } + } + + /*----------------------------------------------------------------* + * Common updates + *----------------------------------------------------------------*/ + + IF( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ + { + st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; + move32(); + IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) + { + st_ivas->last_active_ivas_total_brate = st_ivas->last_active_ivas_total_brate; + move32(); + } + ELSE + { + st_ivas->last_active_ivas_total_brate = ivas_total_brate; + move32(); + } + } + + test(); + test(); + if ( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ + { + st_ivas->ini_frame = add( st_ivas->ini_frame, 1 ); + move16(); + } + + test(); + test(); + if ( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ + { + st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 ); + move16(); + } + + st_ivas->last_ivas_format = st_ivas->ivas_format; + move32(); + pop_wmops(); + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_get_num_tc_channels() + * + * Get the number of transport channels provided to the renderer + *--------------------------------------------------------------------------*/ + +Word16 ivas_dec_get_num_tc_channels_fx( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) +{ + Word16 num_tc; + Word32 ivas_total_brate; + AUDIO_CONFIG output_config; + + IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + move16(); + } + ELSE + { + num_tc = st_ivas->nchan_transport; + move16(); + } + output_config = st_ivas->hDecoderConfig->output_config; + move16(); + + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); + + test(); + test(); + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) + { + num_tc = 1; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) + { + num_tc = 1; + move16(); + } + ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + { + if ( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) + { + num_tc = 1; + move16(); + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + IF( st_ivas->sba_dirac_stereo_flag ) + { + num_tc = CPE_CHANNELS; + move16(); + } + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && GT_16( st_ivas->nCPE, 0 ) && st_ivas->hCPE[0] != NULL && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) + { + num_tc = 1; /* Only one channel transported */ + move16(); + } + + test(); + test(); + test(); + test(); + IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->nchan_transport, 2 ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) + { + num_tc = CPE_CHANNELS; + move16(); + } + IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) + { + if ( EQ_16( num_tc, 3 ) ) + { + num_tc = add( num_tc, 1 ); + } + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + { + IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + test(); + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + num_tc = add( num_tc, 1 ); + } + ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + num_tc = add( num_tc, st_ivas->nchan_ism ); + } + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + if ( st_ivas->sba_dirac_stereo_flag ) + { + num_tc = CPE_CHANNELS; + move16(); + } + + if ( EQ_16( num_tc, 3 ) ) + { + num_tc = add( num_tc, 1 ); + } + if ( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + num_tc = add( num_tc, st_ivas->nchan_ism ); + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) + { + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) ) + { + num_tc = 1; + move16(); + } + ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + { + num_tc = 2; + move16(); + } + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) ) + { + /* do all static dmx already in the TC decoder if less channels than transported... */ + test(); + test(); + test(); + test(); + test(); + IF( NE_16( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + { + if ( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) + { + num_tc = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); + } + } + ELSE IF( ( EQ_16( st_ivas->renderer_type, RENDERER_MC ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) + { + num_tc = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + } + } + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + { + num_tc = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; + move16(); + } + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + { + if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + num_tc = add( num_tc, 1 ); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + if ( st_ivas->hOutSetup.separateChannelEnabled && ( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) || + EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || + EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) ) ) + { + /* LFE is synthesized in TD with the TCs*/ + num_tc = add( num_tc, 1 ); + } + } + } + + return num_tc; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_get_tc_buffer_mode() + * + * + *--------------------------------------------------------------------------*/ + +TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + TC_BUFFER_MODE buffer_mode; + + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + + SWITCH( st_ivas->renderer_type ) + { + /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */ + case RENDERER_DISABLE: + case RENDERER_MCMASA_MONO_STEREO: + case RENDERER_OSBA_STEREO: + case RENDERER_MONO_DOWNMIX: + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + BREAK; + case RENDERER_NON_DIEGETIC_DOWNMIX: + case RENDERER_TD_PANNING: + case RENDERER_BINAURAL_OBJECTS_TD: + case RENDERER_BINAURAL_FASTCONV: + case RENDERER_BINAURAL_FASTCONV_ROOM: + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: + case RENDERER_STEREO_PARAMETRIC: + case RENDERER_DIRAC: + case RENDERER_PARAM_ISM: + case RENDERER_BINAURAL_MIXER_CONV: + case RENDERER_BINAURAL_MIXER_CONV_ROOM: + case RENDERER_OMASA_OBJECT_EXT: + case RENDERER_OMASA_MIX_EXT: + case RENDERER_OSBA_AMBI: + case RENDERER_OSBA_LS: + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + BREAK; + case RENDERER_MC_PARAMMC: + IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + { + buffer_mode = TC_BUFFER_MODE_BUFFER; /* TCs are already the DMX to mono or stereo */ + move16(); + } + ELSE + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + case RENDERER_MC: + if ( NE_16( ivas_dec_get_num_tc_channels_fx( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) ) + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + case RENDERER_SBA_LINEAR_ENC: + test(); + test(); + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) && ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( ( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), ( add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) ) + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + } + ELSE + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + case RENDERER_SBA_LINEAR_DEC: + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + } + ELSE + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + } + + return buffer_mode; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_tc_audio_allocate() + * + * allocate and initialize TC audio buffer + *--------------------------------------------------------------------------*/ + +static ivas_error ivas_dec_tc_audio_allocate_fx( + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC buffer handle */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 Opt_tsm /* i : TSM option flag */ +) +{ + Word16 nsamp_to_allocate; + Word16 ch_idx, n_samp_full, n_samp_residual, offset; + + IF( Opt_tsm ) + { + n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); + n_samp_full = s_max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */ + n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); + } + ELSE + { + n_samp_full = extract_l( Mpy_32_32( output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + n_samp_residual = 0; + move16(); + } + + nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ), n_samp_full ); + + IF( Opt_tsm ) + { + /* note: this is stack memory buffer for TC decoded and also time-scale modified audio signals */ + IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + } + set_zero_fx( hTcBuffer->tc_buffer_fx, nsamp_to_allocate ); + + offset = 0; + move16(); + FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + { + hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; + offset = add( offset, n_samp_full ); + } + FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc_fx[ch_idx] = NULL; + } + + /* memory buffer for TC audio samples not rendered in the previous frame */ + FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + IF( ( hTcBuffer->tc_buffer_old_fx[ch_idx] = (Word32 *) malloc( n_samp_residual * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + } + set_zero_fx( hTcBuffer->tc_buffer_old_fx[ch_idx], n_samp_residual ); + } + FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; + } + } + else + { + hTcBuffer->tc_buffer_fx = NULL; + + FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc_fx[ch_idx] = NULL; + } + + FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; + } + } + + hTcBuffer->tc_buffer2_fx = NULL; + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_tc_buffer_open() + * + * Open and initialize transport channel buffer handle + *--------------------------------------------------------------------------*/ + +ivas_error ivas_dec_tc_buffer_open_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ + const Word16 nchan_transport_rend, /* i : number of TCs for rendering */ + const Word16 nchan_transport_internal, /* i : number of totally buffered channels */ + const Word16 nchan_full, /* i : number of channels to fully store */ + const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ +) +{ + DECODER_TC_BUFFER_HANDLE hTcBuffer; + Word16 nMaxSlotsPerSubframe; + ivas_error error; + Word16 tmp, tmp_e; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + IF( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + } + + hTcBuffer->tc_buffer_mode = tc_buffer_mode; + move16(); + hTcBuffer->nchan_transport_rend = nchan_transport_rend; + move16(); + hTcBuffer->nchan_transport_internal = nchan_transport_internal; + move16(); + hTcBuffer->nchan_buffer_full = nchan_full; + move16(); + hTcBuffer->n_samples_granularity = n_samples_granularity; + move16(); + hTcBuffer->n_samples_available = 0; + move16(); + hTcBuffer->n_samples_buffered = 0; + move16(); + hTcBuffer->n_samples_rendered = 0; + move16(); + hTcBuffer->slots_rendered = 0; + move16(); + hTcBuffer->subframes_rendered = 0; + move16(); + hTcBuffer->n_samples_discard = 0; + move16(); + hTcBuffer->n_samples_flushed = 0; + move16(); + hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; + move16(); + + /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ + + hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); + move16(); + + set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); + set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); + + IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->hTcBuffer = hTcBuffer; + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_audio_deallocate() + * + * deallocate TC audio buffer + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_tc_audio_deallocate_fx( + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */ +) +{ + Word16 ch_idx; + + IF( hTcBuffer != NULL ) + { + IF( hTcBuffer->tc_buffer_fx != NULL ) + { + FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc_fx[ch_idx] = NULL; + } + + free( hTcBuffer->tc_buffer_fx ); + hTcBuffer->tc_buffer_fx = NULL; + } + + FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + IF( hTcBuffer->tc_buffer_old_fx[ch_idx] != NULL ) + { + free( hTcBuffer->tc_buffer_old_fx[ch_idx] ); + hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; + } + } + + IF( hTcBuffer->tc_buffer2_fx != NULL ) + { + free( hTcBuffer->tc_buffer2_fx ); + hTcBuffer->tc_buffer2_fx = NULL; + } + } + + return; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_tc_buffer_close() + * + * Close transport channel buffer handle + *--------------------------------------------------------------------------*/ + +void ivas_dec_tc_buffer_close_fx( + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ +) +{ + IF( *phTcBuffer != NULL ) + { + ivas_jbm_dec_tc_audio_deallocate_fx( *phTcBuffer ); + + free( *phTcBuffer ); + *phTcBuffer = NULL; + } + + return; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_tc_buffer_reconfigure() + * + * Reconfigure transport channel buffer handle + *--------------------------------------------------------------------------*/ + +ivas_error ivas_dec_tc_buffer_reconfigure_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const Word16 nchan_transport_rend, /* i : new number of TCs for rendering */ + const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ + const Word16 nchan_full, /* i : new number of channels to fully store */ + const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ +) +{ + Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available; + Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1]; + ivas_error error; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; + move16(); + + num_tc_buffer_mem = 0; + move16(); + n_samples_still_available = 0; + move16(); + + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { + /* save samples of the TC buffer from the previous frame */ + num_tc_buffer_mem = s_min( hTcBuffer->nchan_transport_internal, nchan_transport_internal ); + n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); + + /* what is remaining from last frame needs always be smaller than the new granularity */ + assert( n_samples_still_available < n_samples_granularity ); + + FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ ) + { + Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx] + hTcBuffer->n_samples_flushed, tc_buffer_mem[ch_idx], n_samples_still_available ); + } + } + + /* if granularity changes, adapt subframe_nb_slots */ + IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) ) + { + Word16 nMaxSlotsPerSubframeNew; + Word16 tmp, tmp_e; + + /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */ + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + tmp = BASOP_Util_Divide1616_Scale( tmp, n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ + + /* if samples were flushed, take that into account here */ + test(); + IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 ) + { + hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = idiv1616( hTcBuffer->n_samples_flushed, n_samples_granularity ); + hTcBuffer->n_samples_flushed = 0; + move16(); + move16(); + } + ELSE + { + hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = nMaxSlotsPerSubframeNew; + move16(); + } + } + + hTcBuffer->tc_buffer_mode = tc_buffer_mode; + move16(); + hTcBuffer->nchan_transport_rend = nchan_transport_rend; + move16(); + hTcBuffer->nchan_transport_internal = nchan_transport_internal; + move16(); + hTcBuffer->nchan_buffer_full = nchan_full; + move16(); + hTcBuffer->n_samples_granularity = n_samples_granularity; + move16(); + + /* reallocate TC audio buffers */ + + ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer ); + + IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* propagate samples of the TC buffer from the previous frame */ + FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ ) + { + Copy32( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old_fx[ch_idx], n_samples_still_available ); + } + + return IVAS_ERR_OK; +} diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_dec_render_fx.c similarity index 64% rename from lib_dec/ivas_jbm_dec_fx.c rename to lib_dec/ivas_dec_render_fx.c index 55788b01c..5b685edd4 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -67,814 +67,824 @@ static Word16 ceil_fx16( return ret; } + +/*--------------------------------------------------------------------------* + * ivas_dec_feed_tc_to_renderer() + * + * Feed decoded transport channels to the IVAS renderer routine + * + digest TC channels in ParamISM and ParamMC + *--------------------------------------------------------------------------*/ + +void ivas_dec_feed_tc_to_renderer_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ + Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ +) +{ + Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k]; + Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS]; + Word16 n, n_render_timeslots, n_ch_cldfb; + Word16 ch, offset, len_offset; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; + n_ch_cldfb = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + move16(); + + hTcBuffer->q_tc_fx = Q11; + move16(); + + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { + Word16 n_samples_still_available; + Word16 n_ch_full_copy, n_ch_res_copy; + + n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); + hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard ); + hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) ); + *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available ); + move16(); + move16(); + move16(); + n_ch_full_copy = s_min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + + /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': + in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffer + pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */ + len_offset = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ); + IF( LT_16( len_offset, L_FRAME48k ) ) + { + offset = 0; + move16(); + FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch++ ) + { + hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset]; + st_ivas->p_output_fx[ch] = hTcBuffer->tc_fx[ch]; + offset = add( offset, len_offset ); + } + } + + FOR( ch = 0; ch < n_ch_full_copy; ch++ ) + { + Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); + set_zero_fx( hTcBuffer->tc_fx[ch], hTcBuffer->n_samples_discard ); + Copy32( hTcBuffer->tc_buffer_old_fx[ch], hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); + Copy32( tmp_buf_fx, hTcBuffer->tc_fx[ch] + n_samples_still_available + hTcBuffer->n_samples_discard, nSamplesForRendering - *nSamplesResidual ); + Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual ); + } + + IF( n_ch_res_copy > 0 ) + { + FOR( ; ch < hTcBuffer->nchan_transport_rend; ch++ ) + { + p_data_fx[ch] = hTcBuffer->tc_fx[ch]; + Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); + Copy32( hTcBuffer->tc_buffer_old_fx[ch], p_data_fx[ch], n_samples_still_available ); + Copy32( tmp_buf_fx, p_data_fx[ch] + n_samples_still_available, sub( nSamplesForRendering, *nSamplesResidual ) ); + Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual ); + } + } + + n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity ); + } + ELSE + { + FOR( n = 0; n < n_ch_cldfb; n++ ) + { + p_data_fx[n] = &st_ivas->p_output_fx[n][0]; + move16(); + } + + ch = s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + FOR( n = 0; n < ch; n++ ) + { + hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */ + move16(); + } + + hTcBuffer->n_samples_buffered = nSamplesForRendering; + hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; + *nSamplesResidual = 0; + move16(); + move16(); + move16(); + + n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS; + move16(); + } + + /* CLDFB analysis for ParamMC/ParamISM */ + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) ) + { + ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_fx, Q11 ); + } + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) && EQ_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) ) + { + ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, p_data_fx, Q11 ); + } + + hTcBuffer->n_samples_rendered = 0; + move16(); + hTcBuffer->subframes_rendered = 0; + move16(); + + return; +} + + /*--------------------------------------------------------------------------* - * ivas_dec() + * ivas_dec_render() * - * Principal IVAS decoder routine, decoding of metadata and transport channels + * Principal IVAS internal rendering routine *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +ivas_error ivas_dec_render_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const UWord16 nSamplesAsked, /* i : number of samples wanted */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ + Word16 *data /* o : output synthesis signal Q0*/ ) { - Word16 ch, n, output_frame, nchan_out, i, s; - Decoder_State *st; /* used for bitstream handling */ - Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */ + Word16 n, nchan_out; + Word16 nchan_transport_rend; Word16 nchan_remapped; - Word16 nb_bits_metadata[MAX_SCE + 1]; - Word32 output_Fs, ivas_total_brate; + Word32 output_Fs; AUDIO_CONFIG output_config; + Word16 nSamplesAskedLocal; ivas_error error; - Word16 num_md_sub_frames; - Word32 ism_total_brate; + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + Word32 *p_tc_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; + Word16 subframe_len, gd_bits, exp, nchan_in, i, j, ch; + const Word16 output_q_factor = Q11; + move16(); + Word16 nchan_out_syn_output; - push_wmops( "ivas_dec" ); + push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); - nchan_out = st_ivas->hTcBuffer->nchan_transport_rend; + nchan_out = st_ivas->hDecoderConfig->nchan_out; + move16(); + nchan_transport_rend = st_ivas->hTcBuffer->nchan_transport_rend; move16(); output_config = st_ivas->hDecoderConfig->output_config; - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); + nSamplesAskedLocal = add( nSamplesAsked, st_ivas->hTcBuffer->n_samples_discard ); + move16(); - output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) /* output_Fs / FRAMES_PER_SEC */; - - /* set pointers to transport channels audio */ - FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) + FOR( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { p_output_fx[n] = st_ivas->p_output_fx[n]; - IF( p_output_fx[n] != NULL ) + } + + IF( !st_ivas->hDecoderConfig->Opt_tsm ) + { + FOR( n = 0; n < MAX_INTERN_CHANNELS; n++ ) { - set32_fx( p_output_fx[n], 0, L_FRAME48k ); + st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; } } + FOR( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + { + p_tc_fx[n] = &st_ivas->hTcBuffer->tc_fx[n][st_ivas->hTcBuffer->n_samples_rendered]; + } + /*----------------------------------------------------------------* - * Decoding + pre-rendering + * Update combined orientation access index *----------------------------------------------------------------*/ - test(); - IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - + IF( st_ivas->hCombinedOrientationData != NULL ) { - st_ivas->hCPE[0]->element_brate = ivas_total_brate; - move32(); - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start = sub( st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start, st_ivas->hTcBuffer->n_samples_discard ); + move16(); - /* HP filtering */ - FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); } - ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) - { - /* Metadata decoding and configuration */ - test(); - IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) - { - ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); - IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) - { - return error; - } + /*----------------------------------------------------------------* + * Rendering + *----------------------------------------------------------------*/ - ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); + *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); - ivas_param_ism_dec_dequant_md_fx( st_ivas ); + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) ) + { + assert( 0 ); + } + ELSE IF( EQ_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) + { + ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); + } + ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + { + /* Rendering */ + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) + { + ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { - IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - - ivas_param_ism_dec_dequant_md_fx( st_ivas ); + ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); } - ELSE /* ISM_MODE_DISC */ + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } + ivas_stereo2sba_fx( p_tc_fx, p_output_fx, *nSamplesRendered ); } - - FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + } + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* Rendering */ + IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { - /* for DTX frames, dominant object has already been decoded before */ test(); test(); - IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) ) + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) + { + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output_fx ); + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) ) + ivas_param_ism_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ); + + IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - return error; + /* Convert CICP19 -> Ambisonics */ + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); } } - - /* HP filtering */ - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } - - test(); - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) - { - ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); - - Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) + ELSE /* ISM_MODE_DISC */ { - /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame ); /*returns Q-1*/ - - FOR( i = 0; i < st_ivas->nchan_transport; i++ ) + test(); + test(); + /* Loudspeaker or Ambisonics rendering */ + IF( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q + /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ + ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); } - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) - { - set16_fx( nb_bits_metadata, 0, MAX_SCE ); - - /* read parameters from the bitstream */ - test(); - IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hQMetaData != NULL ) - { - // st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - IF( st_ivas->nSCE > 0 ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { - st = st_ivas->hSCE[0]->hCoreCoder[0]; + ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); } - ELSE +#ifdef DEBUGGING + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) +#else + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) +#endif { - st = st_ivas->hCPE[0]->hCoreCoder[0]; + /* Convert to Ambisonics */ + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) + { + FOR( j = 0; j < HOA3_CHANNELS; j++ ) + { + st_ivas->hIsmRendererData->gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q30 -> Q29 + move32(); + st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29 + move32(); + } + } + + ivas_ism2sba_sf_fx( p_tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); + + Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) ); + FOR( j = 0; j < sba_num_chans; j++ ) + { + scale_sig32( p_output_fx[j], *nSamplesRendered, sub( Q11, sub( add( output_q_factor, 29 ), 31 ) ) ); // Q11 + } + + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) + { + FOR( j = 0; j < 16; j++ ) + { + st_ivas->hIsmRendererData->gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q29 -> Q30 + move32(); + st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q29 -> Q30 + move32(); + } + } } - IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + /* Binaural rendering */ + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - return error; + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } + } } - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) - { - IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - return error; + st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; + subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity ); + gd_bits = find_guarded_bits_fx( subframe_len ); + exp = 13; + move16(); + nchan_in = 12; + move16(); + nchan_out = 2; + move16(); + exp = sub( exp, gd_bits ); + *st_ivas->hCrendWrapper->p_io_qfactor = exp; + move16(); + FOR( i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 + } + + IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + + FOR( i = 0; i < nchan_out; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 + } } } + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) + { + nchan_remapped = nchan_transport_rend; + move16(); test(); - IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) - { - st_ivas->hCPE[0]->brate_surplus = 0; - move32(); - st_ivas->hCPE[0]->element_brate = ivas_total_brate; - move32(); - } - - /* core-decoding of transport channels */ - IF( EQ_16( st_ivas->nSCE, 1 ) ) + test(); + /* Loudspeakers, Ambisonics or Binaural rendering */ + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); } - ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) { - return error; + ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ); } } - ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) + ELSE { - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) { return error; } } - - /* TCs remapping */ + } + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + { nchan_remapped = st_ivas->nchan_transport; move16(); - test(); test(); test(); - test(); - test(); - IF( st_ivas->sba_dirac_stereo_flag ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - nchan_remapped = nchan_out; - move16(); - - IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) + test(); + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) - { - Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14 - } - SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 nchan_transport; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - move16(); - nchan_out = nchan_transport; - move16(); - - ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); - - IF( st_ivas->hSpar->hPCA != NULL ) + IF( NE_32( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ) ), IVAS_ERR_OK ) ) { - ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output_fx ); + return error; } - - ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } - - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); + ELSE + { + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + } } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) { - nchan_remapped = 1; /* Only one channel transported */ - move16(); + ivas_omasa_dirac_rend_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); } - - /* HP filtering */ - FOR( n = 0; n < nchan_remapped; n++ ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); + ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, *nSamplesRendered ); } + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + nchan_remapped = nchan_transport_rend; + move16(); - IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + /* Loudspeakers, Ambisonics or Binaural rendering */ + IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame ); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - - SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 Q_p_output = MAX_16, temp_min; + SPAR_DEC_HANDLE hSpar; + hSpar = st_ivas->hSpar; + hSpar->hMdDec->Q_mixer_mat = 30; move16(); - Word16 nchan_transport; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - move16(); - nchan_out = nchan_transport; - move16(); - FOR( ch = 0; ch < nchan_transport; ch++ ) + IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) { - temp_min = L_norm_arr( p_output_fx[ch], output_frame ); - Q_p_output = s_min( Q_p_output, temp_min ); + return error; } - Q_p_output = sub( Q_p_output, 2 ); - if ( GT_16( Q_p_output, 20 ) ) + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ) + { + test(); + /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/ + IF( EQ_16( st_ivas->nchan_ism, 1 ) && EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) ) { - Q_p_output = 20; - move16(); + Copy32( p_tc_fx[2], p_output_fx[3], *nSamplesRendered ); + Copy32( p_tc_fx[1], p_output_fx[2], *nSamplesRendered ); + p_tc_fx[1] = p_output_fx[2]; + p_tc_fx[2] = p_output_fx[3]; + } + + /* render objects */ + ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); + + /* add already rendered SBA part */ + ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, st_ivas->hSbaIsmData->gain_bed_fx, nchan_out, st_ivas->nchan_ism, st_ivas->ism_mode, *nSamplesRendered ); + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + IF( NE_32( ( error = ivas_osba_render_sf_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) + { + return error; } - FOR( ch = 0; ch < nchan_transport; ch++ ) + } + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) /*EXT output = individual objects + HOA3*/ + { + IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism] ) ), IVAS_ERR_OK ) ) { - Scale_sig32( p_output_fx[ch], output_frame, Q_p_output ); // Q(11+Q_p_output) + return error; } - ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, Q_p_output ); - FOR( Word16 c = 0; c < nchan_transport; c++ ) + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { - Scale_sig32( p_output_fx[c], output_frame, 11 ); // Q11 + Copy32( p_tc_fx[n], p_output_fx[n], *nSamplesRendered ); } } - ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) + ELSE { - Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; - move16(); - if ( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) ) - size = add( size, 1 ); - - FOR( i = 0; i < size; i++ ) + IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) { - Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14 + return error; } - - ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame ); } } - - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { - Word16 q_shift = 0; - move16(); - - ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); - FOR( i = 0; i < CPE_CHANNELS; i++ ) + FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) + { + scale_sig32( p_output_fx[n], *nSamplesRendered, 1 ); + } + } + ELSE + { + IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) { - Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); + return error; } - test(); - /* external output */ - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { + FOR( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) + { + Copy32( p_output_fx[n], p_output_fx[n + st_ivas->nchan_ism], *nSamplesRendered ); + } FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { - set_zero_fx( p_output_fx[add( st_ivas->nchan_transport, n )], output_frame ); + set32_fx( p_output_fx[n], 0, *nSamplesRendered ); } - - ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, output_frame ); } - } - ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) - { - /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, nchan_remapped, output_frame ); - - FOR( i = 0; i < st_ivas->nchan_transport; i++ ) + FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) { - Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q + scale_sig32( p_output_fx[n], *nSamplesRendered, 1 ); } } } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { - Word16 nchan_ism, nchan_transport_ism; - Word16 dirac_bs_md_write_idx; - - set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); - - /* Set the number of objects for the parametric rendering */ - dirac_bs_md_write_idx = 0; - move16(); - IF( st_ivas->hSpatParamRendCom != NULL ) + IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { - st_ivas->hSpatParamRendCom->numIsmDirections = 0; + Word16 crendInPlaceRotation = FALSE; move16(); + test(); - if ( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + test(); + test(); + IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) { - st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism; - move16(); - } + IF( LT_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) + { + crendInPlaceRotation = TRUE; + move16(); - dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ - move16(); - } + ivas_mc2sba_fx( st_ivas->hTransSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); + } + } - /* MASA metadata decoding */ - IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* Configuration of combined-format bit-budget distribution */ - ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); - - st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); - - IF( NE_32( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) - { - return error; - } - - FOR( n = 0; n < nchan_transport_ism; n++ ) - { - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + /* Rendering */ + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - return error; - } - } + st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; + subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity ); + gd_bits = find_guarded_bits_fx( subframe_len ); + exp = 13; + move16(); + IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ), IVAS_ERR_OK ) ) + { + return error; + } + IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) + { + return error; + } + exp = sub( exp, gd_bits ); + *st_ivas->hCrendWrapper->p_io_qfactor = exp; + move16(); - /* decode MASA channels */ - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( crendInPlaceRotation ) + { + FOR( i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor + } + } + ELSE + { + FOR( i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor + } + } - IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) - { - Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ - } + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), + IVAS_ERR_OK ) ) + { + return error; + } - FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); + } - Word16 output_q = Q11; - move16(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) - { - ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); + IF( crendInPlaceRotation ) + { + n = nchan_in; + } + ELSE + { + n = nchan_out; + } + move16(); - output_q = Q8; - move16(); - } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame ); + FOR( i = 0; i < n; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 + } + + FOR( i = n; i < nchan_in; i++ ) + { + scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 + } } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { - /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */ - ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame ); + ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */ - ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q ); + ivas_mc2sba_fx( st_ivas->hIntSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); } - } - - IF( NE_16( output_q, Q11 ) ) - { - FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11 - } - st_ivas->hCPE[0]->q_output_mem_fx[0] = output_q; - st_ivas->hCPE[0]->q_output_mem_fx[1] = output_q; - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) - { - Word16 nchan_ism, sba_ch_idx; + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + else + { + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } - set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); - nchan_ism = st_ivas->nchan_ism; - move16(); - IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) - { - /* set ISM parameters and decode ISM metadata in OSBA format */ - IF( NE_32( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) - { - return error; + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); + } } - sba_ch_idx = st_ivas->nchan_ism; - move16(); - } - ELSE - { - nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ ); - sba_ch_idx = 0; - move16(); - move16(); - } - - /* SBA metadata decoding */ - IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) - { - return error; } - - test(); - IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { - st_ivas->hCPE[0]->element_brate = ivas_total_brate; - move32(); - } + ivas_mc_paramupmix_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc_fx, p_output_fx ); - /* core-decoding of transport channels */ - IF( EQ_16( st_ivas->nSCE, 1 ) ) - { - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + /* Rendering */ + test(); + test(); + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { - return error; + /* handled in CLDFB domain already */ + IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); + } } - } - ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) - { - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { - return error; + ivas_ls_setup_conversion_fx( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output_fx, p_output_fx ); } - } - ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - return error; + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); } } - - IF( st_ivas->sba_dirac_stereo_flag ) + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { - FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) - { - Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, Q14 - Q11 ); // Q14 - } - SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 nchan_transport; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - move16(); - nchan_out = nchan_transport; + Word16 channel_active_fx[MAX_OUTPUT_CHANNELS]; + Word16 nchan_out_cov; + Word16 nchan_out_cldfb = 0; move16(); - ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); - IF( st_ivas->hSpar->hPCA != NULL ) + set16_fx( channel_active_fx, 0, MAX_LS_CHANNELS ); + Word16 nchan_transport_tmp = st_ivas->nchan_transport; + move16(); + output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); + Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] ); + nchan_out_cldfb = BINAURAL_CHANNELS; + move16(); + set16_fx( channel_active_fx, 1, BINAURAL_CHANNELS ); + nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); } - - ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); - - ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); - } - - /* HP filtering */ - FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } - - nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); - - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) - { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 nchan_transport; - // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - move16(); - nchan_out = nchan_transport; - move16(); - Word16 Q_p_output; - Word16 min_norm = 31; - move16(); - - FOR( ch = 0; ch < nchan_transport; ++ch ) + ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) { - Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel - min_norm = s_min( norm, min_norm ); + nchan_out_cov = nchan_out_transport; + move16(); + nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); } - - Q_p_output = s_max( 3, sub( min_norm, 1 ) ); - - Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30 - FOR( ch = 0; ch < nchan_transport; ch++ ) + ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11 + nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + nchan_out_cldfb = nchan_out_cov; + move16(); + set16_fx( channel_active_fx, 1, nchan_out_cov ); } - Q_p_output = add( Q11, Q_p_output ); - hSpar->hMdDec->Q_mixer_mat = 31; - move16(); - - ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, sub( Q_p_output, Q11 ) ); - FOR( Word16 c = 0; c < nchan_transport; c++ ) + ELSE { - Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); // Q11 + nchan_out_cov = nchan_out_transport; + move16(); + nchan_out_cldfb = nchan_out_transport; + move16(); + set16_fx( channel_active_fx, 1, nchan_out_cov ); } - } - ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 ) - { - Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx ); - if ( EQ_16( size, 3 ) ) + IF( st_ivas->hParamMC->max_band_decorr > 0 ) { - size = add( size, 1 ); + Word16 tmp; + tmp = L_norm_arr( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len ); + scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); // Q(st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer+ tmp) + st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp ); + move16(); } - - FOR( i = sba_ch_idx; i < size; i++ ) + /* CLDFB synthesis */ + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { - Scale_sig32( p_output_fx[i], output_frame, ( Q14 - Q11 ) ); // Q14 + IF( st_ivas->cldfbSynDec[ch] ) + { + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, ( Q5 - Q11 ) ); // Q5 + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; + move16(); + } } - - ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); - } - - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) - { - /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/ - - FOR( i = 0; i < nchan_remapped; i++ ) + Word16 tempp; + FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ ) { - Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q + tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len ); + scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len, tempp ); // Q(31-(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]- tempp)) + st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], tempp ); + move16(); + + IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) + { + tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len ); + scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len, tempp ); // Q(31- (st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] - tempp)) + st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], tempp ); + move16(); + } } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) - { - ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); - Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); // Q11 + ivas_param_mc_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx ); - /* add W */ - FOR( n = 0; n < nchan_out; n++ ) - { - v_add_32( p_output_fx[n], p_output_fx[n + s_max( nchan_out, nchan_ism )], p_output_fx[n], output_frame ); - } - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) - { - IF( st_ivas->nSCE > 0 ) - { - st = st_ivas->hSCE[0]->hCoreCoder[0]; - } - ELSE - { - st = st_ivas->hCPE[0]->hCoreCoder[0]; - } - - IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) - { - /* LFE channel decoder */ - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); - - Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 - - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* HP filtering */ - FOR( n = 0; n < st_ivas->nchan_transport; n++ ) - { - IF( NE_16( n, LFE_CHANNEL ) ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } - } - - test(); - test(); - test(); - IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { - IF( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) + IF( st_ivas->cldfbSynDec[ch] ) { - ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q11 + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; + move16(); } } - - test(); - test(); - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) + IF( EQ_16( st_ivas->hParamMC->slots_rendered, st_ivas->hParamMC->num_slots ) ) { - IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) + FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->hMetadataPMC->nbands_coded; param_band_idx++ ) { - s = Q16 - Q11; - move16(); - s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, s ); // Q(11+s) - } - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) { - Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); // Q11 + Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) ); + st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx]; + move16(); } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 ); + Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) ); + st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]; + move16(); } } } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { - /* LFE channel decoder */ - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); - - Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 - - ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); - - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* HP filtering */ - FOR( n = 0; n < st_ivas->nchan_transport; n++ ) - { - IF( NE_16( n, LFE_CHANNEL ) ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } - } + nchan_remapped = st_ivas->nchan_transport; + move16(); - /* Rendering */ test(); test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - /* Compensate loudness for not doing full upmix */ - FOR( n = 4; n < 8; n++ ) - { - Scale_sig32( p_output_fx[n], output_frame, 1 ); - } + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) /* rendering to CICPxx and Ambisonics */ + { + ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - s = Q16 - Q11; - move16(); - Word16 nchan_transport; - nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); - s = sub( s, find_guarded_bits_fx( nchan_transport ) ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, s ); - } - - ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); - - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) + /* we still need to copy the separate channel if available */ + IF( st_ivas->hOutSetup.separateChannelEnabled ) { - Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); + Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } - } - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) - { - /* read Parametric MC parameters from the bitstream */ - ivas_param_mc_dec_read_BS_fx( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] ); - IF( EQ_16( st_ivas->nCPE, 1 ) ) - { - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); } - } - ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + ELSE IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_5_1 ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ) ) { - return error; + FOR( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); n++ ) + { + set32_fx( p_output_fx[n], 0, *nSamplesRendered ); + } } } - /* HP filtering */ - FOR( n = 0; n < st_ivas->nchan_transport; n++ ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } - - /* Rendering */ - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) - { - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) - { - IF( st_ivas->hOutSetup.separateChannelEnabled ) - { - st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */ - } - - /* read McMASA parameters from the bitstream */ - IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - + /* copy discrete C and TD LFE from internal TC to output */ IF( st_ivas->hOutSetup.separateChannelEnabled ) { - /* Decode the transport audio signals */ - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ - n = LFE_CHANNEL - 1; - move16(); - - /* Decode the separated channel to output[n] to be combined with the synthesized channels */ - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - test(); test(); test(); @@ -882,2169 +892,761 @@ ivas_error ivas_dec_fx( test(); test(); test(); - /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) ) { - ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL ); + Copy32( p_tc_fx[LFE_CHANNEL], p_output_fx[LFE_CHANNEL], *nSamplesRendered ); + Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) { - /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal32_fx( p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); - } - } - ELSE - { - IF( EQ_16( st_ivas->nSCE, 1 ) ) - { - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) - { - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } + Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } } - - IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ - { - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); - } - - /* HP filtering */ - FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } - - IF( EQ_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) - { - ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame ); - } } } /*----------------------------------------------------------------* - * Common updates + * Write IVAS output channels + * - compensation for saturation + * - float to integer conversion *----------------------------------------------------------------*/ - IF( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ + st_ivas->hTcBuffer->n_samples_available = sub( st_ivas->hTcBuffer->n_samples_available, *nSamplesRendered ); + st_ivas->hTcBuffer->n_samples_rendered = add( st_ivas->hTcBuffer->n_samples_rendered, *nSamplesRendered ); + move16(); + move16(); + + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); + + IF( st_ivas->hTcBuffer->n_samples_discard > 0 ) { - st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; - move32(); - IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) + FOR( n = 0; n < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ ) { - st_ivas->last_active_ivas_total_brate = st_ivas->last_active_ivas_total_brate; - move32(); + p_output_fx[n] += st_ivas->hTcBuffer->n_samples_discard; } - ELSE + *nSamplesRendered = sub( (Word16) *nSamplesRendered, st_ivas->hTcBuffer->n_samples_discard ); + move16(); + st_ivas->hTcBuffer->n_samples_discard = 0; + move16(); + } + + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + + nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); + + /* Save TD signals for pose correction if they are to be used. + * + * NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer in lib_dec.c function isar_render_poses. */ + IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) { - st_ivas->last_active_ivas_total_brate = ivas_total_brate; - move32(); + FOR( i = 0; i < nchan_out_syn_output; i++ ) + { + p_output_fx_const[i] = p_output_fx[i]; + } + ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); } - } - test(); - test(); - if ( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + if ( st_ivas->flushing ) + { + nchan_out_syn_output = BINAURAL_CHANNELS; + move16(); + } +#endif + } + ELSE { - st_ivas->ini_frame = add( st_ivas->ini_frame, 1 ); + nchan_out_syn_output = nchan_out; move16(); } - test(); - test(); - if ( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ + IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { - st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 ); - move16(); + IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, output_q_factor ); +#endif + } } - st_ivas->last_ivas_format = st_ivas->ivas_format; - move32(); - pop_wmops(); + ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out_syn_output, data ); + *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; + move16(); + + pop_wmops(); return IVAS_ERR_OK; } /*--------------------------------------------------------------------------* - * ivas_dec_feed_tc_to_renderer() + * ivas_jbm_dec_flush_renderer() * - * Feed decoded transport channels to the IVAS renderer routine - * + digest TC channels in ParamISM and ParamMC + * Flush samples if renderer granularity changes on a bitrate change in JBM *--------------------------------------------------------------------------*/ -void ivas_dec_feed_tc_to_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ - Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ +ivas_error ivas_jbm_dec_flush_renderer_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 tc_granularity_new, /* i : new renderer granularity */ + const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ + const AUDIO_CONFIG intern_config_old, /* i : old internal config */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ + const MC_MODE mc_mode_old, /* i : old MC mode */ + const ISM_MODE ism_mode_old, /* i : old ISM mode */ + UWord16 *nSamplesRendered, /* o : number of samples flushed */ + Word16 *data /* o : output synthesis signal Q0*/ ) { - Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k]; - Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS]; - Word16 n, n_render_timeslots, n_ch_cldfb; - Word16 ch, offset, len_offset; + ivas_error error; + Word16 n_samples_still_available; + Word16 n_slots_still_available; + Word16 n_samples_to_render; + Word16 n_samples_granularity; DECODER_TC_BUFFER_HANDLE hTcBuffer; + Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS]; + Word16 nchan_in, nchan_out; + Word16 ch_idx; + + + IF( !st_ivas->hDecoderConfig->Opt_tsm ) + { + return IVAS_ERR_OK; + } + + FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) + { + p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; + } + *nSamplesRendered = 0; + move16(); hTcBuffer = st_ivas->hTcBuffer; - n_ch_cldfb = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + n_samples_granularity = hTcBuffer->n_samples_granularity; move16(); - hTcBuffer->q_tc_fx = Q11; + /* get number of possible slots in new granularity */ + n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); + + // n_slots_still_available = n_samples_still_available / tc_granularity_new; + Word16 tmp, tmp_e; + tmp = BASOP_Util_Divide1616_Scale( n_samples_still_available, tc_granularity_new, &tmp_e ); + n_slots_still_available = shr( tmp, sub( 15, tmp_e ) ); + *nSamplesRendered = imult1616( n_slots_still_available, tc_granularity_new ); + n_samples_to_render = *nSamplesRendered; move16(); + move16(); + n_samples_still_available = sub( n_samples_still_available, n_samples_to_render ); + assert( n_samples_still_available < tc_granularity_new ); - IF( st_ivas->hDecoderConfig->Opt_tsm ) + /* update combined orientation access index */ + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + + IF( n_slots_still_available ) { - Word16 n_samples_still_available; - Word16 n_ch_full_copy, n_ch_res_copy; - n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); - hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard ); - hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) ); - *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available ); + /* render available full slots (with new lower granularity) */ + FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + { + /* move it at the beginning of the TC buffer with zero padding */ + Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); + set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) ); + } + + /* simple change of the slot info */ + hTcBuffer->num_slots = 1; + hTcBuffer->nb_subframes = 1; + hTcBuffer->subframes_rendered = 0; + hTcBuffer->slots_rendered = 0; + hTcBuffer->subframe_nbslots[0] = 1; + hTcBuffer->n_samples_buffered = add( n_samples_granularity, n_samples_still_available ); + hTcBuffer->n_samples_available = 0; + hTcBuffer->n_samples_flushed = n_samples_to_render; + hTcBuffer->n_samples_rendered = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); move16(); move16(); move16(); - n_ch_full_copy = s_min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); - n_ch_res_copy = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); - /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': - in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffer - pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */ - len_offset = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ); - IF( LT_16( len_offset, L_FRAME48k ) ) + + test(); + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { - offset = 0; - move16(); - FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch++ ) + IF( EQ_16( ism_mode_old, ISM_MODE_DISC ) ) { - hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset]; - st_ivas->p_output_fx[ch] = hTcBuffer->tc_fx[ch]; - offset = add( offset, len_offset ); - } - } + /* Binaural rendering */ + IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) + { + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) + { + /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ + set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, n_samples_granularity ); // 32767=1.0f in Q15 - FOR( ch = 0; ch < n_ch_full_copy; ch++ ) - { - Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); - set_zero_fx( hTcBuffer->tc_fx[ch], hTcBuffer->n_samples_discard ); - Copy32( hTcBuffer->tc_buffer_old_fx[ch], hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); - Copy32( tmp_buf_fx, hTcBuffer->tc_fx[ch] + n_samples_still_available + hTcBuffer->n_samples_discard, nSamplesForRendering - *nSamplesResidual ); - Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual ); - } + ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, n_samples_granularity ); - IF( n_ch_res_copy > 0 ) - { - FOR( ; ch < hTcBuffer->nchan_transport_rend; ch++ ) + st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; + *st_ivas->hCrendWrapper->p_io_qfactor = 11; + + move16(); + IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), + IVAS_ERR_OK ) ) + { + return error; + } + } + } + ELSE { - p_data_fx[ch] = hTcBuffer->tc_fx[ch]; - Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); - Copy32( hTcBuffer->tc_buffer_old_fx[ch], p_data_fx[ch], n_samples_still_available ); - Copy32( tmp_buf_fx, p_data_fx[ch] + n_samples_still_available, sub( nSamplesForRendering, *nSamplesResidual ) ); - Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual ); + return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong ISM_MODE in VoIP renderer flushing!" ); } } - - n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity ); - } - ELSE - { - FOR( n = 0; n < n_ch_cldfb; n++ ) + ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) { - p_data_fx[n] = &st_ivas->p_output_fx[n][0]; - move16(); - } + IF( EQ_16( mc_mode_old, MC_MODE_MCT ) ) + { + Word16 crendInPlaceRotation = FALSE; - ch = s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); - FOR( n = 0; n < ch; n++ ) - { - hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */ - move16(); - } + test(); + test(); + test(); + IF( NE_16( st_ivas->transport_config, intern_config_old ) && ( EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + { + IF( GT_16( sub( add( hIntSetupOld->nchan_out_woLFE, hIntSetupOld->num_lfe ), add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), 0 ) ) + { + crendInPlaceRotation = TRUE; + move16(); + ivas_mc2sba_fx( st_ivas->hTransSetup, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE_FX ); + } + } - hTcBuffer->n_samples_buffered = nSamplesForRendering; - hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; - *nSamplesResidual = 0; - move16(); - move16(); - move16(); + test(); + IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) + { + st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; + IF( NE_32( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ), IVAS_ERR_OK ) ) + { + return error; + } - n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS; - move16(); - } + IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* CLDFB analysis for ParamMC/ParamISM */ - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) ) - { - ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_fx, Q11 ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) && EQ_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) ) - { - ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, p_data_fx, Q11 ); - } + Word16 subframe_len, gd_bits; + subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], n_samples_granularity ); + gd_bits = find_guarded_bits_fx( subframe_len ); + *st_ivas->hCrendWrapper->p_io_qfactor = sub( 13, gd_bits ); + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor + } - hTcBuffer->n_samples_rendered = 0; - move16(); - hTcBuffer->subframes_rendered = 0; - move16(); + IF( NE_32( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ), IVAS_ERR_OK ) ) + { + return error; + } - return; -} + ivas_binaural_add_LFE_fx( st_ivas, n_samples_granularity, hTcBuffer->tc_fx, p_output_fx ); + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 + } + } + ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) + { + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) ) + { + return error; + } -/*--------------------------------------------------------------------------* - * ivas_dec_render() - * - * Principal IVAS internal rendering routine - *--------------------------------------------------------------------------*/ + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, hTcBuffer->tc_fx, p_output_fx ); + } + ELSE + { + return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong renderer in MCT VoIP renderer flushing!" ); + } + } + ELSE + { + return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong MC_MODE in VoIP renderer flushing!" ); + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) + { + IF( EQ_16( ism_mode_old, ISM_MASA_MODE_DISC ) ) + { + Word32 *tc_local_fx[MAX_NUM_OBJECTS]; + Word16 last_dirac_md_idx; + UWord16 nSamplesAvailableNext; + ISM_MODE ism_mode_orig; + RENDERER_TYPE renderer_type_orig; + Word32 ivas_total_brate; -ivas_error ivas_dec_render_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const UWord16 nSamplesAsked, /* i : number of samples wanted */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - Word16 *data /* o : output synthesis signal Q0*/ -) -{ - Word16 n, nchan_out; - Word16 nchan_transport_rend; - Word16 nchan_remapped; - Word32 output_Fs; - AUDIO_CONFIG output_config; - Word16 nSamplesAskedLocal; - ivas_error error; - Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; - Word32 *p_tc_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; - Word16 subframe_len, gd_bits, exp, nchan_in, i, j, ch; - const Word16 output_q_factor = Q11; - move16(); - Word16 nchan_out_syn_output; - - push_wmops( "ivas_dec_render" ); - /*----------------------------------------------------------------* - * Initialization of local vars after struct has been set - *----------------------------------------------------------------*/ - - output_Fs = st_ivas->hDecoderConfig->output_Fs; - move32(); - nchan_out = st_ivas->hDecoderConfig->nchan_out; - move16(); - nchan_transport_rend = st_ivas->hTcBuffer->nchan_transport_rend; - move16(); - output_config = st_ivas->hDecoderConfig->output_config; - move32(); - nSamplesAskedLocal = add( nSamplesAsked, st_ivas->hTcBuffer->n_samples_discard ); - move16(); - - FOR( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) - { - p_output_fx[n] = st_ivas->p_output_fx[n]; - } - - IF( !st_ivas->hDecoderConfig->Opt_tsm ) - { - FOR( n = 0; n < MAX_INTERN_CHANNELS; n++ ) - { - st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; - } - } - - FOR( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) - { - p_tc_fx[n] = &st_ivas->hTcBuffer->tc_fx[n][st_ivas->hTcBuffer->n_samples_rendered]; - } - - /*----------------------------------------------------------------* - * Update combined orientation access index - *----------------------------------------------------------------*/ - - IF( st_ivas->hCombinedOrientationData != NULL ) - { - /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ - st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start = sub( st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start, st_ivas->hTcBuffer->n_samples_discard ); - move16(); - - ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); - } - - /*----------------------------------------------------------------* - * Rendering - *----------------------------------------------------------------*/ - - *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - move16(); - - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) ) - { - assert( 0 ); - } - ELSE IF( EQ_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) - { - ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - /* Rendering */ - IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) - { - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) - { - ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - ivas_stereo2sba_fx( p_tc_fx, p_output_fx, *nSamplesRendered ); - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) - { - /* Rendering */ - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) - { - test(); - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - ivas_param_ism_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ); - - IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - /* Convert CICP19 -> Ambisonics */ - ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); - } - } - } - ELSE /* ISM_MODE_DISC */ - { - test(); - test(); - /* Loudspeaker or Ambisonics rendering */ - IF( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ - ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) - { - ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); - } -#ifdef DEBUGGING - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) -#else - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) -#endif - { - /* Convert to Ambisonics */ - FOR( i = 0; i < st_ivas->nchan_transport; i++ ) - { - FOR( j = 0; j < HOA3_CHANNELS; j++ ) - { - st_ivas->hIsmRendererData->gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q30 -> Q29 - move32(); - st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29 - move32(); - } - } - - ivas_ism2sba_sf_fx( p_tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); - - Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) ); - FOR( j = 0; j < sba_num_chans; j++ ) - { - scale_sig32( p_output_fx[j], *nSamplesRendered, sub( Q11, sub( add( output_q_factor, 29 ), 31 ) ) ); // Q11 - } - - FOR( i = 0; i < st_ivas->nchan_transport; i++ ) - { - FOR( j = 0; j < 16; j++ ) - { - st_ivas->hIsmRendererData->gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q29 -> Q30 - move32(); - st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q29 -> Q30 - move32(); - } - } - } - - /* Binaural rendering */ - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) - { - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity ); - gd_bits = find_guarded_bits_fx( subframe_len ); - exp = 13; - move16(); - nchan_in = 12; - move16(); - nchan_out = 2; - move16(); - exp = sub( exp, gd_bits ); - *st_ivas->hCrendWrapper->p_io_qfactor = exp; + /* copy from ISM delay buffer to the correct place in TCs */ move16(); - FOR( i = 0; i < nchan_in; i++ ) + FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { - scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 + tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx + 2][hTcBuffer->n_samples_rendered]; + Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/ } - IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* to render flushed samples, use configuration from the last received frame */ + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + renderer_type_orig = st_ivas->renderer_type; + ism_mode_orig = st_ivas->ism_mode; + st_ivas->ism_mode = ism_mode_old; + st_ivas->renderer_type = renderer_type_old; + st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; + last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; - FOR( i = 0; i < nchan_out; i++ ) - { - scale_sig32( p_output_fx[i], *nSamplesRendered, sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 - } - } - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) - { - nchan_remapped = nchan_transport_rend; - move16(); + /* transfer adapted sf info from hTcBuffer to DirAC */ + st_ivas->hSpatParamRendCom->nb_subframes = 1; + st_ivas->hSpatParamRendCom->subframes_rendered = 0; + st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpatParamRendCom->slots_rendered = 0; + st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); - test(); - test(); - /* Loudspeakers, Ambisonics or Binaural rendering */ - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) - { - IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) - { - ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ); - } - } - ELSE - { - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) - { - nchan_remapped = st_ivas->nchan_transport; - move16(); - test(); - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - test(); - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) - { - IF( NE_32( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE - { - ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); - } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) - { - ivas_omasa_dirac_rend_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) - { - ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); - ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, *nSamplesRendered ); - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) - { - nchan_remapped = nchan_transport_rend; - move16(); - - /* Loudspeakers, Ambisonics or Binaural rendering */ - IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) - { - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) - { - SPAR_DEC_HANDLE hSpar; - hSpar = st_ivas->hSpar; - hSpar->hMdDec->Q_mixer_mat = 30; - move16(); - - IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ) - { - test(); - /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/ - IF( EQ_16( st_ivas->nchan_ism, 1 ) && EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) ) - { - Copy32( p_tc_fx[2], p_output_fx[3], *nSamplesRendered ); - Copy32( p_tc_fx[1], p_output_fx[2], *nSamplesRendered ); - p_tc_fx[1] = p_output_fx[2]; - p_tc_fx[2] = p_output_fx[3]; - } - - /* render objects */ - ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); - - /* add already rendered SBA part */ - ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, st_ivas->hSbaIsmData->gain_bed_fx, nchan_out, st_ivas->nchan_ism, st_ivas->ism_mode, *nSamplesRendered ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - IF( NE_32( ( error = ivas_osba_render_sf_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) /*EXT output = individual objects + HOA3*/ - { - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism] ) ), IVAS_ERR_OK ) ) - { - return error; - } - - FOR( n = 0; n < st_ivas->nchan_ism; n++ ) - { - Copy32( p_tc_fx[n], p_output_fx[n], *nSamplesRendered ); - } - } - ELSE - { - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) - { - ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); - - FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) - { - scale_sig32( p_output_fx[n], *nSamplesRendered, 1 ); - } - } - ELSE - { - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - FOR( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) - { - Copy32( p_output_fx[n], p_output_fx[n + st_ivas->nchan_ism], *nSamplesRendered ); - } - FOR( n = 0; n < st_ivas->nchan_ism; n++ ) - { - set32_fx( p_output_fx[n], 0, *nSamplesRendered ); - } - } - FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) - { - scale_sig32( p_output_fx[n], *nSamplesRendered, 1 ); - } - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) - { - IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) - { - Word16 crendInPlaceRotation = FALSE; - move16(); - - test(); - test(); - test(); - IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - IF( LT_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) - { - crendInPlaceRotation = TRUE; - move16(); - - ivas_mc2sba_fx( st_ivas->hTransSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); - } - } - - /* Rendering */ - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity ); - gd_bits = find_guarded_bits_fx( subframe_len ); - exp = 13; - move16(); - IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ), IVAS_ERR_OK ) ) - { - return error; - } - IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) - { - return error; - } - exp = sub( exp, gd_bits ); - *st_ivas->hCrendWrapper->p_io_qfactor = exp; - move16(); - - IF( crendInPlaceRotation ) - { - FOR( i = 0; i < nchan_in; i++ ) - { - scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor - } - } - ELSE - { - FOR( i = 0; i < nchan_in; i++ ) - { - scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor - } - } - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), - IVAS_ERR_OK ) ) - { - return error; - } - - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); - } - - IF( crendInPlaceRotation ) - { - n = nchan_in; - } - ELSE - { - n = nchan_out; - } - move16(); - - FOR( i = 0; i < n; i++ ) - { - scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 - } - - FOR( i = n; i < nchan_in; i++ ) - { - scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 - } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) - { - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - ivas_mc2sba_fx( st_ivas->hIntSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) - { - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - else + IF( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output_fx ) ) != IVAS_ERR_OK ) { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) - { - return error; - } - - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); - } - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) - { - ivas_mc_paramupmix_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc_fx, p_output_fx ); - - /* Rendering */ - test(); - test(); - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) - { - /* handled in CLDFB domain already */ - IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); - } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) - { - ivas_ls_setup_conversion_fx( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output_fx, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) - { - Word16 channel_active_fx[MAX_OUTPUT_CHANNELS]; - Word16 nchan_out_cov; - Word16 nchan_out_cldfb = 0; - move16(); - - set16_fx( channel_active_fx, 0, MAX_LS_CHANNELS ); - Word16 nchan_transport_tmp = st_ivas->nchan_transport; - move16(); - output_Fs = st_ivas->hDecoderConfig->output_Fs; - move32(); - Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - nchan_out_cldfb = BINAURAL_CHANNELS; - move16(); - set16_fx( channel_active_fx, 1, BINAURAL_CHANNELS ); - nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); - } - ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) - { - nchan_out_cov = nchan_out_transport; - move16(); - nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); - } - ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) - { - nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); - nchan_out_cldfb = nchan_out_cov; - move16(); - set16_fx( channel_active_fx, 1, nchan_out_cov ); - } - ELSE - { - nchan_out_cov = nchan_out_transport; - move16(); - nchan_out_cldfb = nchan_out_transport; - move16(); - set16_fx( channel_active_fx, 1, nchan_out_cov ); - } - IF( st_ivas->hParamMC->max_band_decorr > 0 ) - { - Word16 tmp; - tmp = L_norm_arr( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len ); - scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); // Q(st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer+ tmp) - st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp ); - move16(); - } - /* CLDFB synthesis */ - FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) - { - IF( st_ivas->cldfbSynDec[ch] ) - { - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, ( Q5 - Q11 ) ); // Q5 - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; - move16(); - } - } - Word16 tempp; - FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ ) - { - tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len ); - scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len, tempp ); // Q(31-(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]- tempp)) - st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], tempp ); - move16(); - - IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) - { - tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len ); - scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len, tempp ); // Q(31- (st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] - tempp)) - st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], tempp ); - move16(); - } - } - - ivas_param_mc_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx ); - - FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) - { - IF( st_ivas->cldfbSynDec[ch] ) - { - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q11 - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; - move16(); - } - } - IF( EQ_16( st_ivas->hParamMC->slots_rendered, st_ivas->hParamMC->num_slots ) ) - { - FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->hMetadataPMC->nbands_coded; param_band_idx++ ) - { - IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) - { - Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) ); - st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx]; - move16(); - } - Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) ); - st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]; - move16(); - } - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) - { - nchan_remapped = st_ivas->nchan_transport; - move16(); - - test(); - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) /* rendering to CICPxx and Ambisonics */ - { - ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ); - - test(); - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - /* we still need to copy the separate channel if available */ - IF( st_ivas->hOutSetup.separateChannelEnabled ) - { - Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); - } - - ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); - } - ELSE IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_5_1 ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ) ) - { - FOR( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); n++ ) - { - set32_fx( p_output_fx[n], 0, *nSamplesRendered ); - } - } - } - - /* copy discrete C and TD LFE from internal TC to output */ - IF( st_ivas->hOutSetup.separateChannelEnabled ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) ) - { - Copy32( p_tc_fx[LFE_CHANNEL], p_output_fx[LFE_CHANNEL], *nSamplesRendered ); - Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); - } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) - { - Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); - } - } - } - } - - /*----------------------------------------------------------------* - * Write IVAS output channels - * - compensation for saturation - * - float to integer conversion - *----------------------------------------------------------------*/ - - st_ivas->hTcBuffer->n_samples_available = sub( st_ivas->hTcBuffer->n_samples_available, *nSamplesRendered ); - st_ivas->hTcBuffer->n_samples_rendered = add( st_ivas->hTcBuffer->n_samples_rendered, *nSamplesRendered ); - move16(); - move16(); - - /* update global combined orientation start index */ - ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); - - IF( st_ivas->hTcBuffer->n_samples_discard > 0 ) - { - FOR( n = 0; n < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ ) - { - p_output_fx[n] += st_ivas->hTcBuffer->n_samples_discard; - } - *nSamplesRendered = sub( (Word16) *nSamplesRendered, st_ivas->hTcBuffer->n_samples_discard ); - move16(); - st_ivas->hTcBuffer->n_samples_discard = 0; - move16(); - } - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; - - nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); - - /* Save TD signals for pose correction if they are to be used. - * - * NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer in lib_dec.c function isar_render_poses. */ - IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) - { - FOR( i = 0; i < nchan_out_syn_output; i++ ) - { - p_output_fx_const[i] = p_output_fx[i]; - } - ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); - } - -#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - if ( st_ivas->flushing ) - { - nchan_out_syn_output = BINAURAL_CHANNELS; - move16(); - } -#endif - } - ELSE - { - nchan_out_syn_output = nchan_out; - move16(); - } - - IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) - { - IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) - { -#ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, output_q_factor ); -#endif - } - } - - ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out_syn_output, data ); - - *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; - move16(); - - pop_wmops(); - return IVAS_ERR_OK; -} - -/*--------------------------------------------------------------------------* - * ivas_jbm_dec_flush_renderer() - * - * Flush samples if renderer granularity changes on a bitrate change in JBM - *--------------------------------------------------------------------------*/ - -ivas_error ivas_jbm_dec_flush_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - UWord16 *nSamplesRendered, /* o : number of samples flushed */ - Word16 *data /* o : output synthesis signal Q0*/ -) -{ - ivas_error error; - Word16 n_samples_still_available; - Word16 n_slots_still_available; - Word16 n_samples_to_render; - Word16 n_samples_granularity; - DECODER_TC_BUFFER_HANDLE hTcBuffer; - Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS]; - Word16 nchan_in, nchan_out; - Word16 ch_idx; - - - IF( !st_ivas->hDecoderConfig->Opt_tsm ) - { - return IVAS_ERR_OK; - } - - FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) - { - p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; - } - - *nSamplesRendered = 0; - move16(); - hTcBuffer = st_ivas->hTcBuffer; - n_samples_granularity = hTcBuffer->n_samples_granularity; - move16(); - - /* get number of possible slots in new granularity */ - n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); - - // n_slots_still_available = n_samples_still_available / tc_granularity_new; - Word16 tmp, tmp_e; - tmp = BASOP_Util_Divide1616_Scale( n_samples_still_available, tc_granularity_new, &tmp_e ); - n_slots_still_available = shr( tmp, sub( 15, tmp_e ) ); - *nSamplesRendered = imult1616( n_slots_still_available, tc_granularity_new ); - n_samples_to_render = *nSamplesRendered; - move16(); - move16(); - n_samples_still_available = sub( n_samples_still_available, n_samples_to_render ); - assert( n_samples_still_available < tc_granularity_new ); - - /* update combined orientation access index */ - ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); - - IF( n_slots_still_available ) - { - - /* render available full slots (with new lower granularity) */ - FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) - { - /* move it at the beginning of the TC buffer with zero padding */ - Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); - set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) ); - } - - /* simple change of the slot info */ - hTcBuffer->num_slots = 1; - hTcBuffer->nb_subframes = 1; - hTcBuffer->subframes_rendered = 0; - hTcBuffer->slots_rendered = 0; - hTcBuffer->subframe_nbslots[0] = 1; - hTcBuffer->n_samples_buffered = add( n_samples_granularity, n_samples_still_available ); - hTcBuffer->n_samples_available = 0; - hTcBuffer->n_samples_flushed = n_samples_to_render; - hTcBuffer->n_samples_rendered = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - - - test(); - IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) - { - IF( EQ_16( ism_mode_old, ISM_MODE_DISC ) ) - { - /* Binaural rendering */ - IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) - { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ - set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, n_samples_granularity ); // 32767=1.0f in Q15 - - ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, n_samples_granularity ); - - st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - *st_ivas->hCrendWrapper->p_io_qfactor = 11; - - move16(); - IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), - IVAS_ERR_OK ) ) - { - return error; - } - } - } - ELSE - { - return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong ISM_MODE in VoIP renderer flushing!" ); - } - } - ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) - { - IF( EQ_16( mc_mode_old, MC_MODE_MCT ) ) - { - Word16 crendInPlaceRotation = FALSE; - - test(); - test(); - test(); - IF( NE_16( st_ivas->transport_config, intern_config_old ) && ( EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - IF( GT_16( sub( add( hIntSetupOld->nchan_out_woLFE, hIntSetupOld->num_lfe ), add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), 0 ) ) - { - crendInPlaceRotation = TRUE; - move16(); - ivas_mc2sba_fx( st_ivas->hTransSetup, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE_FX ); - } - } - - test(); - IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - IF( NE_32( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ), IVAS_ERR_OK ) ) - { - return error; - } - - IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) - { - return error; - } - - Word16 subframe_len, gd_bits; - subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], n_samples_granularity ); - gd_bits = find_guarded_bits_fx( subframe_len ); - *st_ivas->hCrendWrapper->p_io_qfactor = sub( 13, gd_bits ); - FOR( Word16 i = 0; i < nchan_in; i++ ) - { - scale_sig32( p_output_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor - } - - IF( NE_32( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ), IVAS_ERR_OK ) ) - { - return error; - } - - ivas_binaural_add_LFE_fx( st_ivas, n_samples_granularity, hTcBuffer->tc_fx, p_output_fx ); - - FOR( Word16 i = 0; i < nchan_in; i++ ) - { - scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 - } - } - ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) - { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) ) - { - return error; - } - - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, hTcBuffer->tc_fx, p_output_fx ); - } - ELSE - { - return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong renderer in MCT VoIP renderer flushing!" ); - } - } - ELSE - { - return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong MC_MODE in VoIP renderer flushing!" ); - } - } - ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) - { - IF( EQ_16( ism_mode_old, ISM_MASA_MODE_DISC ) ) - { - Word32 *tc_local_fx[MAX_NUM_OBJECTS]; - Word16 last_dirac_md_idx; - UWord16 nSamplesAvailableNext; - ISM_MODE ism_mode_orig; - RENDERER_TYPE renderer_type_orig; - Word32 ivas_total_brate; - - /* copy from ISM delay buffer to the correct place in TCs */ - move16(); - FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) - { - tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx + 2][hTcBuffer->n_samples_rendered]; - Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/ - } - - /* to render flushed samples, use configuration from the last received frame */ - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - renderer_type_orig = st_ivas->renderer_type; - ism_mode_orig = st_ivas->ism_mode; - st_ivas->ism_mode = ism_mode_old; - st_ivas->renderer_type = renderer_type_old; - st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; - last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; - - /* transfer adapted sf info from hTcBuffer to DirAC */ - st_ivas->hSpatParamRendCom->nb_subframes = 1; - st_ivas->hSpatParamRendCom->subframes_rendered = 0; - st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; - st_ivas->hSpatParamRendCom->slots_rendered = 0; - st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; - set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); - - IF( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output_fx ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* restore original configuration */ - st_ivas->ism_mode = ism_mode_orig; - st_ivas->renderer_type = renderer_type_orig; - st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; - } - } - ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) - { - IF( EQ_32( ism_mode_old, ISM_SBA_MODE_DISC ) ) - { - Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; - Word16 last_spar_md_idx; - Word16 last_dirac_md_idx; - UWord16 nSamplesAvailableNext; - ISM_MODE ism_mode_orig; - RENDERER_TYPE renderer_type_orig; - Word32 ivas_total_brate; - - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - renderer_type_orig = st_ivas->renderer_type; - ism_mode_orig = st_ivas->ism_mode; - - /* to render flushed samples, use configuration from the last received frame */ - move32(); - st_ivas->ism_mode = ism_mode_old; - st_ivas->renderer_type = renderer_type_old; - st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; - - last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; - last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; - move16(); - move16(); - - /* copy from ISM delay buffer to the correct place in TCs */ - FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) - { - tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx][hTcBuffer->n_samples_rendered]; - Copy32( st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); - } - - /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */ - st_ivas->hSpar->nb_subframes = 1; - st_ivas->hSpar->subframes_rendered = 0; - st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; - st_ivas->hSpar->slots_rendered = 0; - st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; - st_ivas->hSpatParamRendCom->nb_subframes = 1; - st_ivas->hSpatParamRendCom->subframes_rendered = 0; - st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; - st_ivas->hSpatParamRendCom->slots_rendered = 0; - st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - - /* also adapt md maps, just use the last index */ - set16_fx( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); - set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); - - /* render the last subframe */ - IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* restore original configuration */ - st_ivas->ism_mode = ism_mode_orig; - st_ivas->renderer_type = renderer_type_orig; - st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; - } - } - ELSE - { - return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); - } - - hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; - } - - /* update global combined orientation start index */ - ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); - - *nSamplesRendered = n_samples_to_render; - move16(); - - /* Only write out the valid data*/ - IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) - { - IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) - { -#ifndef DISABLE_LIMITER - Word16 exp = 11; - move16(); - FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; - } - ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); -#endif - } - } - - ivas_syn_output_fx( p_output_fx, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data ); - - return IVAS_ERR_OK; -} - - -/*--------------------------------------------------------------------------* - * ivas_jbm_dec_set_discard_samples() - * - * Set number of samples to discard in the first subframe - * if the renderer granularity changes on a bitrate change in JBM processing - *--------------------------------------------------------------------------*/ - -ivas_error ivas_jbm_dec_set_discard_samples_fx( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ -) -{ - Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe; - Word16 temp, temp_e; - - /* render first frame with front zero padding and discarding those samples */ - /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ - temp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); - temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); - nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */ - nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); - - IF( nSlotsInFirstSubframe > 0 ) - { - st_ivas->hTcBuffer->n_samples_discard = imult1616( sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ), st_ivas->hTcBuffer->n_samples_granularity ); - /* set last subframes number to max to ensure correct continuation */ - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; - move16(); - move16(); - } - - return IVAS_ERR_OK; -} - - -/*--------------------------------------------------------------------------* - * ivas_dec_get_adapted_linear_interpolator() - * - * Get an interpolator that is adapted to (time scale modified) IVAS frame - *--------------------------------------------------------------------------*/ - -void ivas_dec_get_adapted_linear_interpolator_fx( - const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */ - const Word16 interp_length, /* i : length of the interpolator to be created */ - Word16 *interpolator_fx /* o : the interpolator Q15 */ -) -{ - Word16 segment_len, idx; - Word16 dec_fx; - Word16 dec_e; - - segment_len = shr( default_interp_length, 1 ); - dec_fx = divide1616( 1, default_interp_length ); /*32767 / default_interp_length*/ - - interpolator_fx[interp_length - 1] = 32767; /* (1.0f in Q15) -1 */ - move16(); - interpolator_fx[interp_length - 2] = add( sub( 32767, dec_fx ), 1 ); // Use 32768 to maintain precision - move16(); - FOR( idx = interp_length - 3; idx >= segment_len; idx-- ) - { - interpolator_fx[idx] = s_max( 0, sub( interpolator_fx[idx + 1], dec_fx ) ); - move16(); - } - - IF( interpolator_fx[idx + 1] > 0 ) - { - dec_fx = BASOP_Util_Divide1616_Scale( interpolator_fx[idx + 1], add( segment_len, 1 ), &dec_e ); - dec_fx = shr( dec_fx, sub( 15, dec_e ) ); // Q0 - FOR( ; idx >= 0; idx-- ) - { - interpolator_fx[idx] = sub( interpolator_fx[idx + 1], dec_fx ); - move16(); - } - } - ELSE - { - set16_fx( interpolator_fx, 0, add( idx, 1 ) ); - } - - return; -} - - -/*--------------------------------------------------------------------------* - * ivas_dec_get_adapted_subframes() - * - * Get an interpolator that is adapted to (time scale modified) IVAS frame - *--------------------------------------------------------------------------*/ - -void ivas_dec_get_adapted_subframes_fx( - const Word16 nCldfbTs, /* i : number of time slots in the current frame */ - Word16 *subframe_nbslots, /* i/o: subframe grid */ - Word16 *nb_subframes /* i/o: number of subframes in the frame */ -) -{ - UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; - UWord16 nCldfbSlotsLocal = nCldfbTs; - move16(); - Word16 temp, temp_e; - - /* get last subframe size from previous frame, determine how many slots have to be processed - in the first subframe (i.e. potential leftover of a 5ms subframe) */ - nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) ); - *nb_subframes = 0; - move16(); - IF( nSlotsInFirstSubframe > 0 ) - { - *nb_subframes = 1; - move16(); - nCldfbSlotsLocal = sub( nCldfbSlotsLocal, nSlotsInFirstSubframe ); - } - - temp = BASOP_Util_Divide3232_Scale( L_add( nCldfbSlotsLocal, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1 ), PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, &temp_e ); - *nb_subframes = add( *nb_subframes, shr( temp, sub( 15, temp_e ) ) ); // Q0 - move16(); - nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; - move16(); - - set16_fx( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); - set16_fx( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); - - IF( nSlotsInFirstSubframe > 0 ) - { - subframe_nbslots[0] = nSlotsInFirstSubframe; - move16(); - } - - IF( nSlotsInLastSubframe > 0 ) - { - subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; - move16(); - } - - return; -} - - -/*--------------------------------------------------------------------------* - * ivas_dec_get_md_map() - * - * Get an meta data map adapted to a time scale modified IVAS frame - *--------------------------------------------------------------------------*/ - -void ivas_dec_get_md_map_fx( - const Word16 default_len, /* i : default frame length in metadata slots */ - const Word16 len, /* i : length of the modified frames in metadata slots*/ - const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the MD buffer */ - const Word16 buf_len, /* i : length of the metadata buffer */ - Word16 *map /* o : metadata index map */ -) -{ - Word16 jbm_segment_len, map_idx, src_idx, src_idx_map; - Word32 dec_fx, src_idx_fx; - Word16 temp_e; - Word16 temp; - jbm_segment_len = shr( default_len, 1 ); - - FOR( ( map_idx = len - 1, src_idx = default_len - 1 ); map_idx >= jbm_segment_len; ( map_idx--, src_idx-- ) ) - { - temp = BASOP_Util_Divide1616_Scale( src_idx, subframe_len, &temp_e ); - temp = shr( temp, sub( 15, temp_e ) ); // Q0 - src_idx_map = s_max( 0, temp ); - map[map_idx] = add( offset, src_idx_map ) % buf_len; - move16(); - } - - /* changed part (first segment), interpolate index to parameters - (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ - IF( src_idx >= 0 ) - { - dec_fx = BASOP_Util_Divide3232_Scale( L_shl( add( src_idx, 1 ), 16 ), jbm_segment_len, &temp_e ); - dec_fx = L_shr( dec_fx, sub( 15, temp_e ) ); - src_idx_fx = L_sub( L_shl( add( src_idx, 1 ), 16 ), dec_fx ); - FOR( ; map_idx >= 0; map_idx-- ) - { - temp = BASOP_Util_Divide1616_Scale( round_fx( src_idx_fx ), subframe_len, &temp_e ); - temp = shr( temp, sub( 15, temp_e ) ); // Q0 - src_idx = s_max( 0, temp ); - map[map_idx] = add( offset, src_idx ) % buf_len; - src_idx_fx = L_sub( src_idx_fx, dec_fx ); - } - } - ELSE - { - set16_fx( map, offset, add( map_idx, 1 ) ); - } - - return; -} - - -/*--------------------------------------------------------------------------* - * ivas_dec_get_md_map_even_spacing() - * - * Get an meta data map adapted to (time scale modified) IVAS frame. - * Distribute slots evenly across the (modified) frame. - *--------------------------------------------------------------------------*/ - -void ivas_dec_get_md_map_even_spacing_fx( - const Word16 len, /* i : length of the modified frames in metadata slots*/ - const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the MD buffer */ - const Word16 buf_len, /* i : length of the metadata buffer */ - Word16 *map /* o : metadata index map */ -) -{ - Word16 map_idx, sf_idx, sf_length, increment, subframes_written; - Word32 decimal_fx, decimal_sum_fx, eps_fx; // q = 16 - Word16 subframe_map_length[MAX_PARAM_SPATIAL_SUBFRAMES]; - - /* subframe map length */ - sf_length = idiv1616( len, subframe_len ); - IF( len % subframe_len == 0 ) - { - /* even subframes */ - FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - subframe_map_length[sf_idx] = sf_length; - move16(); - } - } - ELSE - { - /* uneven subframes */ - Word32 temp; - Word16 temp_e; - temp = BASOP_Util_Divide3232_Scale( L_shl( len, 16 ), subframe_len, &temp_e ); - temp = L_shr( temp, sub( 15, temp_e ) ); // Q16 - decimal_fx = L_sub( temp, L_shl( sf_length, 16 ) ); // Q16 - decimal_sum_fx = decimal_fx; - - eps_fx = 65; - move32(); - move32(); - FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - increment = extract_l( L_shr( L_add( decimal_sum_fx, eps_fx ), 16 ) ); - subframe_map_length[sf_idx] = add( sf_length, increment ); - move16(); - IF( increment > 0 ) - { - decimal_sum_fx = L_sub( decimal_sum_fx, ONE_IN_Q16 ); - } - decimal_sum_fx = L_add( decimal_sum_fx, decimal_fx ); - } - } - - /* map slots to subframes */ - sf_idx = 0; - subframes_written = 0; - move16(); - move16(); - FOR( map_idx = 0; map_idx < len; map_idx++ ) - { - map[map_idx] = add( offset, sf_idx ) % buf_len; - move16(); - IF( GE_16( sub( map_idx, subframes_written ), sub( subframe_map_length[sf_idx], 1 ) ) ) - { - subframes_written = add( subframes_written, subframe_map_length[sf_idx] ); - sf_idx = add( sf_idx, 1 ); - } - } - - return; -} - - -/*--------------------------------------------------------------------------* - * ivas_dec_get_num_tc_channels() - * - * Get the number of transport channels provided to the renderer - *--------------------------------------------------------------------------*/ - -Word16 ivas_dec_get_num_tc_channels_fx( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -) -{ - Word16 num_tc; - Word32 ivas_total_brate; - AUDIO_CONFIG output_config; - - IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) - { - num_tc = st_ivas->hDecoderConfig->nchan_out; - move16(); - } - ELSE - { - num_tc = st_ivas->nchan_transport; - move16(); - } - output_config = st_ivas->hDecoderConfig->output_config; - move16(); - - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - move32(); - - test(); - test(); - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) - { - num_tc = 1; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) - { - num_tc = 1; - move16(); - } - ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) - { - if ( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) - { - num_tc = 1; - move16(); - } - } - ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( st_ivas->sba_dirac_stereo_flag ) - { - num_tc = CPE_CHANNELS; - move16(); - } - ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && GT_16( st_ivas->nCPE, 0 ) && st_ivas->hCPE[0] != NULL && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) - { - num_tc = 1; /* Only one channel transported */ - move16(); - } - - test(); - test(); - test(); - test(); - IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->nchan_transport, 2 ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) - { - num_tc = CPE_CHANNELS; - move16(); - } - IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) - { - if ( EQ_16( num_tc, 3 ) ) - { - num_tc = add( num_tc, 1 ); - } - } - } - ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) - { - IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - test(); - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - num_tc = add( num_tc, 1 ); - } - ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - num_tc = add( num_tc, st_ivas->nchan_ism ); - } - } - } - ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) - { - if ( st_ivas->sba_dirac_stereo_flag ) - { - num_tc = CPE_CHANNELS; - move16(); - } - - if ( EQ_16( num_tc, 3 ) ) - { - num_tc = add( num_tc, 1 ); - } - if ( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) - { - num_tc = add( num_tc, st_ivas->nchan_ism ); - } - } - ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) - { - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) ) - { - num_tc = 1; - move16(); - } - ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) - { - num_tc = 2; - move16(); + return error; + } + + /* restore original configuration */ + st_ivas->ism_mode = ism_mode_orig; + st_ivas->renderer_type = renderer_type_orig; + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; + } } - ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) ) + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - /* do all static dmx already in the TC decoder if less channels than transported... */ - test(); - test(); - test(); - test(); - test(); - IF( NE_16( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + IF( EQ_32( ism_mode_old, ISM_SBA_MODE_DISC ) ) { - if ( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) + Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; + Word16 last_spar_md_idx; + Word16 last_dirac_md_idx; + UWord16 nSamplesAvailableNext; + ISM_MODE ism_mode_orig; + RENDERER_TYPE renderer_type_orig; + Word32 ivas_total_brate; + + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + renderer_type_orig = st_ivas->renderer_type; + ism_mode_orig = st_ivas->ism_mode; + + /* to render flushed samples, use configuration from the last received frame */ + move32(); + st_ivas->ism_mode = ism_mode_old; + st_ivas->renderer_type = renderer_type_old; + st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; + + last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; + last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; + move16(); + move16(); + + /* copy from ISM delay buffer to the correct place in TCs */ + FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { - num_tc = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); + tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx][hTcBuffer->n_samples_rendered]; + Copy32( st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); } - } - ELSE IF( ( EQ_16( st_ivas->renderer_type, RENDERER_MC ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) - { - num_tc = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + + /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */ + st_ivas->hSpar->nb_subframes = 1; + st_ivas->hSpar->subframes_rendered = 0; + st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpar->slots_rendered = 0; + st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpatParamRendCom->nb_subframes = 1; + st_ivas->hSpatParamRendCom->subframes_rendered = 0; + st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpatParamRendCom->slots_rendered = 0; + st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + + /* also adapt md maps, just use the last index */ + set16_fx( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); + set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); + + /* render the last subframe */ + IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* restore original configuration */ + st_ivas->ism_mode = ism_mode_orig; + st_ivas->renderer_type = renderer_type_orig; + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; } } - ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + ELSE { - num_tc = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; - move16(); + return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } - ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) - { - if ( st_ivas->hOutSetup.separateChannelEnabled ) - { - num_tc = add( num_tc, 1 ); - } - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( st_ivas->hOutSetup.separateChannelEnabled && ( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) || - EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || - EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) ) ) + hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; + } + + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); + + *nSamplesRendered = n_samples_to_render; + move16(); + + /* Only write out the valid data*/ + IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + { + IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) + { +#ifndef DISABLE_LIMITER + Word16 exp = 11; + move16(); + FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { - /* LFE is synthesized in TD with the TCs*/ - num_tc = add( num_tc, 1 ); + p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; } + ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); +#endif } } - return num_tc; + ivas_syn_output_fx( p_output_fx, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data ); + + return IVAS_ERR_OK; } /*--------------------------------------------------------------------------* - * ivas_dec_get_render_granularity() + * ivas_jbm_dec_set_discard_samples() * - * Get renderer granularity + * Set number of samples to discard in the first subframe + * if the renderer granularity changes on a bitrate change in JBM processing *--------------------------------------------------------------------------*/ -/*! r: render granularity */ -Word16 ivas_dec_get_render_granularity_fx( - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ - const Word32 output_Fs /* i : sampling rate */ +ivas_error ivas_jbm_dec_set_discard_samples_fx( + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) { - Word16 render_granularity; + Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe; + Word16 temp, temp_e; - test(); - test(); - test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || /* TD renderer */ - EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) || /* Crend */ - EQ_32( renderer_type_sec, RENDERER_BINAURAL_OBJECTS_TD ) /* TD rend as a secondary renderer -> set the common granularity for both renderers */ - ) + /* render first frame with front zero padding and discarding those samples */ + /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ + temp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); + nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */ + nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); + + IF( nSlotsInFirstSubframe > 0 ) { - /* 5 ms granularity */ - render_granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + st_ivas->hTcBuffer->n_samples_discard = imult1616( sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ), st_ivas->hTcBuffer->n_samples_granularity ); + /* set last subframes number to max to ensure correct continuation */ + st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; move16(); - } - ELSE - { - /* 1.25 ms granularity */ - render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ); move16(); } - return render_granularity; + return IVAS_ERR_OK; } /*--------------------------------------------------------------------------* - * ivas_dec_tc_audio_allocate() + * ivas_dec_get_adapted_linear_interpolator() * - * allocate and initialize TC audio buffer + * Get an interpolator that is adapted to (time scale modified) IVAS frame *--------------------------------------------------------------------------*/ -static ivas_error ivas_dec_tc_audio_allocate_fx( - DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC buffer handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 Opt_tsm /* i : TSM option flag */ +void ivas_dec_get_adapted_linear_interpolator_fx( + const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */ + const Word16 interp_length, /* i : length of the interpolator to be created */ + Word16 *interpolator_fx /* o : the interpolator Q15 */ ) { - Word16 nsamp_to_allocate; - Word16 ch_idx, n_samp_full, n_samp_residual, offset; + Word16 segment_len, idx; + Word16 dec_fx; + Word16 dec_e; - IF( Opt_tsm ) - { - n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); - n_samp_full = s_max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */ - n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); - } - ELSE + segment_len = shr( default_interp_length, 1 ); + dec_fx = divide1616( 1, default_interp_length ); /*32767 / default_interp_length*/ + + interpolator_fx[interp_length - 1] = 32767; /* (1.0f in Q15) -1 */ + move16(); + interpolator_fx[interp_length - 2] = add( sub( 32767, dec_fx ), 1 ); // Use 32768 to maintain precision + move16(); + FOR( idx = interp_length - 3; idx >= segment_len; idx-- ) { - n_samp_full = extract_l( Mpy_32_32( output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - n_samp_residual = 0; + interpolator_fx[idx] = s_max( 0, sub( interpolator_fx[idx + 1], dec_fx ) ); move16(); } - nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ), n_samp_full ); - - IF( Opt_tsm ) + IF( interpolator_fx[idx + 1] > 0 ) { - /* note: this is stack memory buffer for TC decoded and also time-scale modified audio signals */ - IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); - } - set_zero_fx( hTcBuffer->tc_buffer_fx, nsamp_to_allocate ); - - offset = 0; - move16(); - FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; - offset = add( offset, n_samp_full ); - } - FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } - - /* memory buffer for TC audio samples not rendered in the previous frame */ - FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - IF( ( hTcBuffer->tc_buffer_old_fx[ch_idx] = (Word32 *) malloc( n_samp_residual * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); - } - set_zero_fx( hTcBuffer->tc_buffer_old_fx[ch_idx], n_samp_residual ); - } - FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + dec_fx = BASOP_Util_Divide1616_Scale( interpolator_fx[idx + 1], add( segment_len, 1 ), &dec_e ); + dec_fx = shr( dec_fx, sub( 15, dec_e ) ); // Q0 + FOR( ; idx >= 0; idx-- ) { - hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; + interpolator_fx[idx] = sub( interpolator_fx[idx + 1], dec_fx ); + move16(); } } - else + ELSE { - hTcBuffer->tc_buffer_fx = NULL; - - FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } - - FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) - { - hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; - } + set16_fx( interpolator_fx, 0, add( idx, 1 ) ); } - hTcBuffer->tc_buffer2_fx = NULL; - - return IVAS_ERR_OK; + return; } /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_audio_deallocate() + * ivas_dec_get_adapted_subframes() * - * deallocate TC audio buffer + * Get an interpolator that is adapted to (time scale modified) IVAS frame *--------------------------------------------------------------------------*/ -static void ivas_jbm_dec_tc_audio_deallocate_fx( - DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */ +void ivas_dec_get_adapted_subframes_fx( + const Word16 nCldfbTs, /* i : number of time slots in the current frame */ + Word16 *subframe_nbslots, /* i/o: subframe grid */ + Word16 *nb_subframes /* i/o: number of subframes in the frame */ ) { - Word16 ch_idx; + UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; + UWord16 nCldfbSlotsLocal = nCldfbTs; + move16(); + Word16 temp, temp_e; - IF( hTcBuffer != NULL ) + /* get last subframe size from previous frame, determine how many slots have to be processed + in the first subframe (i.e. potential leftover of a 5ms subframe) */ + nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) ); + *nb_subframes = 0; + move16(); + IF( nSlotsInFirstSubframe > 0 ) { - IF( hTcBuffer->tc_buffer_fx != NULL ) - { - FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } + *nb_subframes = 1; + move16(); + nCldfbSlotsLocal = sub( nCldfbSlotsLocal, nSlotsInFirstSubframe ); + } - free( hTcBuffer->tc_buffer_fx ); - hTcBuffer->tc_buffer_fx = NULL; - } + temp = BASOP_Util_Divide3232_Scale( L_add( nCldfbSlotsLocal, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1 ), PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, &temp_e ); + *nb_subframes = add( *nb_subframes, shr( temp, sub( 15, temp_e ) ) ); // Q0 + move16(); + nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; + move16(); - FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) - { - IF( hTcBuffer->tc_buffer_old_fx[ch_idx] != NULL ) - { - free( hTcBuffer->tc_buffer_old_fx[ch_idx] ); - hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; - } - } + set16_fx( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); + set16_fx( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); + + IF( nSlotsInFirstSubframe > 0 ) + { + subframe_nbslots[0] = nSlotsInFirstSubframe; + move16(); + } - IF( hTcBuffer->tc_buffer2_fx != NULL ) - { - free( hTcBuffer->tc_buffer2_fx ); - hTcBuffer->tc_buffer2_fx = NULL; - } + IF( nSlotsInLastSubframe > 0 ) + { + subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; + move16(); } return; } + /*--------------------------------------------------------------------------* - * ivas_dec_tc_buffer_open() + * ivas_dec_get_md_map() * - * Open and initialize transport channel buffer handle + * Get an meta data map adapted to a time scale modified IVAS frame *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_tc_buffer_open_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const Word16 nchan_transport_rend, /* i : number of TCs for rendering */ - const Word16 nchan_transport_internal, /* i : number of totally buffered channels */ - const Word16 nchan_full, /* i : number of channels to fully store */ - const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ +void ivas_dec_get_md_map_fx( + const Word16 default_len, /* i : default frame length in metadata slots */ + const Word16 len, /* i : length of the modified frames in metadata slots*/ + const Word16 subframe_len, /* i : default length of a subframe */ + const Word16 offset, /* i : current read offset into the MD buffer */ + const Word16 buf_len, /* i : length of the metadata buffer */ + Word16 *map /* o : metadata index map */ ) { - DECODER_TC_BUFFER_HANDLE hTcBuffer; - Word16 nMaxSlotsPerSubframe; - ivas_error error; - Word16 tmp, tmp_e; - - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + Word16 jbm_segment_len, map_idx, src_idx, src_idx_map; + Word32 dec_fx, src_idx_fx; + Word16 temp_e; + Word16 temp; + jbm_segment_len = shr( default_len, 1 ); - IF( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL ) + FOR( ( map_idx = len - 1, src_idx = default_len - 1 ); map_idx >= jbm_segment_len; ( map_idx--, src_idx-- ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + temp = BASOP_Util_Divide1616_Scale( src_idx, subframe_len, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); // Q0 + src_idx_map = s_max( 0, temp ); + map[map_idx] = add( offset, src_idx_map ) % buf_len; + move16(); } - hTcBuffer->tc_buffer_mode = tc_buffer_mode; - move16(); - hTcBuffer->nchan_transport_rend = nchan_transport_rend; - move16(); - hTcBuffer->nchan_transport_internal = nchan_transport_internal; - move16(); - hTcBuffer->nchan_buffer_full = nchan_full; - move16(); - hTcBuffer->n_samples_granularity = n_samples_granularity; - move16(); - hTcBuffer->n_samples_available = 0; - move16(); - hTcBuffer->n_samples_buffered = 0; - move16(); - hTcBuffer->n_samples_rendered = 0; - move16(); - hTcBuffer->slots_rendered = 0; - move16(); - hTcBuffer->subframes_rendered = 0; - move16(); - hTcBuffer->n_samples_discard = 0; - move16(); - hTcBuffer->n_samples_flushed = 0; - move16(); - hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; - move16(); - - /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); - tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); - nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ - - hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); - move16(); - - set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); - set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); - - IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + /* changed part (first segment), interpolate index to parameters + (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ + IF( src_idx >= 0 ) + { + dec_fx = BASOP_Util_Divide3232_Scale( L_shl( add( src_idx, 1 ), 16 ), jbm_segment_len, &temp_e ); + dec_fx = L_shr( dec_fx, sub( 15, temp_e ) ); + src_idx_fx = L_sub( L_shl( add( src_idx, 1 ), 16 ), dec_fx ); + FOR( ; map_idx >= 0; map_idx-- ) + { + temp = BASOP_Util_Divide1616_Scale( round_fx( src_idx_fx ), subframe_len, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); // Q0 + src_idx = s_max( 0, temp ); + map[map_idx] = add( offset, src_idx ) % buf_len; + src_idx_fx = L_sub( src_idx_fx, dec_fx ); + } + } + ELSE { - return error; + set16_fx( map, offset, add( map_idx, 1 ) ); } - st_ivas->hTcBuffer = hTcBuffer; - - return IVAS_ERR_OK; + return; } /*--------------------------------------------------------------------------* - * ivas_dec_tc_buffer_reconfigure() + * ivas_dec_get_md_map_even_spacing() * - * Reconfigure transport channel buffer handle + * Get an meta data map adapted to (time scale modified) IVAS frame. + * Distribute slots evenly across the (modified) frame. *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_tc_buffer_reconfigure_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const Word16 nchan_transport_rend, /* i : new number of TCs for rendering */ - const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ - const Word16 nchan_full, /* i : new number of channels to fully store */ - const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ +void ivas_dec_get_md_map_even_spacing_fx( + const Word16 len, /* i : length of the modified frames in metadata slots*/ + const Word16 subframe_len, /* i : default length of a subframe */ + const Word16 offset, /* i : current read offset into the MD buffer */ + const Word16 buf_len, /* i : length of the metadata buffer */ + Word16 *map /* o : metadata index map */ ) { - Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available; - Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1]; - ivas_error error; - DECODER_TC_BUFFER_HANDLE hTcBuffer; - - hTcBuffer = st_ivas->hTcBuffer; - move16(); - - num_tc_buffer_mem = 0; - move16(); - n_samples_still_available = 0; - move16(); + Word16 map_idx, sf_idx, sf_length, increment, subframes_written; + Word32 decimal_fx, decimal_sum_fx, eps_fx; // q = 16 + Word16 subframe_map_length[MAX_PARAM_SPATIAL_SUBFRAMES]; - IF( st_ivas->hDecoderConfig->Opt_tsm ) + /* subframe map length */ + sf_length = idiv1616( len, subframe_len ); + IF( len % subframe_len == 0 ) { - /* save samples of the TC buffer from the previous frame */ - num_tc_buffer_mem = s_min( hTcBuffer->nchan_transport_internal, nchan_transport_internal ); - n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); - - /* what is remaining from last frame needs always be smaller than the new granularity */ - assert( n_samples_still_available < n_samples_granularity ); - - FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ ) + /* even subframes */ + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx] + hTcBuffer->n_samples_flushed, tc_buffer_mem[ch_idx], n_samples_still_available ); + subframe_map_length[sf_idx] = sf_length; + move16(); } } - - /* if granularity changes, adapt subframe_nb_slots */ - IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) ) + ELSE { - Word16 nMaxSlotsPerSubframeNew; - Word16 tmp, tmp_e; - - /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */ - tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); - tmp = BASOP_Util_Divide1616_Scale( tmp, n_samples_granularity, &tmp_e ); - nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ + /* uneven subframes */ + Word32 temp; + Word16 temp_e; + temp = BASOP_Util_Divide3232_Scale( L_shl( len, 16 ), subframe_len, &temp_e ); + temp = L_shr( temp, sub( 15, temp_e ) ); // Q16 + decimal_fx = L_sub( temp, L_shl( sf_length, 16 ) ); // Q16 + decimal_sum_fx = decimal_fx; - /* if samples were flushed, take that into account here */ - test(); - IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 ) - { - hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = idiv1616( hTcBuffer->n_samples_flushed, n_samples_granularity ); - hTcBuffer->n_samples_flushed = 0; - move16(); - move16(); - } - ELSE + eps_fx = 65; + move32(); + move32(); + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = nMaxSlotsPerSubframeNew; + increment = extract_l( L_shr( L_add( decimal_sum_fx, eps_fx ), 16 ) ); + subframe_map_length[sf_idx] = add( sf_length, increment ); move16(); + IF( increment > 0 ) + { + decimal_sum_fx = L_sub( decimal_sum_fx, ONE_IN_Q16 ); + } + decimal_sum_fx = L_add( decimal_sum_fx, decimal_fx ); } } - hTcBuffer->tc_buffer_mode = tc_buffer_mode; - move16(); - hTcBuffer->nchan_transport_rend = nchan_transport_rend; - move16(); - hTcBuffer->nchan_transport_internal = nchan_transport_internal; - move16(); - hTcBuffer->nchan_buffer_full = nchan_full; + /* map slots to subframes */ + sf_idx = 0; + subframes_written = 0; move16(); - hTcBuffer->n_samples_granularity = n_samples_granularity; move16(); + FOR( map_idx = 0; map_idx < len; map_idx++ ) + { + map[map_idx] = add( offset, sf_idx ) % buf_len; + move16(); + IF( GE_16( sub( map_idx, subframes_written ), sub( subframe_map_length[sf_idx], 1 ) ) ) + { + subframes_written = add( subframes_written, subframe_map_length[sf_idx] ); + sf_idx = add( sf_idx, 1 ); + } + } + + return; +} - /* reallocate TC audio buffers */ - ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer ); +/*--------------------------------------------------------------------------* + * ivas_dec_get_render_granularity() + * + * Get renderer granularity + *--------------------------------------------------------------------------*/ + +/*! r: render granularity */ +Word16 ivas_dec_get_render_granularity_fx( + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const Word32 output_Fs /* i : sampling rate */ +) +{ + Word16 render_granularity; - IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + test(); + test(); + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || /* TD renderer */ + EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) || /* Crend */ + EQ_32( renderer_type_sec, RENDERER_BINAURAL_OBJECTS_TD ) /* TD rend as a secondary renderer -> set the common granularity for both renderers */ + ) { - return error; + /* 5 ms granularity */ + render_granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + move16(); } - - /* propagate samples of the TC buffer from the previous frame */ - FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ ) + ELSE { - Copy32( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old_fx[ch_idx], n_samples_still_available ); + /* 1.25 ms granularity */ + render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ); + move16(); } - return IVAS_ERR_OK; + return render_granularity; } @@ -3103,28 +1705,6 @@ static void ivas_dec_tc_buffer_playout_fx( } -/*--------------------------------------------------------------------------* - * ivas_dec_tc_buffer_close() - * - * Close transport channel buffer handle - *--------------------------------------------------------------------------*/ - -void ivas_dec_tc_buffer_close_fx( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ -) -{ - IF( *phTcBuffer != NULL ) - { - ivas_jbm_dec_tc_audio_deallocate_fx( *phTcBuffer ); - - free( *phTcBuffer ); - *phTcBuffer = NULL; - } - - return; -} - - /*--------------------------------------------------------------------------* * ivas_dec_td_renderers_adapt_subframes() * @@ -3202,105 +1782,6 @@ void ivas_dec_td_renderers_adapt_subframes_fx( } -/*--------------------------------------------------------------------------* - * ivas_dec_get_tc_buffer_mode() - * - * - *--------------------------------------------------------------------------*/ - -TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - TC_BUFFER_MODE buffer_mode; - - buffer_mode = TC_BUFFER_MODE_BUFFER; - move16(); - - SWITCH( st_ivas->renderer_type ) - { - /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */ - case RENDERER_DISABLE: - case RENDERER_MCMASA_MONO_STEREO: - case RENDERER_OSBA_STEREO: - case RENDERER_MONO_DOWNMIX: - buffer_mode = TC_BUFFER_MODE_BUFFER; - move16(); - BREAK; - case RENDERER_NON_DIEGETIC_DOWNMIX: - case RENDERER_TD_PANNING: - case RENDERER_BINAURAL_OBJECTS_TD: - case RENDERER_BINAURAL_FASTCONV: - case RENDERER_BINAURAL_FASTCONV_ROOM: - case RENDERER_BINAURAL_PARAMETRIC: - case RENDERER_BINAURAL_PARAMETRIC_ROOM: - case RENDERER_STEREO_PARAMETRIC: - case RENDERER_DIRAC: - case RENDERER_PARAM_ISM: - case RENDERER_BINAURAL_MIXER_CONV: - case RENDERER_BINAURAL_MIXER_CONV_ROOM: - case RENDERER_OMASA_OBJECT_EXT: - case RENDERER_OMASA_MIX_EXT: - case RENDERER_OSBA_AMBI: - case RENDERER_OSBA_LS: - buffer_mode = TC_BUFFER_MODE_RENDERER; - move16(); - BREAK; - case RENDERER_MC_PARAMMC: - IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) - { - buffer_mode = TC_BUFFER_MODE_BUFFER; /* TCs are already the DMX to mono or stereo */ - move16(); - } - ELSE - { - buffer_mode = TC_BUFFER_MODE_RENDERER; - move16(); - } - BREAK; - case RENDERER_MC: - if ( NE_16( ivas_dec_get_num_tc_channels_fx( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) ) - { - buffer_mode = TC_BUFFER_MODE_RENDERER; - move16(); - } - BREAK; - case RENDERER_SBA_LINEAR_ENC: - test(); - test(); - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) && ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( ( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), ( add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) ) - { - buffer_mode = TC_BUFFER_MODE_BUFFER; - move16(); - } - ELSE - { - buffer_mode = TC_BUFFER_MODE_RENDERER; - move16(); - } - BREAK; - case RENDERER_SBA_LINEAR_DEC: - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) - { - buffer_mode = TC_BUFFER_MODE_BUFFER; - move16(); - } - ELSE - { - buffer_mode = TC_BUFFER_MODE_RENDERER; - move16(); - } - BREAK; - } - - return buffer_mode; -} - - /*--------------------------------------------------------------------------* * ivas_jbm_dec_masa_metadata_open() * -- GitLab From a37e601cfab94976808a7f557a79567adead8bc4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 28 Jan 2026 16:07:31 +0100 Subject: [PATCH 639/750] [fix] missing sqrt in VectorLength_fx() --- lib_com/ivas_rotation_com_fx.c | 2 +- lib_com/options.h | 1 + lib_rend/ivas_orient_trk_fx.c | 19 ++++++++++++++++++- lib_util/vector3_pair_file_reader.c | 5 +++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 4106e5d05..917d901d8 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -113,7 +113,7 @@ void Copy_Quat_fx( /*------------------------------------------------------------------------- - * Scale_Quat_fx() + * modify_Quat_q_fx() * * Quaternion q factor modification *------------------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index e11d5dffa..2c8a0221f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,6 +111,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ #define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ +#define FIX_BASOP_2361_OTR /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 571106b6c..7b56efdd6 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -482,12 +482,22 @@ static Word32 VectorLength_fx( IVAS_VECTOR3 p, Word16 *q_fact ) { +#ifdef FIX_BASOP_2361_OTR + Word16 sqrt_e; +#endif Word32 result_fx = 0; move32(); result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31 +#ifdef FIX_BASOP_2361_OTR + sqrt_e = sub( 31, sub( add( p.q_fact, p.q_fact ), 31 ) ); /* convert Q to E */ + result_fx = Sqrt32( result_fx, &sqrt_e ); + *q_fact = sub( 31, sqrt_e ); /* back to Q again */ +#else *q_fact = sub( add( p.q_fact, p.q_fact ), 31 ); +#endif move16(); + return result_fx; } @@ -702,7 +712,14 @@ ivas_error ivas_orient_trk_SetReferenceRotation_fx( Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot ); modify_Quat_q_fx( &pOTR->refRot, &pOTR->refRot, Q29 ); } - pOTR->refRot = refRot; +#ifdef FIX_BASOP_2361_OTR + ELSE + { +#endif + pOTR->refRot = refRot; +#ifdef FIX_BASOP_2361_OTR + } +#endif return IVAS_ERR_OK; } diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index c6758b6b1..27a21d21e 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -114,8 +114,13 @@ ivas_error Vector3PairFileReader_read( pSecond->y = y2; pSecond->z = z2; +#ifdef FIX_BASOP_2361_OTR + pFirst->q_fact = 27; // Q27 + pSecond->q_fact = 27; // Q27 +#else pFirst->q_fact = 29; // Q29 pSecond->q_fact = 29; // Q29 +#endif pFirst->x_fx = floatToFixed_32( pFirst->x, pFirst->q_fact ); pFirst->y_fx = floatToFixed_32( pFirst->y, pFirst->q_fact ); pFirst->z_fx = floatToFixed_32( pFirst->z, pFirst->q_fact ); -- GitLab From 61180a9859283715d93ea04b8ee344521b9d15f4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 20:43:36 +0100 Subject: [PATCH 640/750] basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX --- lib_com/options.h | 1 + lib_dec/ivas_mct_dec_fx.c | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e11d5dffa..b8a91d440 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ +#define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index d44ebdb3f..676205a1b 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -214,22 +214,43 @@ ivas_error ivas_mct_dec_fx( } } +#ifndef FIX_2382_COPY_AQ_IN_MCT Word32 Aq_fx_32[6][2][102]; +#endif /* MCT reconstruction and CoreCoder updates */ FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { +#ifdef FIX_2382_COPY_AQ_IN_MCT + Word32 Aq_fx_32[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; +#endif hCPE = st_ivas->hCPE[cpe_id]; FOR( n = 0; n < CPE_CHANNELS; n++ ) { +#ifdef FIX_2382_COPY_AQ_IN_MCT + IF( NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + Word16 nSubframes; + + nSubframes = EQ_16( hCPE->hCoreCoder[n]->core, TCX_10_CORE ) ? NB_DIV : 1; /* Q0 */ + move16(); + + Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[n], i_mult( nSubframes, M ), Q16 - Q12 ); // Q16 + } +#else Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16 - x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 - x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 +#endif + x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 + x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 move16(); move16(); } +#ifdef FIX_2382_COPY_AQ_IN_MCT + ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32, 1, 20 ); +#else ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 ); +#endif } test(); -- GitLab From 20caaf8d402aa11e312058d8323dfbb2f60283ce Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 21:07:25 +0100 Subject: [PATCH 641/750] Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered --- lib_com/options.h | 1 + lib_dec/dec_tcx_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index e11d5dffa..6f12164eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ +#define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index e48affb21..ed170d598 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -1075,6 +1075,10 @@ void decoder_tcx_fx( Word16 predictionGain; /* not counted */ predictionGain = 0; move16(); +#ifdef FIX_2383_INIT_Q_A_ITF + Q_A_itf = 15; + move16(); +#endif FOR( j = startLine; j < endLine; j++ ) { -- GitLab From 889b97c4fa02e01176224b631954e6aa9e2cf71d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 28 Jan 2026 21:43:27 +0100 Subject: [PATCH 642/750] only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization --- lib_com/options.h | 1 + lib_dec/ivas_mc_param_dec_fx.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index e11d5dffa..99e1479b3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ +#define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index ea889cc7b..70b4b645c 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -3142,6 +3142,9 @@ static void ivas_param_mc_dequantize_cov_fx( const PARAM_MC_ILD_MAPPING *h_ild_mapping; Word32 Cy_state_int_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word16 Cy_state_int_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; +#ifdef FIX_2384_INIT_DEQUANT_COV + Word16 nY_norm; +#endif set16_fx( Cp_buf_e, Cproto_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); set32_fx( Nrqq_fx, 0, MAX_OUTPUT_CHANNELS ); @@ -3395,22 +3398,38 @@ static void ivas_param_mc_dequantize_cov_fx( Cyp_e += nY_cov; } } +#ifdef FIX_2384_INIT_DEQUANT_COV + nY_norm = nY_cov; + move16(); +#endif } ELSE { Copy32( Cy_state_int_fx, Cy_state_fx, imult1616( nY_int, nY_int ) ); Copy( Cy_state_int_e, Cy_buf_e, imult1616( nY_int, nY_int ) ); +#ifdef FIX_2384_INIT_DEQUANT_COV + nY_norm = nY_int; + move16(); +#endif } /*normalize output matrix to a common exponent*/ tmp = 0; +#ifdef FIX_2384_INIT_DEQUANT_COV + FOR( k = 0; k < nY_norm * nY_norm; k++ ) +#else FOR( k = 0; k < nY_int * nY_int; k++ ) +#endif { Cy_state_fx[k] = BASOP_Util_Add_Mant32Exp( Cy_state_fx[k], Cy_buf_e[k], 0, 0, &Cy_buf_e[k] ); move32(); tmp = s_max( tmp, Cy_buf_e[k] ); } +#ifdef FIX_2384_INIT_DEQUANT_COV + FOR( k = 0; k < nY_norm * nY_norm; k++ ) +#else FOR( k = 0; k < nY_int * nY_int; k++ ) +#endif { L_tmp = L_shr( Cy_state_fx[k], sub( tmp, Cy_buf_e[k] ) ); Cy_state_fx[k] = L_tmp; -- GitLab From 141573c95e8677e73c9338879456dcfdfcf32f96 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 29 Jan 2026 09:09:31 +0100 Subject: [PATCH 643/750] correct MASA DTX printout --- apps/encoder.c | 2 +- apps/encoder_fmtsw.c | 2 +- readme.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 4f7ea89bf..40a043fc8 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -2049,7 +2049,7 @@ static void usage_enc( void ) fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" ); - fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, SBA up to 80kbps and MASA up to 128kbps \n" ); + fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA (up to 80kbps)\n" ); fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" ); fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" ); fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" ); diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index da63039f3..c58d42fca 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -2152,7 +2152,7 @@ static void usage_enc( void ) fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" ); - fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, SBA up to 80kbps and MASA up to 128kbps \n" ); + fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA (up to 80kbps)\n" ); fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" ); fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" ); fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" ); diff --git a/readme.txt b/readme.txt index f30b97b28..0c83ee5e8 100644 --- a/readme.txt +++ b/readme.txt @@ -242,7 +242,7 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -dtx D : Activate DTX mode, D = (0, 3-100) is the SID update rate where 0 = adaptive, 3-100 = fixed in number of frames, default is deactivated -dtx : Activate DTX mode with a SID update rate of 8 frames - Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA up to 80kbps + Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA (up to 80kbps) -rf p o : Activate channel-aware mode in EVS for WB and SWB signal at 13.2kbps, where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames. Alternatively p and o can be replaced by a rf configuration file with each line -- GitLab From b079126b12e3e304ea1668e1f4699598ad64c54e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 29 Jan 2026 09:59:03 +0100 Subject: [PATCH 644/750] basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() --- lib_com/options.h | 1 + lib_dec/hq_hr_dec_fx.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index e11d5dffa..b308d494c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ +#define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 858306b17..bcc330d61 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -435,7 +435,10 @@ void hq_hr_dec_fx( move16(); HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; - +#ifdef FIX_2391_INIT_HQ_GENERIC_OFFSET + hq_generic_offset = 0; + move16(); +#endif move16(); Q_audio = 0; /* to avoid compilation warnings */ -- GitLab From c4b90a512e049429a56550cfecfb324c1fb5eeba Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 29 Jan 2026 10:14:20 +0100 Subject: [PATCH 645/750] replace ternary operator by if()-statement --- lib_dec/ivas_mct_dec_fx.c | 7 ++++++- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 676205a1b..81b41d175 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -232,8 +232,13 @@ ivas_error ivas_mct_dec_fx( { Word16 nSubframes; - nSubframes = EQ_16( hCPE->hCoreCoder[n]->core, TCX_10_CORE ) ? NB_DIV : 1; /* Q0 */ + nSubframes = 1; /* Q0 */ move16(); + if ( EQ_16( hCPE->hCoreCoder[n]->core, TCX_10_CORE ) ) + { + nSubframes = NB_DIV; + move16; + } Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[n], i_mult( nSubframes, M ), Q16 - Q12 ); // Q16 } diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 118baa38b..cb3173ea6 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -298,8 +298,19 @@ void stereo_mdct_core_dec_fx( FOR( ch = 0; ch < nChannels; ch++ ) { +#ifdef FIX_2382_COPY_AQ_IN_MCT + nSubframes[ch] = 1; /* Q0 */ + move16(); + + if ( EQ_16( sts[ch]->core, TCX_10_CORE ) ) + { + nSubframes[ch] = NB_DIV; + move16(); + } +#else nSubframes[ch] = EQ_16( sts[ch]->core, TCX_10_CORE ) ? NB_DIV : 1; /* Q0 */ move16(); +#endif FOR( k = 0; k < nSubframes[ch]; k++ ) { -- GitLab From 4de71fe54f1ab40465f1ca215a4d89f1f4575c8e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 29 Jan 2026 10:27:30 +0100 Subject: [PATCH 646/750] fix compilation --- lib_dec/ivas_mct_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 81b41d175..eb52b8ec1 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -237,7 +237,7 @@ ivas_error ivas_mct_dec_fx( if ( EQ_16( hCPE->hCoreCoder[n]->core, TCX_10_CORE ) ) { nSubframes = NB_DIV; - move16; + move16(); } Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[n], i_mult( nSubframes, M ), Q16 - Q12 ); // Q16 -- GitLab From 00b63e8b790d291a743d6cf4d1ca7e1106ae6fb0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 29 Jan 2026 12:26:06 +0100 Subject: [PATCH 647/750] restore bit-exactness --- lib_dec/core_switching_dec_fx.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 0f89d14b0..4873fe0a2 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -446,8 +446,10 @@ ivas_error core_switching_post_dec_fx( test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q11 ); /* Q10 */ +#else + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif core_switch_lb_upsamp_fx( st_fx, output_fx ); } @@ -998,11 +1000,7 @@ void core_switching_hq_prepare_dec_fx( static void core_switch_lb_upsamp_fx( Decoder_State *st, /* i/o: Decoder state */ -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 *output /* i/o: LB synth/upsampled LB synth Q11*/ -#else - Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ -#endif + Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ ) { Word16 i, no_col; @@ -1010,15 +1008,6 @@ static void core_switch_lb_upsamp_fx( Word32 realBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 output_tmp[L_FRAME16k]; - - /* save the original output "buffer" to ensure that it is not overwritten in this function */ - Copy32( output, output_tmp, s_min( st->L_frame, L_FRAME16k ) ); - - Scale_sig32( output, st->L_frame, Q10 - Q11 ); /* Q10 */ -#endif - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ FOR( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) { @@ -1101,7 +1090,7 @@ static void core_switch_lb_upsamp_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Copy32( output_tmp, output, imult1616( no_col, st->cldfbSyn->no_channels ) ); /* Q11 */ + Scale_sig32( output, imult1616( no_col, st->cldfbSyn->no_channels ), Q11 - Q4 ); /* Q11 */ #endif return; -- GitLab From afe02c933dedb9c65e1bb4727ee2c886465429ba Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 29 Jan 2026 14:04:08 +0100 Subject: [PATCH 648/750] update printout --- apps/encoder.c | 2 +- apps/encoder_fmtsw.c | 2 +- readme.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 40a043fc8..9e10a9c5c 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -2049,7 +2049,7 @@ static void usage_enc( void ) fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" ); - fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA (up to 80kbps)\n" ); + fprintf( stdout, " Note: DTX is supported on all bitrates for EVS, stereo, ISM, and MASA, and up to 80 kbps for SBA.\n" ); fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" ); fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" ); fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" ); diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index c58d42fca..12cc57349 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -2152,7 +2152,7 @@ static void usage_enc( void ) fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" ); - fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA (up to 80kbps)\n" ); + fprintf( stdout, " Note: DTX is supported on all bitrates for EVS, stereo, ISM, and MASA, and up to 80 kbps for SBA.\n" ); fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" ); fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" ); fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" ); diff --git a/readme.txt b/readme.txt index 0c83ee5e8..9e5b20aef 100644 --- a/readme.txt +++ b/readme.txt @@ -242,7 +242,7 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -dtx D : Activate DTX mode, D = (0, 3-100) is the SID update rate where 0 = adaptive, 3-100 = fixed in number of frames, default is deactivated -dtx : Activate DTX mode with a SID update rate of 8 frames - Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA (up to 80kbps) + Note: DTX is supported on all bitrates for EVS, stereo, ISM, and MASA, and up to 80 kbps for SBA. -rf p o : Activate channel-aware mode in EVS for WB and SWB signal at 13.2kbps, where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames. Alternatively p and o can be replaced by a rf configuration file with each line -- GitLab From 6150acc6f15a4e03f2073c8fc7cc9ed478d3535b Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 29 Jan 2026 14:50:14 +0100 Subject: [PATCH 649/750] clang format --- apps/decoder.c | 438 ++++++++++++++++++++++++------------------------- 1 file changed, 219 insertions(+), 219 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 24b45c2ee..b44e3a836 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -436,314 +436,314 @@ int main( goto cleanup; } - if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) - { - fprintf( stderr, "\nChanged render framesize, only 20ms allowed!\n" ); - } + if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms allowed!\n" ); } +} - /*------------------------------------------------------------------------------------------* - * Configure VoIP mode - *------------------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------------------* + * Configure VoIP mode + *------------------------------------------------------------------------------------------*/ - if ( arg.voipMode ) +if ( arg.voipMode ) +{ + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) { - if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } + fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; } +} - /*-----------------------------------------------------------------* - * Print config information - *-----------------------------------------------------------------*/ +/*-----------------------------------------------------------------* + * Print config information + *-----------------------------------------------------------------*/ + +if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ) ) != IVAS_ERR_OK ) +{ + fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; +} - if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ) ) != IVAS_ERR_OK ) +/*-------------------------------------------------------------------* + * Load renderer configuration from file + *--------------------------------------------------------------------*/ + +if ( arg.renderConfigEnabled ) +{ + /* sanity check */ + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && + arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.non_diegetic_pan_enabled == false ) { - fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); goto cleanup; } - /*-------------------------------------------------------------------* - * Load renderer configuration from file - *--------------------------------------------------------------------*/ + if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } - if ( arg.renderConfigEnabled ) + if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) { - /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && - arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - arg.non_diegetic_pan_enabled == false ) - { - fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); - goto cleanup; - } + fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", arg.renderConfigFilename ); + goto cleanup; + } - if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } + if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); + goto cleanup; + } - if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", arg.renderConfigFilename ); - goto cleanup; - } + aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); + if ( aeCount > 0 ) + { + uint32_t n; - if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) + pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA * ) ); + + if ( pAE == NULL ) { - fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); + fprintf( stderr, "\nError: cannot allocate memory for acoustic environment array\n\n" ); goto cleanup; } - aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); - if ( aeCount > 0 ) + for ( n = 0; n < aeCount; n++ ) { - uint32_t n; + pAE[n] = NULL; - pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA * ) ); - - if ( pAE == NULL ) + if ( NULL == ( pAE[n] = malloc( sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ) ) ) { - fprintf( stderr, "\nError: cannot allocate memory for acoustic environment array\n\n" ); + fprintf( stderr, "\nError: cannot allocate memory for acoustic environment\n\n" ); goto cleanup; } - - for ( n = 0; n < aeCount; n++ ) - { - pAE[n] = NULL; - - if ( NULL == ( pAE[n] = malloc( sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ) ) ) - { - fprintf( stderr, "\nError: cannot allocate memory for acoustic environment\n\n" ); - goto cleanup; - } - } - - if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, pAE ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Error while getting acoustic environments\n\n" ); - goto cleanup; - } - - for ( n = 0; n < aeCount; n++ ) - { - if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, *pAE[n] ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to add acoustic environments\n\n" ); - goto cleanup; - } - } } - if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity_fx ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); - goto cleanup; - } - if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt_fx ) ) != IVAS_ERR_OK ) + if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, pAE ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); + fprintf( stderr, "Error while getting acoustic environments\n\n" ); goto cleanup; } - if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + for ( n = 0; n < aeCount; n++ ) { - if ( asked_num_subframes != IVAS_RENDER_NUM_SUBFR_20MS && - ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - renderConfig.split_rend_config.dof == 0 ) ) - { - arg.render_num_subframes = asked_num_subframes; - } - else + if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, *pAE[n] ) ) != IVAS_ERR_OK ) { - arg.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; - } - - if ( ( error = IVAS_DEC_SetRenderNumSubfr( hIvasDec, arg.render_num_subframes ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_SetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "Failed to add acoustic environments\n\n" ); goto cleanup; } - - if ( arg.render_num_subframes != asked_num_subframes ) - { - fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); - } } + } - if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity_fx ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); + goto cleanup; + } + if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt_fx ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); + goto cleanup; + } + + if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( asked_num_subframes != IVAS_RENDER_NUM_SUBFR_20MS && + ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) { - if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) - { - if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Invalid reverberation configuration parameters\n\n" ); - goto cleanup; - } - } - else - { - fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); - goto cleanup; - } + arg.render_num_subframes = asked_num_subframes; + } + else + { + arg.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; } - /* ISAR frame size is set from command line, not renderer config file. - * This will be ignored if output format is not split rendering. */ - renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.render_num_subframes * 5; - - if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_SetRenderNumSubfr( hIvasDec, arg.render_num_subframes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nIVAS_DEC_SetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - } - /*------------------------------------------------------------------------------------------* - * Load custom loudspeaker layout data - *------------------------------------------------------------------------------------------*/ - - if ( arg.customLsOutputEnabled ) - { - IVAS_CUSTOM_LS_DATA hLsCustomData; - LS_CUSTOM_FILEREADER_ERROR lsCustomError; - - if ( ( lsCustomError = CustomLsFileReading( hLsCustomReader, &hLsCustomData ) ) != LS_CUSTOM_FILEREADER_NO_ERROR ) + if ( arg.render_num_subframes != asked_num_subframes ) { - fprintf( stderr, "\nError in reading Custom loudspeaker file %s: %s\n\n", arg.customLsSetupFilename, CustomLoudspeakerLayout_getError( lsCustomError ) ); - goto cleanup; + fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } - for ( int16_t i = 0; i < IVAS_MAX_LS_CHANNELS; i++ ) + } + + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { - hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) ); - hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) ); + if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Invalid reverberation configuration parameters\n\n" ); + goto cleanup; + } } - if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK ) + else { - fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); goto cleanup; } } - /*------------------------------------------------------------------------------------------* - * Initialize HRTF binary file data - *------------------------------------------------------------------------------------------*/ + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.render_num_subframes * 5; - if ( arg.hrtfReaderEnabled ) + if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { - hHrtfBinary.hrtfReader = hrtfReader; - hHrtfBinary.hrtfFileName = arg.hrtfFileName; - hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; - hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; - hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; + fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; } +} - /*------------------------------------------------------------------------------------------* - * Allocate output data buffer - *------------------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------------------* + * Load custom loudspeaker layout data + *------------------------------------------------------------------------------------------*/ - int16_t pcmBufSize; - if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmBufSize ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nGetOutputBufferSize failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } +if ( arg.customLsOutputEnabled ) +{ + IVAS_CUSTOM_LS_DATA hLsCustomData; + LS_CUSTOM_FILEREADER_ERROR lsCustomError; - pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); - if ( pcmBuf == NULL ) + if ( ( lsCustomError = CustomLsFileReading( hLsCustomReader, &hLsCustomData ) ) != LS_CUSTOM_FILEREADER_NO_ERROR ) { - fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); + fprintf( stderr, "\nError in reading Custom loudspeaker file %s: %s\n\n", arg.customLsSetupFilename, CustomLoudspeakerLayout_getError( lsCustomError ) ); goto cleanup; } - - /*-----------------------------------------------------------------* - * Decoding - *-----------------------------------------------------------------*/ - - if ( arg.voipMode ) + for ( int16_t i = 0; i < IVAS_MAX_LS_CHANNELS; i++ ) { - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf ); + hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) ); + hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) ); } - else + if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK ) { - error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); + fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; } +} + +/*------------------------------------------------------------------------------------------* + * Initialize HRTF binary file data + *------------------------------------------------------------------------------------------*/ + +if ( arg.hrtfReaderEnabled ) +{ + hHrtfBinary.hrtfReader = hrtfReader; + hHrtfBinary.hrtfFileName = arg.hrtfFileName; + hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; + hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; + hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; +} + +/*------------------------------------------------------------------------------------------* + * Allocate output data buffer + *------------------------------------------------------------------------------------------*/ - if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) +int16_t pcmBufSize; +if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmBufSize ) ) != IVAS_ERR_OK ) +{ + fprintf( stderr, "\nGetOutputBufferSize failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; +} + +pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); +if ( pcmBuf == NULL ) +{ + fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); + goto cleanup; +} + +/*-----------------------------------------------------------------* + * Decoding + *-----------------------------------------------------------------*/ + +if ( arg.voipMode ) +{ + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf ); +} +else +{ + error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); +} + +if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) +{ + if ( arg.quietModeEnabled ) { - if ( arg.quietModeEnabled ) - { - fprintf( stdout, "Decoding finished\n\n" ); - } - else - { - fprintf( stdout, "\nDecoding of %d frames finished\n\n", frame ); - } + fprintf( stdout, "Decoding finished\n\n" ); } else { - fprintf( stderr, "\nDecoding finished prematurely: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; + fprintf( stdout, "\nDecoding of %d frames finished\n\n", frame ); } +} +else +{ + fprintf( stderr, "\nDecoding finished prematurely: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; +} - /*------------------------------------------------------------------------------------------* - * Close files and deallocate resources - *------------------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ - mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ +mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ -cleanup: +cleanup : free( pcmBuf ); - if ( pAE != NULL ) - { - uint16_t n; - - for ( n = 0; n < aeCount; n++ ) - { - free( pAE[n] ); - } - - free( pAE ); - } +if ( pAE != NULL ) +{ + uint16_t n; - if ( arg.aeSequence.count > 0 ) + for ( n = 0; n < aeCount; n++ ) { - free( arg.aeSequence.pID ); - free( arg.aeSequence.pValidity ); + free( pAE[n] ); } - IVAS_DEC_Close( &hIvasDec ); - CustomLsReader_close( &hLsCustomReader ); - hrtfFileReader_close( &hrtfReader ); - RotationFileReader_close( &headRotReader ); - RotationFileReader_close( &externalOrientationFileReader ); - RotationFileReader_close( &refRotReader ); - Vector3PairFileReader_close( &referenceVectorReader ); - RenderConfigReader_close( &renderConfigReader ); - ObjectEditFileReader_close( &objectEditFileReader ); + free( pAE ); +} - if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError while closing file: %s\nContinuing...\n\n", arg.inputBitstreamFilename ); - } +if ( arg.aeSequence.count > 0 ) +{ + free( arg.aeSequence.pID ); + free( arg.aeSequence.pValidity ); +} + +IVAS_DEC_Close( &hIvasDec ); +CustomLsReader_close( &hLsCustomReader ); +hrtfFileReader_close( &hrtfReader ); +RotationFileReader_close( &headRotReader ); +RotationFileReader_close( &externalOrientationFileReader ); +RotationFileReader_close( &refRotReader ); +Vector3PairFileReader_close( &referenceVectorReader ); +RenderConfigReader_close( &renderConfigReader ); +ObjectEditFileReader_close( &objectEditFileReader ); + +if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK ) +{ + fprintf( stderr, "\nError while closing file: %s\nContinuing...\n\n", arg.inputBitstreamFilename ); +} #ifdef WMOPS - print_wmops(); - print_mem( NULL ); +print_wmops(); +print_mem( NULL ); #endif - if ( !arg.quietModeEnabled ) - { - printf( "\n" ); - } +if ( !arg.quietModeEnabled ) +{ + printf( "\n" ); +} - return mainFailed ? -1 : 0; +return mainFailed ? -1 : 0; } -- GitLab From 6a11d3f99751ad9480410704674e91527fc6cc4b Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 29 Jan 2026 15:28:03 +0100 Subject: [PATCH 650/750] remove superfluous } --- apps/decoder.c | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index b44e3a836..32dde14fe 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -440,7 +440,6 @@ int main( { fprintf( stderr, "\nChanged render framesize, only 20ms allowed!\n" ); } -} /*------------------------------------------------------------------------------------------* * Configure VoIP mode -- GitLab From e6f860be6395e2bdc989805f798397a06919eb57 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 29 Jan 2026 15:30:38 +0100 Subject: [PATCH 651/750] clang format --- apps/decoder.c | 430 ++++++++++++++++++++++++------------------------- 1 file changed, 215 insertions(+), 215 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 32dde14fe..be38d4e85 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -441,308 +441,308 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms allowed!\n" ); } -/*------------------------------------------------------------------------------------------* - * Configure VoIP mode - *------------------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------------------* + * Configure VoIP mode + *------------------------------------------------------------------------------------------*/ -if ( arg.voipMode ) -{ - if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) + if ( arg.voipMode ) { - fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } } -} - -/*-----------------------------------------------------------------* - * Print config information - *-----------------------------------------------------------------*/ -if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ) ) != IVAS_ERR_OK ) -{ - fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; -} - -/*-------------------------------------------------------------------* - * Load renderer configuration from file - *--------------------------------------------------------------------*/ - -if ( arg.renderConfigEnabled ) -{ - /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && - arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - arg.non_diegetic_pan_enabled == false ) - { - fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); - goto cleanup; - } + /*-----------------------------------------------------------------* + * Print config information + *-----------------------------------------------------------------*/ - if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", arg.renderConfigFilename ); - goto cleanup; - } + /*-------------------------------------------------------------------* + * Load renderer configuration from file + *--------------------------------------------------------------------*/ - if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) + if ( arg.renderConfigEnabled ) { - fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); - goto cleanup; - } + /* sanity check */ + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && + arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.non_diegetic_pan_enabled == false ) + { + fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); + goto cleanup; + } - aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); - if ( aeCount > 0 ) - { - uint32_t n; + if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } - pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA * ) ); + if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", arg.renderConfigFilename ); + goto cleanup; + } - if ( pAE == NULL ) + if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError: cannot allocate memory for acoustic environment array\n\n" ); + fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); goto cleanup; } - for ( n = 0; n < aeCount; n++ ) + aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); + if ( aeCount > 0 ) { - pAE[n] = NULL; + uint32_t n; - if ( NULL == ( pAE[n] = malloc( sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ) ) ) + pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA * ) ); + + if ( pAE == NULL ) { - fprintf( stderr, "\nError: cannot allocate memory for acoustic environment\n\n" ); + fprintf( stderr, "\nError: cannot allocate memory for acoustic environment array\n\n" ); goto cleanup; } + + for ( n = 0; n < aeCount; n++ ) + { + pAE[n] = NULL; + + if ( NULL == ( pAE[n] = malloc( sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ) ) ) + { + fprintf( stderr, "\nError: cannot allocate memory for acoustic environment\n\n" ); + goto cleanup; + } + } + + if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, pAE ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error while getting acoustic environments\n\n" ); + goto cleanup; + } + + for ( n = 0; n < aeCount; n++ ) + { + if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, *pAE[n] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to add acoustic environments\n\n" ); + goto cleanup; + } + } } - if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, pAE ) ) != IVAS_ERR_OK ) + if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity_fx ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); + goto cleanup; + } + if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt_fx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error while getting acoustic environments\n\n" ); + fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); goto cleanup; } - for ( n = 0; n < aeCount; n++ ) + if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, *pAE[n] ) ) != IVAS_ERR_OK ) + if ( asked_num_subframes != IVAS_RENDER_NUM_SUBFR_20MS && + ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) { - fprintf( stderr, "Failed to add acoustic environments\n\n" ); - goto cleanup; + arg.render_num_subframes = asked_num_subframes; + } + else + { + arg.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; } - } - } - if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity_fx ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); - goto cleanup; - } - if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt_fx ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); - goto cleanup; - } + if ( ( error = IVAS_DEC_SetRenderNumSubfr( hIvasDec, arg.render_num_subframes ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_SetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } - if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - if ( asked_num_subframes != IVAS_RENDER_NUM_SUBFR_20MS && - ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - renderConfig.split_rend_config.dof == 0 ) ) - { - arg.render_num_subframes = asked_num_subframes; - } - else - { - arg.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; + if ( arg.render_num_subframes != asked_num_subframes ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); + } } - if ( ( error = IVAS_DEC_SetRenderNumSubfr( hIvasDec, arg.render_num_subframes ) ) != IVAS_ERR_OK ) + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - fprintf( stderr, "\nIVAS_DEC_SetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; + if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) + { + if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Invalid reverberation configuration parameters\n\n" ); + goto cleanup; + } + } + else + { + fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); + goto cleanup; + } } - if ( arg.render_num_subframes != asked_num_subframes ) + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.render_num_subframes * 5; + + if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); + fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; } } - if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + /*------------------------------------------------------------------------------------------* + * Load custom loudspeaker layout data + *------------------------------------------------------------------------------------------*/ + + if ( arg.customLsOutputEnabled ) { - if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) + IVAS_CUSTOM_LS_DATA hLsCustomData; + LS_CUSTOM_FILEREADER_ERROR lsCustomError; + + if ( ( lsCustomError = CustomLsFileReading( hLsCustomReader, &hLsCustomData ) ) != LS_CUSTOM_FILEREADER_NO_ERROR ) { - if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Invalid reverberation configuration parameters\n\n" ); - goto cleanup; - } + fprintf( stderr, "\nError in reading Custom loudspeaker file %s: %s\n\n", arg.customLsSetupFilename, CustomLoudspeakerLayout_getError( lsCustomError ) ); + goto cleanup; } - else + for ( int16_t i = 0; i < IVAS_MAX_LS_CHANNELS; i++ ) + { + hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) ); + hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) ); + } + if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); + fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } - /* ISAR frame size is set from command line, not renderer config file. - * This will be ignored if output format is not split rendering. */ - renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.render_num_subframes * 5; + /*------------------------------------------------------------------------------------------* + * Initialize HRTF binary file data + *------------------------------------------------------------------------------------------*/ - if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) + if ( arg.hrtfReaderEnabled ) { - fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; + hHrtfBinary.hrtfReader = hrtfReader; + hHrtfBinary.hrtfFileName = arg.hrtfFileName; + hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; + hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; + hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; } -} -/*------------------------------------------------------------------------------------------* - * Load custom loudspeaker layout data - *------------------------------------------------------------------------------------------*/ - -if ( arg.customLsOutputEnabled ) -{ - IVAS_CUSTOM_LS_DATA hLsCustomData; - LS_CUSTOM_FILEREADER_ERROR lsCustomError; + /*------------------------------------------------------------------------------------------* + * Allocate output data buffer + *------------------------------------------------------------------------------------------*/ - if ( ( lsCustomError = CustomLsFileReading( hLsCustomReader, &hLsCustomData ) ) != LS_CUSTOM_FILEREADER_NO_ERROR ) + int16_t pcmBufSize; + if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmBufSize ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in reading Custom loudspeaker file %s: %s\n\n", arg.customLsSetupFilename, CustomLoudspeakerLayout_getError( lsCustomError ) ); + fprintf( stderr, "\nGetOutputBufferSize failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - for ( int16_t i = 0; i < IVAS_MAX_LS_CHANNELS; i++ ) - { - hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) ); - hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) ); - } - if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK ) + + pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); + if ( pcmBuf == NULL ) { - fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); goto cleanup; } -} - -/*------------------------------------------------------------------------------------------* - * Initialize HRTF binary file data - *------------------------------------------------------------------------------------------*/ - -if ( arg.hrtfReaderEnabled ) -{ - hHrtfBinary.hrtfReader = hrtfReader; - hHrtfBinary.hrtfFileName = arg.hrtfFileName; - hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; - hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; - hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; -} - -/*------------------------------------------------------------------------------------------* - * Allocate output data buffer - *------------------------------------------------------------------------------------------*/ - -int16_t pcmBufSize; -if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmBufSize ) ) != IVAS_ERR_OK ) -{ - fprintf( stderr, "\nGetOutputBufferSize failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; -} - -pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); -if ( pcmBuf == NULL ) -{ - fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); - goto cleanup; -} -/*-----------------------------------------------------------------* - * Decoding - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * Decoding + *-----------------------------------------------------------------*/ -if ( arg.voipMode ) -{ - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf ); -} -else -{ - error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); -} + if ( arg.voipMode ) + { + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf ); + } + else + { + error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); + } -if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) -{ - if ( arg.quietModeEnabled ) + if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) { - fprintf( stdout, "Decoding finished\n\n" ); + if ( arg.quietModeEnabled ) + { + fprintf( stdout, "Decoding finished\n\n" ); + } + else + { + fprintf( stdout, "\nDecoding of %d frames finished\n\n", frame ); + } } else { - fprintf( stdout, "\nDecoding of %d frames finished\n\n", frame ); + fprintf( stderr, "\nDecoding finished prematurely: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; } -} -else -{ - fprintf( stderr, "\nDecoding finished prematurely: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; -} -/*------------------------------------------------------------------------------------------* - * Close files and deallocate resources - *------------------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ -mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ + mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ -cleanup : +cleanup: free( pcmBuf ); -if ( pAE != NULL ) -{ - uint16_t n; - - for ( n = 0; n < aeCount; n++ ) + if ( pAE != NULL ) { - free( pAE[n] ); + uint16_t n; + + for ( n = 0; n < aeCount; n++ ) + { + free( pAE[n] ); + } + + free( pAE ); } - free( pAE ); -} + if ( arg.aeSequence.count > 0 ) + { + free( arg.aeSequence.pID ); + free( arg.aeSequence.pValidity ); + } -if ( arg.aeSequence.count > 0 ) -{ - free( arg.aeSequence.pID ); - free( arg.aeSequence.pValidity ); -} + IVAS_DEC_Close( &hIvasDec ); + CustomLsReader_close( &hLsCustomReader ); + hrtfFileReader_close( &hrtfReader ); + RotationFileReader_close( &headRotReader ); + RotationFileReader_close( &externalOrientationFileReader ); + RotationFileReader_close( &refRotReader ); + Vector3PairFileReader_close( &referenceVectorReader ); + RenderConfigReader_close( &renderConfigReader ); + ObjectEditFileReader_close( &objectEditFileReader ); -IVAS_DEC_Close( &hIvasDec ); -CustomLsReader_close( &hLsCustomReader ); -hrtfFileReader_close( &hrtfReader ); -RotationFileReader_close( &headRotReader ); -RotationFileReader_close( &externalOrientationFileReader ); -RotationFileReader_close( &refRotReader ); -Vector3PairFileReader_close( &referenceVectorReader ); -RenderConfigReader_close( &renderConfigReader ); -ObjectEditFileReader_close( &objectEditFileReader ); - -if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK ) -{ - fprintf( stderr, "\nError while closing file: %s\nContinuing...\n\n", arg.inputBitstreamFilename ); -} + if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError while closing file: %s\nContinuing...\n\n", arg.inputBitstreamFilename ); + } #ifdef WMOPS -print_wmops(); -print_mem( NULL ); + print_wmops(); + print_mem( NULL ); #endif -if ( !arg.quietModeEnabled ) -{ - printf( "\n" ); -} + if ( !arg.quietModeEnabled ) + { + printf( "\n" ); + } -return mainFailed ? -1 : 0; + return mainFailed ? -1 : 0; } -- GitLab From 7e28203d9181cb4b691344f161445293437d2547 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 29 Jan 2026 15:43:16 +0100 Subject: [PATCH 652/750] increase config_str length --- lib_rend/lib_rend_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 527a1b564..3a17884d4 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -11294,7 +11294,7 @@ static ivas_error printConfigInfo_rend( ) { ivas_error error; - Word8 config_str[50]; + Word8 config_str[200]; /*-----------------------------------------------------------------* * Print output audio configuration @@ -11345,7 +11345,7 @@ void IVAS_REND_PrintInputConfig( const IVAS_AUDIO_CONFIG inputConfig /* i : input audio configuration */ ) { - Word8 config_str[50]; + Word8 config_str[200]; get_channel_config( inputConfig, &config_str[0] ); fprintf( stdout, "Input configuration: %s\n", config_str ); -- GitLab From d184787e1e523db3ccbcb299e1be1fb056c354e0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 29 Jan 2026 17:02:15 +0100 Subject: [PATCH 653/750] HARM_BWE --- lib_com/ivas_prot_fx.h | 3 +- lib_com/options.h | 1 + lib_com/prot_fx.h | 5 + lib_dec/evs_dec_fx.c | 8 + lib_dec/ivas_core_dec_fx.c | 9 + lib_dec/swb_tbe_dec_fx.c | 236 ++++++++++++--- lib_enc/evs_enc_fx.c | 5 +- lib_enc/prot_fx_enc.h | 6 +- lib_enc/swb_tbe_enc_fx.c | 592 ++++++++++++++++++++++++++++--------- 9 files changed, 679 insertions(+), 186 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4e380b17c..933aebfbb 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1865,6 +1865,7 @@ void stereoFdCngCoherence_fx( Word16 fft_exp ); +#ifndef HARM_BWE void ivas_wb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -1874,7 +1875,7 @@ void ivas_wb_tbe_dec_fx( Word16 *synth, /* o : WB synthesis/final synthesis */ Word16 *Q_synth ); - +#endif void GenShapedWBExcitation_ivas_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ diff --git a/lib_com/options.h b/lib_com/options.h index e11d5dffa..05f9cdff3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ +#define HARM_BWE /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 3b93fda3b..699b23077 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5789,6 +5789,7 @@ void ivas_dequantizeSHBparams_fx_9_1( Word16 *MSFlag ); void fb_tbe_dec_fx( +#ifndef HARM_BWE Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ Word16 Q_fb_exc, @@ -5796,9 +5797,13 @@ void fb_tbe_dec_fx( Word16 hb_synth_exp ); void fb_tbe_dec_ivas_fx( +#endif Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ Word16 Q_fb_exc, +#ifdef HARM_BWE + Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ +#endif Word32 *hb_synth, /* o : high-band synthesis */ Word16 hb_synth_exp, Word16 *fb_synth_ref, diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index f320e323f..ecec2727f 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -408,7 +408,11 @@ ivas_error evs_dec_fx( test(); IF( EQ_16( output_frame, L_FRAME48k ) && EQ_16( st_fx->extl, FB_TBE ) ) { +#ifdef HARM_BWE + fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame ); +#else fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp ); +#endif } } ELSE IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) || @@ -843,7 +847,11 @@ ivas_error evs_dec_fx( test(); IF( EQ_16( st_fx->extl, FB_TBE ) && EQ_16( output_frame, L_FRAME48k ) ) { +#ifdef HARM_BWE + fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame ); +#else fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp ); +#endif } } Copy( hb_synth_fx, hBWE_TD->old_hb_synth_fx, output_frame ); /*Q15 - hb_synth_fx_exp*/ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 9838195cc..623a6bca6 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1013,7 +1013,11 @@ ivas_error ivas_core_dec_fx( IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE decoder */ +#ifdef HARM_BWE + wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx ); +#else ivas_wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx ); +#endif } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( n, 1 ) && !tdm_LRTD_flag && NE_16( st->extl, -1 ) && st->bws_cnt == 0 && st->extl_brate == 0 ) { @@ -1077,7 +1081,12 @@ ivas_error ivas_core_dec_fx( /* FB TBE decoder */ IF( EQ_16( st->extl, FB_TBE ) ) { +#ifdef HARM_BWE + fb_tbe_dec_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, NULL, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); +#else + fb_tbe_dec_ivas_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); +#endif } } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) || flag_bwe_bws ) diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index b9fb6f1b7..6767fe480 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -594,13 +594,18 @@ void ResetSHBbuffer_Dec_fx( /*--------------------------------------------------------------------------*/ /* CALLED FROM : */ /*==========================================================================*/ + +#ifdef HARM_BWE +void wb_tbe_dec_fx( +#else void ivas_wb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type Q0 */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ - const Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors Q15 */ - Word16 *synth, /* o : WB synthesis/final synthesis Q_synth */ +#endif + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type Q0 */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc */ + const Word16 Q_exc, /* i : Q_exc factor */ + const Word16 voice_factors[], /* i : voicing factors Q15 */ + Word16 *synth, /* o : WB synthesis/final synthesis Q_synth */ Word16 *Q_synth ) { Word16 i; @@ -750,9 +755,18 @@ void ivas_wb_tbe_dec_fx( } ELSE { - /* de-quantization */ - Word16 ignore; - ivas_dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &ignore ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0 ); + } + ELSE + { +#endif + /* de-quantization */ + Word16 ignore; + ivas_dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &ignore ); + } } } ELSE @@ -835,9 +849,21 @@ void ivas_wb_tbe_dec_fx( /* From low band excitation, generate highband excitation */ Lmax = 0; move32(); - FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { - Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) ); + FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + { + Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) ); + } + } + ELSE +#endif + { + FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ ) + { + Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) ); + } } IF( Lmax == 0 ) { @@ -848,7 +874,16 @@ void ivas_wb_tbe_dec_fx( { Q_bwe_exc = norm_l( Lmax ); } - Q_bwe_exc = sub( Q_bwe_exc, 3 ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + Q_bwe_exc = sub( Q_bwe_exc, 1 ); + } + ELSE +#endif + { + Q_bwe_exc = sub( Q_bwe_exc, 3 ); + } Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) ); find_max_mem_wb( st_fx, &n_mem ); @@ -865,38 +900,82 @@ void ivas_wb_tbe_dec_fx( move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */ } - W_tmp = 0; - move64(); - IF( st_fx->element_mode > EVS_MONO ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { - tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); - W_tmp = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ + prev_pow = 0; + move32(); + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + prev_pow = L_mac0_sat( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ + } } - FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + ELSE +#endif { - W_tmp = W_mac_16_16( W_tmp, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16 + 1))*/ + W_tmp = 0; + move64(); + tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); + W_tmp = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + W_tmp = W_mac_16_16( W_tmp, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16 + 1))*/ + } + exp = W_norm( W_tmp ); + prev_pow = W_extract_h( W_shl( W_tmp, exp ) ); + exp = sub( add( add( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 1 ), exp ), 32 ); } - exp = W_norm( W_tmp ); - prev_pow = W_extract_h( W_shl( W_tmp, exp ) ); - exp = sub( add( add( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 1 ), exp ), 32 ); rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET ); + } +#endif + sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); - FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { - bwe_exc_extended_16[cnt] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); - move16(); + FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + { + bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) ); + } + Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); + } + + ELSE +#endif + { + FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ ) + { + bwe_exc_extended_16[cnt] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); + move16(); + } } Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 ); Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); - GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, - hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, - hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, - bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, + hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, + hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, + bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); + } + ELSE +#endif + { + GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, + hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, + hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, + bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); + } curr_pow = 0; move32(); @@ -915,8 +994,16 @@ void ivas_wb_tbe_dec_fx( curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */ } - Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, - exp, &exp ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp ); + } + ELSE +#endif + { + Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, exp, &exp ); + } FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { @@ -932,7 +1019,6 @@ void ivas_wb_tbe_dec_fx( /* Update SHB excitation */ Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); - /* Adjust the subframe and frame gain of the synthesized shb signal */ /* Scale the shaped excitation */ ScaleShapedWB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, @@ -941,9 +1027,21 @@ void ivas_wb_tbe_dec_fx( max = 0; move16(); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + FOR( i = 0; i < L_FRAME16k / 4; i++ ) + { + max = s_max( max, shaped_wb_excitation[i] ); /*Q0*/ + } + } + ELSE +#endif { - max = s_max( max, abs_s( shaped_wb_excitation[i] ) ); + FOR( i = 0; i < L_FRAME16k / 4; i++ ) + { + max = s_max( max, abs_s( shaped_wb_excitation[i] ) ); + } } IF( max == 0 ) @@ -985,8 +1083,12 @@ void ivas_wb_tbe_dec_fx( } test(); - test(); - IF( !st_fx->bfi && ( st_fx->prev_bfi || st_fx->prev_use_partial_copy ) ) +#ifdef HARM_BWE + IF( !st_fx->bfi && st_fx->prev_bfi ) +#else + test(); + IF( !st_fx->bfi && ( st_fx->prev_bfi || st_fx->prev_use_partial_copy ) ) +#endif { IF( GT_32( L_shr( curr_frame_pow, 1 ), hBWE_TD->prev_wb_bwe_frame_pow_fx ) ) { @@ -1063,13 +1165,17 @@ void ivas_wb_tbe_dec_fx( FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ ) { if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] ), max ) ) + { max = abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] ); + } } FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ ) { if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] ), max ) ) + { max = abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] ); + } } IF( EQ_32( st_fx->output_Fs, 32000 ) ) @@ -1178,10 +1284,21 @@ void ivas_wb_tbe_dec_fx( } ELSE IF( EQ_32( st_fx->output_Fs, 48000 ) ) { - Copy_Scale_sig_16_32_no_sat( synth, tmp_synL, L_FRAME48k, sub( Q11, Qx ) ); - interpolate_3_over_1_allpass_fx32( tmp_synL, L_FRAME16k, upsampled_synth_32fx, hBWE_TD->mem_resamp_HB_fx_32 ); - Copy_Scale_sig_32_16( hBWE_TD->mem_resamp_HB_fx_32, hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, Q11 ) ); - Copy_Scale_sig_32_16( upsampled_synth_32fx, synth, L_FRAME48k, sub( Qx, Q11 ) ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + Scale_sig( hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, hBWE_TD->prev_Qx ) ); + interpolate_3_over_1_allpass_fx( synth, L_FRAME16k, upsampled_synth, hBWE_TD->mem_resamp_HB_fx ); + Copy( upsampled_synth, synth, L_FRAME48k ); + } + ELSE +#endif + { + Copy_Scale_sig_16_32_no_sat( synth, tmp_synL, L_FRAME48k, sub( Q11, Qx ) ); + interpolate_3_over_1_allpass_fx32( tmp_synL, L_FRAME16k, upsampled_synth_32fx, hBWE_TD->mem_resamp_HB_fx_32 ); + Copy_Scale_sig_32_16( hBWE_TD->mem_resamp_HB_fx_32, hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, Q11 ) ); + Copy_Scale_sig_32_16( upsampled_synth_32fx, synth, L_FRAME48k, sub( Qx, Q11 ) ); + } } } ELSE @@ -1238,7 +1355,7 @@ void ivas_wb_tbe_dec_fx( return; } - +#ifndef HARM_BWE void wb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -1877,7 +1994,7 @@ void wb_tbe_dec_fx( return; } - +#endif /*======================================================================================*/ /* FUNCTION : void swb_tbe_dec_fx () */ @@ -1896,13 +2013,14 @@ void wb_tbe_dec_fx( /* _(Word16*)White_exc16k : shaped white excitation for the FB TBE Q_synth */ /*--------------------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ Decoder_State *st_fx: : Decoder state structure */ +/* _ Decoder_State *st_fx: : Decoder state structure */ /*--------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* CALLED FROM : RX */ /*======================================================================================*/ + void swb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -4635,7 +4753,9 @@ static void dequantizeSHBparams_fx_9_1( * * FB TBE decoder, 14(resp. 15.5) - 20 kHz band decoding module *-------------------------------------------------------------------*/ + void fb_tbe_dec_fx( +#ifndef HARM_BWE Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ Word16 Q_fb_exc, @@ -4690,9 +4810,13 @@ void fb_tbe_dec_fx( } void fb_tbe_dec_ivas_fx( +#endif Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ Word16 Q_fb_exc, +#ifdef HARM_BWE + Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ +#endif Word32 *hb_synth, /* o : high-band synthesis Q(15 - hb_synth_exp) */ Word16 hb_synth_exp, Word16 *fb_synth_ref, /*Q_fb_synth_ref*/ @@ -4754,17 +4878,31 @@ void fb_tbe_dec_ivas_fx( { Copy_Scale_sig( fb_synth, fb_synth_ref, L_FRAME48k, sub( Q_fb_synth_ref, add( hb_synth_exp, 16 ) ) ); // scaling is required } - /* add the fb_synth component to the hb_synth component */ - /* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/ - FOR( i = 0; i < L_FRAME48k; i++ ) + +/* add the fb_synth component to the hb_synth component */ +#ifdef HARM_BWE + IF( st->element_mode == EVS_MONO ) { - // hb_synth[i] = L_add( hb_synth[i], L_deposit_l(fb_synth[i])); - hb_synth[i] = L_add( hb_synth[i], L_shl( fb_synth[i], Q11 ) ); // hb_synth_exp - move16(); + FOR( i = 0; i < L_FRAME48k; i++ ) + { + hb_synth16[i] = add_sat( hb_synth16[i], fb_synth[i] ); + move16(); + } } + ELSE +#endif + { + FOR( i = 0; i < L_FRAME48k; i++ ) + { + hb_synth[i] = L_add( hb_synth[i], L_shl( fb_synth[i], Q11 ) ); // hb_synth_exp + move16(); + } + } + return; } + void tbe_read_bitstream_fx( Decoder_State *st_fx ) { diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 5f696e899..b6d47f23b 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -427,8 +427,11 @@ ivas_error evs_enc_fx( IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE encoder */ +#ifdef HARM_BWEaa + wb_tbe_enc_ivas_fx( st, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf ); +#else wb_tbe_enc_fx( st, st->coder_type, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf, st->voicing_fx ); - +#endif IF( EQ_16( st->codec_mode, MODE2 ) ) { tbe_write_bitstream_fx( st ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 30aa1498b..20a32694d 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -162,14 +162,14 @@ void fb_tbe_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : i speech at 48 kHz sample rate */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc ); + const Word16 Q_fb_exc ); void fb_tbe_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : i speech at 48 kHz sample rate Q_new_input*/ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc*/ - Word16 Q_fb_exc, - Word16 Q_new_input ); + const Word16 Q_fb_exc, + const Word16 Q_new_input ); void fb_tbe_reset_enc_fx( Word32 elliptic_bpf_2_48k_mem_fx[][4], diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index c0af2d1e5..a6fcf90ef 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -8,7 +8,6 @@ #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "stl.h" #include "ivas_prot_fx.h" @@ -30,12 +29,17 @@ static void singlevectortest_gain_fx( const Word32 *inp, const Word16 dimen, con static void determine_gain_weights_fx( const Word32 *gain, Word16 *weights, const Word16 dims ); static void QuantizeSHBsubgains_fx( Encoder_State *st_fx, Word16 *subgains, const Word16 extl ); - +#ifndef HARM_BWE static void QuantizeSHBsubgains_ivas_fx( Encoder_State *st_fx, Word16 subgains[], const Word16 extl ); +#endif +#ifdef HARM_BWE +static void QuantizeSHBframegain_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind, const Word16 flag_conservative ); +#else static void QuantizeSHBframegain_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind ); static void QuantizeSHBframegain_ivas_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind, const Word16 flag_conservative ); +#endif static Word16 closest_centroid_fx( const Word16 *data, const Word16 *weights, const Word16 *quantizer, const Word16 centroids, const Word16 length ); @@ -65,6 +69,15 @@ static Word16 Quant_mirror_point_fx( const Word16 lsf[], const Word16 lsf_q[], W static Word16 Find_LSF_grid_fx( const Word16 lsf[], Word16 lsf_q[], const Word16 m ); +#ifdef HARM_BWE +static void Quant_BWE_LSF_fx( BSTR_ENC_HANDLE hBstr, TD_BWE_ENC_HANDLE hBWE_TD, const Word16 codec_mode, const Word16 lsf_shb_fx[], Word16 Q_lsfs_fx[], const Word32 extl_brate ); + +static void Quant_shb_ener_sf_fx( Encoder_State *st_fx, Word32 *shb_ener_sf_Q31, const Word16 Q_ener ); + +static void Quant_shb_res_gshape_fx( Encoder_State *st, Word16 shb_res_gshape_fx[] ); + +static void gainFrSmooth_En_fx( Encoder_State *st_fx, Word16 *shb_frame_fx /* Q_in */, const Word16 *lpc_shb_fx /* Q12 */, const Word16 *lsp_shb_fx /* Q15 */, Word16 *MA_lsp_shb_spacing /* Q15 */, Word16 *frGainAttenuate /* Q0 */, Word16 *frGainSmoothEn /* Q0 */ ); +#else static void Quant_BWE_LSF_fx( Encoder_State *st_fx, const Word16 lsp_shb[], Word16 Q_lsfs[] ); static void Quant_BWE_LSF_ivas_fx( BSTR_ENC_HANDLE hBstr, TD_BWE_ENC_HANDLE hBWE_TD, const Word16 codec_mode, const Word16 lsf_shb_fx[], Word16 Q_lsfs_fx[], const Word32 extl_brate ); @@ -80,6 +93,7 @@ static void Quant_shb_res_gshape_ivas_fx( Encoder_State *st, Word16 shb_res_gsha static void gainFrSmooth_En_fx( Encoder_State *st_fx, Word16 *shb_frame_fx, const Word16 *lpc_shb_fx, const Word16 *lsp_shb_fx, Word16 *MA_lsp_shb_spacing, Word16 *frGainAttenuate, Word16 *frGainSmoothEn ); static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, Word16 *shb_frame_fx /* Q_in */, const Word16 *lpc_shb_fx /* Q12 */, const Word16 *lsp_shb_fx /* Q15 */, Word16 *MA_lsp_shb_spacing /* Q15 */, Word16 *frGainAttenuate /* Q0 */, Word16 *frGainSmoothEn /* Q0 */ ); +#endif /*-------------------------------------------------------------------* @@ -1196,7 +1210,11 @@ void wb_tbe_enc_fx( } /* Quantization of the frame gain parameter */ +#ifdef HARM_BWE + QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &hRF->RF_bwe_gainFr_ind, 0 ); +#else QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &hRF->RF_bwe_gainFr_ind ); +#endif /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation*/ @@ -1312,34 +1330,73 @@ void wb_tbe_enc_ivas_fx( k = 0; move16(); - FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { - L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); - hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); - move16(); - i--; - k++; + FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) + { + L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); + hb_old_speech[i] = mac_r( L_tmp, hb_speech[j], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); + move16(); + i--; + } + } + ELSE +#endif + { + FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) + { + L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); + hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); + move16(); + i--; + k++; + } } } - autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, ( ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16 ), win_lpc_hb_wb_ivas_fx, 0, 1 ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, WBTBE_LPCWIN_LENGTH, win_lpc_hb_wb_fx, 0, 1 ); + } + ELSE +#endif + { + autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, ( ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16 ), win_lpc_hb_wb_ivas_fx, 0, 1 ); - /* Ensure R[0] isn't zero when entering Levinson-Durbin */ - R_l[0] = s_max( R_l[0], 1 ); - move16(); + /* Ensure R[0] isn't zero when entering Levinson-Durbin */ + R_l[0] = s_max( R_l[0], 1 ); + move16(); + } E_LPC_lev_dur( R_h, R_l, lpc_wb_temp_fx, LepsP, LPC_SHB_ORDER_WB, NULL ); // Since 0th index will be 1 in floating point buffer, in fixed point one has to take norm of 0th index to identify the Q-factor Copy_Scale_sig( lpc_wb_temp_fx, lpc_wb_temp_fx, LPC_SHB_ORDER_WB + 1, sub( norm_s( lpc_wb_temp_fx[0] ), 2 ) ); // Q12 - /* convert into lsps and calculate weights */ - FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { - lpc_wb_32_fx[i] = L_negate( L_deposit_h( shr( lpc_wb_temp_fx[i], 1 ) ) ); // Q27 - move32(); - } + /* convert into lsps and calculate weights */ + FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ ) + { + lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb_temp_fx[i] ), 1 ) ); + move32(); + } - lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); + } + ELSE +#endif + { + /* convert into lsps and calculate weights */ + FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ ) + { + lpc_wb_32_fx[i] = L_negate( L_deposit_h( shr( lpc_wb_temp_fx[i], 1 ) ) ); // Q27 + move32(); + } + lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); + } FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { @@ -1464,8 +1521,17 @@ void wb_tbe_enc_ivas_fx( /* Quantization of LSFs */ i = closest_centroid_fx( lsp_wb, weights_lsp, wb_bwe_lsfvq_cbook_8bit_fx, 256, LPC_SHB_ORDER_WB ); /*move16(); */ - - push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF ); +#ifdef HARM_BWE + IF( EQ_16( st_fx->codec_mode, MODE2 ) ) + { + hBWE_TD->lsf_WB = i; + move16(); + } + ELSE +#endif + { + push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF ); + } Copy( wb_bwe_lsfvq_cbook_8bit_fx + i * LPC_SHB_ORDER_WB, lsp_wb, LPC_SHB_ORDER_WB ); lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); @@ -1543,43 +1609,63 @@ void wb_tbe_enc_ivas_fx( prev_pow = 0; move32(); - Q_prev_pow = norm_arr( hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); - /* Compare with the guard bits needed in the subsequent operations. - * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3. - */ - IF( LT_16( Q_prev_pow, 3 ) ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { - shaped_wb_exc_scale[i] = shr( hBWE_TD->state_syn_shbexc_fx[i], 3 ); - move16(); + prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /* Q(2*st_fx->prev_Q_bwe_exc) */ } - Q_prev_pow = shl_r( sub( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 3 ), 1 ); - move16(); + + Q_prev_pow = 0; + move32(); } ELSE +#endif { - FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + Q_prev_pow = norm_arr( hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); + /* Compare with the guard bits needed in the subsequent operations. + * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3. + */ + IF( LT_16( Q_prev_pow, 3 ) ) { - shaped_wb_exc_scale[i] = hBWE_TD->state_syn_shbexc_fx[i]; + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + shaped_wb_exc_scale[i] = shr( hBWE_TD->state_syn_shbexc_fx[i], 3 ); + move16(); + } + Q_prev_pow = shl_r( sub( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 3 ), 1 ); + move16(); + } + ELSE + { + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + shaped_wb_exc_scale[i] = hBWE_TD->state_syn_shbexc_fx[i]; + move16(); + } + Q_prev_pow = shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ); move16(); } - Q_prev_pow = shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ); - move16(); - } - IF( st_fx->element_mode > EVS_MONO ) - { tmp = sub( Q_prev_pow, 31 + 16 ); prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q_prev_pow*/ - } - FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) - { - prev_pow = L_mac0( prev_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q_prev_pow */ + + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + prev_pow = L_mac0( prev_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q_prev_pow */ + } } rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ) ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET ); + } +#endif + sc = sub( Q_bwe_exc, add( Q_new, Q_new ) ); FOR( i = 0; i < L_FRAME32k; i++ ) { @@ -1587,69 +1673,117 @@ void wb_tbe_enc_ivas_fx( move16(); } +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); + } +#endif Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 ); Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); - GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, - hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, - hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, - vf_modified_fx, uv_flag, st_fx->igf ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, + hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, + hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, + vf_modified_fx, uv_flag, st_fx->igf ); + } + ELSE +#endif + { + GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, + hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, + hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, + vf_modified_fx, uv_flag, st_fx->igf ); + } curr_pow = 0; move32(); - Q_cur_pow = norm_arr( &shaped_wb_excitation[L_SHB_LAHEAD / 4], L_SHB_LAHEAD / 4 ); - /* Compare with the guard bits needed in the subsequent operations. - * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3. - */ - IF( LT_16( Q_cur_pow, 3 ) ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { - shaped_wb_exc_scale[i] = shr( shaped_wb_excitation[i + L_SHB_LAHEAD / 4], 3 ); + curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ + } + + IF( GT_16( voice_factors[0], 24576 ) ) + { + curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */ + } + + Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ), &exp ); + + FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) + { + L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ + shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ move16(); } - Q_cur_pow = shl_r( sub( Q_bwe_exc_ext, 3 ), 1 ); + + Lscale = root_a_fx( Lscale, 31 - exp, &exp ); + L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */ + shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */ move16(); } ELSE +#endif { - FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + Q_cur_pow = norm_arr( &shaped_wb_excitation[L_SHB_LAHEAD / 4], L_SHB_LAHEAD / 4 ); + /* Compare with the guard bits needed in the subsequent operations. + * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3. + */ + IF( LT_16( Q_cur_pow, 3 ) ) { - shaped_wb_exc_scale[i] = shaped_wb_excitation[i + L_SHB_LAHEAD / 4]; + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + shaped_wb_exc_scale[i] = shr( shaped_wb_excitation[i + L_SHB_LAHEAD / 4], 3 ); + move16(); + } + Q_cur_pow = shl_r( sub( Q_bwe_exc_ext, 3 ), 1 ); move16(); } - Q_cur_pow = shl_r( Q_bwe_exc_ext, 1 ); - move16(); - } - IF( st_fx->element_mode > EVS_MONO ) - { + ELSE + { + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + shaped_wb_exc_scale[i] = shaped_wb_excitation[i + L_SHB_LAHEAD / 4]; + move16(); + } + Q_cur_pow = shl_r( Q_bwe_exc_ext, 1 ); + move16(); + } + tmp = sub( Q_cur_pow, 31 + 16 ); curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(Q_cur_pow)*/ - } - FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) - { - curr_pow = L_mac0( curr_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q(Q_cur_pow) */ - } - IF( GT_16( voice_factors[0], 24576 ) ) - { - curr_pow = L_shr( curr_pow, 2 ); /* Q(Q_pow) */ - } + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + curr_pow = L_mac0( curr_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q(Q_cur_pow) */ + } - Lscale = root_a_over_b_fx( curr_pow, Q_cur_pow, prev_pow, Q_prev_pow, &exp ); + IF( GT_16( voice_factors[0], 24576 ) ) + { + curr_pow = L_shr( curr_pow, 2 ); /* Q(Q_pow) */ + } - FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) - { - L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ - shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ + Lscale = root_a_over_b_fx( curr_pow, Q_cur_pow, prev_pow, Q_prev_pow, &exp ); + + FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) + { + L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ + shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ + move16(); + } + + Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp ); + L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */ + shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ move16(); } - Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp ); - L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */ - shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ - move16(); - /* Update WB excitation */ Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); @@ -1753,7 +1887,11 @@ void wb_tbe_enc_ivas_fx( push_indice( st_fx->hBstr, IND_UV_FLAG, uv_flag, 1 ); /* Quantization of the subframe gain parameter */ +#ifdef HARM_BWE + QuantizeSHBsubgains_fx( st_fx, GainShape, st_fx->extl ); +#else QuantizeSHBsubgains_ivas_fx( st_fx, GainShape, st_fx->extl ); +#endif } /* Compute the power of gains away from the peak gain after quantization */ @@ -1770,14 +1908,22 @@ void wb_tbe_enc_ivas_fx( EstimateSHBFrameGain_ivas_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); - /* If there's a big difference in the power of gains away from the peak gain */ /* due to poor quantization then suppress energy of the high band. */ IF( GT_32( p2m_out, L_shl( p2m_in, 1 ) ) ) { L_tmp = root_a_over_b_fx( L_shl( p2m_in, 1 ), 29, p2m_out, 29, &exp_out ); - GainFrame = L_shl( Mpy_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */ +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + GainFrame = L_shl( Mult_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */ + } + ELSE +#endif + { + GainFrame = L_shl( Mpy_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */ + } } pitBufAvg_fx = 0; @@ -1806,11 +1952,29 @@ void wb_tbe_enc_ivas_fx( } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ - GainFrame = Mpy_32_16_1( GainFrame, tmp ); /* Q18 */ +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + GainFrame = Mult_32_16( GainFrame, tmp ); /* Q18 */ + } + ELSE +#endif + { + GainFrame = Mpy_32_16_1( GainFrame, tmp ); /* Q18 */ + } IF( LT_16( lsp_spacing_fx, 328 ) && lsp_spacing_fx ) { - GainFrame = Mpy_32_16_1( GainFrame, 21299 ); /* Q18 */ +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + GainFrame = Mult_32_16( GainFrame, 21299 ); /* Q18 */ + } + ELSE +#endif + { + GainFrame = Mpy_32_16_1( GainFrame, 21299 ); /* Q18 */ + } } /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ @@ -1826,33 +1990,70 @@ void wb_tbe_enc_ivas_fx( IF( st_fx->igf != 0 && EQ_16( st_fx->coder_type, VOICED ) ) { /*GainFrame *= 0.5f;*/ - GainFrame = Mpy_32_16_1( GainFrame, 16384 ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + GainFrame = Mult_32_16( GainFrame, 16384 ); + } + ELSE +#endif + { + GainFrame = Mpy_32_16_1( GainFrame, 16384 ); + } } ELSE IF( st_fx->igf != 0 && GT_16( avg_voice_fac, 11469 ) ) /*Q15 -> 0.35f*/ { /*GainFrame *= 0.75f;*/ - GainFrame = Mpy_32_16_1( GainFrame, 24576 ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + GainFrame = Mult_32_16( GainFrame, 24576 ); + } + ELSE +#endif + { + GainFrame = Mpy_32_16_1( GainFrame, 24576 ); + } } /* Quantization of the frame gain parameter */ IF( st_fx->rf_mode ) { +#ifdef HARM_BWE + QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &st_fx->hRF->RF_bwe_gainFr_ind, 0 ); +#else QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &st_fx->hRF->RF_bwe_gainFr_ind, 0 ); +#endif } ELSE { +#ifdef HARM_BWE + QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, NULL, 0 ); +#else QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, NULL, 0 ); +#endif } /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation*/ - scale_sig( shaped_wb_excitation, ( L_FRAME16k + L_SHB_LAHEAD ) / 4, -1 ); - scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, -1 ); - Q_bwe_exc_ext = sub( Q_bwe_exc_ext, 1 ); +#ifdef HARM_BWE + IF( st_fx->element_mode > EVS_MONO ) +#endif + { + scale_sig( shaped_wb_excitation, ( L_FRAME16k + L_SHB_LAHEAD ) / 4, -1 ); + scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, -1 ); + Q_bwe_exc_ext = sub( Q_bwe_exc_ext, 1 ); + } + ScaleShapedSHB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, window_wb_fx, subwin_wb_fx, &Q_bwe_exc_ext, &dummy, dummy, dummy ); - Scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, 1 ); +#ifdef HARM_BWE + IF( st_fx->element_mode > EVS_MONO ) +#endif + { + Scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, 1 ); + } hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); @@ -2098,7 +2299,11 @@ void swb_tbe_enc_fx( ELSE { /* LSF quantization (21 bits) */ +#ifdef HARM_BWE + Quant_BWE_LSF_fx( st_fx->hBstr, hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl ); +#else Quant_BWE_LSF_fx( st_fx, lsf_shb_fx, lsf_shb_fx ); +#endif } /* space the lsfs to assert a minimum distance */ @@ -2744,7 +2949,11 @@ void swb_tbe_enc_fx( } /* Quantization of the frame gain parameter */ +#ifdef HARM_BWE + QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind, 0 ); +#else QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind ); +#endif /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation */ @@ -2933,7 +3142,9 @@ void swb_tbe_enc_ivas_fx( move16(); TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; +#ifndef HARM_BWE RF_ENC_HANDLE hRF = st_fx->hRF; +#endif BSTR_ENC_HANDLE hBstr = st_fx->hBstr; /* init and buffers set up */ @@ -3104,7 +3315,11 @@ void swb_tbe_enc_ivas_fx( /* Input signal filtering in case of tonal sounds in the high band gain Frame smoothing and attenuation control */ +#ifdef HARM_BWE + gainFrSmooth_En_fx( st_fx, shb_frame_fx, lpc_shb_fx, lsf_shb_fx, &MA_lsp_shb_spacing, &frGainAttenuate, &frGainSmoothEn ); +#else gainFrSmooth_En_ivas_fx( st_fx, shb_frame_fx, lpc_shb_fx, lsf_shb_fx, &MA_lsp_shb_spacing, &frGainAttenuate, &frGainSmoothEn ); +#endif test(); test(); @@ -3138,7 +3353,11 @@ void swb_tbe_enc_ivas_fx( ELSE { /* LSF quantization (21 bits) */ +#ifdef HARM_BWE + Quant_BWE_LSF_fx( hBstr, st_fx->hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl_brate ); +#else Quant_BWE_LSF_ivas_fx( hBstr, st_fx->hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl_brate ); +#endif } /* space the lsfs to assert a minimum distance */ @@ -3312,7 +3531,11 @@ void swb_tbe_enc_ivas_fx( } shb_ener_sf_Q31 = Mult_32_16( shb_ener_sf_Q31, 102 /*0.003125f Q15*/ ); shb_ener_sf_Q31 = L_add( 1l /*1 Q0*/, shb_ener_sf_Q31 ); +#ifdef HARM_BWE + Quant_shb_ener_sf_fx( st_fx, &shb_ener_sf_Q31, shl( Q_shb, 1 ) ); +#else Quant_shb_ener_sf_ivas_fx( st_fx, &shb_ener_sf_Q31, shl( Q_shb, 1 ) ); +#endif /* -------- calculate the residuals using the FOUR subframe LPCs -------- */ set16_fx( shb_res_fx, 0, L_FRAME16k ); @@ -3359,7 +3582,11 @@ void swb_tbe_enc_ivas_fx( move16(); } +#ifdef HARM_BWE + Quant_shb_res_gshape_fx( st_fx, shb_res_gshape_fx ); +#else Quant_shb_res_gshape_ivas_fx( st_fx, shb_res_gshape_fx ); +#endif } ELSE IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) { @@ -4067,7 +4294,11 @@ void swb_tbe_enc_ivas_fx( } /* Quantization of the gain shape parameter */ +#ifdef HARM_BWE + QuantizeSHBsubgains_fx( st_fx, GainShape_fx, st_fx->extl ); +#else QuantizeSHBsubgains_ivas_fx( st_fx, GainShape_fx, st_fx->extl ); +#endif /* Compute the power of gains away from the peak gain after quantization */ IF( st_fx->element_mode > EVS_MONO ) @@ -4359,6 +4590,9 @@ void swb_tbe_enc_ivas_fx( } /* Quantization of the frame gain parameter */ +#ifdef HARM_BWE + QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, NULL, ( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) ? 1 : 0 ); +#else IF( st_fx->rf_mode ) { QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind, 0 ); @@ -4367,6 +4601,7 @@ void swb_tbe_enc_ivas_fx( { QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, NULL, ( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) ? 1 : 0 ); } +#endif IF( hStereoICBWE != NULL ) { @@ -5393,7 +5628,7 @@ static void QuantizeSHBsubgains_fx( return; } - +#ifndef HARM_BWE /*============================================================*/ /* FUNCTION : static void QuantizeSHBsubgains_ivas_fx() */ /*------------------------------------------------------------*/ @@ -5530,7 +5765,7 @@ static void QuantizeSHBsubgains_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * Quant_shb_ener_sf_fx_fx() @@ -5539,6 +5774,7 @@ static void QuantizeSHBsubgains_ivas_fx( *-------------------------------------------------------------------*/ static void Quant_shb_ener_sf_fx( +#ifndef HARM_BWE Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *shb_ener_sf_Q31, /* i/o: super highband subframe energies */ Word16 Q_ener ) @@ -5595,9 +5831,10 @@ static void Quant_shb_ener_sf_fx( *-------------------------------------------------------------------*/ static void Quant_shb_ener_sf_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *shb_ener_sf_Q31, /* i/o: super highband subframe energies Q_ener */ - Word16 Q_ener ) + const Word16 Q_ener ) { Word16 idxSubEner_fx; Word16 temp_shb_ener_sf_fx; @@ -5605,6 +5842,9 @@ static void Quant_shb_ener_sf_ivas_fx( Word32 L_tmp1, L_tmp; Word32 sum; Word16 tmp; +#ifdef HARM_BWE + Word16 Q_fac; +#endif TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; /* shb_ener_sf_fx[0] = log10(0.003125*shb_ener_sf[0:319]); */ @@ -5613,21 +5853,47 @@ static void Quant_shb_ener_sf_ivas_fx( exp = norm_l( sum ); frac = Log2_norm_lc( L_shl( sum, exp ) ); - exp = sub( 30, add( exp, Q_ener ) ); /* 30-(exp+Q_ener ) */ - L_tmp1 = Mpy_32_16( exp, frac, 308 ); /* 308=LOG10(2) in Q10, so answer Ltmp in Q11 */ + exp = sub( 30, add( exp, Q_ener ) ); /* 30-(exp+Q_ener ) */ +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + L_tmp1 = Mpy_32_16( exp, frac, 617 ); /* 2466=LOG10(2) in Q11, so answer Ltmp in Q12 */ - tmp = extract_l( L_tmp1 ); /* tmp in Q11 */ + tmp = round_fx( L_shl( L_tmp1, 30 - 14 ) ); /* tmp in Q12 */ - temp_shb_ener_sf_fx = 0; - move16(); - idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 43, 1 << NUM_BITS_SHB_ENER_SF ); /* 43 = 0.042f in Q10 = Qin-1 */ - /* o: temp_shb_ener_sf_fx in Q11 */ + temp_shb_ener_sf_fx = 0; + move16(); + idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 86, shl( 1, NUM_BITS_SHB_ENER_SF ) ); /* 86 = 0.042f in Q11 = Qin-1 */ + /* o: temp_shb_ener_sf_fx in Q12 */ + + Q_fac = -Q10; + move16(); + } + ELSE +#endif + { + L_tmp1 = Mpy_32_16( exp, frac, 308 ); /* 308=LOG10(2) in Q10, so answer Ltmp in Q11 */ + + tmp = extract_l( L_tmp1 ); /* tmp in Q11 */ + + temp_shb_ener_sf_fx = 0; + move16(); + idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 43, 1 << NUM_BITS_SHB_ENER_SF ); /* 43 = 0.042f in Q10 = Qin-1 */ + /* o: temp_shb_ener_sf_fx in Q11 */ + + Q_fac = -Q9; + move16(); + } /* shb_ener_sf_fx[0] = pow(10.0, temp_shb_ener_sf_fx ); */ /* = pow(2, 3.321928*temp_shb_ener_sf_fx) */ - L_tmp = L_mult( temp_shb_ener_sf_fx, 27213 ); /* 3.321928 in Q13 -> L_tmp in Q11+Q13+1 = Q25 */ - L_tmp = L_shl( L_tmp, -9 ); /* bring L_tmp from Q25 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent */ + L_tmp = L_mult( temp_shb_ener_sf_fx, 27213 ); /* 3.321928 in Q13 -> L_tmp in Q12/Q11+Q13+1 = Q26/Q25 */ +#ifdef HARM_BWE + L_tmp = L_shl( L_tmp, Q_fac ); /* bring L_tmp from Q26/Q25 to Q16 */ +#else + L_tmp = L_shl( L_tmp, -9 ); /* bring L_tmp from Q25 to Q16 */ +#endif + frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent */ L_tmp = Pow2( 14, frac ); *shb_ener_sf_Q31 = L_shl( L_tmp, add( sub( exp, 14 ), Q_ener ) ); /* In Q_ener */ move32(); @@ -5650,6 +5916,7 @@ static void Quant_shb_ener_sf_ivas_fx( *-------------------------------------------------------------------*/ static void Quant_shb_res_gshape_fx( +#ifndef HARM_BWE Encoder_State *st_fx, /* i/o: encoder state structure */ Word16 shb_res_gshape_fx[] /* i/o: super highband gain shapes Q14 */ ) @@ -5677,7 +5944,6 @@ static void Quant_shb_res_gshape_fx( return; } - /*-------------------------------------------------------------------* * Quant_shb_res_gshape_ivas_fx() * @@ -5685,6 +5951,7 @@ static void Quant_shb_res_gshape_fx( *-------------------------------------------------------------------*/ static void Quant_shb_res_gshape_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 shb_res_gshape_fx[] /* i/o: super highband gain shapes Q14 */ ) @@ -5737,6 +6004,7 @@ static void Quant_shb_res_gshape_ivas_fx( /*==========================================================================*/ static void QuantizeSHBframegain_fx( +#ifndef HARM_BWE Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *GainFrame, /* i/o: Gain Q18 */ const Word16 extl, /* i : extension layer */ @@ -5904,6 +6172,7 @@ return; /*==========================================================================*/ static void QuantizeSHBframegain_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *GainFrame, /* i/o: Gain Q18 */ const Word16 extl, /* i : extension layer */ @@ -5932,11 +6201,25 @@ static void QuantizeSHBframegain_ivas_fx( singlevectortest_gain_fx( GainFrame, 1, 1 << NUM_BITS_SHB_FrameGain_LBR_WB, &idxFrameGain, &Q_GainFrame, SHBCB_FrameGain16_fx ); - test(); - IF( GT_64( W_deposit32_l( Q_GainFrame ), W_shl( W_mult_32_16( *GainFrame, 17367 ), 15 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */ + +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) { - idxFrameGain--; - Q_GainFrame = L_add( SHBCB_FrameGain16_fx[idxFrameGain], 0 ); /* Q18 */ + IF( GT_32( Q_GainFrame, L_shl( Mult_32_16( *GainFrame, 17367 ), 1 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */ + { + idxFrameGain--; + Q_GainFrame = L_add( SHBCB_FrameGain16_fx[idxFrameGain], 0 ); /* Q18 */ + } + } + ELSE +#endif + { + test(); + IF( GT_64( W_deposit32_l( Q_GainFrame ), W_shl( W_mult_32_16( *GainFrame, 17367 ), 15 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */ + { + idxFrameGain--; + Q_GainFrame = L_add( SHBCB_FrameGain16_fx[idxFrameGain], 0 ); /* Q18 */ + } } IF( EQ_16( st_fx->codec_mode, MODE2 ) ) @@ -6510,6 +6793,7 @@ static Word16 Find_LSF_grid_fx( * * Gain frame smoothing and attenuation control *-------------------------------------------------------------------*/ +#ifndef HARM_BWE static void gainFrSmooth_En_fx( Encoder_State *st_fx, Word16 *shb_frame_fx, const Word16 *lpc_shb_fx, @@ -6632,13 +6916,20 @@ static void gainFrSmooth_En_fx( Encoder_State *st_fx, * * Gain frame smoothing and attenuation control *-------------------------------------------------------------------*/ -static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, - Word16 *shb_frame_fx /* Q_in */, - const Word16 *lpc_shb_fx /* Q12 */, - const Word16 *lsp_shb_fx /* Q15 */, - Word16 *MA_lsp_shb_spacing /* Q15 */, - Word16 *frGainAttenuate /* Q0 */, - Word16 *frGainSmoothEn /* Q0 */ ) +#endif + +#ifdef HARM_BWE +static void gainFrSmooth_En_fx( +#else +static void gainFrSmooth_En_ivas_fx( +#endif + Encoder_State *st_fx, + Word16 *shb_frame_fx /* Q_in */, + const Word16 *lpc_shb_fx /* Q12 */, + const Word16 *lsp_shb_fx /* Q15 */, + Word16 *MA_lsp_shb_spacing /* Q15 */, + Word16 *frGainAttenuate /* Q0 */, + Word16 *frGainSmoothEn /* Q0 */ ) { Word16 temp_shb_frame[L_FRAME16k + L_SHB_LAHEAD]; Word32 lsp_slow_evol_rate, lsp_fast_evol_rate; @@ -6686,8 +6977,18 @@ static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, /* estimate the mean square error in lsps from current frame to past frames */ tempQ15_1 = sub( lsp_shb_fx[i], hBWE_TD->lsp_shb_slow_interpl_fx[i] ); tempQ15_2 = sub( lsp_shb_fx[i], hBWE_TD->lsp_shb_fast_interpl_fx[i] ); - lsp_slow_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, L_mult( tempQ15_1, tempQ15_1 ), 0, &lsp_slow_evol_rate_e ); - lsp_fast_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, L_mult( tempQ15_2, tempQ15_2 ), 0, &lsp_fast_evol_rate_e ); +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO ) + { + lsp_slow_evol_rate = L_mac( lsp_slow_evol_rate, tempQ15_1, tempQ15_1 ); + lsp_fast_evol_rate = L_mac( lsp_fast_evol_rate, tempQ15_2, tempQ15_2 ); + } + ELSE +#endif + { + lsp_slow_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, L_mult( tempQ15_1, tempQ15_1 ), 0, &lsp_slow_evol_rate_e ); + lsp_fast_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, L_mult( tempQ15_2, tempQ15_2 ), 0, &lsp_fast_evol_rate_e ); + } /* update the slow and fast interpolation lsps for next frame */ tempQ31 = L_mult( hBWE_TD->lsp_shb_slow_interpl_fx[i], 22937 /* 0.7f in Q15 */ ); @@ -6746,12 +7047,25 @@ static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, } test(); - if ( ( BASOP_Util_Cmp_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, INV_1000_Q31, 0 ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) ) +#ifdef HARM_BWE + IF( st_fx->element_mode == EVS_MONO && LT_32( lsp_slow_evol_rate, INV_1000_Q31 ) && LT_32( lsp_fast_evol_rate, 2147484l /*0.001f Q31*/ ) ) { *frGainSmoothEn = 1; move16(); } + ELSE IF( st_fx->element_mode > EVS_MONO ) +#endif + { + test(); + if ( ( BASOP_Util_Cmp_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, INV_1000_Q31, 0 ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) ) + { + *frGainSmoothEn = 1; + move16(); + } + } } + + return; } #define MAXINT32 MAX_32 @@ -7123,7 +7437,7 @@ static void LVQQuant_BWE_LSF_fx( * * Quantize super highband spectral envolope *-------------------------------------------------------------------*/ - +#ifndef HARM_BWE static void Quant_BWE_LSF_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -7187,9 +7501,14 @@ static void Quant_BWE_LSF_fx( return; } +#endif +#ifdef HARM_BWE +static void Quant_BWE_LSF_fx( +#else static void Quant_BWE_LSF_ivas_fx( +#endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ const Word16 codec_mode, /* i : codec mode */ @@ -7276,7 +7595,7 @@ void fb_tbe_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : input speech at 48 kHz sample rate */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc ) + const Word16 Q_fb_exc ) { Word16 ratio; Word16 tmp_vec[L_FRAME48k]; @@ -7305,10 +7624,7 @@ void fb_tbe_enc_fx( Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp ); - elliptic_bpf_48k_generic_fx( - st->element_mode, - 0, // IsUpsampled3 - input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); + elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; IF( NE_16( st->last_extl, FB_TBE ) ) @@ -7400,8 +7716,8 @@ void fb_tbe_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : input speech at 48 kHz sample rate Q_new_input */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ - Word16 Q_fb_exc, - Word16 Q_new_input ) + const Word16 Q_fb_exc, + const Word16 Q_new_input ) { Word16 ratio; Word16 tmp_vec[L_FRAME48k]; @@ -7434,17 +7750,11 @@ void fb_tbe_enc_ivas_fx( exp_temp = add( exp_temp, Q_new_input ); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { - elliptic_bpf_48k_generic_fx( - st->element_mode, - 0, // IsUpsampled3 - input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); + elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); } ELSE { - elliptic_bpf_48k_generic_fx( - st->element_mode, - 0, // IsUpsampled3 - input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); + elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); } test(); @@ -7541,6 +7851,7 @@ void fb_tbe_enc_ivas_fx( } /* ratio = (float)(1 << idxGain);*/ +#ifndef HARM_BWE IF( EQ_16( st->codec_mode, MODE2 ) ) { hBWE_TD->idxGain = idxGain; @@ -7548,10 +7859,22 @@ void fb_tbe_enc_ivas_fx( } ELSE { +#endif push_indice( st->hBstr, IND_FB_SLOPE, idxGain, 4 ); +#ifndef HARM_BWE } +#endif + return; } + + +/*---------------------------------------------------------------------* + * tbe_write_bitstream() + * + * Write TBE bitstream. + *---------------------------------------------------------------------*/ + void tbe_write_bitstream_fx( Encoder_State *st_fx /* i/o: encoder state structure */ ) @@ -7578,7 +7901,6 @@ void tbe_write_bitstream_fx( ( ( EQ_16( st_fx->bwidth, SWB ) ) || ( EQ_16( st_fx->bwidth, FB ) ) ) ) { /* LSF coefficients */ - test(); IF( ( EQ_16( st_fx->rf_mode, 1 ) ) || EQ_32( st_fx->total_brate, ACELP_9k60 ) ) { @@ -7635,6 +7957,12 @@ void tbe_write_bitstream_fx( } +/*---------------------------------------------------------------------* + * TBEreset_enc() + * + * + *---------------------------------------------------------------------*/ + void TBEreset_enc_fx( TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ const Word16 last_core, /* i : last core */ -- GitLab From aeefdc0f11436f62815b20283992d9d5a284d26a Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 29 Jan 2026 17:15:23 +0100 Subject: [PATCH 654/750] clang-format --- lib_dec/evs_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index ecec2727f..6ecfa4093 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -409,7 +409,7 @@ ivas_error evs_dec_fx( IF( EQ_16( output_frame, L_FRAME48k ) && EQ_16( st_fx->extl, FB_TBE ) ) { #ifdef HARM_BWE - fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame ); + fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame ); #else fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp ); #endif -- GitLab From de111a2cb5d77610c70b7838bec5091e1da0caab Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 29 Jan 2026 11:48:04 -0500 Subject: [PATCH 655/750] proposed fix to 2380, issue with Q_exc being possibly too high when coming from CNG --- lib_com/gs_gains_fx.c | 29 +++++++++++++++++++++++++++-- lib_com/gs_noisefill_fx.c | 36 +++++++++++++++++++++++++++++++++--- lib_com/options.h | 1 + lib_com/prot_fx.h | 14 +++++++++++--- 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 769af2692..b25dace82 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -70,12 +70,19 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const /* _ None */ /*========================================================================*/ +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX +Word16 Comp_and_apply_gain_fx( +#else void Comp_and_apply_gain_fx( +#endif Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + const Word16 max_lt_ener, /* i : max_lt_ener of lt_ener_per_band_fx */ +#endif Word16 Qexc_diff, Word16 Q_exc ) { @@ -83,6 +90,9 @@ void Comp_and_apply_gain_fx( Word16 StartBin, NB_Qbins; Word16 y_gain; Word16 L16, frac, exp1, tmp_exp; +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + Word16 Q_adapt; +#endif Word32 L32; /* Recreate excitation for local synthesis and decoder */ @@ -92,6 +102,16 @@ void Comp_and_apply_gain_fx( move16(); tmp_exp = add( 14, sub( Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/ +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + Q_adapt = 0; + move16(); + test(); + test(); + IF( GT_16( Q_exc, 3 ) && EQ_16( ReUseGain, 0 ) && GT_16( max_lt_ener, 8192 /* 13 bits */ ) ) /* When lt_energy is high, Q_exc shouldn't be high too, addresses cases when switching from CNG */ + { + Q_adapt = sub( 3 - 1, Q_exc ); /* add extra 1 bit headroom */ + } +#endif FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) { StartBin = add( StartBin, NB_Qbins ); @@ -126,7 +146,9 @@ void Comp_and_apply_gain_fx( Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) ); move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); - +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + tmp_exp = add( tmp_exp, Q_adapt ); +#endif FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ @@ -135,8 +157,11 @@ void Comp_and_apply_gain_fx( } } } - +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + return add( Q_exc, Q_adapt ); +#else return; +#endif } #ifndef FIX_2338_HARM_GSC_GAIN_COMP diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 383e2812d..4d902da52 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1081,6 +1081,9 @@ void highband_exc_dct_in_ivas_fx( Word16 frac, exp, tmp1; Word16 tmp2; Word16 *end, Q_hb_exc; +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + Word16 max_lt_ener, old_Q_exc; +#endif FOR( j = 10; j < MBANDS_GN; j++ ) { @@ -1364,10 +1367,9 @@ void highband_exc_dct_in_ivas_fx( move16(); } } -#ifndef FIX_2338_HARM_GSC_GAIN_COMP +#if !defined FIX_2338_HARM_GSC_GAIN_COMP && !defined FIX_2380_HARM_GSC_GAIN_COMP_FX IF( EQ_16( element_mode, EVS_MONO ) ) { -#endif Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); IF( exc_wo_nf != NULL ) @@ -1375,7 +1377,6 @@ void highband_exc_dct_in_ivas_fx( Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } -#ifndef FIX_2338_HARM_GSC_GAIN_COMP } ELSE { @@ -1406,7 +1407,36 @@ void highband_exc_dct_in_ivas_fx( Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); } } +#elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX + max_lt_ener = 0; + move16(); + IF( NE_16( element_mode, EVS_MONO ) ) /* to keep EVS BE */ + { + FOR( i = 0; i < MBANDS_GN; i++ ) + { + max_lt_ener = s_max( max_lt_ener, lt_ener_per_band_fx[i] ); + } + } + old_Q_exc = *Q_exc; + move16(); + *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, max_lt_ener, Qexc_diffQ, *Q_exc ); + Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, old_Q_exc ) ); + + IF( exc_wo_nf != NULL ) + { + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, max_lt_ener, Qexc_diffQ, *Q_exc ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); + } +#else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */ + Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); + + IF( exc_wo_nf != NULL ) + { + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); + } #endif + /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum diff --git a/lib_com/options.h b/lib_com/options.h index 0e313e5e9..e0548ca60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,6 +111,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2380_HARM_GSC_GAIN_COMP_FX /* VA: basop issue 2380 & 2381: Fix issue when switching from CNG low energy to active content with high energy */ #define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 3b93fda3b..f71079f6c 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1703,14 +1703,22 @@ void Ener_per_band_comp_ivas_fx( const Word16 L_frame /* i : frame length */ ); +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX +Word16 Comp_and_apply_gain_fx( +#else void Comp_and_apply_gain_fx( +#endif Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ - Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ - Word16 Mbands_gn, /* i : number of bands */ - const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ + Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ + Word16 Mbands_gn, /* i : number of bands */ + const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + const Word16 max_lt_ener, /* i : max_lt_ener of lt_ener_per_band_fx */ +#endif Word16 Qexc_diff, Word16 Q_exc ); + #ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ -- GitLab From 3e51b45ce930709b2a4cfa975be9de121479691e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 29 Jan 2026 12:01:02 -0500 Subject: [PATCH 656/750] fix encoder --- lib_com/gs_noisefill_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 4d902da52..ec45be809 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1410,7 +1410,7 @@ void highband_exc_dct_in_ivas_fx( #elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX max_lt_ener = 0; move16(); - IF( NE_16( element_mode, EVS_MONO ) ) /* to keep EVS BE */ + IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep EVS BE */ { FOR( i = 0; i < MBANDS_GN; i++ ) { -- GitLab From 009aad4e7200075c4c40a91f4feda2fd4b7fa547 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 30 Jan 2026 10:52:22 +0100 Subject: [PATCH 657/750] - fix alpha computation missing 2pi factor - remove unnecessary caching of q value before call to VectorLength_fx() --- lib_rend/ivas_orient_trk_fx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 7b56efdd6..7d6e3750f 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -841,11 +841,16 @@ ivas_error ivas_orient_trk_SetReferenceVector_fx( return IVAS_ERR_WRONG_PARAMS; } +#ifdef FIX_BASOP_2361_OTR + Word16 tmp_q; + acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &tmp_q ); +#else Word16 accoustic_q = acousticFrontVector.q_fact; move16(); acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &acousticFrontVector.q_fact ); acousticFrontVector.q_fact = accoustic_q; move16(); +#endif /* if the length is zero, the user has entered insensible listener and reference positions */ IF( LE_32( acousticFrontVectorLength, 0 ) ) { @@ -906,6 +911,18 @@ ivas_error ivas_orient_trk_Process_fx( /* Reset average orientation */ pOTR->absAvgRot = absRot; +#ifdef FIX_BASOP_2361_OTR + Word16 scale_e; + Word16 tmp; + tmp = BASOP_Util_Divide3232_Scale( PI2_C_ADP_RATE_Q31, updateRate_fx, &scale_e ); + scale_e = add( scale_e, sub( 23, 31 ) ); /* updateRate_fx is hardcoded in caller to Q23 */ + + /* sin(x) is approx x for small x */ + pOTR->alpha_fx = L_deposit_h( tmp ); + move32(); + pOTR->Q_alpha = sub( Q31, scale_e ); + move16(); +#else Word16 scale_e; Word32 div; div = L_deposit_h( BASOP_Util_Divide3232_Scale( pOTR->centerAdaptationRate_fx, updateRate_fx, &scale_e ) ); @@ -914,6 +931,7 @@ ivas_error ivas_orient_trk_Process_fx( // here div value is less so we can use sandwitch rule of sine// pOTR->alpha_fx = div; move32(); +#endif /* Compute relative orientation = (absolute orientation) - (reference orientation) */ QuaternionInverse_fx( pOTR->refRot, &pOTR->trkRot ); QuaternionProduct_fx( pOTR->trkRot, absRot, &pOTR->trkRot ); @@ -967,6 +985,8 @@ ivas_error ivas_orient_trk_Process_fx( cutoff_prod = L_shl( cutoff_prod, temp_diff ); /* Compute adaptivity cutoff frequency: interpolate between minimum (center) and maximum (off-center) values */ cutoffFrequency_fx = L_add( pOTR->centerAdaptationRate_fx, cutoff_prod ); // Q31 + + /* Compute filter coefficient corresponding to desired cutoff frequency */ cutoff_prod = Mpy_32_32( cutoffFrequency_fx, PI2_C_Q28 ); q_cutoff_prod = ( ( 31 + 28 ) - 31 ); temp_result = BASOP_Util_Divide3232_Scale( cutoff_prod, updateRate_fx, &result_e ); -- GitLab From eac680a19a378feba5854a0606165c8cd1eba370 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 30 Jan 2026 11:08:49 +0100 Subject: [PATCH 658/750] updt --- lib_com/prot_fx.h | 3 +- lib_dec/swb_tbe_dec_fx.c | 86 ++++--- lib_enc/evs_enc_fx.c | 23 +- lib_enc/ivas_core_enc_fx.c | 4 + lib_enc/prot_fx_enc.h | 8 +- lib_enc/swb_tbe_enc_fx.c | 503 +++++++++++++++++++++++++++---------- 6 files changed, 456 insertions(+), 171 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 699b23077..ce33afa73 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5775,6 +5775,7 @@ void swb_tbe_dec_fx( Word16 *Q_synth, Word16 *pitch_buf ); +#ifndef HARM_BWE void ivas_dequantizeSHBparams_fx_9_1( Decoder_State *st_fx, const Word16 extl, /* i : extension layer */ @@ -5787,7 +5788,7 @@ void ivas_dequantizeSHBparams_fx_9_1( Word16 *Q_shb_res_gshape, /* o : Q14 */ Word16 *Q_mixFactors, /* o : Q15 */ Word16 *MSFlag ); - +#endif void fb_tbe_dec_fx( #ifndef HARM_BWE Decoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 6767fe480..41d9e320a 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -2,22 +2,23 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ - #include #include "options.h" #include "rom_com.h" #include "prot_fx.h" #include "rom_dec.h" #include "stl.h" - #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* * Local functions *-----------------------------------------------------------------*/ +#ifdef HARM_BWE +static void dequantizeSHBparams_fx( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors, Word16 *MSFlag ); +#else static void dequantizeSHBparams_fx_9_1( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors ); - +#endif static void find_max_mem_dec( Decoder_State *st_fx, Word16 *n_mem, Word16 *n_mem2, Word16 *n_mem3 ); static void rescale_genSHB_mem_dec( Decoder_State *st_fx, Word16 sf ); static void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem ); @@ -27,15 +28,15 @@ static void Map_higher_LSF_fx( Word16 lsf_q[], const Word16 m, const Word16 grid static void Dequant_mirror_point_fx( const Word16 lsf_q[], const Word16 m_idx, Word16 *m ); static Word16 dotp_loc( const Word16 x[], const Word32 y[], const Word16 n ); static void find_max_mem_dec_m3( Decoder_State *st, Word16 *n_mem3 ); - -/* gain shape concealment code */ static void gradientGainShape( Decoder_State *st_fx, Word16 *GainShape, Word32 *GainFrame ); + /*-------------------------------------------------------------------* * find_max_mem_dec() * * Find norm and max in TBE memories and past buffers *-------------------------------------------------------------------*/ + static void find_max_mem_dec( Decoder_State *st_fx, Word16 *n_mem, @@ -219,14 +220,17 @@ static void find_max_mem_dec( because of the Hilber transform and Q14 coeffs */ *n_mem3 = s_max( tempQ15, 0 ); move16(); - /* --------------------------------------------------------------*/ + + return; } + /*-------------------------------------------------------------------* * rescale_genSHB_mem_dec() * * Rescale genSHB memories *-------------------------------------------------------------------*/ + static void rescale_genSHB_mem_dec( Decoder_State *st_fx, Word16 sf ) @@ -276,9 +280,13 @@ static void rescale_genSHB_mem_dec( move16(); hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf ); move16(); + + return; } -void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem ) +static void find_max_mem_wb( + Decoder_State *st_fx, + Word16 *n_mem ) { Word16 i; Word16 max = 0; @@ -311,21 +319,18 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem ) FOR( i = 0; i < 7; i++ ) { - if ( GT_16( abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] ), max ) ) max = abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] ); } FOR( i = 0; i < 10; i++ ) { - if ( GT_16( abs_s( hBWE_TD->state_lpc_syn_fx[i] ), max ) ) max = abs_s( hBWE_TD->state_lpc_syn_fx[i] ); } FOR( i = 0; i < 5; i++ ) { - if ( GT_16( abs_s( hBWE_TD->state_syn_shbexc_fx[i] ), max ) ) max = abs_s( hBWE_TD->state_syn_shbexc_fx[i] ); } @@ -341,10 +346,8 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem ) move16(); } - FOR( i = 0; i < 2; i++ ) { - if ( GT_32( L_abs( hBWE_TD->mem_csfilt_fx[i] ), Lmax ) ) Lmax = L_abs( hBWE_TD->mem_csfilt_fx[i] ); } @@ -363,9 +366,14 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem ) move16(); *n_mem = s_max( *n_mem, 0 ); move16(); + + return; } -void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf ) + +static void rescale_genWB_mem( + Decoder_State *st_fx, + Word16 sf ) { Word16 i; TD_BWE_DEC_HANDLE hBWE_TD; @@ -587,7 +595,7 @@ void ResetSHBbuffer_Dec_fx( /* _Word16 *synth o : WB synthesis/final synthesis Q_synth */ /*--------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* Decoder_State *st_fx, i/o: decoder state structure */ +/* Decoder_State *st_fx, i/o: decoder state structure */ /*--------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ @@ -640,8 +648,10 @@ void ivas_wb_tbe_dec_fx( Word16 f, inc; Word64 W_tmp; TD_BWE_DEC_HANDLE hBWE_TD; + hBWE_TD = st_fx->hBWE_TD; set32_fx( &dummy2[0], 0, HILBERT_MEM_SIZE ); + IF( st_fx->bws_cnt == 0 ) { /* Initialization */ @@ -756,17 +766,13 @@ void ivas_wb_tbe_dec_fx( ELSE { #ifdef HARM_BWE - IF( st_fx->element_mode == EVS_MONO ) - { - dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0 ); - } - ELSE - { + /* de-quantization */ + dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &j /*temp*/ ); +#else + /* de-quantization */ + Word16 ignore; + ivas_dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &ignore ); #endif - /* de-quantization */ - Word16 ignore; - ivas_dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &ignore ); - } } } ELSE @@ -1086,8 +1092,8 @@ void ivas_wb_tbe_dec_fx( #ifdef HARM_BWE IF( !st_fx->bfi && st_fx->prev_bfi ) #else - test(); - IF( !st_fx->bfi && ( st_fx->prev_bfi || st_fx->prev_use_partial_copy ) ) + test(); + IF( !st_fx->bfi && ( st_fx->prev_bfi || st_fx->prev_use_partial_copy ) ) #endif { IF( GT_32( L_shr( curr_frame_pow, 1 ), hBWE_TD->prev_wb_bwe_frame_pow_fx ) ) @@ -2328,10 +2334,14 @@ void swb_tbe_dec_fx( } ELSE { - /* de-quantization */ +#ifdef HARM_BWE + dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp, + &shb_ener_sf_32, shb_res_gshape, &mixFactors, &j /*temp*/ ); +#else dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp, &shb_ener_sf_32, shb_res_gshape, &mixFactors ); +#endif Q_shb = 0; move16(); /* o: shb_ener_sf_32 in (2*Q_shb) */ @@ -3985,6 +3995,7 @@ static Word16 dotp_loc( Word16 i; Word32 suma; Word16 guarded_bits = find_guarded_bits_fx( n ); + suma = L_shr( Mpy_32_16_1( y[0], x[0] ), guarded_bits ); /*Qx + Qy - guarded_bits*/ FOR( i = 1; i < n; i++ ) @@ -3996,7 +4007,18 @@ static Word16 dotp_loc( return extract_h( suma ); /*Qx + Qy - 16*/ } + +/*-------------------------------------------------------------------* + * dequantizeSHBparams() + * + * Dequantize super highband spectral envolope, temporal gains and frame gain + *-------------------------------------------------------------------*/ + +#ifdef HARM_BWE +static void dequantizeSHBparams_fx( +#else void ivas_dequantizeSHBparams_fx_9_1( +#endif Decoder_State *st_fx, const Word16 extl, /* i : extension layer */ Word32 extl_brate, /* i : extensiuon layer bitrate */ @@ -4428,7 +4450,7 @@ void ivas_dequantizeSHBparams_fx_9_1( return; } - +#ifndef HARM_BWE /*==========================================================================*/ /* FUNCTION : static void dequantizeSHBparams_fx_9_1 () */ /*--------------------------------------------------------------------------*/ @@ -4747,6 +4769,7 @@ static void dequantizeSHBparams_fx_9_1( return; } +#endif /*-------------------------------------------------------------------* * fb_tbe_dec() @@ -4879,7 +4902,7 @@ void fb_tbe_dec_ivas_fx( Copy_Scale_sig( fb_synth, fb_synth_ref, L_FRAME48k, sub( Q_fb_synth_ref, add( hb_synth_exp, 16 ) ) ); // scaling is required } -/* add the fb_synth component to the hb_synth component */ + /* add the fb_synth component to the hb_synth component */ #ifdef HARM_BWE IF( st->element_mode == EVS_MONO ) { @@ -5935,8 +5958,13 @@ void ivas_swb_tbe_dec_fx( ELSE { /* de-quantization */ +#ifdef HARM_BWE + dequantizeSHBparams_fx( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp, + &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag ); +#else ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp, &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag ); +#endif if ( hStereoICBWE != NULL ) { hStereoICBWE->MSFlag = MSFlag; diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index b6d47f23b..622f2225c 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -79,9 +79,6 @@ ivas_error evs_enc_fx( #endif ivas_error error; SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR; - // NOISE_EST_HANDLE hNoiseEst = st->hNoiseEst; - // VAD_HANDLE hVAD = st->hVAD; - // DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; LPD_state_HANDLE hLPDmem = st->hLPDmem; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; @@ -95,7 +92,6 @@ ivas_error evs_enc_fx( Q_shb_spch = 0; move16(); /* to avoid compiler warnings */ - /*------------------------------------------------------------------* * Initializiation *-----------------------------------------------------------------*/ @@ -176,19 +172,19 @@ ivas_error evs_enc_fx( /*---------------------------------------------------------------------* * Pre-processing *---------------------------------------------------------------------*/ + #ifdef FIX_I4_OL_PITCH - pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type ); + pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag, + &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r ); #else pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, pitch_orig, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r ); #endif - // st->sharpFlag = sharpFlag; IF( EQ_16( st->mdct_sw, MODE2 ) ) { - Mpy_32_16_ss( st->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ st->bits_frame_nominal = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ @@ -271,6 +267,7 @@ ivas_error evs_enc_fx( acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag, attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, Q_new, shift ); } + /*---------------------------------------------------------------------* * HQ core encoding *---------------------------------------------------------------------*/ @@ -283,6 +280,7 @@ ivas_error evs_enc_fx( /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ + core_switching_post_enc_fx( st, old_inp_12k8, old_inp_16k, A, shift, Q_new, st->Q_syn2, &Q_synth ); #ifndef FIX_I4_OL_PITCH IF( EQ_16( st->core, HQ_CORE ) ) @@ -447,6 +445,7 @@ ivas_error evs_enc_fx( * SWB(FB) TBE encoding * SWB BWE encoding *---------------------------------------------------------------------*/ + test(); IF( !st->Opt_SC_VBR && GE_32( st->input_Fs, 32000 ) ) { @@ -476,7 +475,11 @@ ivas_error evs_enc_fx( IF( EQ_16( st->extl, FB_TBE ) ) { /* FB TBE encoder */ +#ifdef HARM_BWE + fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc, 0 ); +#else fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc ); +#endif } IF( EQ_16( st->codec_mode, MODE2 ) ) @@ -649,9 +652,11 @@ static void initFrameHeader_loc( Encoder_State *st ) * * Write MODE2 frame header *-------------------------------------------------------------------*/ -static void writeFrameHeader_loc( Encoder_State *st ) -{ +static void writeFrameHeader_loc( + Encoder_State *st /* i/o: encoder state structure */ +) +{ BSTR_ENC_HANDLE hBstr = st->hBstr; IF( NE_32( st->core_brate, FRAME_NO_DATA ) ) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 14230d021..ab3aadeb0 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -786,7 +786,11 @@ ivas_error ivas_core_enc_fx( IF( EQ_16( st->extl, FB_TBE ) ) { /* FB TBE encoder */ +#ifdef HARM_BWE + fb_tbe_enc_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp ); +#else fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp ); +#endif } } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 20a32694d..598301820 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -159,15 +159,17 @@ Word16 dtx_hangover_addition_fx( Word16 *rem_dtx_ho ); void fb_tbe_enc_fx( +#ifndef HARM_BWE Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : i speech at 48 kHz sample rate */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ const Word16 Q_fb_exc ); void fb_tbe_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 new_input[], /* i : i speech at 48 kHz sample rate Q_new_input*/ - const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc*/ +#endif + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 new_input[], /* i : i speech at 48 kHz sample rate Q_new_input*/ + const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc*/ const Word16 Q_fb_exc, const Word16 Q_new_input ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index a6fcf90ef..6b0810af3 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -45,23 +45,27 @@ static Word16 closest_centroid_fx( const Word16 *data, const Word16 *weights, co static Word16 closest_centroid_lc_fx( const Word16 *data, const Word16 *quantizer, const Word16 centroids ); +#ifdef HARM_BWE +static void EstimateSHBFrameGain_fx( const Word16 element_mode, const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); +#else static void EstimateSHBFrameGain_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); static void EstimateSHBFrameGain_ivas_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); +#endif static void EstimateSHBGainShape_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, const Word16 *subwin, Word16 *n_subfr_saturation, const Flag limit_min_gain ); -static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ); +static Word32 pow_off_pk_fx( const Word16 a[], const Word16 len, const Word16 step ); -static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step ); +static Word32 pow_off_pk_corrected_fx( const Word16 a[], const Word16 len, const Word16 step ); static void find_max_mem_enc( Encoder_State *st_fx, Word16 *n_mem, Word16 *n_mem2 ); -static void rescale_genSHB_mem_enc( Encoder_State *st_fx, Word16 sf ); +static void rescale_genSHB_mem_enc( Encoder_State *st_fx, const Word16 sf ); static void find_max_mem_wb_enc( Encoder_State *st_fx, Word16 *n_mem ); -static void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf ); +static void rescale_genWB_mem_enc( Encoder_State *st_fx, const Word16 sf ); static void Quant_lower_LSF_fx( const Word16 lsf[], Word16 lsf_q[], Word16 lsf_idx[] ); @@ -218,9 +222,9 @@ void find_max_mem_enc( * Rescale genSHB memories *-------------------------------------------------------------------*/ -void rescale_genSHB_mem_enc( +static void rescale_genSHB_mem_enc( Encoder_State *st_fx, - Word16 sf ) + const Word16 sf ) { Word16 i; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -260,9 +264,14 @@ void rescale_genSHB_mem_enc( move16(); hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf ); move16(); + + return; } -void find_max_mem_wb_enc( Encoder_State *st_fx, Word16 *n_mem ) + +static void find_max_mem_wb_enc( + Encoder_State *st_fx, + Word16 *n_mem ) { Word16 i; Word16 n_mem_32; @@ -337,9 +346,14 @@ void find_max_mem_wb_enc( Encoder_State *st_fx, Word16 *n_mem ) move16(); *n_mem = s_max( *n_mem, 0 ); move16(); + + return; } -void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf ) + +static void rescale_genWB_mem_enc( + Encoder_State *st_fx, + const Word16 sf ) { Word16 i; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -385,6 +399,8 @@ void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf ) hBWE_TD->mem_csfilt_fx[i] = L_shl( hBWE_TD->mem_csfilt_fx[i], sf ); move32(); } + + return; } @@ -1136,8 +1152,13 @@ void wb_tbe_enc_fx( p2m_out = pow_off_pk_fx( GainShape, NUM_SHB_SUBFR / 2, 2 ); /* Estimate the gain parameter */ +#ifdef HARM_BWE + EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, + &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); +#else EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); +#endif /* If there's a big difference in the power of gains away from the peak gain */ /* due to poor quantization then suppress energy of the high band. */ @@ -1282,10 +1303,7 @@ void wb_tbe_enc_ivas_fx( Word32 LepsP[LPC_SHB_ORDER_WB + 1]; Word32 prev_pow, curr_pow, Lscale; - /* Word16 scale; */ - /*Word16 ramp_flag;*/ Word32 p2m_in, p2m_out; - /*Word16 cnt, max =0;*/ Word16 n_mem, Q_bwe_exc, Q_bwe_exc_ext, exp_out, Q_cur_pow, Q_prev_pow; /* Q_hb_frame; */ Word32 L_tmp, Lmax; Word16 tmp, exp, Q_out, sc; @@ -1305,7 +1323,6 @@ void wb_tbe_enc_ivas_fx( TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; move16(); - /*Word16 att = 32767;*/ set16_fx( bwe_exc_extended_16, 0, L_FRAME32k + NL_BUFF_OFFSET ); hb_new_speech = hb_old_speech + WBTBE_LOOK_LSUFBR_5_OVER_16; hb_frame = hb_old_speech + WBTBE_LSUBFR_5_OVER_16 + WBTBE_ANA_ALIGNDELAY; @@ -1404,20 +1421,11 @@ void wb_tbe_enc_ivas_fx( move16(); } - /* lsp_spacing_fx = 16384; move16(); */ lsp_spacing_fx = lsp_wb_temp_fx[0]; move16(); FOR( i = 1; i < LPC_SHB_ORDER_WB; i++ ) { - /*if ( i == 0 ) - { - tmp = lsp_wb_temp_fx[0]; move16(); - } - else - {*/ tmp = sub( lsp_wb_temp_fx[i], lsp_wb_temp_fx[i - 1] ); - /*} */ - lsp_spacing_fx = s_min( lsp_spacing_fx, tmp ); } @@ -1521,6 +1529,7 @@ void wb_tbe_enc_ivas_fx( /* Quantization of LSFs */ i = closest_centroid_fx( lsp_wb, weights_lsp, wb_bwe_lsfvq_cbook_8bit_fx, 256, LPC_SHB_ORDER_WB ); /*move16(); */ + #ifdef HARM_BWE IF( EQ_16( st_fx->codec_mode, MODE2 ) ) { @@ -1809,6 +1818,7 @@ void wb_tbe_enc_ivas_fx( temp_wb_fac_fx = 0; move16(); } + L_feedback = L_mult0( temp_wb_fac_fx, temp_wb_fac_fx ); FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) { @@ -1905,8 +1915,13 @@ void wb_tbe_enc_ivas_fx( } /* Estimate the gain parameter */ +#ifdef HARM_BWE + EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, + &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); +#else EstimateSHBFrameGain_ivas_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); +#endif /* If there's a big difference in the power of gains away from the peak gain */ /* due to poor quantization then suppress energy of the high band. */ @@ -2061,6 +2076,12 @@ void wb_tbe_enc_ivas_fx( } +/*-------------------------------------------------------------------* + * fb_tbe_reset_enc() + * + * Reset the extra parameters needed for FB TBE encoding + *-------------------------------------------------------------------*/ + void fb_tbe_reset_enc_fx( Word32 elliptic_bpf_2_48k_mem_fx[][4], Word32 *prev_fb_energy_fx, @@ -2839,8 +2860,13 @@ void swb_tbe_enc_fx( p2m_out_fx = pow_off_pk_fx( GainShape_fx, NUM_SHB_SUBFR, 4 ); /* Estimate the gain parameter */ +#ifdef HARM_BWE + EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, + GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); +#else EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); +#endif IF( EQ_16( st_fx->tec_tfa, 1 ) ) { @@ -4344,8 +4370,13 @@ void swb_tbe_enc_ivas_fx( } /* Estimate the gain parameter */ +#ifdef HARM_BWE + EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, + GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); +#else EstimateSHBFrameGain_ivas_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); +#endif IF( EQ_16( st_fx->tec_tfa, 1 ) ) { @@ -4697,7 +4728,11 @@ void swb_tbe_enc_ivas_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------*/ + static void EstimateSHBFrameGain_fx( +#ifdef HARM_BWE + const Word16 element_mode, /* i : element mode */ +#endif const Word16 length, /* i : SHB overlap length */ const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ const Word16 Q_oriSHB, /* i : Q of arget original SHB frame */ @@ -4709,6 +4744,7 @@ static void EstimateSHBFrameGain_fx( const Word16 *subwin_shb_local, /* i : SHB subframe window Q15 */ const Word16 n_subfr_saturation /* i : Number of subframes which saturated in GainShape oriNrg calculation */ ) +#ifndef HARM_BWE { const Word16 *skip; Word16 i, j, k, l_shb_lahead, l_frame; @@ -4893,6 +4929,7 @@ static void EstimateSHBFrameGain_ivas_fx( const Word16 *subwin_shb_local, /* i : SHB subframe window Q15 */ const Word16 n_subfr_saturation /* i : Number of subframes which saturated in GainShape oriNrg calculation */ ) +#endif { const Word16 *skip; Word16 i, j, k, l_shb_lahead, l_frame; @@ -4932,34 +4969,70 @@ static void EstimateSHBFrameGain_ivas_fx( move16(); j = skip[0]; move16(); - FOR( k = 0; k < length / 2; k++ ) - { - sum_gain = mult_r( subwin_shb_local[2 * k + 2], subgain[0] ); /* Q15 */ - mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain ); - move32(); /* Q(16+Q_synSHB) */ - mod_syn[j + k + length / 2] = L_mult0( synSHB[j + k + length / 2], subgain[0] ); - move32(); /* Q(16+Q_synSHB) */ - } - FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ ) +#ifdef HARM_BWE + IF( element_mode == EVS_MONO ) { - j = skip[i]; - move16(); - FOR( k = 0; k < length; k++ ) + FOR( k = 0; k < length / 2; k++ ) { - L_tmp = L_mult0( subwin_shb_local[k + 1], subgain[i] ); /* Q30 */ - sum_gain = round_fx( L_mac0( L_tmp, subwin_shb_local[length - k - 1], subgain[i - 1] ) ); /* Q14 */ - mod_syn[j + k] = L_mult( sum_gain, synSHB[j + k] ); + sum_gain = mult_r( subwin_shb_local[2 * k + 2], subgain[0] ); /* Q15 */ + mod_syn[j + k] = L_mult( synSHB[j + k], sum_gain ); + move32(); /* Q(16+Q_synSHB) */ + mod_syn[j + k + length / 2] = L_mult( synSHB[j + k + length / 2], subgain[0] ); + move32(); /* Q(16+Q_synSHB) */ + } + FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ ) + { + j = skip[i]; + move16(); + FOR( k = 0; k < length; k++ ) + { + L_tmp = L_mult0( subwin_shb_local[k + 1], subgain[i] ); /* Q30 */ + sum_gain = round_fx( L_mac0( L_tmp, subwin_shb_local[length - k - 1], subgain[i - 1] ) ); /* Q14 */ + mod_syn[j + k] = L_shl( L_mult( sum_gain, synSHB[j + k] ), 1 ); + move32(); /* Q(16+Q_synSHB) */ + } + } + FOR( k = 0; k < length / 2; k++ ) + { + j = skip[i]; + move16(); + sum_gain = mult_r( subwin_shb_fx[length - 2 * k - 2], subgain[i - 1] ); /* Q15 */ + mod_syn[j + k] = L_mult( synSHB[j + k], sum_gain ); move32(); /* Q(16+Q_synSHB) */ } } - FOR( k = 0; k < length / 2; k++ ) + ELSE +#endif { - j = skip[i]; - move16(); - sum_gain = mult_r( subwin_shb_fx[length - 2 * k - 2], subgain[i - 1] ); /* Q15 */ - mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain ); - move32(); /* Q(16+Q_synSHB) */ + FOR( k = 0; k < length / 2; k++ ) + { + sum_gain = mult_r( subwin_shb_local[2 * k + 2], subgain[0] ); /* Q15 */ + mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain ); + move32(); /* Q(16+Q_synSHB) */ + mod_syn[j + k + length / 2] = L_mult0( synSHB[j + k + length / 2], subgain[0] ); + move32(); /* Q(16+Q_synSHB) */ + } + FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ ) + { + j = skip[i]; + move16(); + FOR( k = 0; k < length; k++ ) + { + L_tmp = L_mult0( subwin_shb_local[k + 1], subgain[i] ); /* Q30 */ + sum_gain = round_fx( L_mac0( L_tmp, subwin_shb_local[length - k - 1], subgain[i - 1] ) ); /* Q14 */ + mod_syn[j + k] = L_mult( sum_gain, synSHB[j + k] ); + move32(); /* Q(16+Q_synSHB) */ + } + } + FOR( k = 0; k < length / 2; k++ ) + { + j = skip[i]; + move16(); + sum_gain = mult_r( subwin_shb_fx[length - 2 * k - 2], subgain[i - 1] ); /* Q15 */ + mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain ); + move32(); /* Q(16+Q_synSHB) */ + } } } ELSE @@ -4969,45 +5042,93 @@ static void EstimateSHBFrameGain_ivas_fx( join_length = i_mult2( num_join, length ); j = 0; move16(); - FOR( k = 0; k < length; k++ ) - { - sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */ - mod_syn[j] = L_mult0( synSHB[j], sum_gain ); - move32(); /* Q(16+Q_synSHB) */ - j++; - } - FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ ) + +#ifdef HARM_BWE + IF( element_mode == EVS_MONO ) { - FOR( k = 0; k < join_length - length; k++ ) + FOR( k = 0; k < length; k++ ) { - mod_syn[j] = L_mult0( synSHB[j], subgain[i * num_join] ); + sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */ + mod_syn[j] = L_mult( synSHB[j], sum_gain ); move32(); /* Q(16+Q_synSHB) */ j++; } + FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ ) + { + FOR( k = 0; k < join_length - length; k++ ) + { + mod_syn[j] = L_mult( synSHB[j], subgain[i * num_join] ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + FOR( k = 0; k < length; k++ ) + { + L_tmp = L_mult0( subwin_shb_local[length - k - 1], subgain[i * num_join] ); + tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */ + mod_syn[j] = L_shl( L_mult( tmp, synSHB[j] ), 1 ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + } + FOR( k = 0; k < join_length - length; k++ ) + { + mod_syn[j] = L_mult( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); + move32(); /* Q(16+Q_synSHB)*/ + j++; + } FOR( k = 0; k < length; k++ ) { - L_tmp = L_mult0( subwin_shb_local[length - k - 1], subgain[i * num_join] ); - tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */ + tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */ mod_syn[j] = L_mult( tmp, synSHB[j] ); - move32(); /* Q(16+Q_synSHB) */ + move32(); /* Q(16+Q_synSHB ) */ j++; } } - FOR( k = 0; k < join_length - length; k++ ) - { - mod_syn[j] = L_mult0( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); - move32(); /* Q(16+Q_synSHB)*/ - j++; - } - FOR( k = 0; k < length; k++ ) + ELSE +#endif { - tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */ - mod_syn[j] = L_mult0( tmp, synSHB[j] ); - move32(); /* Q(16+Q_synSHB ) */ - j++; + FOR( k = 0; k < length; k++ ) + { + sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */ + mod_syn[j] = L_mult0( synSHB[j], sum_gain ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ ) + { + FOR( k = 0; k < join_length - length; k++ ) + { + mod_syn[j] = L_mult0( synSHB[j], subgain[i * num_join] ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + + FOR( k = 0; k < length; k++ ) + { + L_tmp = L_mult0( subwin_shb_local[length - k - 1], subgain[i * num_join] ); + tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */ + mod_syn[j] = L_mult( tmp, synSHB[j] ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + } + FOR( k = 0; k < join_length - length; k++ ) + { + mod_syn[j] = L_mult0( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); + move32(); /* Q(16+Q_synSHB)*/ + j++; + } + FOR( k = 0; k < length; k++ ) + { + tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */ + mod_syn[j] = L_mult0( tmp, synSHB[j] ); + move32(); /* Q(16+Q_synSHB ) */ + j++; + } } } + /* adjust frame energy */ oriNrg = L_deposit_l( 0 ); synNrg = L_deposit_l( 0 ); @@ -5017,14 +5138,14 @@ static void EstimateSHBFrameGain_ivas_fx( sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB / 2*Q_synSHB - 2*/ } FOR( ; i < l_frame; i++ ) { oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB / 2*Q_oriSHB - 2*/ } tmp = add( l_frame, l_shb_lahead ); @@ -5033,7 +5154,7 @@ static void EstimateSHBFrameGain_ivas_fx( sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB / 2*Q_oriSHB - 2*/ } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -5056,7 +5177,17 @@ static void EstimateSHBFrameGain_ivas_fx( oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ } } - L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out ); + +#ifdef HARM_BWE + IF( element_mode == EVS_MONO ) + { + L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, shl( Q_synSHB, 1 ), &exp_out ); + } + ELSE +#endif + { + L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out ); + } exp_out = sub( exp_out, scaling ); frame_gain = L_shl_sat( L_tmp, sub( exp_out, 13 ) ); /* Q18 */ *GainFrame = frame_gain; @@ -5066,7 +5197,10 @@ static void EstimateSHBFrameGain_ivas_fx( } -static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) +static Word32 pow_off_pk_fx( + const Word16 a[], + const Word16 len, + const Word16 step ) { Word16 i, j; Word32 sum, L_tmp; @@ -5092,7 +5226,10 @@ static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) } -static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step ) +static Word32 pow_off_pk_corrected_fx( + const Word16 a[], + const Word16 len, + const Word16 step ) { Word16 i, j; Word32 sum, L_tmp; @@ -5404,6 +5541,7 @@ static void EstimateSHBGainShape_fx( /* RETURN ARGUMENTS : */ /* _ Word16 : index Q0 */ /*--------------------------------------------------------------------------*/ + static Word16 closest_centroid_fx( const Word16 *data, /* i : input data Qx*/ const Word16 *weights, /* i : weights */ @@ -5449,6 +5587,7 @@ static Word16 closest_centroid_fx( /* PURPOSE : Determine a set of closest VQ centroids for a given input */ /* Gain shape is 4 dimensional */ /*--------------------------------------------------------------------------*/ + static Word16 closest_centroid_lc_fx( const Word16 *data, /* i : input data Qx*/ const Word16 *quantizer, /* i : quantizer table Qx*/ @@ -6425,6 +6564,7 @@ return; /* RETURN ARGUMENTS : */ /* _ None */ /*------------------------------------------------------------*/ + static void determine_gain_weights_fx( const Word32 *gain, /* i : Gain parameter Q18 */ Word16 *weights, /* o : gain weights Q12/Q6*/ @@ -6489,6 +6629,7 @@ static void determine_gain_weights_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*------------------------------------------------------------------------------*/ + static void singlevectortest_gain_fx( const Word32 *inp, /* i : input gain vector Q18*/ const Word16 dimen, /* i : dimension of the input vector */ @@ -6557,6 +6698,7 @@ static void singlevectortest_gain_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*------------------------------------------------------------------------------*/ + static void return_M_Least_fx_GainFrame( const Word32 *inp, /* i: input Q18*/ const Word32 *codebook, /* i: codebook Q18*/ @@ -7592,6 +7734,7 @@ static void Quant_BWE_LSF_ivas_fx( *-------------------------------------------------------------------*/ void fb_tbe_enc_fx( +#ifndef HARM_BWE Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : input speech at 48 kHz sample rate */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ @@ -7713,6 +7856,7 @@ void fb_tbe_enc_fx( } void fb_tbe_enc_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : input speech at 48 kHz sample rate Q_new_input */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ @@ -7732,13 +7876,30 @@ void fb_tbe_enc_ivas_fx( TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; Word16 q_diff, q_input_fhb; Word64 temp1, temp2; +#ifdef HARM_BWE + Word16 offset; + + offset = 0; + move16(); + if ( st->element_mode > EVS_MONO ) + { + offset = NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); + } +#endif s_max_value = 0; move16(); +#ifdef HARM_BWE + FOR( i = 0; i < add( L_FRAME48k, offset ); i++ ) + { + s_max_value = s_max( s_max_value, abs_s( new_input[i - offset] ) ); + } +#else FOR( i = 0; i < L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); i++ ) { s_max_value = s_max( s_max_value, abs_s( new_input[i - NS2SA( 48000, DELAY_FIR_RESAMPL_NS )] ) ); } +#endif exp_temp = norm_s( s_max_value ); if ( s_max_value == 0 ) { @@ -7746,21 +7907,36 @@ void fb_tbe_enc_ivas_fx( move16(); } +#ifdef HARM_BWE + if ( st->element_mode == EVS_MONO ) + { + exp_temp = sub( exp_temp, 1 ); + } +#endif + +#ifdef HARM_BWE + Copy_Scale_sig( new_input - offset, input_fhb_new, add( L_FRAME48k, offset ), exp_temp ); +#else Copy_Scale_sig( new_input - NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_fhb_new, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), exp_temp ); +#endif exp_temp = add( exp_temp, Q_new_input ); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); } ELSE { +#ifdef HARM_BWE + elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new + offset, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); +#else elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); +#endif } test(); IF( GT_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_SCE ) ) { - IF( EQ_16( st->L_frame, L_FRAME ) ) { Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2; @@ -7783,75 +7959,147 @@ void fb_tbe_enc_ivas_fx( set16_fx( tmp_vec, 0, L_FRAME16k ); } - q_diff = sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q ); - Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); // hBWE_TD->old_input_fhb_fx_Q - Copy( tmp_vec, input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ) ); // exp_temp - IF( q_diff > 0 ) - { - scale_sig( input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ), negate( q_diff ) ); // hBWE_TD->old_input_fhb_fx_Q - q_input_fhb = hBWE_TD->old_input_fhb_fx_Q; +#ifdef HARM_BWE + IF( st->element_mode == EVS_MONO ) + { + Word32 L_tmp, temp32, fb_exc_energy32; + Word16 tmp1; + + Copy_Scale_sig( hBWE_TD->old_input_fhb_fx, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP, sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q ) ); + hBWE_TD->old_input_fhb_fx_Q = exp_temp; + Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); + Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); + Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); + temp32 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ + temp32 = L_add_sat( temp32, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ + hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ + hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); + fb_exc_energy32 = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ + + /*ratio = (float) sqrt( temp32 / fb_exc_energy );*/ + L_tmp = L_max( 1, temp32 ); /*Q6*/ + exp = norm_l( L_tmp ); + tmp = extract_h( L_shl( L_tmp, exp ) ); + exp = sub( sub( 31, sub( add( exp_temp, exp_temp ), 8 ) ), exp ); /* in Q15 (L_tmp in Q6)*/ + + exp2 = norm_l( fb_exc_energy32 ); + tmp2 = extract_h( L_shl( fb_exc_energy32, exp2 ) ); + tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /*1 - 9*/ + exp2 = sub( sub( 31, tmp1 ), exp2 ); /* in Q15 (L_tmp in Q6)*/ + + exp = sub( exp2, exp ); /* Denormalize and substract */ + IF( GT_16( tmp2, tmp ) ) + { + tmp2 = shr( tmp2, 1 ); + exp = add( exp, 1 ); + } + IF( 0 != tmp ) + { + tmp = div_s( tmp2, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ + L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ + } + ELSE + { + L_tmp = 0; + } + + /* idxGain = (short)( log2_f ((float)ratio) + 0.5f ); + idxGain = max( 0, min(15,idxGain) ); */ + ratio = 0; move16(); + IF( GE_32( L_tmp, 32768 ) ) + { + idxGain = 15; + move16(); + } + ELSE + { + ratio = extract_l( L_tmp ); + idxGain = sub( 14, norm_s( ratio ) ); + idxGain = s_max( 0, idxGain ); + } + + test(); + test(); + IF( GT_16( idxGain, 2 ) && LT_16( idxGain, 15 ) && GT_16( ratio, add( shl( 2, sub( idxGain, 1 ) ), shl( 2, sub( idxGain, 2 ) ) ) ) ) + { + idxGain = add( idxGain, 1 ); + } } ELSE +#endif { - scale_sig( input_fhb, Sample_Delay_HP, q_diff ); // exp_temp - q_input_fhb = exp_temp; + q_diff = sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q ); + Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); // hBWE_TD->old_input_fhb_fx_Q + Copy( tmp_vec, input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ) ); // exp_temp + IF( q_diff > 0 ) + { + scale_sig( input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ), negate( q_diff ) ); // hBWE_TD->old_input_fhb_fx_Q + q_input_fhb = hBWE_TD->old_input_fhb_fx_Q; + move16(); + } + ELSE + { + scale_sig( input_fhb, Sample_Delay_HP, q_diff ); // exp_temp + q_input_fhb = exp_temp; + move16(); + } + Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); + hBWE_TD->old_input_fhb_fx_Q = exp_temp; move16(); - } - Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - hBWE_TD->old_input_fhb_fx_Q = exp_temp; - move16(); - temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */ - temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( shl( q_input_fhb, 1 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb + temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */ + temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( shl( q_input_fhb, 1 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb - temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb - exp = W_norm( temp1 ); - temp1 = W_shl( temp1, exp ); // 2*q_input_fhb+exp - hBWE_TD->prev_fb_energy_fx = W_extract_h( temp1 ); // 2*q_input_fhb+exp-32 - move32(); - hBWE_TD->prev_fb_energy_fx_Q = sub( add( shl( q_input_fhb, 1 ), exp ), 32 ); - move16(); + temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb + exp = W_norm( temp1 ); + temp1 = W_shl( temp1, exp ); // 2*q_input_fhb+exp + hBWE_TD->prev_fb_energy_fx = W_extract_h( temp1 ); // 2*q_input_fhb+exp-32 + move32(); + hBWE_TD->prev_fb_energy_fx_Q = sub( add( shl( q_input_fhb, 1 ), exp ), 32 ); + move16(); - fb_exc_energy = sum2_fx_no_sat( fb_exc, L_FRAME16k ); // 2*Q_fb_exc + fb_exc_energy = sum2_fx_no_sat( fb_exc, L_FRAME16k ); // 2*Q_fb_exc - /*ratio = (float) sqrt( temp2 / fb_exc_energy );*/ - exp = sub( W_norm( temp2 ), 1 ); - tmp = extract_h( W_extract_h( W_shl( temp2, exp ) ) ); // 2*q_input_fhb+exp-48 - exp = sub( 63, add( shl( q_input_fhb, 1 ), exp ) ); // 15-(2*q_input_fhb+exp-48) + /*ratio = (float) sqrt( temp2 / fb_exc_energy );*/ + exp = sub( W_norm( temp2 ), 1 ); + tmp = extract_h( W_extract_h( W_shl( temp2, exp ) ) ); // 2*q_input_fhb+exp-48 + exp = sub( 63, add( shl( q_input_fhb, 1 ), exp ) ); // 15-(2*q_input_fhb+exp-48) - exp2 = W_norm( fb_exc_energy ); - tmp2 = extract_h( W_extract_h( W_shl( fb_exc_energy, exp2 ) ) ); // 2*Q_fb_exc+exp2-48 - exp2 = sub( 63, add( shl( Q_fb_exc, 1 ), exp2 ) ); // 15-(2*Q_fb_exc+exp2-48) + exp2 = W_norm( fb_exc_energy ); + tmp2 = extract_h( W_extract_h( W_shl( fb_exc_energy, exp2 ) ) ); // 2*Q_fb_exc+exp2-48 + exp2 = sub( 63, add( shl( Q_fb_exc, 1 ), exp2 ) ); // 15-(2*Q_fb_exc+exp2-48) - ratio = 0; - idxGain = 0; - move16(); - move16(); - test(); - IF( tmp != 0 && tmp2 != 0 ) - { - ratio = div_s( tmp, tmp2 ); // exp: exp-exp2 - exp = sub( exp, exp2 ); - /* ratio = (float) sqrt( temp2 / fb_exc_energy ); - idxGain = (short)( log2_f ((float)ratio) + 0.5f ); + ratio = 0; + idxGain = 0; + move16(); + move16(); + test(); + IF( tmp != 0 && tmp2 != 0 ) + { + ratio = div_s( tmp, tmp2 ); // exp: exp-exp2 + exp = sub( exp, exp2 ); + /* ratio = (float) sqrt( temp2 / fb_exc_energy ); + idxGain = (short)( log2_f ((float)ratio) + 0.5f ); - => idxGain = (short)( log2_f (sqrt( temp2 / fb_exc_energy )) + 0.5f ) - = (short)(log2f(sqrt(temp2 / fb_exc_energy)) + log2f(sqrt(2))) - = (short)log2f(sqrt(2 * (temp2 / fb_exc_energy))) - increase the exp of division result by one, two accommodate the multiplication with 2 in sqrt - */ - exp = add( exp, 1 ); - ratio = Sqrt16( ratio, &exp ); - /* Since ratio always lie betwwen 16384 and 32767, subtract the Q of sqrt result from 14 to get the integral part of log value */ - idxGain = sub( exp, 1 ); // 14 - (15-exp) + => idxGain = (short)( log2_f (sqrt( temp2 / fb_exc_energy )) + 0.5f ) + = (short)(log2f(sqrt(temp2 / fb_exc_energy)) + log2f(sqrt(2))) + = (short)log2f(sqrt(2 * (temp2 / fb_exc_energy))) + increase the exp of division result by one, two accommodate the multiplication with 2 in sqrt + */ + exp = add( exp, 1 ); + ratio = Sqrt16( ratio, &exp ); + /* Since ratio always lie betwwen 16384 and 32767, subtract the Q of sqrt result from 14 to get the integral part of log value */ + idxGain = sub( exp, 1 ); // 14 - (15-exp) - /* idxGain = max( 0, min( 15, idxGain ) ); */ - idxGain = s_max( 0, s_min( 15, idxGain ) ); + /* idxGain = max( 0, min( 15, idxGain ) ); */ + idxGain = s_max( 0, s_min( 15, idxGain ) ); + } } /* ratio = (float)(1 << idxGain);*/ -#ifndef HARM_BWE IF( EQ_16( st->codec_mode, MODE2 ) ) { hBWE_TD->idxGain = idxGain; @@ -7859,11 +8107,8 @@ void fb_tbe_enc_ivas_fx( } ELSE { -#endif push_indice( st->hBstr, IND_FB_SLOPE, idxGain, 4 ); -#ifndef HARM_BWE } -#endif return; } -- GitLab From 94edac5f11696beca1b7506bca908753f27bd8f5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 30 Jan 2026 11:13:18 +0100 Subject: [PATCH 659/750] rename HARM_BWE -> HARMONIZE_TBE --- lib_com/ivas_prot_fx.h | 2 +- lib_com/options.h | 2 +- lib_com/prot_fx.h | 6 +- lib_dec/evs_dec_fx.c | 4 +- lib_dec/ivas_core_dec_fx.c | 4 +- lib_dec/swb_tbe_dec_fx.c | 42 ++++++------- lib_enc/evs_enc_fx.c | 4 +- lib_enc/ivas_core_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- lib_enc/swb_tbe_enc_fx.c | 126 ++++++++++++++++++------------------- 10 files changed, 97 insertions(+), 97 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 933aebfbb..39db9ec08 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1865,7 +1865,7 @@ void stereoFdCngCoherence_fx( Word16 fft_exp ); -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE void ivas_wb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ diff --git a/lib_com/options.h b/lib_com/options.h index ea62fd7e4..0e07484bb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,7 @@ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ #define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */ -#define HARM_BWE +#define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ce33afa73..948bfea0b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5775,7 +5775,7 @@ void swb_tbe_dec_fx( Word16 *Q_synth, Word16 *pitch_buf ); -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE void ivas_dequantizeSHBparams_fx_9_1( Decoder_State *st_fx, const Word16 extl, /* i : extension layer */ @@ -5790,7 +5790,7 @@ void ivas_dequantizeSHBparams_fx_9_1( Word16 *MSFlag ); #endif void fb_tbe_dec_fx( -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ Word16 Q_fb_exc, @@ -5802,7 +5802,7 @@ void fb_tbe_dec_ivas_fx( Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ Word16 Q_fb_exc, -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ #endif Word32 *hb_synth, /* o : high-band synthesis */ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 6ecfa4093..07b2deddc 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -408,7 +408,7 @@ ivas_error evs_dec_fx( test(); IF( EQ_16( output_frame, L_FRAME48k ) && EQ_16( st_fx->extl, FB_TBE ) ) { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame ); #else fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp ); @@ -847,7 +847,7 @@ ivas_error evs_dec_fx( test(); IF( EQ_16( st_fx->extl, FB_TBE ) && EQ_16( output_frame, L_FRAME48k ) ) { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame ); #else fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp ); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 623a6bca6..d7a837852 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1013,7 +1013,7 @@ ivas_error ivas_core_dec_fx( IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE decoder */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx ); #else ivas_wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx ); @@ -1081,7 +1081,7 @@ ivas_error ivas_core_dec_fx( /* FB TBE decoder */ IF( EQ_16( st->extl, FB_TBE ) ) { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE fb_tbe_dec_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, NULL, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); #else diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 41d9e320a..6498a8262 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -14,7 +14,7 @@ * Local functions *-----------------------------------------------------------------*/ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE static void dequantizeSHBparams_fx( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors, Word16 *MSFlag ); #else static void dequantizeSHBparams_fx_9_1( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors ); @@ -603,7 +603,7 @@ void ResetSHBbuffer_Dec_fx( /* CALLED FROM : */ /*==========================================================================*/ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE void wb_tbe_dec_fx( #else void ivas_wb_tbe_dec_fx( @@ -765,7 +765,7 @@ void ivas_wb_tbe_dec_fx( } ELSE { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE /* de-quantization */ dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &j /*temp*/ ); #else @@ -855,7 +855,7 @@ void ivas_wb_tbe_dec_fx( /* From low band excitation, generate highband excitation */ Lmax = 0; move32(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) @@ -880,7 +880,7 @@ void ivas_wb_tbe_dec_fx( { Q_bwe_exc = norm_l( Lmax ); } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { Q_bwe_exc = sub( Q_bwe_exc, 1 ); @@ -906,7 +906,7 @@ void ivas_wb_tbe_dec_fx( move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */ } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { prev_pow = 0; @@ -934,7 +934,7 @@ void ivas_wb_tbe_dec_fx( rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET ); @@ -942,7 +942,7 @@ void ivas_wb_tbe_dec_fx( #endif sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) @@ -966,7 +966,7 @@ void ivas_wb_tbe_dec_fx( Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, @@ -1000,7 +1000,7 @@ void ivas_wb_tbe_dec_fx( curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */ } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp ); @@ -1033,7 +1033,7 @@ void ivas_wb_tbe_dec_fx( max = 0; move16(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { FOR( i = 0; i < L_FRAME16k / 4; i++ ) @@ -1089,7 +1089,7 @@ void ivas_wb_tbe_dec_fx( } test(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( !st_fx->bfi && st_fx->prev_bfi ) #else test(); @@ -1290,7 +1290,7 @@ void ivas_wb_tbe_dec_fx( } ELSE IF( EQ_32( st_fx->output_Fs, 48000 ) ) { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { Scale_sig( hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, hBWE_TD->prev_Qx ) ); @@ -1361,7 +1361,7 @@ void ivas_wb_tbe_dec_fx( return; } -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE void wb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -2335,7 +2335,7 @@ void swb_tbe_dec_fx( ELSE { /* de-quantization */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp, &shb_ener_sf_32, shb_res_gshape, &mixFactors, &j /*temp*/ ); #else @@ -4014,7 +4014,7 @@ static Word16 dotp_loc( * Dequantize super highband spectral envolope, temporal gains and frame gain *-------------------------------------------------------------------*/ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE static void dequantizeSHBparams_fx( #else void ivas_dequantizeSHBparams_fx_9_1( @@ -4450,7 +4450,7 @@ void ivas_dequantizeSHBparams_fx_9_1( return; } -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE /*==========================================================================*/ /* FUNCTION : static void dequantizeSHBparams_fx_9_1 () */ /*--------------------------------------------------------------------------*/ @@ -4778,7 +4778,7 @@ static void dequantizeSHBparams_fx_9_1( *-------------------------------------------------------------------*/ void fb_tbe_dec_fx( -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ Word16 Q_fb_exc, @@ -4837,7 +4837,7 @@ void fb_tbe_dec_ivas_fx( Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ Word16 Q_fb_exc, -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ #endif Word32 *hb_synth, /* o : high-band synthesis Q(15 - hb_synth_exp) */ @@ -4903,7 +4903,7 @@ void fb_tbe_dec_ivas_fx( } /* add the fb_synth component to the hb_synth component */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st->element_mode == EVS_MONO ) { FOR( i = 0; i < L_FRAME48k; i++ ) @@ -5958,7 +5958,7 @@ void ivas_swb_tbe_dec_fx( ELSE { /* de-quantization */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE dequantizeSHBparams_fx( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp, &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag ); #else diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 622f2225c..18cd6b96f 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -425,7 +425,7 @@ ivas_error evs_enc_fx( IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE encoder */ -#ifdef HARM_BWEaa +#ifdef HARMONIZE_TBEaa wb_tbe_enc_ivas_fx( st, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf ); #else wb_tbe_enc_fx( st, st->coder_type, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf, st->voicing_fx ); @@ -475,7 +475,7 @@ ivas_error evs_enc_fx( IF( EQ_16( st->extl, FB_TBE ) ) { /* FB TBE encoder */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc, 0 ); #else fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index ab3aadeb0..b08dd6f67 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -786,7 +786,7 @@ ivas_error ivas_core_enc_fx( IF( EQ_16( st->extl, FB_TBE ) ) { /* FB TBE encoder */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE fb_tbe_enc_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp ); #else fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 598301820..bb85cd536 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -159,7 +159,7 @@ Word16 dtx_hangover_addition_fx( Word16 *rem_dtx_ho ); void fb_tbe_enc_fx( -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : i speech at 48 kHz sample rate */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 6b0810af3..86540d0cb 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -29,11 +29,11 @@ static void singlevectortest_gain_fx( const Word32 *inp, const Word16 dimen, con static void determine_gain_weights_fx( const Word32 *gain, Word16 *weights, const Word16 dims ); static void QuantizeSHBsubgains_fx( Encoder_State *st_fx, Word16 *subgains, const Word16 extl ); -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE static void QuantizeSHBsubgains_ivas_fx( Encoder_State *st_fx, Word16 subgains[], const Word16 extl ); #endif -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE static void QuantizeSHBframegain_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind, const Word16 flag_conservative ); #else static void QuantizeSHBframegain_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind ); @@ -45,7 +45,7 @@ static Word16 closest_centroid_fx( const Word16 *data, const Word16 *weights, co static Word16 closest_centroid_lc_fx( const Word16 *data, const Word16 *quantizer, const Word16 centroids ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE static void EstimateSHBFrameGain_fx( const Word16 element_mode, const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); #else static void EstimateSHBFrameGain_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); @@ -73,7 +73,7 @@ static Word16 Quant_mirror_point_fx( const Word16 lsf[], const Word16 lsf_q[], W static Word16 Find_LSF_grid_fx( const Word16 lsf[], Word16 lsf_q[], const Word16 m ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE static void Quant_BWE_LSF_fx( BSTR_ENC_HANDLE hBstr, TD_BWE_ENC_HANDLE hBWE_TD, const Word16 codec_mode, const Word16 lsf_shb_fx[], Word16 Q_lsfs_fx[], const Word32 extl_brate ); static void Quant_shb_ener_sf_fx( Encoder_State *st_fx, Word32 *shb_ener_sf_Q31, const Word16 Q_ener ); @@ -1152,7 +1152,7 @@ void wb_tbe_enc_fx( p2m_out = pow_off_pk_fx( GainShape, NUM_SHB_SUBFR / 2, 2 ); /* Estimate the gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); #else @@ -1231,7 +1231,7 @@ void wb_tbe_enc_fx( } /* Quantization of the frame gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &hRF->RF_bwe_gainFr_ind, 0 ); #else QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &hRF->RF_bwe_gainFr_ind ); @@ -1347,7 +1347,7 @@ void wb_tbe_enc_ivas_fx( k = 0; move16(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) @@ -1372,7 +1372,7 @@ void wb_tbe_enc_ivas_fx( } } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, WBTBE_LPCWIN_LENGTH, win_lpc_hb_wb_fx, 0, 1 ); @@ -1391,7 +1391,7 @@ void wb_tbe_enc_ivas_fx( Copy_Scale_sig( lpc_wb_temp_fx, lpc_wb_temp_fx, LPC_SHB_ORDER_WB + 1, sub( norm_s( lpc_wb_temp_fx[0] ), 2 ) ); // Q12 -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { /* convert into lsps and calculate weights */ @@ -1530,7 +1530,7 @@ void wb_tbe_enc_ivas_fx( /* Quantization of LSFs */ i = closest_centroid_fx( lsp_wb, weights_lsp, wb_bwe_lsfvq_cbook_8bit_fx, 256, LPC_SHB_ORDER_WB ); /*move16(); */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( EQ_16( st_fx->codec_mode, MODE2 ) ) { hBWE_TD->lsf_WB = i; @@ -1618,7 +1618,7 @@ void wb_tbe_enc_ivas_fx( prev_pow = 0; move32(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) @@ -1668,7 +1668,7 @@ void wb_tbe_enc_ivas_fx( rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ) ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET ); @@ -1682,7 +1682,7 @@ void wb_tbe_enc_ivas_fx( move16(); } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); @@ -1691,7 +1691,7 @@ void wb_tbe_enc_ivas_fx( Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 ); Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, @@ -1710,7 +1710,7 @@ void wb_tbe_enc_ivas_fx( curr_pow = 0; move32(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) @@ -1897,7 +1897,7 @@ void wb_tbe_enc_ivas_fx( push_indice( st_fx->hBstr, IND_UV_FLAG, uv_flag, 1 ); /* Quantization of the subframe gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE QuantizeSHBsubgains_fx( st_fx, GainShape, st_fx->extl ); #else QuantizeSHBsubgains_ivas_fx( st_fx, GainShape, st_fx->extl ); @@ -1915,7 +1915,7 @@ void wb_tbe_enc_ivas_fx( } /* Estimate the gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); #else @@ -1929,7 +1929,7 @@ void wb_tbe_enc_ivas_fx( IF( GT_32( p2m_out, L_shl( p2m_in, 1 ) ) ) { L_tmp = root_a_over_b_fx( L_shl( p2m_in, 1 ), 29, p2m_out, 29, &exp_out ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { GainFrame = L_shl( Mult_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */ @@ -1967,7 +1967,7 @@ void wb_tbe_enc_ivas_fx( } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { GainFrame = Mult_32_16( GainFrame, tmp ); /* Q18 */ @@ -1980,7 +1980,7 @@ void wb_tbe_enc_ivas_fx( IF( LT_16( lsp_spacing_fx, 328 ) && lsp_spacing_fx ) { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { GainFrame = Mult_32_16( GainFrame, 21299 ); /* Q18 */ @@ -2005,7 +2005,7 @@ void wb_tbe_enc_ivas_fx( IF( st_fx->igf != 0 && EQ_16( st_fx->coder_type, VOICED ) ) { /*GainFrame *= 0.5f;*/ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { GainFrame = Mult_32_16( GainFrame, 16384 ); @@ -2019,7 +2019,7 @@ void wb_tbe_enc_ivas_fx( ELSE IF( st_fx->igf != 0 && GT_16( avg_voice_fac, 11469 ) ) /*Q15 -> 0.35f*/ { /*GainFrame *= 0.75f;*/ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { GainFrame = Mult_32_16( GainFrame, 24576 ); @@ -2034,7 +2034,7 @@ void wb_tbe_enc_ivas_fx( /* Quantization of the frame gain parameter */ IF( st_fx->rf_mode ) { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &st_fx->hRF->RF_bwe_gainFr_ind, 0 ); #else QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &st_fx->hRF->RF_bwe_gainFr_ind, 0 ); @@ -2042,7 +2042,7 @@ void wb_tbe_enc_ivas_fx( } ELSE { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, NULL, 0 ); #else QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, NULL, 0 ); @@ -2051,7 +2051,7 @@ void wb_tbe_enc_ivas_fx( /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation*/ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode > EVS_MONO ) #endif { @@ -2063,7 +2063,7 @@ void wb_tbe_enc_ivas_fx( ScaleShapedSHB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, window_wb_fx, subwin_wb_fx, &Q_bwe_exc_ext, &dummy, dummy, dummy ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode > EVS_MONO ) #endif { @@ -2320,7 +2320,7 @@ void swb_tbe_enc_fx( ELSE { /* LSF quantization (21 bits) */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Quant_BWE_LSF_fx( st_fx->hBstr, hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl ); #else Quant_BWE_LSF_fx( st_fx, lsf_shb_fx, lsf_shb_fx ); @@ -2860,7 +2860,7 @@ void swb_tbe_enc_fx( p2m_out_fx = pow_off_pk_fx( GainShape_fx, NUM_SHB_SUBFR, 4 ); /* Estimate the gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); #else @@ -2975,7 +2975,7 @@ void swb_tbe_enc_fx( } /* Quantization of the frame gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind, 0 ); #else QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind ); @@ -3168,7 +3168,7 @@ void swb_tbe_enc_ivas_fx( move16(); TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE RF_ENC_HANDLE hRF = st_fx->hRF; #endif BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -3341,7 +3341,7 @@ void swb_tbe_enc_ivas_fx( /* Input signal filtering in case of tonal sounds in the high band gain Frame smoothing and attenuation control */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE gainFrSmooth_En_fx( st_fx, shb_frame_fx, lpc_shb_fx, lsf_shb_fx, &MA_lsp_shb_spacing, &frGainAttenuate, &frGainSmoothEn ); #else gainFrSmooth_En_ivas_fx( st_fx, shb_frame_fx, lpc_shb_fx, lsf_shb_fx, &MA_lsp_shb_spacing, &frGainAttenuate, &frGainSmoothEn ); @@ -3379,7 +3379,7 @@ void swb_tbe_enc_ivas_fx( ELSE { /* LSF quantization (21 bits) */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Quant_BWE_LSF_fx( hBstr, st_fx->hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl_brate ); #else Quant_BWE_LSF_ivas_fx( hBstr, st_fx->hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl_brate ); @@ -3557,7 +3557,7 @@ void swb_tbe_enc_ivas_fx( } shb_ener_sf_Q31 = Mult_32_16( shb_ener_sf_Q31, 102 /*0.003125f Q15*/ ); shb_ener_sf_Q31 = L_add( 1l /*1 Q0*/, shb_ener_sf_Q31 ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Quant_shb_ener_sf_fx( st_fx, &shb_ener_sf_Q31, shl( Q_shb, 1 ) ); #else Quant_shb_ener_sf_ivas_fx( st_fx, &shb_ener_sf_Q31, shl( Q_shb, 1 ) ); @@ -3608,7 +3608,7 @@ void swb_tbe_enc_ivas_fx( move16(); } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Quant_shb_res_gshape_fx( st_fx, shb_res_gshape_fx ); #else Quant_shb_res_gshape_ivas_fx( st_fx, shb_res_gshape_fx ); @@ -4320,7 +4320,7 @@ void swb_tbe_enc_ivas_fx( } /* Quantization of the gain shape parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE QuantizeSHBsubgains_fx( st_fx, GainShape_fx, st_fx->extl ); #else QuantizeSHBsubgains_ivas_fx( st_fx, GainShape_fx, st_fx->extl ); @@ -4370,7 +4370,7 @@ void swb_tbe_enc_ivas_fx( } /* Estimate the gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); #else @@ -4621,7 +4621,7 @@ void swb_tbe_enc_ivas_fx( } /* Quantization of the frame gain parameter */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, NULL, ( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) ? 1 : 0 ); #else IF( st_fx->rf_mode ) @@ -4730,7 +4730,7 @@ void swb_tbe_enc_ivas_fx( /*--------------------------------------------------------------------------*/ static void EstimateSHBFrameGain_fx( -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE const Word16 element_mode, /* i : element mode */ #endif const Word16 length, /* i : SHB overlap length */ @@ -4744,7 +4744,7 @@ static void EstimateSHBFrameGain_fx( const Word16 *subwin_shb_local, /* i : SHB subframe window Q15 */ const Word16 n_subfr_saturation /* i : Number of subframes which saturated in GainShape oriNrg calculation */ ) -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE { const Word16 *skip; Word16 i, j, k, l_shb_lahead, l_frame; @@ -4970,7 +4970,7 @@ static void EstimateSHBFrameGain_ivas_fx( j = skip[0]; move16(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( element_mode == EVS_MONO ) { FOR( k = 0; k < length / 2; k++ ) @@ -5043,7 +5043,7 @@ static void EstimateSHBFrameGain_ivas_fx( j = 0; move16(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( element_mode == EVS_MONO ) { FOR( k = 0; k < length; k++ ) @@ -5178,7 +5178,7 @@ static void EstimateSHBFrameGain_ivas_fx( } } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( element_mode == EVS_MONO ) { L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, shl( Q_synSHB, 1 ), &exp_out ); @@ -5767,7 +5767,7 @@ static void QuantizeSHBsubgains_fx( return; } -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE /*============================================================*/ /* FUNCTION : static void QuantizeSHBsubgains_ivas_fx() */ /*------------------------------------------------------------*/ @@ -5913,7 +5913,7 @@ static void QuantizeSHBsubgains_ivas_fx( *-------------------------------------------------------------------*/ static void Quant_shb_ener_sf_fx( -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *shb_ener_sf_Q31, /* i/o: super highband subframe energies */ Word16 Q_ener ) @@ -5981,7 +5981,7 @@ static void Quant_shb_ener_sf_ivas_fx( Word32 L_tmp1, L_tmp; Word32 sum; Word16 tmp; -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Word16 Q_fac; #endif TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -5993,7 +5993,7 @@ static void Quant_shb_ener_sf_ivas_fx( exp = norm_l( sum ); frac = Log2_norm_lc( L_shl( sum, exp ) ); exp = sub( 30, add( exp, Q_ener ) ); /* 30-(exp+Q_ener ) */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { L_tmp1 = Mpy_32_16( exp, frac, 617 ); /* 2466=LOG10(2) in Q11, so answer Ltmp in Q12 */ @@ -6027,7 +6027,7 @@ static void Quant_shb_ener_sf_ivas_fx( /* shb_ener_sf_fx[0] = pow(10.0, temp_shb_ener_sf_fx ); */ /* = pow(2, 3.321928*temp_shb_ener_sf_fx) */ L_tmp = L_mult( temp_shb_ener_sf_fx, 27213 ); /* 3.321928 in Q13 -> L_tmp in Q12/Q11+Q13+1 = Q26/Q25 */ -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE L_tmp = L_shl( L_tmp, Q_fac ); /* bring L_tmp from Q26/Q25 to Q16 */ #else L_tmp = L_shl( L_tmp, -9 ); /* bring L_tmp from Q25 to Q16 */ @@ -6055,7 +6055,7 @@ static void Quant_shb_ener_sf_ivas_fx( *-------------------------------------------------------------------*/ static void Quant_shb_res_gshape_fx( -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE Encoder_State *st_fx, /* i/o: encoder state structure */ Word16 shb_res_gshape_fx[] /* i/o: super highband gain shapes Q14 */ ) @@ -6143,7 +6143,7 @@ static void Quant_shb_res_gshape_ivas_fx( /*==========================================================================*/ static void QuantizeSHBframegain_fx( -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *GainFrame, /* i/o: Gain Q18 */ const Word16 extl, /* i : extension layer */ @@ -6341,7 +6341,7 @@ static void QuantizeSHBframegain_ivas_fx( 1 << NUM_BITS_SHB_FrameGain_LBR_WB, &idxFrameGain, &Q_GainFrame, SHBCB_FrameGain16_fx ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { IF( GT_32( Q_GainFrame, L_shl( Mult_32_16( *GainFrame, 17367 ), 1 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */ @@ -6935,7 +6935,7 @@ static Word16 Find_LSF_grid_fx( * * Gain frame smoothing and attenuation control *-------------------------------------------------------------------*/ -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE static void gainFrSmooth_En_fx( Encoder_State *st_fx, Word16 *shb_frame_fx, const Word16 *lpc_shb_fx, @@ -7060,7 +7060,7 @@ static void gainFrSmooth_En_fx( Encoder_State *st_fx, *-------------------------------------------------------------------*/ #endif -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE static void gainFrSmooth_En_fx( #else static void gainFrSmooth_En_ivas_fx( @@ -7119,7 +7119,7 @@ static void gainFrSmooth_En_ivas_fx( /* estimate the mean square error in lsps from current frame to past frames */ tempQ15_1 = sub( lsp_shb_fx[i], hBWE_TD->lsp_shb_slow_interpl_fx[i] ); tempQ15_2 = sub( lsp_shb_fx[i], hBWE_TD->lsp_shb_fast_interpl_fx[i] ); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO ) { lsp_slow_evol_rate = L_mac( lsp_slow_evol_rate, tempQ15_1, tempQ15_1 ); @@ -7189,7 +7189,7 @@ static void gainFrSmooth_En_ivas_fx( } test(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st_fx->element_mode == EVS_MONO && LT_32( lsp_slow_evol_rate, INV_1000_Q31 ) && LT_32( lsp_fast_evol_rate, 2147484l /*0.001f Q31*/ ) ) { *frGainSmoothEn = 1; @@ -7579,7 +7579,7 @@ static void LVQQuant_BWE_LSF_fx( * * Quantize super highband spectral envolope *-------------------------------------------------------------------*/ -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE static void Quant_BWE_LSF_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -7646,7 +7646,7 @@ static void Quant_BWE_LSF_fx( #endif -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE static void Quant_BWE_LSF_fx( #else static void Quant_BWE_LSF_ivas_fx( @@ -7734,7 +7734,7 @@ static void Quant_BWE_LSF_ivas_fx( *-------------------------------------------------------------------*/ void fb_tbe_enc_fx( -#ifndef HARM_BWE +#ifndef HARMONIZE_TBE Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : input speech at 48 kHz sample rate */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ @@ -7876,7 +7876,7 @@ void fb_tbe_enc_ivas_fx( TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; Word16 q_diff, q_input_fhb; Word64 temp1, temp2; -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Word16 offset; offset = 0; @@ -7889,7 +7889,7 @@ void fb_tbe_enc_ivas_fx( s_max_value = 0; move16(); -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE FOR( i = 0; i < add( L_FRAME48k, offset ); i++ ) { s_max_value = s_max( s_max_value, abs_s( new_input[i - offset] ) ); @@ -7907,14 +7907,14 @@ void fb_tbe_enc_ivas_fx( move16(); } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE if ( st->element_mode == EVS_MONO ) { exp_temp = sub( exp_temp, 1 ); } #endif -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE Copy_Scale_sig( new_input - offset, input_fhb_new, add( L_FRAME48k, offset ), exp_temp ); #else Copy_Scale_sig( new_input - NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_fhb_new, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), exp_temp ); @@ -7927,7 +7927,7 @@ void fb_tbe_enc_ivas_fx( } ELSE { -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new + offset, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); #else elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); @@ -7959,7 +7959,7 @@ void fb_tbe_enc_ivas_fx( set16_fx( tmp_vec, 0, L_FRAME16k ); } -#ifdef HARM_BWE +#ifdef HARMONIZE_TBE IF( st->element_mode == EVS_MONO ) { Word32 L_tmp, temp32, fb_exc_energy32; -- GitLab From e21d3a202a352816406e9568deb16aa81ff411de Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 30 Jan 2026 11:19:33 +0100 Subject: [PATCH 660/750] updt --- lib_enc/init_enc_fx.c | 9 +++++++-- lib_enc/ivas_stereo_switching_enc_fx.c | 4 ++++ lib_enc/ivas_stereo_td_enc_fx.c | 4 ++++ lib_enc/prot_fx_enc.h | 3 ++- lib_enc/swb_tbe_enc_fx.c | 2 ++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 4a55101d5..6781802a4 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -842,8 +842,9 @@ ivas_error init_encoder_fx( { return error; } - +#ifndef HARMONIZE_TBE InitSWBencBuffer_fx( st->hBWE_TD ); +#endif } ELSE { @@ -851,9 +852,13 @@ ivas_error init_encoder_fx( { return error; } - +#ifndef HARMONIZE_TBE InitSWBencBuffer_ivas_fx( st->hBWE_TD ); +#endif } +#ifdef HARMONIZE_TBE + InitSWBencBuffer_fx( st->hBWE_TD ); +#endif ResetSHBbuffer_Enc_fx( st->hBWE_TD ); } ELSE diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index a87edb39f..58f1fc7a5 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -434,7 +434,11 @@ ivas_error stereo_memory_enc_fx( } } +#ifdef HARMONIZE_TBE + InitSWBencBuffer_fx( st->hBWE_TD ); +#else InitSWBencBuffer_ivas_fx( st->hBWE_TD ); +#endif ResetSHBbuffer_Enc_fx( st->hBWE_TD ); IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 92bd08afd..be0234c41 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -325,7 +325,11 @@ ivas_error stereo_set_tdm_fx( return error; } +#ifdef HARMONIZE_TBE + InitSWBencBuffer_fx( st->hBWE_TD ); +#else InitSWBencBuffer_ivas_fx( st->hBWE_TD ); +#endif ResetSHBbuffer_Enc_fx( st->hBWE_TD ); IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index bb85cd536..7861d0d64 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3972,10 +3972,11 @@ void InitSWBencBuffer_fx( TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); +#ifndef HARMONIZE_TBE void InitSWBencBuffer_ivas_fx( TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); - +#endif void ResetSHBbuffer_Enc_fx( TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 86540d0cb..7bc5ae489 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -413,6 +413,7 @@ static void rescale_genWB_mem_enc( void InitSWBencBuffer_fx( TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) +#ifndef HARMONIZE_TBE { Word16 i; @@ -510,6 +511,7 @@ void InitSWBencBuffer_fx( void InitSWBencBuffer_ivas_fx( TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) +#endif { Word16 i; -- GitLab From 9723e7db98ad9915d3f1c8bbdc982d9a8d3b8f3b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 30 Jan 2026 11:22:10 +0100 Subject: [PATCH 661/750] fix copy of uninit values in MDCT-stereo core for bfi == 1 --- lib_com/options.h | 1 + lib_dec/ivas_stereo_mdct_core_dec_fx.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index b584b6931..171cc33f0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ +#define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index cb3173ea6..cdbe4a84c 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -382,6 +382,23 @@ void stereo_mdct_core_dec_fx( } } +#ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI + IF( NE_16( bfi, 1 ) ) + { +#ifdef FIX_2352_COPY_AQ_IN_TCX + FOR( ch = 0; ch < nChannels; ch++ ) +#else + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) +#endif + { +#ifdef FIX_2352_COPY_AQ_IN_TCX + Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], nSubframes[ch] * M, sub( Q16, Q12 ) ); /* Q16 */ +#else + Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ +#endif + } + } +#else #ifdef FIX_2352_COPY_AQ_IN_TCX FOR( ch = 0; ch < nChannels; ch++ ) #else @@ -394,6 +411,7 @@ void stereo_mdct_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ #endif } +#endif /*--------------------------------------------------------------------------------* * Stereo processing -- GitLab From 26c610621d2618b86d2c9e87e3429fca69e4db52 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 30 Jan 2026 11:32:21 +0100 Subject: [PATCH 662/750] updt --- lib_com/ivas_prot_fx.h | 2 ++ lib_dec/swb_tbe_dec_fx.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 39db9ec08..e2d5a52ee 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1601,6 +1601,7 @@ void ivas_hq_core_dec_fx( Word16 *Q_output ); +#ifndef HARMONIZE_TBE void ivas_HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ @@ -1616,6 +1617,7 @@ void ivas_HQ_FEC_Mem_update_fx( Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ Word16 output_frame ); +#endif /* o : Consumed bits Q0 */ Word16 ivas_hq_classifier_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 6498a8262..910e2f756 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -259,13 +259,21 @@ static void rescale_genSHB_mem_dec( { FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { +#ifdef HARMONIZE_TBE + hBWE_TD->state_lpc_syn_fx[i] = shl_sat( hBWE_TD->state_lpc_syn_fx[i], sf ); +#else hBWE_TD->state_lpc_syn_fx[i] = shl( hBWE_TD->state_lpc_syn_fx[i], sf ); +#endif move16(); } FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { +#ifdef HARMONIZE_TBE + hBWE_TD->state_syn_shbexc_fx[i] = shl_sat( hBWE_TD->state_syn_shbexc_fx[i], sf ); +#else hBWE_TD->state_syn_shbexc_fx[i] = shl( hBWE_TD->state_syn_shbexc_fx[i], sf ); +#endif move16(); } } @@ -5542,6 +5550,7 @@ static void calc_tilt_bwe_fx_loc( return; } +#ifndef HARMONIZE_TBE /*-------------------------------------------------------------------* * swb_tbe_dec() * @@ -5588,6 +5597,7 @@ static void rescale_genSHB_mem_dec_ivas( return; } +#endif static void find_max_mem_dec_m3( Decoder_State *st, @@ -6358,7 +6368,11 @@ void ivas_swb_tbe_dec_fx( sc = sub( Q_bwe_exc, st->prev_Q_bwe_exc ); IF( sc != 0 ) { +#ifdef HARMONIZE_TBE + rescale_genSHB_mem_dec( st, sc ); +#else rescale_genSHB_mem_dec_ivas( st, sc ); +#endif } /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */ -- GitLab From 1467784cd0a33552f721315fa4222e046619ec8a Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 30 Jan 2026 13:00:45 +0100 Subject: [PATCH 663/750] fix, updt --- lib_com/ivas_prot_fx.h | 4 +- lib_com/prot_fx.h | 114 +++++++++++++--------- lib_com/swb_tbe_com_fx.c | 129 ++++++++++++++----------- lib_dec/swb_tbe_dec_fx.c | 11 ++- lib_enc/evs_enc_fx.c | 4 +- lib_enc/init_enc_fx.c | 2 +- lib_enc/ivas_core_enc_fx.c | 4 + lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_enc/ivas_stereo_td_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 5 + lib_enc/swb_tbe_enc_fx.c | 27 +++++- 11 files changed, 187 insertions(+), 117 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index e2d5a52ee..b4d09d5ec 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1877,7 +1877,7 @@ void ivas_wb_tbe_dec_fx( Word16 *synth, /* o : WB synthesis/final synthesis */ Word16 *Q_synth ); -#endif + void GenShapedWBExcitation_ivas_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ @@ -1896,7 +1896,7 @@ void GenShapedWBExcitation_ivas_fx( const Word16 uv_flag, /* i : unvoiced flag */ const Word16 igf_flag ); - +#endif /* o : Q_syn_hb*/ Word16 ivas_wb_bwe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 948bfea0b..c45c2a749 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2856,11 +2856,12 @@ void Calc_rc0_h( Word16 *rc0 /* o : 1st parcor */ ); +#ifndef HARMONIZE_TBE void Calc_rc0_h_ivas_enc_fx( Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ ); - +#endif void PostShortTerm_fx( Word16 *sig_in, /* i : i signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ @@ -2895,11 +2896,11 @@ void PostShortTerm_ivas_dec_fx( ); void flip_spectrum_and_decimby4_fx( - const Word16 i[], /* i : i spectrum */ + const Word16 i[], /* i : i spectrum */ Word16 output[], /* o : output spectrum */ const Word16 length, /* i : vector length */ - Word16 mem1[], /* i/o : memory */ - Word16 mem2[], /* i/o : memory */ + Word16 mem1[], /* i/o: memory */ + Word16 mem2[], /* i/o: memory */ const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ ); @@ -2913,69 +2914,90 @@ void GenShapedWBExcitation_fx( Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ Word16 *state_lpc_syn, /* i/o : memory */ const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ + const Word16 element_mode, /* i : element mode */ const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_bwe_exc, - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor */ + const Word16 Q_bwe_exc, /* i : Q for memories */ + Word16 bwe_seed[], /* i/o : random number generator seed */ + const Word16 voice_factors[], /* i : voicing factor */ const Word16 signal_type, const Word16 igf_flag ); +#ifdef HARMONIZE_TBE +void GenShapedWBExcitation_ivas_fx( + Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ + Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/ + Word32 *mem_csfilt, /* i/o: memory Q_bwe_exc+16*/ + Word16 *mem_genSHBexc_filt_down1, /* i/o: memory Q_bwe_exc*/ + Word16 *mem_genSHBexc_filt_down2, /* i/o: memory Q_bwe_exc*/ + Word16 *mem_genSHBexc_filt_down3, /* i/o: memory Q_bwe_exc*/ + Word16 *state_lpc_syn, /* i/o: memory Q_bwe_exc*/ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/ + const Word16 Q_bwe_exc, /* i : Q for memories */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + const Word16 voice_factors[], /* i : voicing factor Q15*/ + const Word16 uv_flag, /* i : unvoiced flag */ + const Word16 igf_flag /* i : IGF flag */ +); + +#endif void GenWBSynth_fx( - const Word16 *input_synspeech, /* i : i synthesized speech */ + const Word16 *input_synspeech, /* i : i synthesized speech */ Word16 *shb_syn_speech_16k, /* o : output highband compnent */ Word16 *state_lsyn_filt_shb1, /* i/o: memory */ Word16 *state_lsyn_filt_shb2 /* i/o: memory */ ); void GenShapedSHBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ Word32 *mem_csfilt, /* i/o: memory */ Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ Word16 *tbe_demph, /* i/o: de-emphasis memory */ Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ + Word16 *lpc_shb_sf, /* i : LP coefficients */ + const Word32 shb_ener_sf_32, /* i : i shb ener, Q31 */ + Word16 *shb_res_gshape, /* i : i res gain shape, Q14 */ Word16 *shb_res, Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ Word16 fb_state_lpc_syn[], /* i/o: memory */ Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ Word16 *Q_bwe_exc, Word16 *Q_bwe_exc_fb, const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ const Word32 bitrate, const Word16 prev_bfi ); void GenShapedSHBExcitation_ivas_enc_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ Word32 *mem_csfilt, /* i/o: memory */ Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ Word16 *tbe_demph, /* i/o: de-emphasis memory */ Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *lpc_shb_sf, /* i : LP coefficients */ + const Word32 shb_ener_sf_32, /* i : input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i : input res gain shape, Q14 */ Word16 *shb_res, Word16 *vf_ind, const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ @@ -3087,19 +3109,19 @@ void ScaleShapedSHB_fx32( Word16 *Q_new ); void ScaleShapedWB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o : synthesized shb signal */ - Word16 *overlap, /* i/o : buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - const Word16 Q_bwe_exc, - Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ - Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ - Word16 *Qx, /* o : newly computed Q factor for synSHB */ - Word16 prev_Qx, /* i : prev_Qx for memory scaling */ - Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o: synthesized shb signal */ + Word16 *overlap, /* i/o: buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + const Word16 Q_bwe_exc, /* i : Q for memories */ + Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ + Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ + Word16 *Qx, /* o : newly computed Q factor for synSHB */ + Word16 prev_Qx, /* i : prev_Qx for memory scaling */ + Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ ); void non_linearity_fx( diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e06c8c4f6..8f5f19d13 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -8,30 +8,29 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" #include "basop_util.h" -#include "ivas_prot_fx.h" /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ -#define POW_EXC16k_WHTND 1.14e11f /* power of random excitation, length 320 samples, uniform distribution */ -#define POW_EXC16k_WHTND_FX_INV_SQRT 6360 // Q31 +#define POW_EXC16k_WHTND_FX_INV_SQRT 6360 // 1.14e11f in Q31 power of random excitation, length 320 samples, uniform distribution #define POW_EXC16k_WHTND_FX_INV_SQRT_IN_Q49 1667313793 // Q49 #define POW_EXC16k_WHTND_FX 178125000 // Q-6 -#define THR_ENV_ERROR_PLOSIVE 200.0f /* threshold for envelope error used in plosive detection */ #define THR_ENV_ERROR_PLOSIVE_FX 200 /* threshold for envelope error used in plosive detection Q0 */ + /*-----------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------*/ static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[], Word16 element_mode ); static void flip_spectrum_fx( const Word16 input[], Word16 output[], const Word16 length ); -static void Calc_st_filt_tbe( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero ); +static void Calc_st_filt_tbe_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero ); static void Hilbert_transform_fx( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id ); static void Hilbert_transform_sp_fx( Word16 tmp_R[], Word16 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id ); -void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind ); +static void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind ); + /*-------------------------------------------------------------------* * swb_tbe_reset() @@ -720,9 +719,15 @@ void Calc_rc0_h( *rc0 = negate( *rc0 ); move16(); } + + return; } +#ifdef HARMONIZE_TBE +static void Calc_rc0_h_ivas_enc_fx( +#else void Calc_rc0_h_ivas_enc_fx( +#endif Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ ) @@ -781,7 +786,7 @@ void Calc_rc0_h_ivas_enc_fx( } } -static void Calc_st_filt_tbe( +static void Calc_st_filt_tbe_fx( Word16 *apond2, /* i : coefficients of numerator */ Word16 *apond1, /* i : coefficients of denominator */ Word16 *parcor0, /* o : 1st parcor calcul. on composed filter */ @@ -819,6 +824,8 @@ static void Calc_st_filt_tbe( move16(); } } + + return; } static void Calc_st_filt_tbe_ivas_enc_fx( @@ -859,8 +866,11 @@ static void Calc_st_filt_tbe_ivas_enc_fx( move16(); } } + + return; } +#ifndef HARMONIZE_TBE static void Calc_st_filt_tbe_ivas_dec_fx( Word16 *apond2, /* i : coefficients of numerator */ Word16 *apond1, /* i : coefficients of denominator */ @@ -899,8 +909,10 @@ static void Calc_st_filt_tbe_ivas_dec_fx( move16(); } } -} + return; +} +#endif static void filt_mu_fx( const Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : output signal */ @@ -1103,7 +1115,7 @@ void PostShortTerm_fx( move16(); /* Control short term pst filter gain and compute parcor0 */ - Calc_st_filt_tbe( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); + Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); /* o: parcor0 in Q15 */ /* i/o: sig_ltp_fx in Q_bwe_exc */ @@ -1223,7 +1235,11 @@ void PostShortTerm_ivas_dec_fx( move16(); /* Control short term pst filter gain and compute parcor0 */ +#ifdef HARMONIZE_TBE + Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); +#else Calc_st_filt_tbe_ivas_dec_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); +#endif /* o: parcor0 in Q15 */ /* i/o: sig_ltp_fx in Q_bwe_exc */ @@ -1240,6 +1256,13 @@ void PostShortTerm_ivas_dec_fx( return; } + +/*-------------------------------------------------------------------* + * flip_spectrum_and_decimby4() + * + * + *-------------------------------------------------------------------*/ + void flip_spectrum_and_decimby4_fx( const Word16 input[], /* i : input spectrum Q_inp */ Word16 output[], /* o : output spectrum Q_inp */ @@ -1319,22 +1342,23 @@ void flip_spectrum_and_decimby4_fx( /*==========================================================================*/ void GenShapedWBExcitation_ivas_fx( - Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/ - Word32 *mem_csfilt, /* i/o : memory Q_bwe_exc+16*/ - Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q_bwe_exc*/ - Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q_bwe_exc*/ - Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q_bwe_exc*/ - Word16 *state_lpc_syn, /* i/o : memory Q_bwe_exc*/ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/ - const Word16 Q_bwe_exc, - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor Q15*/ - const Word16 uv_flag, /* i : unvoiced flag */ - const Word16 igf_flag ) + Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ + Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/ + Word32 *mem_csfilt, /* i/o: memory Q_bwe_exc+16*/ + Word16 *mem_genSHBexc_filt_down1, /* i/o: memory Q_bwe_exc*/ + Word16 *mem_genSHBexc_filt_down2, /* i/o: memory Q_bwe_exc*/ + Word16 *mem_genSHBexc_filt_down3, /* i/o: memory Q_bwe_exc*/ + Word16 *state_lpc_syn, /* i/o: memory Q_bwe_exc*/ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/ + const Word16 Q_bwe_exc, /* i : Q for memories */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + const Word16 voice_factors[], /* i : voicing factor Q15*/ + const Word16 uv_flag, /* i : unvoiced flag */ + const Word16 igf_flag /* i : IGF flag */ +) { Word16 i, j, k; Word16 wht_fil_mem[LPC_WHTN_ORDER_WB]; @@ -4868,7 +4892,6 @@ void ScaleShapedSHB_fx( } } - Q_gFr_norm = norm_l( frame_gain ); if ( frame_gain == 0 ) { @@ -5106,19 +5129,19 @@ void ScaleShapedSHB_fx32( *-------------------------------------------------------------------*/ void ScaleShapedWB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o : synthesized shb signal Q_bwe_exc/Qx */ - Word16 *overlap, /* i/o : buffer for overlap-add Q_bwe_exc/Qx */ - const Word16 *subgain, /* i : subframe gain Q15*/ - const Word32 frame_gain, /* i : frame gain Q18 */ - const Word16 *win, /* i : window Q15*/ - const Word16 *subwin, /* i : subframes window Q15*/ - const Word16 Q_bwe_exc, - Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ - Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ - Word16 *Qx, /* o : newly computed Q factor for synSHB */ - Word16 prev_Qx, /* i : prev_Qx for memory scaling */ - Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o: synthesized shb signal Q_bwe_exc/Qx*/ + Word16 *overlap, /* i/o: buffer for overlap-add Q_bwe_exc/Qx*/ + const Word16 *subgain, /* i : subframe gain Q15*/ + const Word32 frame_gain, /* i : frame gain Q18*/ + const Word16 *win, /* i : window Q15*/ + const Word16 *subwin, /* i : subframes window Q15*/ + const Word16 Q_bwe_exc, /* i : Q for memories */ + Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ + Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ + Word16 *Qx, /* o : newly computed Q factor for synSHB */ + Word16 prev_Qx, /* i : prev_Qx for memory scaling */ + Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ ) { const Word16 *skip; @@ -5128,6 +5151,7 @@ void ScaleShapedWB_fx( Word16 sum_gain; Word32 L_tmp; Word16 max_val, abs_sig, sc1, sc2, shift, max_headroom, min_shift, max_shift, max_shift2; + /* Init */ set32_fx( mod_syn, 0, L_FRAME16k + L_SHB_LAHEAD ); @@ -5225,7 +5249,6 @@ void ScaleShapedWB_fx( } } - max_val = 0; move16(); FOR( i = 0; i < l_frame + l_shb_lahead; i++ ) @@ -5997,6 +6020,7 @@ void interp_code_5over2_fx( Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[1] ); /*Q(16+x) */ interp_code_fx[i + 1] = round_fx( Ltemp ); /*Qx */ move16(); + return; } @@ -6224,7 +6248,6 @@ void elliptic_bpf_48k_generic_fx( } /*IsUpsampled3*/ - memory_fx2[0][0] = input_fx[L_FRAME48k - 4]; memory_fx2[0][1] = input_fx[L_FRAME48k - 3]; memory_fx2[0][2] = input_fx[L_FRAME48k - 2]; @@ -6272,7 +6295,6 @@ void elliptic_bpf_48k_generic_fx( } } - Q_temp = norm_l( L_tmpMax ); Q_temp = sub( Q_temp, 4 ); Scale_sig32( L_tmp2, 960, Q_temp ); @@ -6334,7 +6356,6 @@ void elliptic_bpf_48k_generic_fx( } } - memory_fx2[2][0] = L_tmp2[L_FRAME48k - 4]; memory_fx2[2][1] = L_tmp2[L_FRAME48k - 3]; memory_fx2[2][2] = L_tmp2[L_FRAME48k - 2]; @@ -6372,6 +6393,8 @@ void elliptic_bpf_48k_generic_fx( return; } + + /*-------------------------------------------------------------------* * synthesise_fb_high_band() * @@ -6428,20 +6451,12 @@ void synthesise_fb_high_band_fx( IF( EQ_16( L_frame, L_FRAME16k ) ) { /* for 16kHz ACELP core */ - elliptic_bpf_48k_generic_fx( - element_mode, - 1, // IsUpsampled3 - excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx - - ); + elliptic_bpf_48k_generic_fx( element_mode, 1, /* IsUpsampled3 */ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx ); } ELSE { /* for 12.8kHz ACELP core */ - elliptic_bpf_48k_generic_fx( - element_mode, - 1, // IsUpsampled3 - excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); + elliptic_bpf_48k_generic_fx( element_mode, 1, /* IsUpsampled3 */ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); } /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */ temp1 = sum2_fx_mod( tmp, L_FRAME48k ); @@ -6524,15 +6539,18 @@ void synthesise_fb_high_band_fx( move16(); } } + return; } + /*-------------------------------------------------------------------* * Estimate_mix_factors_fx() * * * * Estimate mix factors for SHB excitation generation * *-------------------------------------------------------------------*/ -void Estimate_mix_factors_fx( + +static void Estimate_mix_factors_fx( const Word16 *shb_res, /* i : SHB LP residual in Q = Q_shb */ const Word16 Q_shb, const Word16 *exc16kWhtnd, /* i : SHB transformed low band excitation Q_bwe_exc */ @@ -6596,7 +6614,6 @@ void Estimate_mix_factors_fx( /* (Q_bwe_exc) */ } - length = L_FRAME16k; move16(); temp_p1_p2 = Dot_product( temp_numer1, temp_numer2, length ); /* 2*(Q_bwe_exc)+1 */ @@ -6672,6 +6689,7 @@ void Estimate_mix_factors_fx( return; } + /*======================================================================================*/ /* FUNCTION : prep_tbe_exc_fx() */ /*--------------------------------------------------------------------------------------*/ @@ -6721,7 +6739,6 @@ void prep_tbe_exc_fx( const Word16 idchan, /* i : channel ID */ const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ - ) { Word16 i; diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 910e2f756..2d99d9a4a 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -7,7 +7,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "rom_dec.h" -#include "stl.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* @@ -278,9 +277,6 @@ static void rescale_genSHB_mem_dec( } } - if ( EQ_16( st_fx->extl, FB_TBE ) ) - { - } hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf ); move32(); @@ -292,6 +288,7 @@ static void rescale_genSHB_mem_dec( return; } + static void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem ) @@ -482,6 +479,12 @@ static void InitSWBdecBuffer_fx( } +/*-------------------------------------------------------------------* + * ResetSHBbuffer_Dec() + * + * + *-------------------------------------------------------------------*/ + void ResetSHBbuffer_Dec_fx( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ const Word16 extl /* i : BWE extension layer */ diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 18cd6b96f..45e58c5e8 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -425,8 +425,8 @@ ivas_error evs_enc_fx( IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE encoder */ -#ifdef HARMONIZE_TBEaa - wb_tbe_enc_ivas_fx( st, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf ); +#ifdef HARMONIZE_TBE + wb_tbe_enc_fx( st, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf ); #else wb_tbe_enc_fx( st, st->coder_type, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf, st->voicing_fx ); #endif diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 6781802a4..b30b95806 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -857,7 +857,7 @@ ivas_error init_encoder_fx( #endif } #ifdef HARMONIZE_TBE - InitSWBencBuffer_fx( st->hBWE_TD ); + InitSWBencBuffer_fx( st->element_mode, st->hBWE_TD ); #endif ResetSHBbuffer_Enc_fx( st->hBWE_TD ); } diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index b08dd6f67..214daa265 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -666,7 +666,11 @@ ivas_error ivas_core_enc_fx( IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE encoder */ +#ifdef HARMONIZE_TBE + wb_tbe_enc_fx( st, hb_speech_fx, bwe_exc_extended_fx[n], Q_new[n], voice_factors_fx[n], pitch_buf_fx[n] ); +#else wb_tbe_enc_ivas_fx( st, hb_speech_fx, bwe_exc_extended_fx[n], Q_new[n], voice_factors_fx[n], pitch_buf_fx[n] ); +#endif } ELSE IF( EQ_16( st->extl, WB_BWE ) && n == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 58f1fc7a5..a4a3080a7 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -435,7 +435,7 @@ ivas_error stereo_memory_enc_fx( } #ifdef HARMONIZE_TBE - InitSWBencBuffer_fx( st->hBWE_TD ); + InitSWBencBuffer_fx( st->element_mode, st->hBWE_TD ); #else InitSWBencBuffer_ivas_fx( st->hBWE_TD ); #endif diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index be0234c41..4e3b5fdd1 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -326,7 +326,7 @@ ivas_error stereo_set_tdm_fx( } #ifdef HARMONIZE_TBE - InitSWBencBuffer_fx( st->hBWE_TD ); + InitSWBencBuffer_fx( st->element_mode, st->hBWE_TD ); #else InitSWBencBuffer_ivas_fx( st->hBWE_TD ); #endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 7861d0d64..49c438515 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -700,6 +700,7 @@ void wb_pre_proc_ivas_fx( ); void wb_tbe_enc_fx( +#ifndef HARMONIZE_TBE Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 coder_type, /* i : coding type */ const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */ @@ -711,6 +712,7 @@ void wb_tbe_enc_fx( ); void wb_tbe_enc_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */ const Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation Q(2*Q_new) */ @@ -3969,6 +3971,9 @@ void noise_est_init_ivas_fx( ); void InitSWBencBuffer_fx( +#ifdef HARMONIZE_TBE + const Word16 element_mode, /* i : element mode */ +#endif TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 7bc5ae489..e11cd8d7b 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -18,6 +18,7 @@ #define ENVSHBRES_ACORR_MIN 40 /* minimum lag for calculating autocorrelation function on SHB residual TD envelope */ #define ENVSHBRES_ACORR_MAX 80 /* maximum lag for calculating autocorrelation function on SHB residual TD envelope */ + /*-----------------------------------------------------------------* * Local functions *-----------------------------------------------------------------*/ @@ -411,6 +412,9 @@ static void rescale_genWB_mem_enc( *-------------------------------------------------------------------*/ void InitSWBencBuffer_fx( +#ifdef HARMONIZE_TBE + const Word16 element_mode, /* i : element mode */ +#endif TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) #ifndef HARMONIZE_TBE @@ -593,10 +597,23 @@ void InitSWBencBuffer_ivas_fx( hBWE_TD->prev_fb_energy_fx_Q = 0; move16(); - hBWE_TD->prev_Q_bwe_exc = 15; - move16(); - hBWE_TD->prev_Q_bwe_syn = 15; - move16(); +#ifdef HARMONIZE_TBE + IF( element_mode == EVS_MONO ) + { + hBWE_TD->prev_Q_bwe_exc = 31; + move16(); + hBWE_TD->prev_Q_bwe_syn = 31; + move16(); + } + ELSE +#endif + { + hBWE_TD->prev_Q_bwe_exc = 51; + move16(); + hBWE_TD->prev_Q_bwe_syn = 15; + move16(); + } + set16_fx( hBWE_TD->prev_lsp_wb_fx, 0, 6 ); set16_fx( hBWE_TD->prev_lsp_wb_temp_fx, 0, 6 ); set16_fx( hBWE_TD->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); @@ -676,6 +693,7 @@ void ResetSHBbuffer_Enc_fx( #define WBTBE_LPCWIN_LENGTH ( L_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 16 - 1 void wb_tbe_enc_fx( +#ifndef HARMONIZE_TBE Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 coder_type, /* i : coding type */ const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz at Q-1 */ @@ -1276,6 +1294,7 @@ void wb_tbe_enc_fx( /*==========================================================================*/ void wb_tbe_enc_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */ const Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation Q(2*Q_new) */ -- GitLab From a6dcf4cbdaaf2229583c2558624a65a1a2bd3892 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 30 Jan 2026 14:00:33 +0100 Subject: [PATCH 664/750] address open questions --- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index cdbe4a84c..d61e541e9 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -383,7 +383,7 @@ void stereo_mdct_core_dec_fx( } #ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI - IF( NE_16( bfi, 1 ) ) + IF( !bfi ) { #ifdef FIX_2352_COPY_AQ_IN_TCX FOR( ch = 0; ch < nChannels; ch++ ) @@ -392,7 +392,7 @@ void stereo_mdct_core_dec_fx( #endif { #ifdef FIX_2352_COPY_AQ_IN_TCX - Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], nSubframes[ch] * M, sub( Q16, Q12 ) ); /* Q16 */ + Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], i_mult( nSubframes[ch], M ), sub( Q16, Q12 ) ); /* Q16 */ #else Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ #endif -- GitLab From a1e21be182aa40399ece7079869025a76d2f644b Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 30 Jan 2026 14:16:23 +0100 Subject: [PATCH 665/750] fix --- lib_enc/swb_tbe_enc_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index e11cd8d7b..3b7f0956d 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -6039,10 +6039,11 @@ static void Quant_shb_ener_sf_ivas_fx( temp_shb_ener_sf_fx = 0; move16(); idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 43, 1 << NUM_BITS_SHB_ENER_SF ); /* 43 = 0.042f in Q10 = Qin-1 */ - /* o: temp_shb_ener_sf_fx in Q11 */ - + /* o: temp_shb_ener_sf_fx in Q11 */ +#ifdef HARMONIZE_TBE Q_fac = -Q9; move16(); +#endif } /* shb_ener_sf_fx[0] = pow(10.0, temp_shb_ener_sf_fx ); */ -- GitLab From 8fe12e33030330a1cf0a16755fb6234b6eb1be1b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 30 Jan 2026 14:17:20 +0100 Subject: [PATCH 666/750] implement reviewer suggestions --- lib_com/ivas_rotation_com_fx.c | 15 +++++++++++++++ lib_rend/ivas_orient_trk_fx.c | 16 ++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 917d901d8..5fc6261a9 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -124,10 +124,18 @@ void modify_Quat_q_fx( Word16 q_new /* i : quaternion describing the rotation */ ) { +#ifdef FIX_BASOP_2361_OTR + Word16 shift = sub( q_new, in_quat->q_fact ); + out_quat->w_fx = L_shl_sat( in_quat->w_fx, shift ); // q_new + out_quat->x_fx = L_shl_sat( in_quat->x_fx, shift ); // q_new + out_quat->y_fx = L_shl_sat( in_quat->y_fx, shift ); // q_new + out_quat->z_fx = L_shl_sat( in_quat->z_fx, shift ); // q_new +#else out_quat->w_fx = L_shl_sat( in_quat->w_fx, sub( q_new, in_quat->q_fact ) ); // q_new out_quat->x_fx = L_shl_sat( in_quat->x_fx, sub( q_new, in_quat->q_fact ) ); // q_new out_quat->y_fx = L_shl_sat( in_quat->y_fx, sub( q_new, in_quat->q_fact ) ); // q_new out_quat->z_fx = L_shl_sat( in_quat->z_fx, sub( q_new, in_quat->q_fact ) ); // q_new +#endif out_quat->q_fact = q_new; return; } @@ -147,12 +155,19 @@ void modify_Rmat_q_fx( ) { Word16 j, k; +#ifdef FIX_BASOP_2361_OTR + Word16 shift = sub( q_new, q_cur ); +#endif FOR( j = 0; j < 3; j++ ) { FOR( k = 0; k < 3; k++ ) { +#ifdef FIX_BASOP_2361_OTR + Rmat_out[j][k] = L_shl( Rmat_in[j][k], shift ); +#else Rmat_out[j][k] = L_shl( Rmat_in[j][k], sub( q_new, q_cur ) ); +#endif move32(); } } diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 7d6e3750f..18fabc032 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -484,20 +484,20 @@ static Word32 VectorLength_fx( { #ifdef FIX_BASOP_2361_OTR Word16 sqrt_e; -#endif - Word32 result_fx = 0; - move32(); - result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31 -#ifdef FIX_BASOP_2361_OTR - sqrt_e = sub( 31, sub( add( p.q_fact, p.q_fact ), 31 ) ); /* convert Q to E */ + Word32 result_fx; + result_fx = Madd_32_32( Madd_32_32( Mpy_32_32( p.x_fx, p.x_fx ), p.y_fx, p.y_fx ), p.z_fx, p.z_fx ); + sqrt_e = shl( sub( 31, p.q_fact ), 1 ); /* convert Q to E */ result_fx = Sqrt32( result_fx, &sqrt_e ); *q_fact = sub( 31, sqrt_e ); /* back to Q again */ #else + Word32 result_fx = 0; + move32(); + result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31 + *q_fact = sub( add( p.q_fact, p.q_fact ), 31 ); #endif move16(); - return result_fx; } @@ -915,7 +915,7 @@ ivas_error ivas_orient_trk_Process_fx( Word16 scale_e; Word16 tmp; tmp = BASOP_Util_Divide3232_Scale( PI2_C_ADP_RATE_Q31, updateRate_fx, &scale_e ); - scale_e = add( scale_e, sub( 23, 31 ) ); /* updateRate_fx is hardcoded in caller to Q23 */ + scale_e = add( scale_e, 23 - 31 ); /* updateRate_fx is hardcoded in caller to Q23 */ /* sin(x) is approx x for small x */ pOTR->alpha_fx = L_deposit_h( tmp ); -- GitLab From f45b1a13b8b5bea501939a0652bc05958b2a98c6 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 14:51:57 +0100 Subject: [PATCH 667/750] Keep TC channel pointers in one constant place during decoding and rendering --- lib_com/ivas_prot_fx.h | 13 ++++++++++++ lib_com/ivas_tools_fx.c | 41 ++++++++++++++++++++++++++++++++++++ lib_com/options.h | 1 + lib_dec/ivas_dec_fx.c | 3 +++ lib_dec/ivas_dec_render_fx.c | 2 ++ lib_dec/ivas_stat_dec.h | 3 +++ lib_dec/lib_dec_fx.c | 8 +++++++ 7 files changed, 71 insertions(+) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4e380b17c..c970406f4 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2064,15 +2064,28 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( Word32 *audio, /* i/o: audio buffer */ const Word16 n_channels, /* i : number of channels */ const Word16 frame_length, /* i : frame length (one channel) */ +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ +#else const Word16 n_samp_full /* i : full frame length (one channel) */ +#endif ); +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER +void ivas_buffer_deinterleaved_to_interleaved_fx( + Word32 *audio, /* i/o: audio buffer */ + const Word16 n_channels, /* i : number of channels */ + const Word16 frame_length, /* i : frame length (one channel) */ + const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ +); +#else void ivas_buffer_deinterleaved_to_interleaved_fx( Word32 *audio[], /* i : deinterleaved audio buffer */ const Word16 n_channels, /* i : number of channels */ const Word16 frame_length, /* i : frame length (one channel) */ Word32 *audio_out /* o : interleaved audio buffer */ ); +#endif void stereo_tcx_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 52a84a92d..05d950b43 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -164,7 +164,11 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( Word32 *audio, /* i/o: audio buffer */ const Word16 n_channels, /* i : number of channels */ const Word16 frame_length, /* i : frame length (one channel) */ +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ +#else const Word16 n_samp_full /* i : full frame length (one channel) */ +#endif ) { Word16 offset, ch, m; @@ -184,7 +188,11 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( FOR( ch = 0; ch < n_channels; ch++ ) { Copy32( buffer[ch], audio + offset, frame_length ); +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + offset = add( offset, deinterleaved_stride ); +#else offset = add( offset, n_samp_full ); +#endif } return; @@ -197,6 +205,38 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( * Convert a deinterleaved buffer of audio channels to interleaved one *-------------------------------------------------------------------*/ +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER +void ivas_buffer_deinterleaved_to_interleaved_fx( + Word32 *audio, /* i/o: audio buffer */ + const Word16 n_channels, /* i : number of channels */ + const Word16 frame_length, /* i : frame length (one channel) */ + const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ +) +{ + Word16 offset, ch, m; + Word32 buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; + + offset = 0; + move16(); + FOR( ch = 0; ch < n_channels; ch++ ) + { + Copy32( audio + offset, buffer[ch], frame_length ); + offset = add( offset, deinterleaved_stride ); + } + + + FOR( ch = 0; ch < n_channels; ch++ ) + { + FOR( m = 0; m < frame_length; m++ ) + { + audio[m * n_channels + ch] = buffer[ch][m]; + move32(); + } + } + + return; +} +#else void ivas_buffer_deinterleaved_to_interleaved_fx( Word32 *audio[], /* i/o: deinterleaved audio buffer */ const Word16 n_channels, /* i : number of channels */ @@ -224,6 +264,7 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( return; } +#endif /*-------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index b584b6931..83bac531a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ +#define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index bd3eab3e4..a9fab7a06 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -1262,6 +1262,9 @@ static ivas_error ivas_dec_tc_audio_allocate_fx( move16(); } +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + hTcBuffer->tc_stride = n_samp_full; +#endif nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ), n_samp_full ); IF( Opt_tsm ) diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index 5b685edd4..1dc05fddd 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -109,6 +109,7 @@ void ivas_dec_feed_tc_to_renderer_fx( n_ch_full_copy = s_min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); +#ifndef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffer pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */ @@ -125,6 +126,7 @@ void ivas_dec_feed_tc_to_renderer_fx( } } +#endif FOR( ch = 0; ch < n_ch_full_copy; ch++ ) { Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1f406c338..56a111357 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1001,6 +1001,9 @@ typedef struct decoder_tc_buffer_structure Word32 *tc_buffer_old_fx[MAX_INTERN_CHANNELS]; /* TC audio samples not rendered in the previous frame */ Word32 *tc_buffer_fx; /* the buffer itself */ Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + Word16 tc_stride; /* Stride (offset) between subsequent channel pointers in tc_fx */ +#endif Word16 q_tc_fx; /* TC channels Q-factor */ TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ Word16 nchan_transport_rend; /* number of TCs provided to the renderer */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d1e5fc209..1c447a905 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3934,7 +3934,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } /* convert deinterleaved decoded TC audio channels buffer to an interleaved one */ +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, hIvasDec->nSamplesFrame, st_ivas->hTcBuffer->tc_stride ); +#else ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->p_output_fx, nTransportChannels, hIvasDec->nSamplesFrame, st_ivas->hTcBuffer->tc_buffer_fx ); +#endif IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { @@ -3954,7 +3958,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( move16(); /* convert interleaved time-scaled TC audio channels buffer to deinterleaved one */ +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, nSamplesTcsScaled, st_ivas->hTcBuffer->tc_stride ); +#else ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, nSamplesTcsScaled, NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); +#endif } else { -- GitLab From 508be0e23f5f33dfc09739b95d63bc0a11fdd08b Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 14:59:28 +0100 Subject: [PATCH 668/750] Fix formatting --- lib_com/ivas_tools_fx.c | 12 ++++++------ lib_dec/ivas_stat_dec.h | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 05d950b43..48543975e 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -165,9 +165,9 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( const Word16 n_channels, /* i : number of channels */ const Word16 frame_length, /* i : frame length (one channel) */ #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ + const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ #else - const Word16 n_samp_full /* i : full frame length (one channel) */ + const Word16 n_samp_full /* i : full frame length (one channel) */ #endif ) { @@ -207,10 +207,10 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER void ivas_buffer_deinterleaved_to_interleaved_fx( - Word32 *audio, /* i/o: audio buffer */ - const Word16 n_channels, /* i : number of channels */ - const Word16 frame_length, /* i : frame length (one channel) */ - const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ + Word32 *audio, /* i/o: audio buffer */ + const Word16 n_channels, /* i : number of channels */ + const Word16 frame_length, /* i : frame length (one channel) */ + const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ ) { Word16 offset, ch, m; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 56a111357..cfa5b41bf 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1002,17 +1002,17 @@ typedef struct decoder_tc_buffer_structure Word32 *tc_buffer_fx; /* the buffer itself */ Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - Word16 tc_stride; /* Stride (offset) between subsequent channel pointers in tc_fx */ + Word16 tc_stride; /* Stride (offset) between subsequent channel pointers in tc_fx */ #endif - Word16 q_tc_fx; /* TC channels Q-factor */ - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - Word16 nchan_transport_rend; /* number of TCs provided to the renderer */ - Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - Word16 nchan_buffer_full; /* number of channels to be fully buffered */ - Word16 n_samples_available; /* samples still available for rendering in the current frame */ - Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - Word16 n_samples_rendered; /* samples already rendered in the current frame */ - Word16 n_samples_granularity; /* render granularity */ + Word16 q_tc_fx; /* TC channels Q-factor */ + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + Word16 nchan_transport_rend; /* number of TCs provided to the renderer */ + Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + Word16 nchan_buffer_full; /* number of channels to be fully buffered */ + Word16 n_samples_available; /* samples still available for rendering in the current frame */ + Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + Word16 n_samples_rendered; /* samples already rendered in the current frame */ + Word16 n_samples_granularity; /* render granularity */ Word16 n_samples_flushed; Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; Word16 nb_subframes; -- GitLab From 559fd9f2ff44d65c83eb5e10c28c97d21922f7da Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 15:03:15 +0100 Subject: [PATCH 669/750] Remove unused variables --- lib_dec/ivas_dec_render_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index 1dc05fddd..93e30218b 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -83,8 +83,12 @@ void ivas_dec_feed_tc_to_renderer_fx( { Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k]; Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS]; +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER + Word16 n, n_render_timeslots, n_ch_cldfb, ch; +#else Word16 n, n_render_timeslots, n_ch_cldfb; Word16 ch, offset, len_offset; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; -- GitLab From a5f9279d6a8aed9f53ab9bd9534c33d9ec8b8bf6 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 30 Jan 2026 15:12:58 +0100 Subject: [PATCH 670/750] add equivalent fix in MCT code --- lib_dec/ivas_mct_dec_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index eb52b8ec1..b50fb4ae9 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -228,7 +228,12 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { #ifdef FIX_2382_COPY_AQ_IN_MCT +#ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI + test(); + IF( !st_ivas->bfi && NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) +#else IF( NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) +#endif { Word16 nSubframes; -- GitLab From a372743d752c038c688705d1cfd69b76231499c1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 30 Jan 2026 15:28:47 +0100 Subject: [PATCH 671/750] fix --- lib_dec/ivas_core_dec_fx.c | 1 - lib_enc/ivas_core_enc_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 4f813e50c..a7eebafb5 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1086,7 +1086,6 @@ ivas_error ivas_core_dec_fx( #ifdef HARMONIZE_TBE fb_tbe_dec_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, NULL, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); #else - fb_tbe_dec_ivas_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); #endif } diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 214daa265..2880c054a 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -759,7 +759,7 @@ ivas_error ivas_core_enc_fx( Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch Q_shb_spch = add( Q_shb_spch, shift ); #endif - IF( st->hBWE_FD ) // VE: to be moved to the end of swb_pre_proc_ivas_fx() + IF( st->hBWE_FD ) { shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); st->Q_old_wtda = add( st->Q_old_wtda, shift ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 3b7f0956d..d6fe95325 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -608,7 +608,7 @@ void InitSWBencBuffer_ivas_fx( ELSE #endif { - hBWE_TD->prev_Q_bwe_exc = 51; + hBWE_TD->prev_Q_bwe_exc = 15; move16(); hBWE_TD->prev_Q_bwe_syn = 15; move16(); -- GitLab From a8c09bd05266af40fe944bcdaca6d61cb75d2074 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 15:33:43 +0100 Subject: [PATCH 672/750] Move switch to non-BE section: FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 83bac531a..59700e19c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,7 +107,6 @@ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ -#define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ /* #################### End BE switches ################################## */ @@ -119,6 +118,7 @@ #define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ #define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ +#define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 112f7d6ee3e6ccfb122b7b691a690889c1128cbb Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 15:43:58 +0100 Subject: [PATCH 673/750] Add missing move16() --- lib_dec/ivas_dec_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index a9fab7a06..959b4bb45 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -1264,6 +1264,7 @@ static ivas_error ivas_dec_tc_audio_allocate_fx( #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER hTcBuffer->tc_stride = n_samp_full; + move16(); #endif nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ), n_samp_full ); -- GitLab From 6941a77d7ec8afcdade175d94adb0b2ddfa22926 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 15:44:40 +0100 Subject: [PATCH 674/750] Whitespace changes --- lib_com/ivas_tools_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 48543975e..90f538739 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -224,7 +224,6 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( offset = add( offset, deinterleaved_stride ); } - FOR( ch = 0; ch < n_channels; ch++ ) { FOR( m = 0; m < frame_length; m++ ) -- GitLab From cad35b811d2fd528d1236f73ba00d95bbd7762d2 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 16:34:45 +0100 Subject: [PATCH 675/750] Align fix with float repo --- lib_com/ivas_prot_fx.h | 21 ++++++++----- lib_com/ivas_tools_fx.c | 68 ++++++++++++++++++++++++++++------------- lib_dec/ivas_dec_fx.c | 4 --- lib_dec/ivas_stat_dec.h | 21 ++++++------- lib_dec/lib_dec_fx.c | 4 +-- 5 files changed, 71 insertions(+), 47 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c970406f4..2d66e6c17 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2060,23 +2060,28 @@ UWord32 ivas_syn_output_fx( Word16 *synth_out /* o : integer 16 bits synthesis signal */ ); +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER +void ivas_buffer_interleaved_to_deinterleaved_fx( + Word32 *audio_in, /* i : interleaved audio buffer */ + Word32 *audio_out[], /* o : pointers to each channel of deinterleaved audio buffer */ + const Word16 n_channels, /* i : number of channels */ + const Word16 frame_length /* i : frame length (one channel) */ +); +#else void ivas_buffer_interleaved_to_deinterleaved_fx( Word32 *audio, /* i/o: audio buffer */ const Word16 n_channels, /* i : number of channels */ const Word16 frame_length, /* i : frame length (one channel) */ -#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ -#else const Word16 n_samp_full /* i : full frame length (one channel) */ -#endif ); +#endif #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER void ivas_buffer_deinterleaved_to_interleaved_fx( - Word32 *audio, /* i/o: audio buffer */ - const Word16 n_channels, /* i : number of channels */ - const Word16 frame_length, /* i : frame length (one channel) */ - const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ + Word32 *audio_in[], /* i : pointers to each channel of deinterleaved audio buffer */ + Word32 *audio_out, /* o : interleaved audio buffer */ + const Word16 n_channels, /* i : number of channels */ + const Word16 frame_length /* i : frame length (one channel) */ ); #else void ivas_buffer_deinterleaved_to_interleaved_fx( diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 90f538739..14a9cc955 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -160,15 +160,43 @@ UWord32 ivas_syn_output_fx( * Convert an interleaved buffer of audio channels to deinterleaved one *-------------------------------------------------------------------*/ +#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER +void ivas_buffer_interleaved_to_deinterleaved_fx( + Word32 *audio_in, /* i : interleaved audio buffer */ + Word32 *audio_out[], /* o : pointers to each channel of deinterleaved audio buffer */ + const Word16 n_channels, /* i : number of channels */ + const Word16 frame_length /* i : frame length (one channel) */ +) +{ + Word16 ch, s; + Word32 buffer[MAX_TRANSPORT_CHANNELS][MAX_JBM_L_FRAME48k]; /* temp buffer needed when "*audio_in" and "*audio_out[]" point to the same memory */ + + FOR( ch = 0; ch < n_channels; ch++ ) + { + FOR( s = 0; s < frame_length; s++ ) + { + buffer[ch][s] = audio_in[s * n_channels + ch]; + move32(); + } + } + + FOR( ch = 0; ch < n_channels; ch++ ) + { + FOR( s = 0; s < frame_length; s++ ) + { + audio_out[ch][s] = buffer[ch][s]; + move32(); + } + } + + return; +} +#else void ivas_buffer_interleaved_to_deinterleaved_fx( Word32 *audio, /* i/o: audio buffer */ const Word16 n_channels, /* i : number of channels */ const Word16 frame_length, /* i : frame length (one channel) */ -#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ -#else - const Word16 n_samp_full /* i : full frame length (one channel) */ -#endif + const Word16 n_samp_full /* i : full frame length (one channel) */ ) { Word16 offset, ch, m; @@ -188,15 +216,12 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( FOR( ch = 0; ch < n_channels; ch++ ) { Copy32( buffer[ch], audio + offset, frame_length ); -#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - offset = add( offset, deinterleaved_stride ); -#else offset = add( offset, n_samp_full ); -#endif } return; } +#endif /*-------------------------------------------------------------------* @@ -207,28 +232,29 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER void ivas_buffer_deinterleaved_to_interleaved_fx( - Word32 *audio, /* i/o: audio buffer */ - const Word16 n_channels, /* i : number of channels */ - const Word16 frame_length, /* i : frame length (one channel) */ - const Word16 deinterleaved_stride /* i : offset between subsequent channels in deinterleaved layout */ + Word32 *audio_in[], /* i : pointers to each channel of deinterleaved audio buffer */ + Word32 *audio_out, /* o : interleaved audio buffer */ + const Word16 n_channels, /* i : number of channels */ + const Word16 frame_length /* i : frame length (one channel) */ ) { - Word16 offset, ch, m; - Word32 buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; + Word16 ch, s; + Word32 buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* temp buffer needed when "*audio_in[]" and "*audio_out" point to the same memory */ - offset = 0; - move16(); FOR( ch = 0; ch < n_channels; ch++ ) { - Copy32( audio + offset, buffer[ch], frame_length ); - offset = add( offset, deinterleaved_stride ); + FOR( s = 0; s < frame_length; s++ ) + { + buffer[ch][s] = audio_in[ch][s]; + move32(); + } } FOR( ch = 0; ch < n_channels; ch++ ) { - FOR( m = 0; m < frame_length; m++ ) + FOR( s = 0; s < frame_length; s++ ) { - audio[m * n_channels + ch] = buffer[ch][m]; + audio_out[s * n_channels + ch] = buffer[ch][s]; move32(); } } diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index 959b4bb45..bd3eab3e4 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -1262,10 +1262,6 @@ static ivas_error ivas_dec_tc_audio_allocate_fx( move16(); } -#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - hTcBuffer->tc_stride = n_samp_full; - move16(); -#endif nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ), n_samp_full ); IF( Opt_tsm ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index cfa5b41bf..1f406c338 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1001,18 +1001,15 @@ typedef struct decoder_tc_buffer_structure Word32 *tc_buffer_old_fx[MAX_INTERN_CHANNELS]; /* TC audio samples not rendered in the previous frame */ Word32 *tc_buffer_fx; /* the buffer itself */ Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ -#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - Word16 tc_stride; /* Stride (offset) between subsequent channel pointers in tc_fx */ -#endif - Word16 q_tc_fx; /* TC channels Q-factor */ - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - Word16 nchan_transport_rend; /* number of TCs provided to the renderer */ - Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - Word16 nchan_buffer_full; /* number of channels to be fully buffered */ - Word16 n_samples_available; /* samples still available for rendering in the current frame */ - Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - Word16 n_samples_rendered; /* samples already rendered in the current frame */ - Word16 n_samples_granularity; /* render granularity */ + Word16 q_tc_fx; /* TC channels Q-factor */ + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + Word16 nchan_transport_rend; /* number of TCs provided to the renderer */ + Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + Word16 nchan_buffer_full; /* number of channels to be fully buffered */ + Word16 n_samples_available; /* samples still available for rendering in the current frame */ + Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + Word16 n_samples_rendered; /* samples already rendered in the current frame */ + Word16 n_samples_granularity; /* render granularity */ Word16 n_samples_flushed; Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; Word16 nb_subframes; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 1c447a905..fbd748b84 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3935,7 +3935,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /* convert deinterleaved decoded TC audio channels buffer to an interleaved one */ #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, hIvasDec->nSamplesFrame, st_ivas->hTcBuffer->tc_stride ); + ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->p_output_fx, st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, hIvasDec->nSamplesFrame ); #else ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->p_output_fx, nTransportChannels, hIvasDec->nSamplesFrame, st_ivas->hTcBuffer->tc_buffer_fx ); #endif @@ -3959,7 +3959,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /* convert interleaved time-scaled TC audio channels buffer to deinterleaved one */ #ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER - ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, nSamplesTcsScaled, st_ivas->hTcBuffer->tc_stride ); + ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, st_ivas->p_output_fx, nTransportChannels, nSamplesTcsScaled ); #else ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, nSamplesTcsScaled, NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); #endif -- GitLab From 1c09f8b6b9cad840a8478bde3ad56bf884cb388c Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 30 Jan 2026 16:36:51 +0100 Subject: [PATCH 676/750] Fix formatting --- lib_com/ivas_tools_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 14a9cc955..fae273974 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -183,7 +183,7 @@ void ivas_buffer_interleaved_to_deinterleaved_fx( FOR( ch = 0; ch < n_channels; ch++ ) { FOR( s = 0; s < frame_length; s++ ) - { + { audio_out[ch][s] = buffer[ch][s]; move32(); } -- GitLab From c01b2c44575699f750dd94f90a202923c5ae2d7c Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 30 Jan 2026 11:05:37 -0500 Subject: [PATCH 677/750] Use target energy instead of lt_ener, adapt variable name accordingly --- lib_com/gs_gains_fx.c | 4 ++-- lib_com/gs_noisefill_fx.c | 13 +++++++------ lib_com/prot_fx.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index b25dace82..43c3e85e0 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -81,7 +81,7 @@ void Comp_and_apply_gain_fx( Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - const Word16 max_lt_ener, /* i : max_lt_ener of lt_ener_per_band_fx */ + const Word16 max_target_ener, /* i : max_target_ener of Ener_per_bd_iQ */ #endif Word16 Qexc_diff, Word16 Q_exc ) @@ -107,7 +107,7 @@ void Comp_and_apply_gain_fx( move16(); test(); test(); - IF( GT_16( Q_exc, 3 ) && EQ_16( ReUseGain, 0 ) && GT_16( max_lt_ener, 8192 /* 13 bits */ ) ) /* When lt_energy is high, Q_exc shouldn't be high too, addresses cases when switching from CNG */ + IF( GT_16( Q_exc, 3 ) && EQ_16( ReUseGain, 0 ) && GT_16( max_target_ener, 12 ) ) /* When target energy is high, Q_exc shouldn't be high too, addresses cases when switching from CNG or from almos*/ { Q_adapt = sub( 3 - 1, Q_exc ); /* add extra 1 bit headroom */ } diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index ec45be809..296df4cbc 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1082,7 +1082,7 @@ void highband_exc_dct_in_ivas_fx( Word16 tmp2; Word16 *end, Q_hb_exc; #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - Word16 max_lt_ener, old_Q_exc; + Word16 max_target_ener, old_Q_exc; #endif FOR( j = 10; j < MBANDS_GN; j++ ) @@ -1408,23 +1408,24 @@ void highband_exc_dct_in_ivas_fx( } } #elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX - max_lt_ener = 0; + max_target_ener = 0; move16(); IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep EVS BE */ { - FOR( i = 0; i < MBANDS_GN; i++ ) + FOR( i = 0; i < MBANDS_GN/2; i++ ) { - max_lt_ener = s_max( max_lt_ener, lt_ener_per_band_fx[i] ); + max_target_ener = s_max( max_target_ener, Ener_per_bd_iQ[i] ); } + max_target_ener = sub( 15, norm_s( max_target_ener ) ); } old_Q_exc = *Q_exc; move16(); - *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, max_lt_ener, Qexc_diffQ, *Q_exc ); + *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, max_target_ener, Qexc_diffQ, *Q_exc ); Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, old_Q_exc ) ); IF( exc_wo_nf != NULL ) { - Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, max_lt_ener, Qexc_diffQ, *Q_exc ); + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, max_target_ener, Qexc_diffQ, *Q_exc ); Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } #else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f71079f6c..0435db6a2 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1714,7 +1714,7 @@ void Comp_and_apply_gain_fx( Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - const Word16 max_lt_ener, /* i : max_lt_ener of lt_ener_per_band_fx */ + const Word16 max_target_ener, /* i : Ener_per_bd_iQ of lt_ener_per_band_fx */ #endif Word16 Qexc_diff, Word16 Q_exc ); -- GitLab From b82f9751cea168fc9633ce639a54a6dc0e654b2b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 30 Jan 2026 11:35:16 -0500 Subject: [PATCH 678/750] Fix clang --- lib_com/gs_noisefill_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 296df4cbc..cc487f876 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1412,7 +1412,7 @@ void highband_exc_dct_in_ivas_fx( move16(); IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep EVS BE */ { - FOR( i = 0; i < MBANDS_GN/2; i++ ) + FOR( i = 0; i < MBANDS_GN / 2; i++ ) { max_target_ener = s_max( max_target_ener, Ener_per_bd_iQ[i] ); } @@ -1429,13 +1429,13 @@ void highband_exc_dct_in_ivas_fx( Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } #else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */ - Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); + Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); - IF( exc_wo_nf != NULL ) - { - Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); - Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); - } + IF( exc_wo_nf != NULL ) + { + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); + } #endif /*--------------------------------------------------------------------------------------* -- GitLab From 044c43e067f08dd98786a4998697488ae0963aeb Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 30 Jan 2026 14:34:29 -0500 Subject: [PATCH 679/750] Change of strategy and and reuse Ittiam approache for the first computation of gains and Q_exc adjutement (for the second run, it not necessary as both excitation vectors have the same dynamic --- lib_com/gs_gains_fx.c | 61 ++++++++++++++++++++++++++++----------- lib_com/gs_noisefill_fx.c | 17 +++++------ lib_com/prot_fx.h | 2 +- 3 files changed, 52 insertions(+), 28 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 43c3e85e0..cb7cc852e 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -81,7 +81,7 @@ void Comp_and_apply_gain_fx( Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - const Word16 max_target_ener, /* i : max_target_ener of Ener_per_bd_iQ */ + const Word16 Flag_adj_q_exc, /* i : Flag allowing Q_exc adjustment */ #endif Word16 Qexc_diff, Word16 Q_exc ) @@ -92,6 +92,8 @@ void Comp_and_apply_gain_fx( Word16 L16, frac, exp1, tmp_exp; #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX Word16 Q_adapt; + Word16 Q_exc_diffQ[L_FRAME16k]; + Word32 exc_diffQ32[L_FRAME16k]; #endif Word32 L32; @@ -102,16 +104,7 @@ void Comp_and_apply_gain_fx( move16(); tmp_exp = add( 14, sub( Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/ -#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - Q_adapt = 0; - move16(); - test(); - test(); - IF( GT_16( Q_exc, 3 ) && EQ_16( ReUseGain, 0 ) && GT_16( max_target_ener, 12 ) ) /* When target energy is high, Q_exc shouldn't be high too, addresses cases when switching from CNG or from almos*/ - { - Q_adapt = sub( 3 - 1, Q_exc ); /* add extra 1 bit headroom */ - } -#endif + FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) { StartBin = add( StartBin, NB_Qbins ); @@ -147,18 +140,52 @@ void Comp_and_apply_gain_fx( move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - tmp_exp = add( tmp_exp, Q_adapt ); + IF( Flag_adj_q_exc != 0) + { + FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) + { + exc_diffQ32[i] = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ + move32(); + Q_exc_diffQ[i] = Q_exc; + if ( exc_diffQ[i] ) + { + Q_exc_diffQ[i] = sub( Q_exc_diffQ[i], tmp_exp ); + move16(); + } + } + } + ELSE #endif - FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { - L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ - exc_diffQ[i] = round_fx_sat( L_shl_sat( L32, tmp_exp ) ); /*Q_exc */ - move16(); + FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) + { + L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ + exc_diffQ[i] = round_fx_sat( L_shl_sat( L32, tmp_exp ) ); /*Q_exc */ + move16(); + } } + } } #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - return add( Q_exc, Q_adapt ); + Q_adapt = Q_exc; + move16(); + test(); + IF( EQ_16( ReUseGain, 0 ) && Flag_adj_q_exc != 0 ) + { + Word16 total_bins = add( StartBin, NB_Qbins ); + move16(); + FOR(i = 0; i < total_bins; i++) + { + Q_adapt = s_min( Q_adapt, add( Q_exc_diffQ[i], norm_l( exc_diffQ32[i] ) ) ); + move16(); + } + FOR(i = 0; i < total_bins; i++) + { + exc_diffQ[i] = round_fx( L_shl( exc_diffQ32[i], sub( Q_adapt, Q_exc_diffQ[i] ) ) ); /*Q_exc*/ + } + } + return Q_adapt; #else return; #endif diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index cc487f876..123e4a7f3 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1082,7 +1082,7 @@ void highband_exc_dct_in_ivas_fx( Word16 tmp2; Word16 *end, Q_hb_exc; #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - Word16 max_target_ener, old_Q_exc; + Word16 Flag_adj_q_exc, old_Q_exc; #endif FOR( j = 10; j < MBANDS_GN; j++ ) @@ -1408,24 +1408,21 @@ void highband_exc_dct_in_ivas_fx( } } #elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX - max_target_ener = 0; + Flag_adj_q_exc = 0; move16(); - IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep EVS BE */ + IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep all EVS BE */ { - FOR( i = 0; i < MBANDS_GN / 2; i++ ) - { - max_target_ener = s_max( max_target_ener, Ener_per_bd_iQ[i] ); - } - max_target_ener = sub( 15, norm_s( max_target_ener ) ); + Flag_adj_q_exc = 1; + move16(); } old_Q_exc = *Q_exc; move16(); - *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, max_target_ener, Qexc_diffQ, *Q_exc ); + *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Flag_adj_q_exc, Qexc_diffQ, *Q_exc ); Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, old_Q_exc ) ); IF( exc_wo_nf != NULL ) { - Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, max_target_ener, Qexc_diffQ, *Q_exc ); + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Flag_adj_q_exc, Qexc_diffQ, *Q_exc ); Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } #else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0435db6a2..c06a57180 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1714,7 +1714,7 @@ void Comp_and_apply_gain_fx( Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - const Word16 max_target_ener, /* i : Ener_per_bd_iQ of lt_ener_per_band_fx */ + const Word16 Flag_adj_q_exc, /* i : Ener_per_bd_iQ of lt_ener_per_band_fx */ #endif Word16 Qexc_diff, Word16 Q_exc ); -- GitLab From ad4e9f58dd109dd5d38e30e3a30009411efe3c77 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 30 Jan 2026 14:40:48 -0500 Subject: [PATCH 680/750] Fix clang --- lib_com/gs_gains_fx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index cb7cc852e..e84336385 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -140,7 +140,7 @@ void Comp_and_apply_gain_fx( move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - IF( Flag_adj_q_exc != 0) + IF( Flag_adj_q_exc != 0 ) { FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { @@ -164,7 +164,6 @@ void Comp_and_apply_gain_fx( move16(); } } - } } #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX @@ -175,12 +174,12 @@ void Comp_and_apply_gain_fx( { Word16 total_bins = add( StartBin, NB_Qbins ); move16(); - FOR(i = 0; i < total_bins; i++) + FOR( i = 0; i < total_bins; i++ ) { Q_adapt = s_min( Q_adapt, add( Q_exc_diffQ[i], norm_l( exc_diffQ32[i] ) ) ); move16(); } - FOR(i = 0; i < total_bins; i++) + FOR( i = 0; i < total_bins; i++ ) { exc_diffQ[i] = round_fx( L_shl( exc_diffQ32[i], sub( Q_adapt, Q_exc_diffQ[i] ) ) ); /*Q_exc*/ } -- GitLab From 07e09291ddc0ddbb6eed2920e7f80c50ec90a2da Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 09:54:21 +0100 Subject: [PATCH 681/750] HARMONIZE_ACELP_ENC --- lib_com/options.h | 1 + lib_com/prot_fx.h | 40 ++- lib_enc/acelp_core_enc_fx.c | 569 +++++++++++++++++++++++-------- lib_enc/decision_matrix_enc_fx.c | 5 + lib_enc/evs_enc_fx.c | 27 +- lib_enc/ivas_core_enc_fx.c | 4 + lib_enc/pre_proc_fx.c | 8 + 7 files changed, 484 insertions(+), 170 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b584b6931..ba4e80378 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ +#define HARMONIZE_ACELP_ENC /* VA: basop issue 2400: Remove duplicated main ACELP encoder function */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 3b93fda3b..b9a066c27 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10825,24 +10825,30 @@ ivas_error init_encoder_fx( ); ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, /* o : Q factor of old_syn_12k8_16k[] */ + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - const Word16 Q_new ); +#ifdef HARMONIZE_ACELP_ENC + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift need to obtain 12 bits vectors */ +#else + const Word16 Q_new +#endif +); void flip_and_downmix_generic_fx32( Word32 input[], /* i : input spectrum Qx*/ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index c5dc5e511..4cd1872c0 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -675,24 +675,30 @@ ivas_error acelp_core_enc_fx( *--------------------------------------------------------------------*/ ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - const Word16 Q_new ) + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, /* o : Q factor of old_syn_12k8_16k[] */ + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ +#ifdef HARMONIZE_ACELP_ENC + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift need to obtain 12 bits vectors */ +#else + const Word16 Q_new +#endif +) { Word16 i, nBits; /* reserved bits */ LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */ @@ -720,54 +726,74 @@ ivas_error acelp_core_enc_ivas_fx( Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */ Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */ +#ifdef HARMONIZE_ACELP_ENC + /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */ + Word16 mCb1_fx, pstreaklen_fx; + Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], lsf_new_bck_fx[M], lsp_mid_bck_fx[M], mem_syn_bck_fx[M]; + Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2]; + Word16 tilt_code_bck_fx; + Word32 gc_threshold_bck_fx; + Word16 clip_var_bck_fx[6]; + Word16 next_force_sf_bck_fx; + Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx; + Word16 ppp_mode, nelp_mode; + Word16 enr, enr_index; +#else set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ); set16_fx( old_exc_fx, 0, L_EXC ); set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) ); set16_fx( syn_fx, 0, L_FRAME16k ); +#endif Word32 q_env_fx[NUM_ENV_CNG]; +#ifndef HARMONIZE_ACELP_ENC set32_fx( q_env_fx, 0, NUM_ENV_CNG ); set16_fx( exc2_fx, 0, L_FRAME16k ); +#endif Word16 exc3_fx[L_FRAME16k]; Word16 syn1_fx[L_FRAME16k]; Word16 *tdm_Pri_pitch_buf_fx; Word16 att_fx; Word16 tmpF_fx; + ivas_error error; - test(); - IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL ) - { - Scale_sig( st->hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2, sub( Q_new, st->prev_Q_new ) ); // Q_new - } - IF( st->hLPDmem ) +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode > EVS_MONO ) +#endif { - Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, st->hLPDmem->q_lpd_old_exc ) ); // Q_new - st->hLPDmem->q_lpd_old_exc = Q_new; - move16(); - Scale_sig( st->hLPDmem->syn, M + 1, sub( Q_new, st->hLPDmem->q_lpd_syn ) ); // Q_new - st->hLPDmem->q_lpd_syn = Q_new; - move16(); - Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + test(); + IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL ) + { + Scale_sig( st->hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2, sub( Q_new, st->prev_Q_new ) ); // Q_new + } + IF( st->hLPDmem ) + { + Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, st->hLPDmem->q_lpd_old_exc ) ); // Q_new + st->hLPDmem->q_lpd_old_exc = Q_new; + move16(); + Scale_sig( st->hLPDmem->syn, M + 1, sub( Q_new, st->hLPDmem->q_lpd_syn ) ); // Q_new + st->hLPDmem->q_lpd_syn = Q_new; + move16(); + Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + move16(); + st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); + move16(); + } + + Scale_sig32( st->Bin_E_old_fx, L_FFT / 2, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E_old ) ); // Q_new + Q_scale - 2 + st->q_Bin_E_old = add( Q_new, Q_SCALE - 2 ); move16(); - st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); + Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); // Q_new + Q_scale - 2 + st->q_Bin_E = add( Q_new, Q_SCALE - 2 ); move16(); } - Scale_sig32( st->Bin_E_old_fx, L_FFT / 2, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E_old ) ); // Q_new + Q_scale - 2 - st->q_Bin_E_old = add( Q_new, Q_SCALE - 2 ); - move16(); - Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); // Q_new + Q_scale - 2 - st->q_Bin_E = add( Q_new, Q_SCALE - 2 ); - move16(); - - ivas_error error; - error = IVAS_ERR_OK; move32(); @@ -788,9 +814,11 @@ ivas_error acelp_core_enc_ivas_fx( Es_pred_fx = 0; move16(); - exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */ - Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); /* Q_new */ + exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */ + Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); /* Q_new */ +#ifndef HARMONIZE_ACELP_ENC Scale_sig( old_exc_fx, L_EXC_MEM, sub( Q_new, hLPDmem->q_lpd_old_exc ) ); // Q_new +#endif IF( st->hBWE_TD != NULL ) { bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */ @@ -847,6 +875,37 @@ ivas_error acelp_core_enc_ivas_fx( position = -1; move16(); +#ifdef HARMONIZE_ACELP_ENC + /* SC-VBR temporary variables */ + mCb1_fx = 0; //-> to be removed + move16(); + pstreaklen_fx = 0; + move16(); + clip_var_fx = 0; + move16(); + mem_w0_bck_fx = 0; + move16(); + streaklimit_fx = 0; + move16(); + + /* channel-aware mode */ + reset_rf_indices_fx( st ); + /* VBR modes */ + IF( st->Opt_SC_VBR ) + { + ppp_mode = st->hSC_VBR->ppp_mode; + nelp_mode = st->hSC_VBR->nelp_mode; + move16(); + move16(); + } + ELSE + { + ppp_mode = 0; + nelp_mode = 0; + move16(); + move16(); + } +#endif test(); /* TD stereo */ @@ -963,62 +1022,111 @@ ivas_error acelp_core_enc_ivas_fx( &st->hDtxEnc->first_CNG, &st->hTdCngEnc->cng_ener_seed, bwe_exc_fx, allow_cn_step, &st->hTdCngEnc->last_allow_cn_step, sub( st->prev_Q_new, 1 ), sub( Q_new, 1 ), st->hTdCngEnc->num_ho, q_env_fx, st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->old_env_fx, st->hTdCngEnc->exc_mem_fx, st->hTdCngEnc->exc_mem1_fx, &sid_bw, &st->hTdCngEnc->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, EVS_MONO ); - Scale_sig( exc_fx, st->L_frame, 1 ); // Q_new + 1 +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode > EVS_MONO ) +#endif + { + Scale_sig( exc_fx, st->L_frame, 1 ); // Q_new + 1 + } } ELSE { - test(); - IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - FdCng_encodeSID_ivas_fx( st ); - st->hDtxEnc->last_CNG_L_frame = st->L_frame; - move16(); - } - - Word16 Q_cngNoise = Q31, zero_flag = 0; - move16(); - move16(); - FOR( Word16 j = 0; j < NPART; j++ ) +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) { - IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[j] != 0 ) + test(); + IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - zero_flag = 1; + FdCng_encodeSID_fx( st->hFdCngEnc, st, st->preemph_fac ); + st->hDtxEnc->last_CNG_L_frame = st->L_frame; move16(); - BREAK; } - } - IF( zero_flag ) - { - Q_cngNoise = getScaleFactor32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART ); - } - Scale_sig32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART, Q_cngNoise ); /* st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp - Q_cngNoise */ - st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp, Q_cngNoise ); - move16(); - generate_comfort_noise_enc_ivas_fx( st, Q_new, 1 ); - st->hTcxEnc->q_Txnq = Q_new; - move16(); - Scale_sig( st->hFdCngEnc->hFdCngCom->A_cng, ( M + 1 ), sub( Q12, sub( 14, norm_s( st->hFdCngEnc->hFdCngCom->A_cng[0] ) ) ) ); /* Q12 */ - FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); - Copy( exc2_fx, exc3_fx, st->L_frame ); // Q_new + generate_comfort_noise_enc_fx( st, Q_new, 1 ); - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - IF( st->hTdCngEnc != NULL ) + FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, + st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); + + Copy( exc2_fx, exc3_fx, st->L_frame ); // Q12 + + IF( EQ_32( st->core_brate, SID_2k40 ) ) { - Word16 enr, enr_index; - enr = cng_energy_ivas_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att_fx, exc_fx, st->L_frame, Q_new ); /* Q8 */ + IF( st->hTdCngEnc != NULL ) + { + enr = cng_energy_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, /*st->hTdCngEnc->CNG_att*/ 0, exc_fx, st->L_frame, Q_new ); // Q8 - /* calculate the energy quantization index */ - enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ - enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ + /* calculate the energy quantization index */ + enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ + enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ - /* limit the energy quantization index */ - enr_index = s_min( enr_index, 127 ); /* Q0 */ - enr_index = s_max( enr_index, 0 ); - st->hTdCngEnc->old_enr_index = enr_index; /* Q0 */ + /* limit the energy quantization index */ + enr_index = s_min( enr_index, 127 ); // Q0 + enr_index = s_max( enr_index, 0 ); + + st->hTdCngEnc->old_enr_index = enr_index; /* Q0 */ + move16(); + } + } + } + ELSE +#endif + { + test(); + IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + FdCng_encodeSID_ivas_fx( st ); + st->hDtxEnc->last_CNG_L_frame = st->L_frame; move16(); } + + Word16 Q_cngNoise = Q31, zero_flag = 0; + move16(); + move16(); + FOR( Word16 j = 0; j < NPART; j++ ) + { + IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[j] != 0 ) + { + zero_flag = 1; + move16(); + BREAK; + } + } + IF( zero_flag ) + { + Q_cngNoise = getScaleFactor32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART ); + } + Scale_sig32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART, Q_cngNoise ); /* st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp - Q_cngNoise */ + st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp, Q_cngNoise ); + move16(); + + generate_comfort_noise_enc_ivas_fx( st, Q_new, 1 ); + st->hTcxEnc->q_Txnq = Q_new; + move16(); + + Scale_sig( st->hFdCngEnc->hFdCngCom->A_cng, ( M + 1 ), sub( Q12, sub( 14, norm_s( st->hFdCngEnc->hFdCngCom->A_cng[0] ) ) ) ); /* Q12 */ + FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); + Copy( exc2_fx, exc3_fx, st->L_frame ); // Q_new + + IF( EQ_32( st->core_brate, SID_2k40 ) ) + { + IF( st->hTdCngEnc != NULL ) + { +#ifndef HARMONIZE_ACELP_ENC + Word16 enr, enr_index; +#endif + enr = cng_energy_ivas_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att_fx, exc_fx, st->L_frame, Q_new ); /* Q8 */ + + /* calculate the energy quantization index */ + enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ + enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ + + /* limit the energy quantization index */ + enr_index = s_min( enr_index, 127 ); /* Q0 */ + enr_index = s_max( enr_index, 0 ); + st->hTdCngEnc->old_enr_index = enr_index; /* Q0 */ + move16(); + } + } } } @@ -1029,22 +1137,33 @@ ivas_error acelp_core_enc_ivas_fx( move16(); } - Scale_sig( st->hLPDmem->mem_syn, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn2, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn3, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - move16(); - st->hLPDmem->q_mem_syn = st->Q_syn; - move16(); - /* synthesis at 12.8kHz sampling rate */ - syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn ); +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) + { + /* synthesis at 12.8kHz sampling rate */ + syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, Q_new, st->Q_syn ); + } + ELSE +#endif + { + Scale_sig( st->hLPDmem->mem_syn, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( st->hLPDmem->mem_syn2, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( st->hLPDmem->mem_syn3, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn + st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn + move16(); + st->hLPDmem->q_mem_syn = st->Q_syn; + move16(); + + /* synthesis at 12.8kHz sampling rate */ + syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn ); + } /* reset the encoder */ CNG_reset_enc_fx( st, hLPDmem, pitch_buf, voice_factors_fx, 0 ); - /* update st->mem_syn1_flt for ACELP core switching */ + /* update st->mem_syn1_fx for ACELP core switching */ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M ); /* hLPDmem->q_mem_syn */ /* update ACELP core synthesis filter memory */ @@ -1056,14 +1175,23 @@ ivas_error acelp_core_enc_ivas_fx( /* save and delay synthesis to be used by SWB BWE */ IF( st->hBWE_FD != NULL ) { - st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */ - move16(); - Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */ - save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); - *q_old_syn_12k8_16 = st->Q_syn; - move16(); - st->hBWE_FD->q_mem_deemph_old_syn = st->Q_syn; - move16(); +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) + { + save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); + } + ELSE +#endif + { + st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */ + move16(); + Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */ + save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); + *q_old_syn_12k8_16 = st->Q_syn; + move16(); + st->hBWE_FD->q_mem_deemph_old_syn = st->Q_syn; + move16(); + } } Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); /* st->Q_syn */ @@ -1081,10 +1209,15 @@ ivas_error acelp_core_enc_ivas_fx( ELSE { - Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k ); - Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */ - st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp ); - move16(); +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode > EVS_MONO ) +#endif + { + Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k ); + Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */ + st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp ); + move16(); + } /*-----------------------------------------------------------------* * Configure ACELP bit allocation @@ -1097,7 +1230,13 @@ ivas_error acelp_core_enc_ivas_fx( uc_two_stage_flag = 0; move16(); - config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#ifdef HARMONIZE_ACELP_ENC + test(); + IF( !nelp_mode && !ppp_mode ) +#endif + { + config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + } /*-----------------------------------------------------------------* * After inactive period, use the most up-to-date ISPs @@ -1134,6 +1273,12 @@ ivas_error acelp_core_enc_ivas_fx( * A[z] calculation *-----------------------------------------------------------------*/ +#ifdef HARMONIZE_ACELP_ENC + /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */ + lsf_syn_mem_backup_fx( st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck_fx, lsp_new, lsf_new_fx, lsp_mid, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsf_new_bck_fx, + lsp_mid_bck_fx, &mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen_fx ); +#endif + IF( !tdm_lp_reuse_flag ) { lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); @@ -1172,6 +1317,7 @@ ivas_error acelp_core_enc_ivas_fx( st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15 move16(); } + test(); IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { @@ -1236,6 +1382,7 @@ ivas_error acelp_core_enc_ivas_fx( /*------------------------------------------------------------* * Encode excitation according to coding type *------------------------------------------------------------*/ + test(); test(); IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */ @@ -1249,28 +1396,82 @@ ivas_error acelp_core_enc_ivas_fx( encod_gen_2sbfr_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); } } +#ifdef HARMONIZE_ACELP_ENC + ELSE IF( nelp_mode ) + { + /* SC-VBR - NELP frames */ + encod_nelp_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, shift ); + } +#endif ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ +#ifdef HARMONIZE_ACELP_ENC + encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, shift ); +#else encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); +#endif } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { +#ifdef HARMONIZE_ACELP_ENC + encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, shift, Q_new ); +#else encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); +#endif } +#ifdef HARMONIZE_ACELP_ENC + ELSE IF( ppp_mode ) + { + IF( ( error = encod_ppp_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, shift ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( st->hSC_VBR->bump_up ) /* PPP failed, bump up */ + { + /* restore memories of LSF quantizer and synthesis filter */ + lsf_syn_mem_restore_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck_fx, + lsp_new, lsf_new_fx, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsf_new_bck_fx, + lsp_mid_bck_fx, mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen_fx ); + + /* Configure ACELP bit allocation */ + config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + + /* redo LSF quantization */ + lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, 0, -1, NULL, Q_new ); + + /* recalculation of LP residual (filtering through A[z] filter) */ + calc_residu_fx( st, inp, res_fx, Aq ); + + st->hTdCngEnc->burst_ho_cnt = 0; + move16(); + /* VOICED frames in SC-VBR when bumped up*/ + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, shift, Q_new ); + } + } +#endif 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 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 +#ifdef HARMONIZE_ACELP_ENC + 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, shift ); #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 #endif } ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ +#ifdef HARMONIZE_ACELP_ENC + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, shift, Q_new ); +#else encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#endif } /* update mem_syn1_flt for ACELP core switching */ @@ -1278,7 +1479,12 @@ ivas_error acelp_core_enc_ivas_fx( /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // hLPDmem->q_mem_syn - Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode > EVS_MONO ) +#endif + { + Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn + } /* save and delay synthesis to be used by SWB BWE */ IF( st->hBWE_FD != NULL ) @@ -1296,6 +1502,11 @@ ivas_error acelp_core_enc_ivas_fx( } /*Update MODE2 core switching memory*/ +#ifdef HARMONIZE_ACELP_ENC + Copy( syn_fx, syn1_fx, st->L_frame ); // Q_syn + E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &hLPDmem->syn[M] ); + Copy( syn1_fx + st->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn +#else Copy( syn_fx, syn1_fx, st->L_frame ); // st->Q_syn Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); // st->Q_syn @@ -1306,6 +1517,7 @@ ivas_error acelp_core_enc_ivas_fx( deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); // st->Q_syn +#endif test(); IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) @@ -1320,23 +1532,45 @@ ivas_error acelp_core_enc_ivas_fx( * Modify the excitation signal when the noise is stationary *--------------------------------------------------------------------------------------*/ - test(); - test(); - test(); - IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) { - /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */ - Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new - Word16 q_exc2 = Q_new; - move16(); - stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, &q_exc2 ); + IF( NE_16( nelp_mode, 1 ) ) + { + Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new + stat_noise_uv_enc_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, Q_new ); + } + } + ELSE +#endif + { + test(); + test(); + test(); + IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) + { + /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */ + Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new + Word16 q_exc2 = Q_new; + move16(); + stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, &q_exc2 ); + } } /*-----------------------------------------------------------------* * Encode supplementary information for Frame Error Concealment *-----------------------------------------------------------------*/ - FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1 ), 0 ); +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) + { + FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, Q_new, shift ); + } + ELSE +#endif + { + FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1 ), 0 ); + } IF( st->hBWE_TD != NULL ) { @@ -1350,10 +1584,8 @@ ivas_error acelp_core_enc_ivas_fx( } } - } /* end of active inp coding */ - /*-----------------------------------------------------------------* * Write ACELP unused bits *-----------------------------------------------------------------*/ @@ -1386,7 +1618,13 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); +#ifdef HARMONIZE_ACELP_ENC + test(); + test(); + IF( ( st->last_Opt_SC_VBR == 1 && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) +#else IF( ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) +#endif { st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); @@ -1397,12 +1635,26 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); +#ifdef HARMONIZE_ACELP_ENC + test(); + IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) +#else IF( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) +#endif { /* Apply a non linearity to the SHB excitation */ - Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc - non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); - Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) + { + non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); + } + ELSE +#endif + { + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + } } test(); @@ -1417,35 +1669,55 @@ ivas_error acelp_core_enc_ivas_fx( * Updates *-----------------------------------------------------------------*/ - if ( st->hBWE_TD != NULL ) +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode > EVS_MONO ) +#endif { - st->Q_exc = Q_new; + if ( st->hBWE_TD != NULL ) + { + st->Q_exc = Q_new; + move16(); + } +#ifdef HARMONIZE_ACELP_ENC + st->hLPDmem->q_lpd_old_exc = Q_new; move16(); +#endif } updt_enc_fx( st, old_exc_fx, pitch_buf, Es_pred_fx, Aq, lsf_new_fx, lsp_new, old_bwe_exc_fx ); +#ifndef HARMONIZE_ACELP_ENC st->hLPDmem->q_lpd_old_exc = Q_new; move16(); +#endif test(); test(); IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && GT_32( st->core_brate, SID_2k40 ) ) { /* update CNG parameters in active frames */ - Word16 q_exc = st->hTdCngEnc->cng_Qexc_buf[0]; +#ifdef HARMONIZE_ACELP_ENC + Word16 q_exc = Q_new; move16(); - FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) - { - q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ); - } - q_exc = s_min( q_exc, Q_new ); - - Scale_sig( exc_fx, L_EXC - L_EXC_MEM, sub( q_exc, Q_new ) ); // q_exc - FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) + IF( st->element_mode > EVS_MONO ) +#endif { - Scale_sig( st->hTdCngEnc->cng_exc2_buf + ii * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ) ); // Q_exc - st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc; +#ifndef HARMONIZE_ACELP_ENC + Word16 q_exc = st->hTdCngEnc->cng_Qexc_buf[0]; move16(); +#endif + FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) + { + q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ); + } + q_exc = s_min( q_exc, Q_new ); + + Scale_sig( exc_fx, L_EXC - L_EXC_MEM, sub( q_exc, Q_new ) ); // q_exc + FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) + { + Scale_sig( st->hTdCngEnc->cng_exc2_buf + ii * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ) ); // Q_exc + st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc; + move16(); + } } cng_params_upd_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, @@ -1475,6 +1747,15 @@ ivas_error acelp_core_enc_ivas_fx( } } +#ifdef HARMONIZE_ACELP_ENC + /* SC-VBR update of average data rate */ + test(); + IF( EQ_16( st->vad_flag, 1 ) && ( st->hSC_VBR != NULL ) ) + { + update_average_rate_fx( st->hSC_VBR, st->core_brate ); + } +#endif + pop_wmops(); return error; diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index 0b51816dc..ed6c09bb7 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -174,6 +174,11 @@ void decision_matrix_enc_fx( } } +#ifdef HARMONIZE_ACELP_ENC + /* set inactive coder_type flag in ACELP core to GSC */ + st_fx->inactive_coder_type_flag = 1; +#endif + return; } diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 5f696e899..cf1cd2852 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -43,11 +43,13 @@ ivas_error evs_enc_fx( Word32 ener; /* residual energy from Levinson-Durbin */ Word16 A[NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ Word16 Aw[NB_SUBFR16k * ( M + 1 )]; /* weighted A(z) unquantized for subframes */ - Word16 epsP_h[M + 1]; /* LP prediction errors */ - Word16 epsP_l[M + 1]; /* LP prediction errors */ - Word32 epsP[M + 1]; /* LP prediction errors */ - Word16 lsp_new[M]; /* LSPs at the end of the frame */ - Word16 lsp_mid[M]; /* ISPs in the middle of the frame */ +#ifndef HARMONIZE_ACELP_ENCaa + Word16 epsP_h[M + 1]; /* LP prediction errors */ + Word16 epsP_l[M + 1]; /* LP prediction errors */ +#endif + Word32 epsP[M + 1]; /* LP prediction errors */ + Word16 lsp_new[M]; /* LSPs at the end of the frame */ + Word16 lsp_mid[M]; /* ISPs in the middle of the frame */ Word16 vad_hover_flag; Word16 hq_core_type; /* HQ core type (HQ, or LR-MDCT) */ @@ -79,9 +81,6 @@ ivas_error evs_enc_fx( #endif ivas_error error; SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR; - // NOISE_EST_HANDLE hNoiseEst = st->hNoiseEst; - // VAD_HANDLE hVAD = st->hVAD; - // DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; LPD_state_HANDLE hLPDmem = st->hLPDmem; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; @@ -176,6 +175,7 @@ ivas_error evs_enc_fx( /*---------------------------------------------------------------------* * Pre-processing *---------------------------------------------------------------------*/ + #ifdef FIX_I4_OL_PITCH pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type ); #else @@ -184,7 +184,6 @@ ivas_error evs_enc_fx( &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r ); #endif - // st->sharpFlag = sharpFlag; IF( EQ_16( st->mdct_sw, MODE2 ) ) { @@ -268,9 +267,18 @@ ivas_error evs_enc_fx( IF( EQ_16( st->core, ACELP_CORE ) ) { +#ifdef HARMONIZE_ACELP_ENC + Word16 Q_old_syn_12k8_16k; + IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, &Q_old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, Q_new, shift ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag, attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, Q_new, shift ); +#endif } + /*---------------------------------------------------------------------* * HQ core encoding *---------------------------------------------------------------------*/ @@ -283,6 +291,7 @@ ivas_error evs_enc_fx( /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ + core_switching_post_enc_fx( st, old_inp_12k8, old_inp_16k, A, shift, Q_new, st->Q_syn2, &Q_synth ); #ifndef FIX_I4_OL_PITCH IF( EQ_16( st->core, HQ_CORE ) ) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 14230d021..a1f34c221 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -318,7 +318,11 @@ ivas_error ivas_core_enc_fx( /* ACELP core encoder */ Word16 Q_old_syn_12k8_16k = 0; move16(); +#ifdef HARMONIZE_ACELP_ENC + IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n], 0 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp_fx[n], /*ener[n],*/ A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n] ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 479df45be..824503d8a 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -586,6 +586,7 @@ void pre_proc_fx( long_enr_fx( st, *Etot, localVAD_HE_SAD, high_lpn_flag ); /* has to be after after sp_music classfier */ + /*----------------------------------------------------------------* * Rewrite the VAD flag by VAD flag with DTX hangover for further processing) *----------------------------------------------------------------*/ @@ -1336,5 +1337,12 @@ void pre_proc_fx( } } +#ifdef HARMONIZE_ACELP_ENC + epsP[0] = L_Comp( epsP_h[2], epsP_l[2] ); + move32(); + epsP[1] = L_Comp( epsP_h[M], epsP_l[M] ); + move32(); + +#endif return; } -- GitLab From 1a84494094015ebff41d50302a2d9351ddac6528 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 09:58:11 +0100 Subject: [PATCH 682/750] HARMONIZE_ACELP_ENC --- lib_enc/evs_enc_fx.c | 6 +++++- lib_enc/pre_proc_fx.c | 32 ++++++++++++++++---------------- lib_enc/prot_fx_enc.h | 12 +++++++----- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index cf1cd2852..77b15c977 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -43,7 +43,7 @@ ivas_error evs_enc_fx( Word32 ener; /* residual energy from Levinson-Durbin */ Word16 A[NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ Word16 Aw[NB_SUBFR16k * ( M + 1 )]; /* weighted A(z) unquantized for subframes */ -#ifndef HARMONIZE_ACELP_ENCaa +#ifndef HARMONIZE_ACELP_ENC Word16 epsP_h[M + 1]; /* LP prediction errors */ Word16 epsP_l[M + 1]; /* LP prediction errors */ #endif @@ -180,7 +180,11 @@ ivas_error evs_enc_fx( pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type ); #else pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, +#ifdef HARMONIZE_ACELP_ENC + pitch_orig, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, +#else pitch_orig, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag, +#endif &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r ); #endif diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 824503d8a..533ce13eb 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -32,16 +32,17 @@ void pre_proc_fx( #endif Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - Word16 epsP_h[M + 1], /* o : LP prediction errors */ - Word16 epsP_l[M + 1], /* o : LP prediction errors */ - Word32 epsP[M + 1], /* o : LP prediction errors */ - Word16 lsp_new[M], /* o : LSPs at the end of the frame */ - Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ +#ifndef HARMONIZE_ACELP_ENC + Word16 epsP_h[M + 1], /* o : LP prediction errors */ + Word16 epsP_l[M + 1], /* o : LP prediction errors */ +#endif + Word32 epsP[M + 1], /* o : LP prediction errors */ + Word16 lsp_new[M], /* o : LSPs at the end of the frame */ + Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ Word16 *vad_hover_flag, - Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ - Word16 *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ - + Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ + Word16 *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ @@ -53,7 +54,6 @@ void pre_proc_fx( { Word16 delay; const Word16 *signal_in; - Word16 i; Word16 *inp_12k8, *new_inp_12k8, *inp_16k, *new_inp_16k; /* pointers to current frame and new data */ Word16 old_wsp[L_WSP], *wsp; /* weighted input signal buffer */ @@ -69,13 +69,14 @@ void pre_proc_fx( Word16 cor_map_sum, sp_div; /* speech/music clasif. parameters */ Word32 PS[128]; Word16 L_look; /* length of look-ahead */ +#ifdef HARMONIZE_ACELP_ENC + Word16 epsP_h[M + 1], epsP_l[M + 1]; +#endif Word16 Q_sp_div, Q_esp; Word16 localVAD_HE_SAD; /* HE SAD parameters */ Word16 snr_sum_he; /* HE SAD parameters */ - Word16 vad_flag_cldfb; - Word16 vad_flag_dtx; Word16 old_cor; Word32 hp_E[2]; /* Energy in HF */ @@ -126,10 +127,10 @@ void pre_proc_fx( LPD_state_HANDLE hLPDmem = st->hLPDmem; FD_BWE_ENC_HANDLE hBWE_FD = st->hBWE_FD; - /*------------------------------------------------------------------* * Initializations *------------------------------------------------------------------*/ + signal_in = st->input_fx; vad_flag_dtx = 0; @@ -209,16 +210,17 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); + /*------------------------------------------------------------------* * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1 *-----------------------------------------------------------------*/ /* rf_mode: first time Q_new is computed here inside Preemph_scaled() for primary copy these are the same memories used in partial frame assembly as well */ - headroom = 1; move16(); test(); @@ -483,7 +485,6 @@ void pre_proc_fx( move16(); } - /*------------------------------------------------------------------* * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ @@ -586,7 +587,6 @@ void pre_proc_fx( long_enr_fx( st, *Etot, localVAD_HE_SAD, high_lpn_flag ); /* has to be after after sp_music classfier */ - /*----------------------------------------------------------------* * Rewrite the VAD flag by VAD flag with DTX hangover for further processing) *----------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 30aa1498b..0d72a4416 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3587,11 +3587,13 @@ void pre_proc_fx( #endif Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - Word16 epsP_h[M + 1], /* o : LP prediction errors */ - Word16 epsP_l[M + 1], /* o : LP prediction errors */ - Word32 epsP[M + 1], /* o : LP prediction errors */ - Word16 lsp_new[M], /* o : LSPs at the end of the frame */ - Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ +#ifndef HARMONIZE_ACELP_ENC + Word16 epsP_h[M + 1], /* o : LP prediction errors */ + Word16 epsP_l[M + 1], /* o : LP prediction errors */ +#endif + Word32 epsP[M + 1], /* o : LP prediction errors */ + Word16 lsp_new[M], /* o : LSPs at the end of the frame */ + Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ Word16 *vad_hover_flag, Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ -- GitLab From 2e5f3bd50b5c940b757bfbb5b0af2ba150dadeef Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 3 Feb 2026 10:19:39 +0100 Subject: [PATCH 683/750] replace sizeof() with strlen() --- apps/decoder.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index be38d4e85..a5927d06e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1713,9 +1713,13 @@ static ivas_error initOnFirstGoodFrame( if ( arg.rtpOutSR && srRtp != NULL ) { FILE *fParamsSR = NULL; - char srParamsFile[FILENAME_MAX], *ext = ".sr.txt"; - strncpy( srParamsFile, arg.outputWavFilename, FILENAME_MAX - sizeof( ext ) ); - strncat( srParamsFile, ext, sizeof( ext ) + 1 ); + char srParamsFile[FILENAME_MAX]; + const char *ext = ".sr.txt"; + + strncpy( srParamsFile, arg.outputWavFilename, FILENAME_MAX - strlen( ext ) - 1 ); + srParamsFile[FILENAME_MAX - strlen( ext ) - 1] = '\0'; + strncat( srParamsFile, ext, strlen( ext ) ); + srParamsFile[FILENAME_MAX - 1] = '\0'; /* Write the Split Rendering Params passed from SDP to srParamsFile */ fParamsSR = fopen( srParamsFile, "w" ); -- GitLab From bfa5613d8f5a33995dd624c86164a9743da6f80e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 11:36:05 +0100 Subject: [PATCH 684/750] fix --- lib_com/prot_fx.h | 32 ++++++---- lib_enc/acelp_core_enc_fx.c | 124 ++++++++++++++++++++++-------------- lib_enc/evs_enc_fx.c | 3 +- lib_enc/ivas_core_enc_fx.c | 8 ++- lib_enc/prot_fx_enc.h | 3 +- 5 files changed, 104 insertions(+), 66 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index b9a066c27..a6b806456 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10824,20 +10824,26 @@ ivas_error init_encoder_fx( const Word32 element_brate /* i : element bitrate */ ); +#ifdef HARMONIZE_ACELP_ENC +ivas_error acelp_core_enc_fx( +#else ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, /* o : Q factor of old_syn_12k8_16k[] */ +#endif + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ +#ifndef HARMONIZE_ACELP_ENC + Word16 *q_old_syn_12k8_16, /* o : Q factor of old_syn_12k8_16k[] */ +#endif Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 4cd1872c0..108d2ff30 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -11,7 +11,6 @@ #include "rom_com.h" #include "rom_enc.h" /* Encoder static table prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "ivas_cnst.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* @@ -19,7 +18,9 @@ * * ACELP core encoder *--------------------------------------------------------------------*/ + ivas_error acelp_core_enc_fx( +#ifndef HARMONIZE_ACELP_ENC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/ const Word32 ener_fx, /* i : residual energy from Levinson-Durbin Q6*/ @@ -675,19 +676,22 @@ ivas_error acelp_core_enc_fx( *--------------------------------------------------------------------*/ ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, /* o : Q factor of old_syn_12k8_16k[] */ +#endif + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ +#ifndef HARMONIZE_ACELP_ENC + Word16 *q_old_syn_12k8_16, /* o : Q factor of old_syn_12k8_16k[] */ +#endif Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ @@ -758,7 +762,11 @@ ivas_error acelp_core_enc_ivas_fx( Word16 tmpF_fx; ivas_error error; + hLPDmem = st->hLPDmem; + #ifdef HARMONIZE_ACELP_ENC + set16_fx( old_exc_fx, 0, L_EXC ); + IF( st->element_mode > EVS_MONO ) #endif { @@ -767,22 +775,22 @@ ivas_error acelp_core_enc_ivas_fx( { Scale_sig( st->hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2, sub( Q_new, st->prev_Q_new ) ); // Q_new } - IF( st->hLPDmem ) + IF( hLPDmem ) { - Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, st->hLPDmem->q_lpd_old_exc ) ); // Q_new - st->hLPDmem->q_lpd_old_exc = Q_new; + Scale_sig( hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, hLPDmem->q_lpd_old_exc ) ); // Q_new + hLPDmem->q_lpd_old_exc = Q_new; move16(); - Scale_sig( st->hLPDmem->syn, M + 1, sub( Q_new, st->hLPDmem->q_lpd_syn ) ); // Q_new - st->hLPDmem->q_lpd_syn = Q_new; + Scale_sig( hLPDmem->syn, M + 1, sub( Q_new, hLPDmem->q_lpd_syn ) ); // Q_new + hLPDmem->q_lpd_syn = Q_new; move16(); - Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 - st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); // Q_new -1 + Scale_sig( hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); // Q_new -1 + hLPDmem->mem_w0 = shl_sat( hLPDmem->mem_w0, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); // Q_new -1 move16(); - st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); + hLPDmem->q_mem_syn = sub( Q_new, 1 ); move16(); } @@ -809,8 +817,6 @@ ivas_error acelp_core_enc_ivas_fx( * Initialization *------------------------------------------------------------------*/ - hLPDmem = st->hLPDmem; - Es_pred_fx = 0; move16(); @@ -877,7 +883,7 @@ ivas_error acelp_core_enc_ivas_fx( #ifdef HARMONIZE_ACELP_ENC /* SC-VBR temporary variables */ - mCb1_fx = 0; //-> to be removed + mCb1_fx = 0; move16(); pstreaklen_fx = 0; move16(); @@ -890,7 +896,8 @@ ivas_error acelp_core_enc_ivas_fx( /* channel-aware mode */ reset_rf_indices_fx( st ); - /* VBR modes */ + + /* SC-VBR modes */ IF( st->Opt_SC_VBR ) { ppp_mode = st->hSC_VBR->ppp_mode; @@ -1146,14 +1153,14 @@ ivas_error acelp_core_enc_ivas_fx( ELSE #endif { - Scale_sig( st->hLPDmem->mem_syn, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn2, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn3, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn - st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( hLPDmem->mem_syn, M, sub( st->Q_syn, hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( hLPDmem->mem_syn2, M, sub( st->Q_syn, hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( hLPDmem->mem_syn3, M, sub( st->Q_syn, hLPDmem->q_mem_syn ) ); // st->Q_syn + Scale_sig( hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, hLPDmem->q_mem_syn ) ); // st->Q_syn + hLPDmem->mem_w0 = shl_sat( hLPDmem->mem_w0, sub( st->Q_syn, hLPDmem->q_mem_syn ) ); // st->Q_syn move16(); - st->hLPDmem->q_mem_syn = st->Q_syn; + hLPDmem->q_mem_syn = st->Q_syn; move16(); /* synthesis at 12.8kHz sampling rate */ @@ -1187,20 +1194,37 @@ ivas_error acelp_core_enc_ivas_fx( move16(); Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */ save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); +#ifdef HARMONIZE_ACELP_ENC + Scale_sig( old_syn_12k8_16k, st->L_frame, sub( sub( Q_new, 1 ), st->Q_syn ) ); // Q_syn +#else *q_old_syn_12k8_16 = st->Q_syn; move16(); +#endif st->hBWE_FD->q_mem_deemph_old_syn = st->Q_syn; move16(); } } - Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); /* st->Q_syn */ - st->hLPDmem->q_lpd_syn = st->Q_syn; - move16(); +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) + { + /* Update MODE2 core switching memory */ + tmpF_fx = hLPDmem->syn[M]; + move16(); + E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); + Copy( syn1_fx + st->L_frame - M - 1, hLPDmem->syn, M + 1 ); /* st_fx->Q_syn */ + } + ELSE +#endif + { + Scale_sig( hLPDmem->syn, M + 1, sub( st->Q_syn, hLPDmem->q_lpd_syn ) ); /* st->Q_syn */ + hLPDmem->q_lpd_syn = st->Q_syn; + move16(); - /*Update MODE2 core switching memory*/ - deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); - Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); /* st->Q_syn */ + /*Update MODE2 core switching memory*/ + deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); + Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); /* st->Q_syn */ + } } /*----------------------------------------------------------------* @@ -1326,7 +1350,7 @@ ivas_error acelp_core_enc_ivas_fx( move16(); preemph_fx( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx ); Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M ); /* Q_new */ - Scale_sig( st->hLPDmem->mem_syn, M, sub( st->hLPDmem->q_mem_syn, Q_new ) ); + Scale_sig( hLPDmem->mem_syn, M, sub( hLPDmem->q_mem_syn, Q_new ) ); Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 ); } @@ -1481,10 +1505,12 @@ ivas_error acelp_core_enc_ivas_fx( Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // hLPDmem->q_mem_syn #ifdef HARMONIZE_ACELP_ENC IF( st->element_mode > EVS_MONO ) -#endif { - Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn + Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn } +#else + Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn +#endif /* save and delay synthesis to be used by SWB BWE */ IF( st->hBWE_FD != NULL ) @@ -1494,8 +1520,12 @@ ivas_error acelp_core_enc_ivas_fx( Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); +#ifdef HARMONIZE_ACELP_ENC + Scale_sig( old_syn_12k8_16k, st->L_frame, sub( sub( Q_new, 1 ), st->Q_syn ) ); // Q_syn +#else *q_old_syn_12k8_16 = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ); move16(); +#endif st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ); move16(); Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) ); // st->Q_syn @@ -1679,7 +1709,7 @@ ivas_error acelp_core_enc_ivas_fx( move16(); } #ifdef HARMONIZE_ACELP_ENC - st->hLPDmem->q_lpd_old_exc = Q_new; + hLPDmem->q_lpd_old_exc = Q_new; move16(); #endif } diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 77b15c977..37ab34802 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -272,8 +272,7 @@ ivas_error evs_enc_fx( IF( EQ_16( st->core, ACELP_CORE ) ) { #ifdef HARMONIZE_ACELP_ENC - Word16 Q_old_syn_12k8_16k; - IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, &Q_old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, Q_new, shift ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = acelp_core_enc_fx( st, inp, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, Q_new, shift ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index a1f34c221..f62f88921 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -316,17 +316,19 @@ ivas_error ivas_core_enc_fx( IF( st->core == ACELP_CORE ) { /* ACELP core encoder */ - Word16 Q_old_syn_12k8_16k = 0; - move16(); #ifdef HARMONIZE_ACELP_ENC - IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n], 0 ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = acelp_core_enc_fx( st, inp_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n], 0 ) ), IVAS_ERR_OK ) ) #else + Word16 Q_old_syn_12k8_16k = 0; + move16(); IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp_fx[n], /*ener[n],*/ A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n] ) ), IVAS_ERR_OK ) ) #endif { return error; } +#ifndef HARMONIZE_ACELP_ENC Scale_sig( old_syn_12k8_16k_fx[n], st->L_frame, sub( sub( Q_new[n], 1 ), Q_old_syn_12k8_16k ) ); // Q_old_syn_12k8_16k -> Q_new[n] - 1 +#endif } test(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0d72a4416..239be90de 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -41,6 +41,7 @@ #include "ivas_stat_enc.h" +#ifndef HARMONIZE_ACELP_ENC ivas_error acelp_core_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/ @@ -61,7 +62,7 @@ ivas_error acelp_core_enc_fx( STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ const Word16 Q_new, const Word16 shift ); - +#endif void analy_lp_fx( const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ const Word16 L_frame, /* i :(q0) length of the frame */ -- GitLab From 60f50588cc0aa0871c260d4892b8577c472bdcce Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 11:40:24 +0100 Subject: [PATCH 685/750] simplification --- lib_enc/acelp_core_enc_fx.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 108d2ff30..2c1858d60 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1205,26 +1205,19 @@ ivas_error acelp_core_enc_ivas_fx( } } + Scale_sig( hLPDmem->syn, M + 1, sub( st->Q_syn, hLPDmem->q_lpd_syn ) ); /* st->Q_syn */ + hLPDmem->q_lpd_syn = st->Q_syn; + move16(); + + /*Update MODE2 core switching memory*/ #ifdef HARMONIZE_ACELP_ENC - IF( st->element_mode == EVS_MONO ) - { - /* Update MODE2 core switching memory */ - tmpF_fx = hLPDmem->syn[M]; - move16(); - E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); - Copy( syn1_fx + st->L_frame - M - 1, hLPDmem->syn, M + 1 ); /* st_fx->Q_syn */ - } - ELSE + tmpF_fx = hLPDmem->syn[M]; + move16(); + E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); +#else + deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); #endif - { - Scale_sig( hLPDmem->syn, M + 1, sub( st->Q_syn, hLPDmem->q_lpd_syn ) ); /* st->Q_syn */ - hLPDmem->q_lpd_syn = st->Q_syn; - move16(); - - /*Update MODE2 core switching memory*/ - deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); - Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); /* st->Q_syn */ - } + Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); /* st->Q_syn */ } /*----------------------------------------------------------------* -- GitLab From 508ae451f29e636985b16074621d9119fb93d796 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 12:17:25 +0100 Subject: [PATCH 686/750] formatting --- lib_com/gs_gains_fx.c | 62 ++++++++++++++++++++++++++++++++++++--- lib_com/gs_noisefill_fx.c | 36 +++++++++++++++++++++-- 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 769af2692..de3d3e7a4 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -70,12 +70,19 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const /* _ None */ /*========================================================================*/ +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX +Word16 Comp_and_apply_gain_fx( +#else void Comp_and_apply_gain_fx( +#endif Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + const Word16 Flag_adj_q_exc, /* i : Flag allowing Q_exc adjustment */ +#endif Word16 Qexc_diff, Word16 Q_exc ) { @@ -83,6 +90,11 @@ void Comp_and_apply_gain_fx( Word16 StartBin, NB_Qbins; Word16 y_gain; Word16 L16, frac, exp1, tmp_exp; +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + Word16 Q_adapt; + Word16 Q_exc_diffQ[L_FRAME16k]; + Word32 exc_diffQ32[L_FRAME16k]; +#endif Word32 L32; /* Recreate excitation for local synthesis and decoder */ @@ -92,6 +104,7 @@ void Comp_and_apply_gain_fx( move16(); tmp_exp = add( 14, sub( Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/ + FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) { StartBin = add( StartBin, NB_Qbins ); @@ -127,16 +140,57 @@ void Comp_and_apply_gain_fx( move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); - FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + IF( Flag_adj_q_exc != 0 ) { - L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ - exc_diffQ[i] = round_fx_sat( L_shl_sat( L32, tmp_exp ) ); /*Q_exc */ - move16(); + FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) + { + exc_diffQ32[i] = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ + move32(); + Q_exc_diffQ[i] = Q_exc; + if ( exc_diffQ[i] ) + { + Q_exc_diffQ[i] = sub( Q_exc_diffQ[i], tmp_exp ); + move16(); + } + } + } + ELSE +#endif + { + FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) + { + L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ + exc_diffQ[i] = round_fx_sat( L_shl_sat( L32, tmp_exp ) ); /*Q_exc */ + move16(); + } } } } +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + Q_adapt = Q_exc; + move16(); + test(); + IF( EQ_16( ReUseGain, 0 ) && Flag_adj_q_exc != 0 ) + { + Word16 total_bins = add( StartBin, NB_Qbins ); + move16(); + FOR( i = 0; i < total_bins; i++ ) + { + Q_adapt = s_min( Q_adapt, add( Q_exc_diffQ[i], norm_l( exc_diffQ32[i] ) ) ); + move16(); + } + FOR( i = 0; i < total_bins; i++ ) + { + exc_diffQ[i] = round_fx( L_shl( exc_diffQ32[i], sub( Q_adapt, Q_exc_diffQ[i] ) ) ); /*Q_exc*/ + } + } + + return Q_adapt; +#else return; +#endif } #ifndef FIX_2338_HARM_GSC_GAIN_COMP diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 383e2812d..c7dce95bd 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1081,6 +1081,9 @@ void highband_exc_dct_in_ivas_fx( Word16 frac, exp, tmp1; Word16 tmp2; Word16 *end, Q_hb_exc; +#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX + Word16 Flag_adj_q_exc, old_Q_exc; +#endif FOR( j = 10; j < MBANDS_GN; j++ ) { @@ -1364,10 +1367,9 @@ void highband_exc_dct_in_ivas_fx( move16(); } } -#ifndef FIX_2338_HARM_GSC_GAIN_COMP +#if !defined FIX_2338_HARM_GSC_GAIN_COMP && !defined FIX_2380_HARM_GSC_GAIN_COMP_FX IF( EQ_16( element_mode, EVS_MONO ) ) { -#endif Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); IF( exc_wo_nf != NULL ) @@ -1375,7 +1377,6 @@ void highband_exc_dct_in_ivas_fx( Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } -#ifndef FIX_2338_HARM_GSC_GAIN_COMP } ELSE { @@ -1406,7 +1407,36 @@ void highband_exc_dct_in_ivas_fx( Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); } } +#elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX + + Flag_adj_q_exc = 0; + move16(); + IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep all EVS BE */ + { + Flag_adj_q_exc = 1; + move16(); + } + + old_Q_exc = *Q_exc; + move16(); + *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Flag_adj_q_exc, Qexc_diffQ, *Q_exc ); + Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, old_Q_exc ) ); + + IF( exc_wo_nf != NULL ) + { + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Flag_adj_q_exc, Qexc_diffQ, *Q_exc ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); + } +#else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */ + Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); + + IF( exc_wo_nf != NULL ) + { + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); + } #endif + /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum -- GitLab From d2aee0226d20ee74702cc7c9f34852e2b1941284 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 12:18:56 +0100 Subject: [PATCH 687/750] Revert "formatting" This reverts commit 508ae451f29e636985b16074621d9119fb93d796. --- lib_com/gs_gains_fx.c | 62 +++------------------------------------ lib_com/gs_noisefill_fx.c | 36 ++--------------------- 2 files changed, 7 insertions(+), 91 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index de3d3e7a4..769af2692 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -70,19 +70,12 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const /* _ None */ /*========================================================================*/ -#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX -Word16 Comp_and_apply_gain_fx( -#else void Comp_and_apply_gain_fx( -#endif Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ -#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - const Word16 Flag_adj_q_exc, /* i : Flag allowing Q_exc adjustment */ -#endif Word16 Qexc_diff, Word16 Q_exc ) { @@ -90,11 +83,6 @@ void Comp_and_apply_gain_fx( Word16 StartBin, NB_Qbins; Word16 y_gain; Word16 L16, frac, exp1, tmp_exp; -#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - Word16 Q_adapt; - Word16 Q_exc_diffQ[L_FRAME16k]; - Word32 exc_diffQ32[L_FRAME16k]; -#endif Word32 L32; /* Recreate excitation for local synthesis and decoder */ @@ -104,7 +92,6 @@ void Comp_and_apply_gain_fx( move16(); tmp_exp = add( 14, sub( Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/ - FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) { StartBin = add( StartBin, NB_Qbins ); @@ -140,57 +127,16 @@ void Comp_and_apply_gain_fx( move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); -#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - IF( Flag_adj_q_exc != 0 ) - { - FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) - { - exc_diffQ32[i] = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ - move32(); - Q_exc_diffQ[i] = Q_exc; - if ( exc_diffQ[i] ) - { - Q_exc_diffQ[i] = sub( Q_exc_diffQ[i], tmp_exp ); - move16(); - } - } - } - ELSE -#endif + FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { - FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) - { - L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ - exc_diffQ[i] = round_fx_sat( L_shl_sat( L32, tmp_exp ) ); /*Q_exc */ - move16(); - } + L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ + exc_diffQ[i] = round_fx_sat( L_shl_sat( L32, tmp_exp ) ); /*Q_exc */ + move16(); } } } -#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - Q_adapt = Q_exc; - move16(); - test(); - IF( EQ_16( ReUseGain, 0 ) && Flag_adj_q_exc != 0 ) - { - Word16 total_bins = add( StartBin, NB_Qbins ); - move16(); - FOR( i = 0; i < total_bins; i++ ) - { - Q_adapt = s_min( Q_adapt, add( Q_exc_diffQ[i], norm_l( exc_diffQ32[i] ) ) ); - move16(); - } - FOR( i = 0; i < total_bins; i++ ) - { - exc_diffQ[i] = round_fx( L_shl( exc_diffQ32[i], sub( Q_adapt, Q_exc_diffQ[i] ) ) ); /*Q_exc*/ - } - } - - return Q_adapt; -#else return; -#endif } #ifndef FIX_2338_HARM_GSC_GAIN_COMP diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index c7dce95bd..383e2812d 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1081,9 +1081,6 @@ void highband_exc_dct_in_ivas_fx( Word16 frac, exp, tmp1; Word16 tmp2; Word16 *end, Q_hb_exc; -#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX - Word16 Flag_adj_q_exc, old_Q_exc; -#endif FOR( j = 10; j < MBANDS_GN; j++ ) { @@ -1367,9 +1364,10 @@ void highband_exc_dct_in_ivas_fx( move16(); } } -#if !defined FIX_2338_HARM_GSC_GAIN_COMP && !defined FIX_2380_HARM_GSC_GAIN_COMP_FX +#ifndef FIX_2338_HARM_GSC_GAIN_COMP IF( EQ_16( element_mode, EVS_MONO ) ) { +#endif Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); IF( exc_wo_nf != NULL ) @@ -1377,6 +1375,7 @@ void highband_exc_dct_in_ivas_fx( Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } +#ifndef FIX_2338_HARM_GSC_GAIN_COMP } ELSE { @@ -1407,36 +1406,7 @@ void highband_exc_dct_in_ivas_fx( Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); } } -#elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX - - Flag_adj_q_exc = 0; - move16(); - IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep all EVS BE */ - { - Flag_adj_q_exc = 1; - move16(); - } - - old_Q_exc = *Q_exc; - move16(); - *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Flag_adj_q_exc, Qexc_diffQ, *Q_exc ); - Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, old_Q_exc ) ); - - IF( exc_wo_nf != NULL ) - { - Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Flag_adj_q_exc, Qexc_diffQ, *Q_exc ); - Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); - } -#else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */ - Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); - - IF( exc_wo_nf != NULL ) - { - Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); - Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); - } #endif - /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum -- GitLab From e80f68375b2e90016c9b1a6811b86139979aa20e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 13:13:40 +0100 Subject: [PATCH 688/750] fix --- lib_enc/acelp_core_enc_fx.c | 48 +++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 2c1858d60..ed04aaadf 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1089,9 +1089,9 @@ ivas_error acelp_core_enc_ivas_fx( Word16 Q_cngNoise = Q31, zero_flag = 0; move16(); move16(); - FOR( Word16 j = 0; j < NPART; j++ ) + FOR( i = 0; i < NPART; i++ ) { - IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[j] != 0 ) + IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[i] != 0 ) { zero_flag = 1; move16(); @@ -1508,6 +1508,14 @@ ivas_error acelp_core_enc_ivas_fx( /* save and delay synthesis to be used by SWB BWE */ IF( st->hBWE_FD != NULL ) { +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) + { + save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); + } + ELSE +#endif + { st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) move16(); Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) @@ -1522,25 +1530,27 @@ ivas_error acelp_core_enc_ivas_fx( st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ); move16(); Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) ); // st->Q_syn + } } /*Update MODE2 core switching memory*/ -#ifdef HARMONIZE_ACELP_ENC Copy( syn_fx, syn1_fx, st->L_frame ); // Q_syn - E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &hLPDmem->syn[M] ); - Copy( syn1_fx + st->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn -#else - Copy( syn_fx, syn1_fx, st->L_frame ); // st->Q_syn - + Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); // st->Q_syn st->hLPDmem->q_lpd_syn = st->Q_syn; move16(); - /*Update MODE2 core switching memory*/ - deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); - - Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); // st->Q_syn +#ifdef HARMONIZE_ACELP_ENC + IF( st->element_mode == EVS_MONO ) + { + E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &hLPDmem->syn[M] ); + } + ELSE #endif + { + deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); + } + Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); // st->Q_syn test(); IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) @@ -1722,26 +1732,28 @@ ivas_error acelp_core_enc_ivas_fx( Word16 q_exc = Q_new; move16(); IF( st->element_mode > EVS_MONO ) -#endif { +#endif #ifndef HARMONIZE_ACELP_ENC Word16 q_exc = st->hTdCngEnc->cng_Qexc_buf[0]; move16(); #endif - FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) + FOR( i = 0; i < HO_HIST_SIZE; i++ ) { - q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ); + q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[i] ); } q_exc = s_min( q_exc, Q_new ); Scale_sig( exc_fx, L_EXC - L_EXC_MEM, sub( q_exc, Q_new ) ); // q_exc - FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) + FOR( i = 0; i < HO_HIST_SIZE; i++ ) { - Scale_sig( st->hTdCngEnc->cng_exc2_buf + ii * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ) ); // Q_exc - st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc; + Scale_sig( st->hTdCngEnc->cng_exc2_buf + i * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[i] ) ); // Q_exc + st->hTdCngEnc->cng_Qexc_buf[i] = q_exc; move16(); } +#ifdef HARMONIZE_ACELP_ENC } +#endif cng_params_upd_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -- GitLab From 5a424b63912f0060e43242ca6cbbacfb9c45f931 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 13:16:41 +0100 Subject: [PATCH 689/750] clang-format --- lib_enc/acelp_core_enc_fx.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ed04aaadf..999891010 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1509,38 +1509,38 @@ ivas_error acelp_core_enc_ivas_fx( IF( st->hBWE_FD != NULL ) { #ifdef HARMONIZE_ACELP_ENC - IF( st->element_mode == EVS_MONO ) - { - save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); - } - ELSE + IF( st->element_mode == EVS_MONO ) + { + save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); + } + ELSE #endif - { - st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) - move16(); - Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) + { + st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) + move16(); + Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) - save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); + save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); #ifdef HARMONIZE_ACELP_ENC - Scale_sig( old_syn_12k8_16k, st->L_frame, sub( sub( Q_new, 1 ), st->Q_syn ) ); // Q_syn + Scale_sig( old_syn_12k8_16k, st->L_frame, sub( sub( Q_new, 1 ), st->Q_syn ) ); // Q_syn #else - *q_old_syn_12k8_16 = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ); - move16(); + *q_old_syn_12k8_16 = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ); + move16(); #endif - st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ); - move16(); - Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) ); // st->Q_syn + st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ); + move16(); + Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) ); // st->Q_syn } } /*Update MODE2 core switching memory*/ Copy( syn_fx, syn1_fx, st->L_frame ); // Q_syn - + Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); // st->Q_syn st->hLPDmem->q_lpd_syn = st->Q_syn; move16(); -#ifdef HARMONIZE_ACELP_ENC +#ifdef HARMONIZE_ACELP_ENC IF( st->element_mode == EVS_MONO ) { E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &hLPDmem->syn[M] ); -- GitLab From e1b2b4fbc510bf71ce02aa9f5d309fc4449071f6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 08:29:09 -0500 Subject: [PATCH 690/750] cleanup in pitch_ol --- lib_com/options.h | 1 + lib_enc/pitch_ol_fx.c | 347 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 342 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..7b7766a8d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +109,7 @@ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ +#define FIX_2403_COMBINE_PITCH_OL /* VA : basop 2403, reusing common code between EVS and IVAS in pitch_ol */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index ab58b31bf..789da2bbd 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -57,8 +57,10 @@ static Word16 pitch_coherence_fx( Word16 pitch0, Word16 pitch1, Word16 fac_max, static Word32 Dot_product12_OL( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 ); static Word32 Dot_product12_OL_back( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 ); - -/*-----------------------------------------------------------------* +#ifdef FIX_2403_COMBINE_PITCH_OL +static void pitch_ol_resolve_fx( Word16 pitch[3], Word16 voicing[3], Word16 *old_pitch, Word16 *old_corr, Word16 *old_thres, Word16 *delta_pit, const Word16 element_mode, const Word16 corr_shift, const Word16 relE, const Word16 Opt_SC_VBR, Word16 pitchX[NHFR][2 * NSECT], Word16 corX[NHFR][2 * NSECT], Word16 scaledX[NHFR][2 * NSECT], const Word16 sect0, const Word16 *pit_max, const Word16 pit_min_coding ); +#endif + /*-----------------------------------------------------------------* * pitch_ol_init() * * Open loop pitch variable initialization @@ -79,7 +81,303 @@ void pitch_ol_init_fx( *old_corr = 0; move16(); } +#ifdef FIX_2403_COMBINE_PITCH_OL +static void pitch_ol_resolve_fx( + Word16 pitch[3], /* o : open loop pitch lag for each half-frame Q0 */ + Word16 voicing[3], /* o : maximum normalized correlation for each half-frame Q15 */ + Word16 *old_pitch, /* i/o: pitch of the 2nd half-frame of previous frame Q0 */ + Word16 *old_corr, /* i/o: correlation of old_pitch Q15 */ + Word16 *old_thres, /* i/o: maximum correlation weighting with respect to past Q15 or Q14) */ + Word16 *delta_pit, /* i/o: old pitch extrapolation correction Q0 */ + const Word16 element_mode, /* i : if element_mode != EVS old_thres is in Q14 */ + const Word16 corr_shift, /* i : normalized correlation correction Q15 */ + const Word16 relE, /* i : relative frame energy Q8 */ + const Word16 Opt_SC_VBR, /* i : SC-VBR flag */ + Word16 pitchX[NHFR][2 * NSECT], /* i : pitch candidates Q0 */ + Word16 corX[NHFR][2 * NSECT], /* i : correlation candidates Q15 */ + Word16 scaledX[NHFR][2 * NSECT], /* i/o: scaled correlation candidates Q12 */ + const Word16 sect0, /* i : section offset */ + const Word16 *pit_max, /* i : maximum pitch delays (array) */ + const Word16 pit_min_coding /* i : minimum pitch delay for coding */ +) +{ + Word16 i, ind, ind1, ind_corX, ind1_corX; + Word16 fac, ftmp, k, tmp16, diff, cnt; + Word16 add_sect0, sub_sect0; + Word16 coh_flag, coh_flag1; + Word16 cor_mean; + Word32 Ltmp; + + Word16 pitch_tmp[2 * NHFR]; + Word16 ind_tmp[2 * NHFR]; + Word16 cor_tmp[2 * NHFR]; + Word16 thres1[2 * NHFR]; + Word16 tmp_buf[NHFR + 1]; + /*-----------------------------------------------------------------* + * Favor a smaller delay if it happens that it has its multiple + * in the longer-delay sections (harmonics check) + *-----------------------------------------------------------------*/ + + FOR( i = 0; i < 2; i++ ) /* loop for the 2 half-frames */ + { + fac = THRES0; + move16(); + find_mult_fx( &fac, pitchX[i][2], pitchX[i][3], pit_max[7], &scaledX[i][2], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][1], pitchX[i][2], pit_max[5], &scaledX[i][1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + } + fac = THRES0; + move16(); + find_mult_fx( &fac, pitchX[i][NSECT + 2], pitchX[i][NSECT + 3], pit_max[7], &scaledX[i][NSECT + 2], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][NSECT + 1], pitchX[i][NSECT + 2], pit_max[6], &scaledX[i][NSECT + 1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][NSECT + 0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][NSECT + 0], pitchX[i][NSECT + 1], pit_max[4], &scaledX[i][NSECT + 0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + } + } + + fac = THRES0; + move16(); /* the look-ahead */ + find_mult_fx( &fac, pitchX[i][2], pitchX[i][3], pit_max[7], &scaledX[i][2], old_pitch, old_corr, 2, 2 ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][1], pitchX[i][2], pit_max[5], &scaledX[i][1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + } + fac = THRES0; + move16(); + find_mult_fx( &fac, pitchX[i][NSECT + 2], pitchX[i][NSECT + 3], pit_max[7], &scaledX[i][NSECT + 2], old_pitch, old_corr, 2, 2 ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][NSECT + 1], pitchX[i][NSECT + 2], pit_max[6], &scaledX[i][NSECT + 1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][NSECT + 0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][NSECT + 0], pitchX[i][NSECT + 1], pit_max[4], &scaledX[i][NSECT + 0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ /* Multiples in 2nd section */ + } + + /*-----------------------------------------------------------------* + * Do 1st estimate for pitch values + * Adjust the normalized correlation using estimated noise level + * Compute the maximum scaling for the neighbour correlation + * reinforcement + *-----------------------------------------------------------------*/ + add_sect0 = add( NSECT, sect0 ); + sub_sect0 = sub( NSECT, sect0 ); + FOR( i = 0; i < NHFR; i++ ) + { + /* 1st set of pitch candidates */ + ind = add( maximum_fx( scaledX[i] + sect0, sub_sect0, &ftmp ), sect0 ); + ind_tmp[i] = ind; + move16(); + pitch_tmp[i] = pitchX[i][ind]; + move16(); + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); + move16(); + + /* Higher is the neighbour's correlation, higher is the weighting */ + /* operands are Q15, result is Q15 */ + thres1[i] = mult( THRES1, cor_tmp[i] ); + move16(); + + /* 2nd set of pitch candidates */ + ind1 = add( maximum_fx( scaledX[i] + add_sect0, sub_sect0, &ftmp ), add_sect0 ); + ind_tmp[i + NHFR] = ind1; + move16(); + pitch_tmp[i + NHFR] = pitchX[i][ind1]; + move16(); + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); + move16(); + + /* Higher is the neighbour's correlation, higher is the weighting */ + /* operands are Q15, result is Q15 */ + thres1[i + NHFR] = mult( THRES1, cor_tmp[i + NHFR] ); + move16(); + } + /*-----------------------------------------------------------------* + * Take into account previous and next pitch values of the present + * frame and look-ahead. Choose the pitch lags and normalize + * correlations for each half-frame & look-ahead + *-----------------------------------------------------------------*/ + + pitch_neighbour_fx( sect0, pitch_tmp, pitchX, cor_tmp, scaledX, thres1, ind_tmp ); + FOR( i = 0; i < NHFR; i++ ) + { + ind = add( maximum_fx( scaledX[i] + sect0, sub_sect0, &ftmp ), sect0 ); + ind_corX = add( maximum_fx( corX[i] + sect0, sub_sect0, &ftmp ), sect0 ); + + ind1 = add( maximum_fx( scaledX[i] + add_sect0, sub_sect0, &ftmp ), add_sect0 ); + ind1_corX = add( maximum_fx( corX[i] + add_sect0, sub_sect0, &ftmp ), add_sect0 ); + + if ( GT_16( scaledX[i][ind1], scaledX[i][ind] ) ) + { + ind = ind1; + move16(); + } + test(); + if ( Opt_SC_VBR && GT_16( corX[i][ind1_corX], corX[i][ind_corX] ) ) + { + ind_corX = ind1_corX; + move16(); + } + test(); + test(); + test(); + IF( Opt_SC_VBR && ( LT_16( mult( pitchX[i][ind], 13107 /*0.4 in Q15*/ ), pitchX[i][ind_corX] ) ) && + ( GT_16( mult( pitchX[i][ind], 19661 /*0.6 in Q15*/ ), pitchX[i][ind_corX] ) ) && + ( GE_16( corX[i][ind_corX], 29491 /*0.9 in Q15*/ ) ) ) + { + pitch[i] = pitchX[i][ind_corX]; + move16(); + voicing[i] = corX[i][ind_corX]; + move16(); + } + ELSE + { + pitch[i] = pitchX[i][ind]; + move16(); + voicing[i] = corX[i][ind]; + move16(); + } + } + + /*-----------------------------------------------------------------* + * Increase the threshold for correlation reinforcement with + * the past if correlation high and pitch stable + *-----------------------------------------------------------------*/ + + /* all Q15 here */ + /* cor_mean = 0.5f * (voicing[0] + voicing[1]) + corr_shift; */ + Ltmp = L_mult( voicing[0], 16384 /*.5 Q15*/ ); + Ltmp = L_mac( Ltmp, voicing[1], 16384 /*.5 Q15*/ ); + cor_mean = round_fx( L_add( Ltmp, corr_shift ) ); + + /* pitch unstable in present frame or from previous frame or normalized correlation too low */ + coh_flag = pitch_coherence_fx( pitch[0], pitch[1], COH_FAC, DELTA_COH ); + move16(); + coh_flag1 = pitch_coherence_fx( pitch[0], *old_pitch, COH_FAC, DELTA_COH ); + move16(); + + test(); + test(); + test(); + IF( ( coh_flag == 0 ) || ( coh_flag1 == 0 ) || ( LT_16( cor_mean, CORR_TH0 ) ) || ( LT_16( relE, THR_relE ) ) ) + { + /* Reset the threshold */ + *old_thres = 0; + move16(); + } + ELSE + { + /* The threshold increase is directly dependent on normalized correlation */ + /* *old_thres += (0.16f * cor_mean); */ + IF( element_mode != EVS_MONO ) + { + *old_thres = round_fx( L_mac0( L_deposit_h( *old_thres ), 5243 /* 0.16f in Q15 */, cor_mean ) ); // Q14 + } + ELSE + { + *old_thres = round_fx( L_mac( L_deposit_h( *old_thres ), 5243 /* 0.16f in Q15 */, cor_mean ) ); // Q15 + } + move16(); + } + IF( element_mode != EVS_MONO ) + { + *old_thres = s_min( *old_thres, 11469 /* 0.7f in Q14 */ ); // Q14 + } + ELSE + { + *old_thres = s_min( *old_thres, THRES3 /* 0.7f in Q14 */ ); // Q15 + } + move16(); + + IF( GT_16( voicing[1], voicing[0] ) ) + { + *old_corr = voicing[1]; + move16(); + } + ELSE + { + *old_corr = cor_mean; + move16(); + } + + /*-----------------------------------------------------------------* + * Extrapolate the pitch value for the next frame by estimating + * the pitch evolution. This value is added to the old_pitch + * in the next frame and is then used when the normalized + * correlation is reinforced by the past estimate + *-----------------------------------------------------------------*/ + tmp_buf[0] = *old_pitch; + move16(); + FOR( i = 0; i < NHFR; i++ ) + { + tmp_buf[i + 1] = pitch[i]; + move16(); + } + + *delta_pit = 0; + move16(); + cnt = 0; + move16(); + + FOR( i = 0; i < NHFR; i++ ) + { + diff = sub( tmp_buf[i + 1], tmp_buf[i] ); + move16(); + coh_flag = pitch_coherence_fx( tmp_buf[i], tmp_buf[i + 1], COH_FAC, DELTA_COH ); + + if ( coh_flag != 0 ) + { + *delta_pit = add( *delta_pit, diff ); + move16(); + } + cnt = add( cnt, coh_flag ); + } + if ( EQ_16( cnt, 2 ) ) + { + /* *delta_pit /= 2; */ + *delta_pit = shr( *delta_pit, 1 ); + move16(); + } + IF( EQ_16( cnt, 3 ) ) + { + k = *delta_pit; + move16(); + /* *delta_pit /= 3; */ + if ( k < 0 ) + { + *delta_pit = mult( *delta_pit, -32768 /*-1 Q15*/ ); + move16(); + } + tmp16 = mult( *delta_pit, 10923 /*1/3 Q15*/ ); + if ( k < 0 ) + { + tmp16 = mult( tmp16, -32768 /*-1 Q15*/ ); + } + *delta_pit = tmp16; + move16(); + } + + /*--------------------------------------------------------------* + * Update old pitch, upsample pitch, + *--------------------------------------------------------------*/ + + *old_pitch = pitch[1]; + move16(); + + FOR( i = 0; i < NHFR; i++ ) + { + /* compensate decimation */ + pitch[i] = i_mult2( pitch[i], OPL_DECIM ); + move16(); + } +} +#endif /*==================================================================================*/ /* FUNCTION : pitch_ol_fx() */ @@ -166,12 +464,18 @@ void pitch_ol_fx( Word16 *pt_exp1, *pt_exp2, *pt_exp3, *pt_exp4; Word16 *pt1, *pt2, *pt3, *pt4, *pt5, *pt6; Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4, *pt_cor5, *pt_cor6; +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 thres1[6]; Word16 diff, cnt, ind, ind1, offset, offset1, offset_la, offset_la1, coh_flag, coh_flag1; Word16 ind_corX, ind1_corX; Word16 i, j, k, m, pit_min, pit_min1, sect0, subsect0, add_sect0, sub_sect0, old_tmp, old_tmp1, len_x, len_x1; +#else + Word16 cnt, ind, ind1, offset, offset1, offset_la, offset_la1; + Word16 i, j, k, m, pit_min, pit_min1, sect0, subsect0, old_tmp, old_tmp1, len_x, len_x1; +#endif Word16 len_temp; +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 pitchX[NHFR][2 * NSECT], pitch_tmp[2 * NHFR], ind_tmp[2 * NHFR], tmp_buf[NHFR + 1]; Word16 enr0[NSECT], enr0_exp[NSECT], enr0_1[NSECT], enr0_1_exp[NSECT], enr1, enr1_exp, enr2_exp; @@ -179,6 +483,14 @@ void pitch_ol_fx( Word16 fac, tmp16, tmp16_2; Word16 qCorX, qScaledX; Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT], cor_tmp[2 * NHFR], cor_mean; +#else + Word16 pitchX[NHFR][2 * NSECT]; + Word16 enr0[NSECT], enr0_exp[NSECT], enr0_1[NSECT], enr0_1_exp[NSECT], enr1, enr1_exp, enr2_exp; + Word32 enr, enr2, Ltmp; + Word16 tmp16, tmp16_2; + Word16 qCorX, qScaledX; + Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT]; +#endif const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1; Word16 pit_min_coding; @@ -801,7 +1113,9 @@ void pitch_ol_fx( } /* FOR j < NSECT */ } /* FOR i < NHFR */ - +#ifdef FIX_2403_COMBINE_PITCH_OL + pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, EVS_MONO, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding ); +#else /*-----------------------------------------------------------------* * Favor a smaller delay if it happens that it has its multiple * in the longer-delay sections (harmonics check) @@ -1050,7 +1364,7 @@ void pitch_ol_fx( pitch[i] = i_mult2( pitch[i], OPL_DECIM ); move16(); } - +#endif return; } @@ -1072,7 +1386,11 @@ void pitch_ol_ivas_fx( Word16 qwsp /* i : Q factor for wsp Q0 */ ) { +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 ftmp, old_wsp2[( L_WSP - L_INTERPOL ) / OPL_DECIM], *wsp2; +#else + Word16 old_wsp2[( L_WSP - L_INTERPOL ) / OPL_DECIM], *wsp2; +#endif Word16 tmp_mem[3]; Word16 scale1[2 * DELTA_COH - 1]; @@ -1082,6 +1400,7 @@ void pitch_ol_ivas_fx( Word16 *pt1, *pt2, *pt3, *pt4, *pt5, *pt6; Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4; Word16 *pt_cor0_exp, *pt_cor1_exp, *pt_cor2_exp, *pt_cor3_exp, *pt_cor4_exp; +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 thres1[6]; Word16 diff, cnt, ind, ind1, offset, offset1, offset_la, offset_la1, coh_flag, coh_flag1; Word16 ind_corX, ind1_corX; @@ -1096,6 +1415,20 @@ void pitch_ol_ivas_fx( Word32 Ltmp; Word16 fac, tmp16, tmp16_2; Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT], cor_tmp[2 * NHFR], cor_mean; +#else + Word16 cnt, ind, ind1, offset, offset1, offset_la, offset_la1; + Word16 i, j, k, m, pit_min, pit_min1, sect0, subsect0, old_tmp, old_tmp1, len_x, len_x1; + Word16 len_temp; + Word16 pitchX[NHFR][2 * NSECT]; + + Word16 enr0_exp[NSECT], enr0_1_exp[NSECT], enr1_exp; + Word32 enr0[NSECT], enr0_1[NSECT], enr1; + Word64 temp, temp1; + Word32 Ltmp; + Word16 tmp16, tmp16_2; + Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT]; +#endif + const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1; Word16 pit_min_coding; @@ -1757,7 +2090,9 @@ void pitch_ol_ivas_fx( } /* FOR j < NSECT */ } /* FOR i < NHFR */ - +#ifdef FIX_2403_COMBINE_PITCH_OL + pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, IVAS_SCE, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding ); /* any element mode other than EVS_MONO is OK here */ +#else /*-----------------------------------------------------------------* * Favor a smaller delay if it happens that it has its multiple * in the longer-delay sections (harmonics check) @@ -2007,7 +2342,7 @@ void pitch_ol_ivas_fx( pitch[i] = i_mult2( pitch[i], OPL_DECIM ); move16(); } - +#endif return; } -- GitLab From aaf24683d04d9a0346dd5ebe23686ffa907d0d2c Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 08:33:26 -0500 Subject: [PATCH 691/750] fix clang format --- lib_enc/pitch_ol_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 789da2bbd..973a2fcb2 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -60,7 +60,7 @@ static Word32 Dot_product12_OL_back( Word16 *sum1, const Word16 x[], const Word1 #ifdef FIX_2403_COMBINE_PITCH_OL static void pitch_ol_resolve_fx( Word16 pitch[3], Word16 voicing[3], Word16 *old_pitch, Word16 *old_corr, Word16 *old_thres, Word16 *delta_pit, const Word16 element_mode, const Word16 corr_shift, const Word16 relE, const Word16 Opt_SC_VBR, Word16 pitchX[NHFR][2 * NSECT], Word16 corX[NHFR][2 * NSECT], Word16 scaledX[NHFR][2 * NSECT], const Word16 sect0, const Word16 *pit_max, const Word16 pit_min_coding ); #endif - /*-----------------------------------------------------------------* +/*-----------------------------------------------------------------* * pitch_ol_init() * * Open loop pitch variable initialization -- GitLab From 6324cd496c6ce24f83deb92c422133f03dadaf53 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 14:49:19 +0100 Subject: [PATCH 692/750] clang-format --- lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/core_switching_dec_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 0b4dd036c..922f7ad1f 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2135,7 +2135,7 @@ ivas_error acelp_core_dec_fx( #ifdef FIX_2379_REMOVE_previoussynth_fx_32 Copy_Scale_sig_32_16( synth_fx, st->previoussynth_fx, output_frame, 0 ); // Q0 #else - Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 + Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 #endif } ELSE diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index c86bd236b..0c94c8c3c 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1663,7 +1663,7 @@ ivas_error core_switching_pre_dec_fx( Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ #else - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif st->lp_gainp_fx = 0; move16(); @@ -1752,7 +1752,7 @@ ivas_error core_switching_pre_dec_fx( Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ #else - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif st->lp_gainp_fx = 0; -- GitLab From 73e27ddde49f7482f26e46a0bbfdca9b42123a4a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 09:42:49 -0500 Subject: [PATCH 693/750] harmonisation of signal_clas --- lib_com/options.h | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 4 ++ lib_enc/prot_fx_enc.h | 4 +- lib_enc/sig_clas_fx.c | 80 +++++++++++++++++++-------- 4 files changed, 63 insertions(+), 27 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..7e9d5383f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ - +#define FIX_2404_HARM_SIGNAL_CLAS /* VA: basop-2404, harmonize signal_clas and signa_ivas_clas */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8541b3fd9..daf84de78 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1258,7 +1258,11 @@ void pre_proc_front_ivas_fx( * TC frame selection *-----------------------------------------------------------------*/ +#ifndef FIX_2404_HARM_SIGNAL_CLAS st->clas = signal_clas_ivas_fx( st, inp_12k8_fx, ee_fx, *relE_fx, L_look, tdm_SM_last_clas ); /* Q0 */ +#else + st->clas = signal_clas_fx( st, inp_12k8_fx, ee_fx, *relE_fx, L_look, tdm_SM_last_clas ); /* Q0 */ +#endif move16(); select_TC_fx( MODE1, st->tc_cnt, &st->coder_type, st->localVAD ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 49c438515..513978304 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -510,7 +510,7 @@ Word16 signal_clas_fx( const Word16 L_look, /* i : look-ahead */ Word16 *uc_clas /* o : temporary classification used in music/speech class*/ ); - +#ifndef FIX_2404_HARM_SIGNAL_CLAS /* o : classification for current frames */ Word16 signal_clas_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ @@ -520,7 +520,7 @@ Word16 signal_clas_ivas_fx( const Word16 L_look, /* i : look-ahead */ Word16 *uc_clas /* o : temporary classification used in music/speech class*/ ); - +#endif void speech_music_classif_fx( Encoder_State *st, /* i/o: state structure */ const Word16 *new_inp, /* i : new input signal */ diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index ccc1e38e9..80136afef 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -55,6 +55,9 @@ Word16 signal_clas_fx( /* o : classification for current Word16 i, clas, pc, zc, lo, lo2, hi, hi2, exp_ee, frac_ee; Word16 tmp16, tmpS; const Word16 *pt1; +#ifdef FIX_2404_HARM_SIGNAL_CLAS + Word64 tmp64; +#endif Flag Overflow = 0; move32(); @@ -69,33 +72,61 @@ Word16 signal_clas_fx( /* o : classification for current Ltmp = L_mult( st->voicing_fx[1], 16384 ); /* Q15*Q14->Q30 */ mean_voi2 = mac_r( Ltmp, st->voicing_fx[2], 16384 ); - /* average spectral tilt in dB */ - lo = L_Extract_lc( ee[0], &hi ); - lo2 = L_Extract_lc( ee[1], &hi2 ); - Ltmp = L_mult( lo, lo2 ); /* Q5*Q5->Q11 */ - test(); - test(); - IF( LT_32( Ltmp, 2048 ) ) +#ifdef FIX_2404_HARM_SIGNAL_CLAS + IF( st->element_mode != EVS_MONO ) { - een = 0; - move16(); - } - ELSE IF( GT_32( Ltmp, THRES_EEN ) || hi > 0 || hi2 > 0 ) - { - een = 512; - move16(); + tmp64 = W_mult0_32_32( ee[0], ee[1] ); + exp_ee = W_norm( tmp64 ); + Ltmp = W_extract_h( W_shl( tmp64, exp_ee ) ); // Q = Q6+Q6 + exp_ee - 32 + exp_ee = sub( 31, sub( add( Q12, exp_ee ), 32 ) ); + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( Ltmp, exp_ee, ONE_IN_Q31, 0 ), -1 ) ) + { + een = 0; + move16(); + } + ELSE + { + /* mean_ee2 = 0.5f * 20.0f * (float)log10( tmp ); */ + /* een = K_EE_ENC * mean_ee2 + C_EE_ENC; */ + Ltmp = BASOP_Util_Log10( Ltmp, exp_ee ); // Q25 + Ltmp = Mpy_32_32( Ltmp, 671088640 /*20.f in Q25*/ ); // Q25 + Q25 -Q31 = Q19 * 0.5 = Q20 + een = extract_l( L_shl( Mpy_32_16_1( Ltmp, K_EE_FX ), Q9 - Q20 ) ); // Q9 + + een = s_min( s_max( een, 0 ), 512 ); + } } - ELSE +#endif { - /* mean_ee2 = 0.5f * 20.0f * (float)log10( tmp ); */ - /* een = K_EE_ENC * mean_ee2 + C_EE_ENC; */ - exp_ee = norm_l( Ltmp ); - frac_ee = Log2_norm_lc( L_shl( Ltmp, exp_ee ) ); - exp_ee = sub( 30 - 11, exp_ee ); - Ltmp = Mpy_32_16( exp_ee, frac_ee, LG10 ); /* Ltmp Q14 */ - een = round_fx( L_shl( Ltmp, 16 - 5 ) ); /* Q14 -> Q9 */ - een = mac_r( C_EE_FX, een, K_EE_FX ); + + /* average spectral tilt in dB */ + lo = L_Extract_lc( ee[0], &hi ); + lo2 = L_Extract_lc( ee[1], &hi2 ); + Ltmp = L_mult( lo, lo2 ); /* Q5*Q5->Q11 */ + + test(); + test(); + IF( LT_32( Ltmp, 2048 ) ) + { + een = 0; + move16(); + } + ELSE IF( GT_32( Ltmp, THRES_EEN ) || hi > 0 || hi2 > 0 ) + { + een = 512; + move16(); + } + ELSE + { + /* mean_ee2 = 0.5f * 20.0f * (float)log10( tmp ); */ + /* een = K_EE_ENC * mean_ee2 + C_EE_ENC; */ + exp_ee = norm_l( Ltmp ); + frac_ee = Log2_norm_lc( L_shl( Ltmp, exp_ee ) ); + exp_ee = sub( 30 - 11, exp_ee ); + Ltmp = Mpy_32_16( exp_ee, frac_ee, LG10 ); /* Ltmp Q14 */ + een = round_fx( L_shl( Ltmp, 16 - 5 ) ); /* Q14 -> Q9 */ + een = mac_r( C_EE_FX, een, K_EE_FX ); + } } /* compute zero crossing rate */ pt1 = speech + sub( L_look, 1 ); @@ -268,7 +299,7 @@ Word16 signal_clas_fx( /* o : classification for current } return clas; } - +#ifndef FIX_2404_HARM_SIGNAL_CLAS Word16 signal_clas_ivas_fx( /* o : classification for current frames */ Encoder_State *st, /* i/o: encoder state structure */ const Word16 *speech, /* i : pointer to speech signal for E computation in Qx */ @@ -498,6 +529,7 @@ Word16 signal_clas_ivas_fx( /* o : classification for cur } return clas; } +#endif /*-------------------------------------------------------------------* * select_TC_fx() -- GitLab From d190c2786a4df4d2592bcc34e50f98017d2a4d8e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 09:50:41 -0500 Subject: [PATCH 694/750] fix clang-format --- lib_enc/sig_clas_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 80136afef..ee23ce5e7 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -73,7 +73,7 @@ Word16 signal_clas_fx( /* o : classification for current mean_voi2 = mac_r( Ltmp, st->voicing_fx[2], 16384 ); -#ifdef FIX_2404_HARM_SIGNAL_CLAS +#ifdef FIX_2404_HARM_SIGNAL_CLAS IF( st->element_mode != EVS_MONO ) { tmp64 = W_mult0_32_32( ee[0], ee[1] ); -- GitLab From 23bf59b5c8beb127f8b98fad533c5304a15b936a Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 16:22:41 +0100 Subject: [PATCH 695/750] fix --- lib_enc/acelp_core_enc_fx.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 999891010..73a2e50c2 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -765,8 +765,6 @@ ivas_error acelp_core_enc_ivas_fx( hLPDmem = st->hLPDmem; #ifdef HARMONIZE_ACELP_ENC - set16_fx( old_exc_fx, 0, L_EXC ); - IF( st->element_mode > EVS_MONO ) #endif { @@ -822,7 +820,9 @@ ivas_error acelp_core_enc_ivas_fx( exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); /* Q_new */ -#ifndef HARMONIZE_ACELP_ENC +#ifdef HARMONIZE_ACELP_ENC + set16_fx( old_exc_fx + L_EXC_MEM, 0, L_EXC - L_EXC_MEM ); +#else Scale_sig( old_exc_fx, L_EXC_MEM, sub( Q_new, hLPDmem->q_lpd_old_exc ) ); // Q_new #endif IF( st->hBWE_TD != NULL ) @@ -1211,12 +1211,15 @@ ivas_error acelp_core_enc_ivas_fx( /*Update MODE2 core switching memory*/ #ifdef HARMONIZE_ACELP_ENC - tmpF_fx = hLPDmem->syn[M]; - move16(); - E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); -#else - deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); + IF( st->element_mode == EVS_MONO ) + { + E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st->preemph_fac, st->L_frame, &hLPDmem->syn[M] ); + } + ELSE #endif + { + deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); + } Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); /* st->Q_syn */ } -- GitLab From aff4167321776d3ee6239940620ca8eeca40c783 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 16:33:14 +0100 Subject: [PATCH 696/750] editorial improvements --- lib_com/options.h | 2 +- lib_enc/pitch_ol_fx.c | 103 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 84 insertions(+), 21 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7b7766a8d..041b64e24 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ -#define FIX_2403_COMBINE_PITCH_OL /* VA : basop 2403, reusing common code between EVS and IVAS in pitch_ol */ +#define FIX_2403_COMBINE_PITCH_OL /* VA : basop 2403, reusing common code between EVS and IVAS in pitch_ol */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 973a2fcb2..b7f79eeea 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -15,6 +15,7 @@ /*-----------------------------------------------------------------* * Local Constants *-----------------------------------------------------------------*/ + #define PIT_MIN2 20 /* pit_min for pitch tracking */ #define PIT_MIN_1 44 /* for second pitch track */ #define PIT_MIN2_1 24 @@ -57,14 +58,18 @@ static Word16 pitch_coherence_fx( Word16 pitch0, Word16 pitch1, Word16 fac_max, static Word32 Dot_product12_OL( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 ); static Word32 Dot_product12_OL_back( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 ); + #ifdef FIX_2403_COMBINE_PITCH_OL static void pitch_ol_resolve_fx( Word16 pitch[3], Word16 voicing[3], Word16 *old_pitch, Word16 *old_corr, Word16 *old_thres, Word16 *delta_pit, const Word16 element_mode, const Word16 corr_shift, const Word16 relE, const Word16 Opt_SC_VBR, Word16 pitchX[NHFR][2 * NSECT], Word16 corX[NHFR][2 * NSECT], Word16 scaledX[NHFR][2 * NSECT], const Word16 sect0, const Word16 *pit_max, const Word16 pit_min_coding ); #endif + + /*-----------------------------------------------------------------* * pitch_ol_init() * * Open loop pitch variable initialization *-----------------------------------------------------------------*/ + void pitch_ol_init_fx( Word16 *old_thres, /* o : threshold for reinforcement of past pitch influence */ Word16 *old_pitch, /* o : pitch of the 2nd half-frame of previous frame */ @@ -80,8 +85,17 @@ void pitch_ol_init_fx( move16(); *old_corr = 0; move16(); + + return; } + #ifdef FIX_2403_COMBINE_PITCH_OL +/*-----------------------------------------------------------------* + * pitch_ol_resolve_fx() + * + * + *-----------------------------------------------------------------*/ + static void pitch_ol_resolve_fx( Word16 pitch[3], /* o : open loop pitch lag for each half-frame Q0 */ Word16 voicing[3], /* o : maximum normalized correlation for each half-frame Q15 */ @@ -113,6 +127,7 @@ static void pitch_ol_resolve_fx( Word16 cor_tmp[2 * NHFR]; Word16 thres1[2 * NHFR]; Word16 tmp_buf[NHFR + 1]; + /*-----------------------------------------------------------------* * Favor a smaller delay if it happens that it has its multiple * in the longer-delay sections (harmonics check) @@ -149,6 +164,7 @@ static void pitch_ol_resolve_fx( { find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ } + fac = THRES0; move16(); find_mult_fx( &fac, pitchX[i][NSECT + 2], pitchX[i][NSECT + 3], pit_max[7], &scaledX[i][NSECT + 2], old_pitch, old_corr, 2, 2 ); /* Multiples in 3rd section */ @@ -165,6 +181,7 @@ static void pitch_ol_resolve_fx( * Compute the maximum scaling for the neighbour correlation * reinforcement *-----------------------------------------------------------------*/ + add_sect0 = add( NSECT, sect0 ); sub_sect0 = sub( NSECT, sect0 ); FOR( i = 0; i < NHFR; i++ ) @@ -197,13 +214,15 @@ static void pitch_ol_resolve_fx( thres1[i + NHFR] = mult( THRES1, cor_tmp[i + NHFR] ); move16(); } - /*-----------------------------------------------------------------* + /*---- + -------------------------------------------------------------* * Take into account previous and next pitch values of the present * frame and look-ahead. Choose the pitch lags and normalize * correlations for each half-frame & look-ahead *-----------------------------------------------------------------*/ pitch_neighbour_fx( sect0, pitch_tmp, pitchX, cor_tmp, scaledX, thres1, ind_tmp ); + FOR( i = 0; i < NHFR; i++ ) { ind = add( maximum_fx( scaledX[i] + sect0, sub_sect0, &ftmp ), sect0 ); @@ -311,6 +330,7 @@ static void pitch_ol_resolve_fx( * in the next frame and is then used when the normalized * correlation is reinforced by the past estimate *-----------------------------------------------------------------*/ + tmp_buf[0] = *old_pitch; move16(); FOR( i = 0; i < NHFR; i++ ) @@ -375,6 +395,8 @@ static void pitch_ol_resolve_fx( pitch[i] = i_mult2( pitch[i], OPL_DECIM ); move16(); } + + return; } #endif @@ -610,6 +632,7 @@ void pitch_ol_fx( /*-----------------------------------------------------------------------------* * Estimate the new pitch by extrapolating the old pitch value for 2 half-frames *-----------------------------------------------------------------------------*/ + old_tmp = add( *old_pitch, *delta_pit ); old_tmp = s_min( old_tmp, PIT_MAX / OPL_DECIM ); old_tmp = s_max( old_tmp, pit_min ); @@ -620,6 +643,7 @@ void pitch_ol_fx( /*-----------------------------------------------------------------* * Loop for all three half-frames (current frame + look-ahead) *-----------------------------------------------------------------*/ + pt_cor0 = scaled_buf + DELTA_COH - 1; pt_cor2 = pt_cor0 - pit_min + old_tmp; @@ -690,6 +714,7 @@ void pitch_ol_fx( /*----------------------------------------------------------* * Find correlation for the non-overlapping pitch lag values *----------------------------------------------------------*/ + exp_sect[subsect0] = 0; move16(); pt_cor5 = pt_cor1; @@ -725,6 +750,7 @@ void pitch_ol_fx( /*----------------------------------------------------------* * For each subsection, find the correlation *----------------------------------------------------------*/ + FOR( j = subsect0; j < NSUBSECT; j++ ) { len_temp = sublen[j]; @@ -837,6 +863,7 @@ void pitch_ol_fx( /*-----------------------------------------------------------------* * Find correlation for the non-overlapping pitch lag values *-----------------------------------------------------------------*/ + exp_sect[subsect0] = 0; move16(); pt_cor5 = pt_cor1; @@ -985,6 +1012,7 @@ void pitch_ol_fx( * Scale correlation function in the neighbourhood of * the extrapolated pitch *-----------------------------------------------------------------*/ + pt_cor1 = pt_cor2 - ( DELTA_COH - 1 ); pt_cor3 = pt_cor4 - ( DELTA_COH - 1 ); pt2 = scale1; @@ -1113,6 +1141,7 @@ void pitch_ol_fx( } /* FOR j < NSECT */ } /* FOR i < NHFR */ + #ifdef FIX_2403_COMBINE_PITCH_OL pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, EVS_MONO, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding ); #else @@ -1365,9 +1394,11 @@ void pitch_ol_fx( move16(); } #endif + return; } + void pitch_ol_ivas_fx( Word16 pitch[3], /* o : open loop pitch lag for each half-frame in range [29,231] Q0 */ Word16 voicing[3], /* o : maximum normalized correlation for each half-frame in [0,1.0[ Q15 */ @@ -1496,6 +1527,7 @@ void pitch_ol_ivas_fx( * Extend the decimation of wsp to the end of the speech buffer * Update wsp memory *--------------------------------------------------------------*/ + Copy( st_old_wsp2, old_wsp2, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); wsp2 = old_wsp2 + ( ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); @@ -1545,6 +1577,7 @@ void pitch_ol_ivas_fx( /*-----------------------------------------------------------------------------* * Estimate the new pitch by extrapolating the old pitch value for 2 half-frames *-----------------------------------------------------------------------------*/ + old_tmp = add( *old_pitch, *delta_pit ); old_tmp = s_min( old_tmp, PIT_MAX / OPL_DECIM ); old_tmp = s_max( old_tmp, pit_min ); @@ -1555,6 +1588,7 @@ void pitch_ol_ivas_fx( /*-----------------------------------------------------------------* * Loop for all three half-frames (current frame + look-ahead) *-----------------------------------------------------------------*/ + pt_cor0 = scaled_buf + DELTA_COH - 1; pt_cor0_exp = scaled_buf_exp + DELTA_COH - 1; @@ -1674,6 +1708,7 @@ void pitch_ol_ivas_fx( /*----------------------------------------------------------* * For each subsection, find the correlation *----------------------------------------------------------*/ + FOR( j = subsect0; j < NSUBSECT; j++ ) { len_temp = sublen[j]; @@ -1759,6 +1794,7 @@ void pitch_ol_ivas_fx( /*-----------------------------------------------------------------* * For each section in both sets, find fixed vector energy *-----------------------------------------------------------------*/ + FOR( j = sect0; j < NSECT; j++ ) /* loop for each section */ { /* 1st set */ @@ -1939,6 +1975,7 @@ void pitch_ol_ivas_fx( * Scale correlation function in the neighbourhood of * the extrapolated pitch *-----------------------------------------------------------------*/ + pt_cor1 = pt_cor2 - ( DELTA_COH - 1 ); pt_cor1_exp = pt_cor2_exp - ( DELTA_COH - 1 ); pt_cor3 = pt_cor4 - ( DELTA_COH - 1 ); @@ -2090,6 +2127,7 @@ void pitch_ol_ivas_fx( } /* FOR j < NSECT */ } /* FOR i < NHFR */ + #ifdef FIX_2403_COMBINE_PITCH_OL pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, IVAS_SCE, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding ); /* any element mode other than EVS_MONO is OK here */ #else @@ -2353,6 +2391,7 @@ void pitch_ol_ivas_fx( * Verifies whether max pitch delays in higher sections have multiples * in lower sections *-----------------------------------------------------------------*/ + static void find_mult_fx( Word16 *fac, /* i/o: correlation scaling factor Q12 */ Word16 pitch0, /* i : pitch of max correlation in the c section */ @@ -2389,6 +2428,8 @@ static void find_mult_fx( pit_min = add( pit_min, pitch0 ); /* next multiple */ delta = add( delta, step ); /* the incertitude to the allowed range */ } + + return; } /*---------------------------------------------------------------------------* @@ -2397,6 +2438,7 @@ static void find_mult_fx( * Verifies if the maximum correlation pitch lag is coherent with neighbour * values *---------------------------------------------------------------------------*/ + static void pitch_neighbour_fx( Word16 sect0, /* i : indicates whether section 0 (below PIT_MIN) is used */ Word16 pitch_tmp[], /* i : estimated pitch values for each half-frame & look-ahead */ @@ -2510,13 +2552,17 @@ static void pitch_neighbour_fx( } } } + + return; } + /*-----------------------------------------------------------------* * pitch_coherence_fx * * Verify if pitch evolution is smooth *-----------------------------------------------------------------*/ + static Word16 pitch_coherence_fx( Word16 pitch0, /* i : first pitch to compare */ Word16 pitch1, /* i : 2nd pitch to compare */ @@ -2543,11 +2589,13 @@ static Word16 pitch_coherence_fx( return pc; } + /*-----------------------------------------------------------------* * LP_Decim2_Copy: * * Decimate a vector by 2 with 2nd order fir filter. *-----------------------------------------------------------------*/ + static void LP_Decim2_Copy( const Word16 x[], /* i: signal to process */ Word16 y[], /* o: signal to process */ @@ -2597,20 +2645,26 @@ static void LP_Decim2_Copy( y[j++] = round_fx( L_tmp ); move16(); } + + return; } + + /*---------------------------------------------------------------------* * Dot_product12_OL * * two different length dot products of x and y *---------------------------------------------------------------------*/ -static Word32 Dot_product12_OL( /* o : Q31: normalized result (1 < val <= -1) */ - Word16 *sum1, /* o : Q31: normalized result 2 */ - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg, /* i : vector length */ - const Word16 lg2, /* i : vector length 2 */ - Word16 *exp, /* o : exponent of result (0..+30) */ - Word16 *exp2 /* o : exponent of result 2 (0..+30) */ + +/* o : Q31: normalized result (1 < val <= -1) */ +static Word32 Dot_product12_OL( + Word16 *sum1, /* o : Q31: normalized result 2 */ + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg, /* i : vector length */ + const Word16 lg2, /* i : vector length 2 */ + Word16 *exp, /* o : exponent of result (0..+30) */ + Word16 *exp2 /* o : exponent of result 2 (0..+30) */ ) { Word16 i, sft; @@ -2662,19 +2716,22 @@ static Word32 Dot_product12_OL( /* o : Q31: normalized result return L_sum; } + /*---------------------------------------------------------------------* * Dot_product12_OL_back() * * two different length dot products of x and y, computed backward *---------------------------------------------------------------------*/ -static Word32 Dot_product12_OL_back( /* o : Q31: normalized result (1 < val <= -1) */ - Word16 *sum1, /* o : Q31: normalized result 2 */ - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg, /* i : vector length */ - const Word16 lg2, /* i : vector length 2 */ - Word16 *exp, /* o : exponent of result (0..+30) */ - Word16 *exp2 /* o : exponent of result 2 (0..+30) */ + +/* o : Q31: normalized result (1 < val <= -1) */ +static Word32 Dot_product12_OL_back( + Word16 *sum1, /* o : Q31: normalized result 2 */ + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg, /* i : vector length */ + const Word16 lg2, /* i : vector length 2 */ + Word16 *exp, /* o : exponent of result (0..+30) */ + Word16 *exp2 /* o : exponent of result 2 (0..+30) */ ) { Word16 i, sft; @@ -2726,6 +2783,13 @@ static Word32 Dot_product12_OL_back( /* o : Q31: normalized r return L_sum; } + +/*---------------------------------------------------------------------* + * pitchDoubling_det_fx() + * + * + *---------------------------------------------------------------------*/ + void pitchDoubling_det_fx( Word16 *wspeech, Word16 *pitch_ol, @@ -2737,7 +2801,6 @@ void pitchDoubling_det_fx( Word16 new_Top[2]; Word16 m, T; - /*save initial values*/ new_Top[0] = pitch_ol[0]; @@ -2747,7 +2810,6 @@ void pitchDoubling_det_fx( FOR( m = 2; m < 5; m++ ) { - /* T= pitch_ol[0]/m; */ T = mult( pitch_ol[0], One_div_fx[m - 1] ); @@ -2800,4 +2862,5 @@ void pitchDoubling_det_fx( pitch_ol[1] = new_Top[1]; move16(); -} /*end of pitch doubling detection*/ + return; +} -- GitLab From dc760cb2bce27b91313a51986d0253159d90ee44 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 10:42:50 -0500 Subject: [PATCH 697/750] harmonisation of smc init --- lib_com/options.h | 2 +- lib_enc/init_enc_fx.c | 4 + lib_enc/ivas_stereo_switching_enc_fx.c | 4 + lib_enc/prot_fx_enc.h | 5 + lib_enc/speech_music_classif_fx.c | 173 +++++++++++++------------ 5 files changed, 103 insertions(+), 85 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..e0498d2df 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ - +#define FIX_2405_HARM_SMC_INIT /* VA, basop 2405, harmonisation of SMC init */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index b30b95806..0bb93ddc3 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -545,6 +545,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); } +#ifndef FIX_2405_HARM_SMC_INIT IF( st->element_mode == EVS_MONO ) { speech_music_clas_init_fx( st->hSpMusClas ); @@ -553,6 +554,9 @@ ivas_error init_encoder_fx( { speech_music_clas_init_ivas_fx( st->hSpMusClas ); } +#else + speech_music_clas_init_fx( st->element_mode, st->hSpMusClas ); +#endif st->sp_aud_decision0 = 0; move16(); st->sp_aud_decision1 = 0; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index a4a3080a7..32d54deb6 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -93,7 +93,11 @@ static ivas_error allocate_CoreCoder_enc_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); } +#ifndef FIX_2405_HARM_SMC_INIT speech_music_clas_init_ivas_fx( st->hSpMusClas ); +#else + speech_music_clas_init_fx( st->element_mode, st->hSpMusClas ); +#endif } return IVAS_ERR_OK; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 49c438515..3b5a0f615 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1132,12 +1132,17 @@ void coder_type_modif_fx( ); void speech_music_clas_init_fx( +#ifdef FIX_2405_HARM_SMC_INIT + const Word16 element_mode, /* element mode to differentiate IVAS only init */ +#endif SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ); +#ifndef FIX_2405_HARM_SMC_INIT void speech_music_clas_init_ivas_fx( SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ); +#endif void pitchDoubling_det_fx( Word16 *wspeech, diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index a60539047..d8fc932f7 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -70,7 +70,7 @@ Word32 log_weights_noise_compute[N_SMC_MIXTURES] = { * * Initialization of speech/music classifier *---------------------------------------------------------------------*/ - +#ifndef FIX_2405_HARM_SMC_INIT void speech_music_clas_init_fx( SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ) @@ -223,67 +223,40 @@ void speech_music_clas_init_fx( } void speech_music_clas_init_ivas_fx( +#else +void speech_music_clas_init_fx( + const Word16 element_mode, /* element mode to differentiate IVAS only init */ +#endif SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ + ) { Word16 i; - set32_fx( hSpMusClas->FV_st_fx, 0, N_SMC_FEATURES ); - hSpMusClas->inact_cnt = 0; move16(); set16_fx( hSpMusClas->past_dec, 0, HANG_LEN - 1 ); set16_fx( hSpMusClas->past_dlp_fx, 0, HANG_LEN - 1 ); - set32_fx( hSpMusClas->past_dlp_mean_ST_fx, 0, HANG_LEN - 1 ); - hSpMusClas->dlp_mean_ST_fx = 0; - move32(); - hSpMusClas->dlp_mean_LT_fx = 0; - move32(); - hSpMusClas->dlp_var_LT_fx = 0; - move32(); - - FOR( i = 0; i < N_SMC_FEATURES; i++ ) - { - hSpMusClas->prev_FV_fx[i] = L_add( L_shr( hout_intervals_fx[2 * i], 1 ), L_shr( hout_intervals_fx[2 * i + 1], 1 ) ); - move32(); - } - - FOR( i = 0; i < NB_BANDS_SPMUS; i++ ) - { - hSpMusClas->past_log_enr_fx[i] = -1448; /* log(E_MIN) in Q8 */ - move16(); - } + set16_fx( hSpMusClas->past_log_enr_fx, -1448, NB_BANDS_SPMUS ); /* log(E_MIN) in Q8 */ hSpMusClas->sp_mus_state = -8; move16(); - hSpMusClas->wdrop_32fx = 0; - move32(); - hSpMusClas->wrise_fx = 0; + hSpMusClas->wdrop_fx = 0; move16(); + hSpMusClas->wdlp_0_95_sp_fx = 0; move16(); - hSpMusClas->wdlp_0_95_sp_32fx = 0; - move32(); - hSpMusClas->wdlp_xtalk_fx = 0; - move16(); set16_fx( hSpMusClas->last_lsp_fx, 0, M_LSP_SPMUS ); hSpMusClas->last_cor_map_sum_fx = 0; move16(); hSpMusClas->last_non_sta_fx = 0; move16(); set32_fx( hSpMusClas->past_PS_fx, 0, HIGHEST_FBIN - LOWEST_FBIN ); - hSpMusClas->past_PS_Q = Q31; - move16(); hSpMusClas->past_ps_diff_fx = 0; move16(); hSpMusClas->past_epsP2_fx = 1024; /* 1.0f in Q10 */ move16(); - hSpMusClas->past_epsP_fx = 0; - move16(); - hSpMusClas->flag_spitch_cnt = 0; - move16(); - hSpMusClas->gsc_thres_fx[0] = TH_0_MIN_FX; move16(); @@ -309,19 +282,6 @@ void speech_music_clas_init_ivas_fx( hSpMusClas->last_sw_dyn_fx = 2560; /* 10.0f in Q7 */ move16(); - hSpMusClas->relE_attack_cnt = 0; - move16(); - hSpMusClas->prev_relE_fx = 0; - move16(); - hSpMusClas->prev_Etot_fx = 0; - move16(); - hSpMusClas->prev_vad = 0; - move16(); - hSpMusClas->vad_0_1_cnt = 0; - move16(); - hSpMusClas->relE_attack_sum_fx = 0; - move16(); - /* speech/music classifier improvement */ FOR( i = 0; i < BUF_LEN; i++ ) { @@ -351,8 +311,6 @@ void speech_music_clas_init_ivas_fx( move16(); hSpMusClas->gsc_cnt = 0; move16(); - hSpMusClas->last_vad_spa = 0; - move16(); set16_fx( hSpMusClas->old_Bin_E_fx, 0, 3 * N_OLD_BIN_E ); set16_fx( hSpMusClas->buf_etot_fx, 0, 4 ); @@ -377,30 +335,18 @@ void speech_music_clas_init_ivas_fx( hSpMusClas->old_lt_diff_fx[1] = 0; move16(); - set32_fx( hSpMusClas->finc_prev_fx, 0, ATT_NSEG ); - hSpMusClas->q_finc_prev = Q31; - move16(); - hSpMusClas->lt_finc_fx = 0; - move32(); - hSpMusClas->Q_lt_finc = Q31; - move16(); - - hSpMusClas->last_strong_attack = 0; + /* GSC - pitch excitation parameters */ + hSpMusClas->high_stable_cor = 0; move16(); - hSpMusClas->tdm_lt_Etot_fx = 3; /* 0.01f in Q8 */ + set16_fx( hSpMusClas->var_cor_t_fx, 0, VAR_COR_LEN ); + hSpMusClas->lps_fx = 0; move16(); - set32_fx( hSpMusClas->tod_lt_Bin_E_fx, 0, TOD_NSPEC ); - hSpMusClas->Q_tod_lt_Bin_E = Q31; + hSpMusClas->lpm_fx = 0; move16(); - set32_fx( hSpMusClas->tod_S_map_lt_fx, 0, TOD_NSPEC ); - hSpMusClas->tod_thr_lt_fx = TOD_THR_MASS_FX_Q22; - move32(); - hSpMusClas->tod_weight_fx = 0; + hSpMusClas->lt_dec_thres_fx = 5120; + move16(); /*10 in Q9 */ + hSpMusClas->ener_RAT_fx = 0; move16(); - hSpMusClas->tod_S_mass_prev_fx = 0; - move32(); - hSpMusClas->tod_S_mass_lt_fx = 0; - move32(); /* speech/music classification */ set16_fx( hSpMusClas->lt_old_mode, 1, 3 ); @@ -428,21 +374,80 @@ void speech_music_clas_init_ivas_fx( hSpMusClas->lt_speech_hangover = 0; move16(); - hSpMusClas->lt_dec_thres_fx = 5120; /* 10.0f in Q9 */ - move16(); - hSpMusClas->ener_RAT_fx = 0; - move16(); +#ifdef FIX_2405_HARM_SMC_INIT + IF( element_mode > EVS_MONO ) + { + set32_fx( hSpMusClas->FV_st_fx, 0, N_SMC_FEATURES ); + set32_fx( hSpMusClas->past_dlp_mean_ST_fx, 0, HANG_LEN - 1 ); + hSpMusClas->dlp_mean_ST_fx = 0; + move32(); + hSpMusClas->dlp_mean_LT_fx = 0; + move32(); + hSpMusClas->dlp_var_LT_fx = 0; + move32(); - hSpMusClas->high_stable_cor = 0; - move16(); - set16_fx( hSpMusClas->var_cor_t_fx, 0, VAR_COR_LEN ); + FOR( i = 0; i < N_SMC_FEATURES; i++ ) + { + hSpMusClas->prev_FV_fx[i] = L_add( L_shr( hout_intervals_fx[2 * i], 1 ), L_shr( hout_intervals_fx[2 * i + 1], 1 ) ); + move32(); + } + hSpMusClas->wdrop_32fx = 0; + move32(); + hSpMusClas->wrise_fx = 0; + move16(); + hSpMusClas->wdlp_0_95_sp_32fx = 0; + move32(); + hSpMusClas->wdlp_xtalk_fx = 0; + move16(); + hSpMusClas->past_PS_Q = Q31; + move16(); + hSpMusClas->past_epsP_fx = 0; + move16(); + hSpMusClas->flag_spitch_cnt = 0; + move16(); + hSpMusClas->relE_attack_cnt = 0; + move16(); + hSpMusClas->prev_relE_fx = 0; + move16(); + hSpMusClas->prev_Etot_fx = 0; + move16(); + hSpMusClas->prev_vad = 0; + move16(); + hSpMusClas->vad_0_1_cnt = 0; + move16(); + hSpMusClas->relE_attack_sum_fx = 0; + move16(); + hSpMusClas->last_vad_spa = 0; + move16(); + set32_fx( hSpMusClas->finc_prev_fx, 0, ATT_NSEG ); + hSpMusClas->q_finc_prev = Q31; + move16(); + hSpMusClas->lt_finc_fx = 0; + move32(); + hSpMusClas->Q_lt_finc = Q31; + move16(); - hSpMusClas->lps_fx = 0; - move16(); - hSpMusClas->lpm_fx = 0; - move16(); - hSpMusClas->lpn_fx = 0; - move16(); + hSpMusClas->last_strong_attack = 0; + move16(); + hSpMusClas->tdm_lt_Etot_fx = 3; /* 0.01f in Q8 */ + move16(); + set32_fx( hSpMusClas->tod_lt_Bin_E_fx, 0, TOD_NSPEC ); + hSpMusClas->Q_tod_lt_Bin_E = Q31; + move16(); + set32_fx( hSpMusClas->tod_S_map_lt_fx, 0, TOD_NSPEC ); + hSpMusClas->tod_thr_lt_fx = TOD_THR_MASS_FX_Q22; + move32(); + hSpMusClas->tod_weight_fx = 0; + move16(); + hSpMusClas->tod_S_mass_prev_fx = 0; + move32(); + hSpMusClas->tod_S_mass_lt_fx = 0; + move32(); + hSpMusClas->lpn_fx = 0; + move16(); + + } +#endif return; } -- GitLab From 8ef2c953864b79020fbe69bd1be3df022f2a5cce Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 16:58:13 +0100 Subject: [PATCH 698/750] remove buffer synth_fxl[960] --- lib_dec/ivas_core_dec_fx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index cae261c21..99b17712e 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -869,7 +869,6 @@ ivas_error ivas_core_dec_fx( move16(); } - test(); test(); test(); @@ -1206,6 +1205,14 @@ ivas_error ivas_core_dec_fx( IF( ( GE_16( output_frame, L_FRAME32k ) && st->hTdCngDec != NULL ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) && st->hTdCngDec != NULL ) ) { /* SHB CNG decoder */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( synth_32_fx[n], synth_16_fx[n], output_frame, -( Q11 + Q2 ) ); // Q0 + Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 + Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 + + swb_CNG_dec_fx( st, synth_16_fx[n], hb_synth_16_fx[n], sid_bw[n], -Q2 ); +#else Word16 synth_fxl[960]; /* Q-2 */ Word16 q; @@ -1217,6 +1224,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 swb_CNG_dec_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); +#endif test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) @@ -1236,7 +1244,7 @@ ivas_error ivas_core_dec_fx( IF( n == 0 && GE_16( st->element_mode, IVAS_CPE_DFT ) ) { Word16 q; - q = 11; + q = Q11; move16(); #ifndef FIX_2367_REMOVE_CODE_ICBWE @@ -1247,6 +1255,7 @@ ivas_error ivas_core_dec_fx( } #endif stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); + test(); test(); test(); -- GitLab From a566bf327acb565255a15371db8e10affad1addc Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 11:22:04 -0500 Subject: [PATCH 699/750] fix clang-format --- lib_enc/prot_fx_enc.h | 2 +- lib_enc/speech_music_classif_fx.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 3b5a0f615..769e34b67 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1133,7 +1133,7 @@ void coder_type_modif_fx( void speech_music_clas_init_fx( #ifdef FIX_2405_HARM_SMC_INIT - const Word16 element_mode, /* element mode to differentiate IVAS only init */ + const Word16 element_mode, /* element mode to differentiate IVAS only init */ #endif SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index d8fc932f7..6edaa31a3 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -70,7 +70,7 @@ Word32 log_weights_noise_compute[N_SMC_MIXTURES] = { * * Initialization of speech/music classifier *---------------------------------------------------------------------*/ -#ifndef FIX_2405_HARM_SMC_INIT +#ifndef FIX_2405_HARM_SMC_INIT void speech_music_clas_init_fx( SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ) @@ -225,7 +225,7 @@ void speech_music_clas_init_fx( void speech_music_clas_init_ivas_fx( #else void speech_music_clas_init_fx( - const Word16 element_mode, /* element mode to differentiate IVAS only init */ + const Word16 element_mode, /* element mode to differentiate IVAS only init */ #endif SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ @@ -445,7 +445,6 @@ void speech_music_clas_init_fx( move32(); hSpMusClas->lpn_fx = 0; move16(); - } #endif -- GitLab From bcb6fa4ff54a2b4e1b1c58089a2374889dc3a37a Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 18:27:08 +0100 Subject: [PATCH 700/750] activate FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8a0467763..2ee68f076 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,7 +110,7 @@ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE #define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ -- GitLab From 5e7e6b41813e02c287753c17ac91b492e483cde1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 18:28:17 +0100 Subject: [PATCH 701/750] clang-format --- lib_dec/ivas_core_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 99b17712e..9bdda48a2 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1207,7 +1207,7 @@ ivas_error ivas_core_dec_fx( /* SHB CNG decoder */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 - Copy_Scale_sig_32_16( synth_32_fx[n], synth_16_fx[n], output_frame, -( Q11 + Q2 ) ); // Q0 + Copy_Scale_sig_32_16( synth_32_fx[n], synth_16_fx[n], output_frame, -( Q11 + Q2 ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 @@ -1255,7 +1255,7 @@ ivas_error ivas_core_dec_fx( } #endif stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); - + test(); test(); test(); -- GitLab From a05efd71c4440c32389e3b20edb492f6af7d6e27 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 12:35:57 -0500 Subject: [PATCH 702/750] add missing ELSE --- lib_enc/sig_clas_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index ee23ce5e7..07ad13389 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -96,6 +96,7 @@ Word16 signal_clas_fx( /* o : classification for current een = s_min( s_max( een, 0 ), 512 ); } } + ELSE #endif { -- GitLab From 62b319ef613d7681ad836f5020f78eac66e29c3c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 19:01:14 +0100 Subject: [PATCH 703/750] editorial improvements --- lib_enc/prot_fx_enc.h | 1 + lib_enc/sig_clas_fx.c | 40 +++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 513978304..11e86137e 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -521,6 +521,7 @@ Word16 signal_clas_ivas_fx( Word16 *uc_clas /* o : temporary classification used in music/speech class*/ ); #endif + void speech_music_classif_fx( Encoder_State *st, /* i/o: state structure */ const Word16 *new_inp, /* i : new input signal */ diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 07ad13389..19c17e404 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -31,9 +31,9 @@ #define K_SNR_FX 3541 /* Q15 .1111 */ #define C_SNR_FX -10921 /* Q15 -0.3333f */ - #define THRES_EEN 514206 /* 251.077 => (10^(1/(K_EE*10))) Q11*/ + /*-------------------------------------------------------------------* * signal_clas_fx() * @@ -41,13 +41,14 @@ * TC frames selection *-------------------------------------------------------------------*/ -Word16 signal_clas_fx( /* o : classification for current frames */ - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *speech, /* i : pointer to speech signal for E computation in Qx */ - const Word32 *ee, /* i : lf/hf E ration for 2 half-frames in Q6 */ - const Word16 relE, /* i : frame relative E to the long term average in Q8 */ - const Word16 L_look, /* i : look-ahead */ - Word16 *clas_mod /* o : class flag for NOOP detection */ +/* o : classification for current frames */ +Word16 signal_clas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *speech, /* i : pointer to speech signal for E computation in Qx */ + const Word32 *ee, /* i : lf/hf E ration for 2 half-frames in Q6 */ + const Word16 relE, /* i : frame relative E to the long term average in Q8 */ + const Word16 L_look, /* i : look-ahead */ + Word16 *clas_mod /* o : class flag for NOOP detection */ ) { Word32 Ltmp; @@ -72,7 +73,6 @@ Word16 signal_clas_fx( /* o : classification for current Ltmp = L_mult( st->voicing_fx[1], 16384 ); /* Q15*Q14->Q30 */ mean_voi2 = mac_r( Ltmp, st->voicing_fx[2], 16384 ); - #ifdef FIX_2404_HARM_SIGNAL_CLAS IF( st->element_mode != EVS_MONO ) { @@ -92,14 +92,12 @@ Word16 signal_clas_fx( /* o : classification for current Ltmp = BASOP_Util_Log10( Ltmp, exp_ee ); // Q25 Ltmp = Mpy_32_32( Ltmp, 671088640 /*20.f in Q25*/ ); // Q25 + Q25 -Q31 = Q19 * 0.5 = Q20 een = extract_l( L_shl( Mpy_32_16_1( Ltmp, K_EE_FX ), Q9 - Q20 ) ); // Q9 - een = s_min( s_max( een, 0 ), 512 ); } } ELSE #endif { - /* average spectral tilt in dB */ lo = L_Extract_lc( ee[0], &hi ); lo2 = L_Extract_lc( ee[1], &hi2 ); @@ -129,6 +127,7 @@ Word16 signal_clas_fx( /* o : classification for current een = mac_r( C_EE_FX, een, K_EE_FX ); } } + /* compute zero crossing rate */ pt1 = speech + sub( L_look, 1 ); tmpS = shr( *pt1, 15 ); /* sets 'tmpS to -1 if *pt1 < 0 */ @@ -146,6 +145,7 @@ Word16 signal_clas_fx( /* o : classification for current pc = add( abs_s( sub( st->pitch[1], st->pitch[0] ) ), abs_s( sub( st->pitch[2], st->pitch[1] ) ) ); st->tdm_pc = pc; move16(); + /*-----------------------------------------------------------------* * Transform parameters to the range <0:1> * Compute the merit function @@ -273,8 +273,8 @@ Word16 signal_clas_fx( /* o : classification for current BREAK; } } - /* Onset classification */ + /* Onset classification */ /* tc_cnt == -1: frame after TC frame in continuous block of GC/VC frames */ /* tc_cnt == 0: UC frame */ /* tc_cnt == 1: onset/transition frame, coded by GC coder type */ @@ -298,8 +298,10 @@ Word16 signal_clas_fx( /* o : classification for current st->tc_cnt = -1; move16(); } + return clas; } + #ifndef FIX_2404_HARM_SIGNAL_CLAS Word16 signal_clas_ivas_fx( /* o : classification for current frames */ Encoder_State *st, /* i/o: encoder state structure */ @@ -552,6 +554,7 @@ void select_TC_fx( * Select TC coder type for appropriate frames which is in general VOICED_TRANSITION, * VOICED_CLAS or ONSET frames following UNVOICED_CLAS frames *---------------------------------------------------------------------*/ + test(); IF( localVAD != 0 && GE_16( tc_cnt, 1 ) ) { @@ -573,21 +576,21 @@ void select_TC_fx( return; } + /*-------------------------------------------------------------------* * coder_type_modif_fx() * * Coder type modification *-------------------------------------------------------------------*/ + void coder_type_modif_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 relE /* i : frame relative E to the long term average */ ) { Word16 unmod_coder_type, vbr_generic_ho; - SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR; - IF( st->Opt_SC_VBR ) { vbr_generic_ho = hSC_VBR->vbr_generic_ho; @@ -615,8 +618,8 @@ void coder_type_modif_fx( test(); test(); test(); - if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || - ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) + if ( ( st->element_mode == EVS_MONO && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || + ( st->element_mode > EVS_MONO && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) { st->coder_type = GENERIC; move16(); @@ -642,8 +645,7 @@ void coder_type_modif_fx( test(); test(); test(); - if ( st->localVAD == 0 && ( ( - EQ_16( st->coder_type, UNVOICED ) && ( ( st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->Opt_SC_VBR, 1 ) ) && vbr_generic_ho == 0 && GT_16( st->last_coder_type, UNVOICED ) ) ) ) || + if ( st->localVAD == 0 && ( ( EQ_16( st->coder_type, UNVOICED ) && ( ( st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->Opt_SC_VBR, 1 ) ) && vbr_generic_ho == 0 && GT_16( st->last_coder_type, UNVOICED ) ) ) ) || EQ_16( st->coder_type, TRANSITION ) || EQ_16( st->coder_type, VOICED ) ) ) @@ -690,7 +692,7 @@ void coder_type_modif_fx( } } - IF( st->element_mode == 0 ) + IF( st->element_mode == EVS_MONO ) { /* At higher rates and with 16kHz core, allow only GC and TC coder type */ test(); -- GitLab From 307b1e39e1611349dcd5a410a8607a088f4a7fe2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 3 Feb 2026 15:30:04 -0500 Subject: [PATCH 704/750] fix proposal for #2407 --- lib_com/options.h | 2 +- lib_com/residu_fx.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..ec9d44855 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,7 @@ #define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ - +#define FIX_2407_FIX_RESIDU_IVAS /* VA: basop 2407, Implementation issue in residu_ivas + unnecessary complexity */ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 60c0c3356..b281f11a2 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -24,6 +24,7 @@ void residu_ivas_fx( const Word16 l /* i : size of filtering */ ) { +#ifndef FIX_2407_FIX_RESIDU_IVAS Word32 s; Word16 i, j; @@ -38,7 +39,24 @@ void residu_ivas_fx( y[i] = s; move32(); } +#else + Word64 s64; + Word16 i, j, scaling; + + scaling = sub( Q15, a_exp ); + FOR( i = 0; i < l; i++ ) + { + s64 = W_mult_32_16( x[i], a[0] ); + move32(); + FOR( j = 1; j <= m; j++ ) + { + s64 = W_mac_32_16( s64, x[i - j], a[j] ); + } + y[i] = W_shl_sat_l( s64, scaling ); + move32(); + } +#endif return; } -- GitLab From ee6d00ba4a0f559becbc1bf4458eaa666141fa6b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Feb 2026 08:01:09 +0100 Subject: [PATCH 705/750] fix compilation with FIX_I4_OL_PITCH --- lib_enc/evs_enc_fx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 7c51c0ef1..8dfb02eda 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -176,17 +176,19 @@ ivas_error evs_enc_fx( *---------------------------------------------------------------------*/ #ifdef FIX_I4_OL_PITCH +#ifdef HARMONIZE_ACELP_ENC + pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, +#else pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag, +#endif &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r ); #else - pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, #ifdef HARMONIZE_ACELP_ENC - pitch_orig, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, + pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, pitch_orig, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, #else - pitch_orig, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag, + pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, pitch_orig, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag, #endif - &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, - &hq_core_type, &Q_new, &shift, Q_r ); + &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r ); #endif IF( EQ_16( st->mdct_sw, MODE2 ) ) -- GitLab From b09f8a9906c25771ef653915af6c114495e7c178 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Feb 2026 08:10:25 +0100 Subject: [PATCH 706/750] merge FIX_2280_REDUCTION_UNNECESSARY_SCALING2 into FIX_2280_REDUCTION_UNNECESSARY_SCALING --- lib_com/options.h | 3 +-- lib_com/prot_fx.h | 7 ++----- lib_dec/core_switching_dec_fx.c | 4 ++-- lib_dec/ivas_core_dec_fx.c | 9 +++------ lib_dec/ivas_mct_dec_fx.c | 4 ++-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2ee68f076..62a5c198b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,8 +110,7 @@ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE /* VA: reduction of unnecessary scaling, non-BE part */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index cd4f2cc00..2ad5f157e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7575,13 +7575,10 @@ ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ -#else - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ -#endif -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ #else + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ #endif const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 0c94c8c3c..56cc1bfc3 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -220,7 +220,7 @@ ivas_error core_switching_post_dec_fx( #else Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ #endif -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ #else Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ @@ -627,7 +627,7 @@ ivas_error core_switching_post_dec_fx( hHQ_core->Q_old_wtda = Qtmp; move16(); } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; IF( output_mem_fx32 != NULL ) { diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 9bdda48a2..2e3abcb5e 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -837,7 +837,7 @@ ivas_error ivas_core_dec_fx( /*core_switching_post_dec*/ Q_synth = add( sub( 15, e_sig[0] ), st->Q_syn_factor ); -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING /*------------------fix-to-fix-end-----------------------*/ Word16 output_mem_16_fx[L_FRAME48k]; @@ -853,12 +853,9 @@ ivas_error ivas_core_dec_fx( p_output_mem_16 = NULL; set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } -#endif -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 -#endif -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ #endif @@ -920,7 +917,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_fx, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index cf4894e5e..aed970f20 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -371,7 +371,7 @@ ivas_error ivas_mct_dec_fx( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 output_mem_fx[L_FRAME48k]; IF( hCPE->output_mem_fx[1] != NULL ) { @@ -396,7 +396,7 @@ ivas_error ivas_mct_dec_fx( dirac_stereo_flag = 0; } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], hCPE->output_mem_fx[1], 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -- GitLab From 0e5d78f2a3cb957796fa95c6f944337466825c89 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Wed, 4 Feb 2026 12:20:56 +0100 Subject: [PATCH 707/750] issue: 2389 Harmonize ReadTnsData_ivas_fx()/ReadTnsData_fx() and DecodeTnsData_ivas_fx()/DecodeTnsData() --- Workspace_msvc/ambi_converter.vcxproj | 6 +- Workspace_msvc/decoder.vcxproj | 8 +- Workspace_msvc/encoder.vcxproj | 6 +- Workspace_msvc/encoder_fmtsw.vcxproj | 6 +- Workspace_msvc/isar_post_rend.vcxproj | 6 +- Workspace_msvc/lib_basop.vcxproj | 6 +- Workspace_msvc/lib_com.vcxproj | 6 +- Workspace_msvc/lib_debug.vcxproj | 6 +- Workspace_msvc/lib_dec.vcxproj | 6 +- Workspace_msvc/lib_enc.vcxproj | 6 +- Workspace_msvc/lib_isar.vcxproj | 6 +- Workspace_msvc/lib_lc3plus.vcxproj | 14 ++- Workspace_msvc/lib_rend.vcxproj | 8 +- Workspace_msvc/lib_rend.vcxproj.filters | 1 + Workspace_msvc/lib_util.vcxproj | 6 +- Workspace_msvc/renderer.vcxproj | 6 +- lib_com/options.h | 2 +- lib_com/parameter_bitmaping_fx.c | 7 ++ lib_com/prot_fx.h | 30 ++++-- lib_dec/dec_prm_fx.c | 21 ++++- lib_dec/dec_tcx_fx.c | 4 +- lib_dec/tns_base_dec_fx.c | 120 ++++++++++++++++++++++++ 22 files changed, 227 insertions(+), 60 deletions(-) diff --git a/Workspace_msvc/ambi_converter.vcxproj b/Workspace_msvc/ambi_converter.vcxproj index 0e17467f0..1e9f4a76c 100644 --- a/Workspace_msvc/ambi_converter.vcxproj +++ b/Workspace_msvc/ambi_converter.vcxproj @@ -14,18 +14,18 @@ ambi_converter {2074FFD6-8056-4C5F-8A08-0B2607D1FEFF} renderer - 10.0.17763.0 + 10.0 Application - v141 + v142 false MultiByte Application - v141 + v142 false MultiByte diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index a27712c39..c58c8c5de 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -14,18 +14,18 @@ decoder {E3DCBC31-7FC9-D127-E000-529F8460D5FD} decoder - 10.0.17763.0 + 10.0 Application - v141 + v142 false MultiByte Application - v141 + v142 false MultiByte @@ -176,4 +176,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj index 1dae36d47..71484a2da 100644 --- a/Workspace_msvc/encoder.vcxproj +++ b/Workspace_msvc/encoder.vcxproj @@ -14,18 +14,18 @@ encoder {B3FC9DFC-7268-8660-7C0D-B60BAF02C554} encoder - 10.0.17763.0 + 10.0 Application - v141 + v142 false MultiByte Application - v141 + v142 false MultiByte diff --git a/Workspace_msvc/encoder_fmtsw.vcxproj b/Workspace_msvc/encoder_fmtsw.vcxproj index 7af057ae8..9e0ebd6f5 100644 --- a/Workspace_msvc/encoder_fmtsw.vcxproj +++ b/Workspace_msvc/encoder_fmtsw.vcxproj @@ -14,18 +14,18 @@ encoder_fmtsw {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B} encoder_fmtsw - 10.0.17763.0 + 10.0 Application - v141 + v142 false MultiByte Application - v141 + v142 false MultiByte diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj index 0f2063d85..b30b36138 100644 --- a/Workspace_msvc/isar_post_rend.vcxproj +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -14,18 +14,18 @@ isar_post_rend {12374ADC-0E5C-4FDD-B903-71D572413831} isar_post_rend - 10.0.17763.0 + 10.0 Application - v141 + v142 false MultiByte Application - v141 + v142 false MultiByte diff --git a/Workspace_msvc/lib_basop.vcxproj b/Workspace_msvc/lib_basop.vcxproj index 8d4f252b5..c780e577a 100644 --- a/Workspace_msvc/lib_basop.vcxproj +++ b/Workspace_msvc/lib_basop.vcxproj @@ -35,18 +35,18 @@ {63747FE7-94BA-410C-8D7F-EB47555DD994} common - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 false MultiByte StaticLibrary - v141 + v142 false MultiByte diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 702c6c1ad..861ed4432 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -13,18 +13,18 @@ {39EC200D-7795-4FF8-B214-B24EDA5526AE} common - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 false MultiByte StaticLibrary - v141 + v142 false MultiByte diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index ef9c58a89..f277d610f 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -13,17 +13,17 @@ {54509728-928B-44D9-A118-A6F92F08B34F} debug - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 MultiByte StaticLibrary - v141 + v142 MultiByte true diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index ef31eea68..a16d94d21 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -14,18 +14,18 @@ lib_dec {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} evs_dec - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 false MultiByte StaticLibrary - v141 + v142 false MultiByte diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 93a2a8548..5f72cd678 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -14,18 +14,18 @@ lib_enc {824DA4CF-06F0-45C9-929A-8792F0E19C3E} evs_enc - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 false MultiByte StaticLibrary - v141 + v142 false MultiByte diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index 20c636309..fb2f69f45 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -14,18 +14,18 @@ lib_isar {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} isar - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 false MultiByte StaticLibrary - v141 + v142 false MultiByte diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index ad5139c35..8c724de77 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -22,22 +22,28 @@ {95030B82-70CD-4C6B-84D4-61096035BEA2} Win32Proj LC3_FL - 10.0.17763.0 + 10.0 StaticLibrary true - v141 + v142 Unicode StaticLibrary false - v141 + v142 true Unicode + + v142 + + + v142 + @@ -192,4 +198,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 4dba9d236..ac8d9ab16 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -14,18 +14,18 @@ lib_rend {718DE063-A18B-BB72-9150-62B892E6FFA6} evs_dec - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 false MultiByte StaticLibrary - v141 + v142 false MultiByte @@ -212,4 +212,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index dfa1253eb..050b97e3d 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -122,6 +122,7 @@ rend_c + diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index bfbfa8d4c..8dd6391c1 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -13,17 +13,17 @@ {2FA8F384-0775-F3B7-F8C3-85209222FC70} utility - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v142 MultiByte StaticLibrary - v141 + v142 MultiByte true diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index d6abf6aa3..9cc2028ea 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -14,18 +14,18 @@ renderer {12B4C8A5-1E06-4E30-B443-D1F916F52B47} renderer - 10.0.17763.0 + 10.0 Application - v141 + v142 false MultiByte Application - v141 + v142 false MultiByte diff --git a/lib_com/options.h b/lib_com/options.h index 89875040e..ca0452a1b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,7 @@ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ - +#define HARMONIZE_READ_DECODE_TNS /* FhG: issue 2389: Harmonization of two pairs ReadTnsData() and DecodeTnsData()*/ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 4225879e6..5a2f8ccfe 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -228,8 +228,15 @@ void SetParameters_fx( IF( s_and( param->pSubParamBitMap != NULL, value > 0 ) ) { pTmp = pParameter; +#ifdef HARMONIZE_READ_DECODE_TNS if ( pSubStruct != NULL ) + { pTmp = pSubStruct; + } +#else + if ( pSubStruct != NULL ) + pTmp = pSubStruct; +#endif SetParameters( param->pSubParamBitMap, value, pTmp, pStream, pnSize ); } } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c45c2a749..a085a005d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8375,7 +8375,21 @@ void tcx_hm_modify_envelope( Word32 env[], /* i/o: envelope Q16 */ Word16 L_frame /* i: number of spectral lines Q0 */ ); +#ifdef HARMONIZE_READ_DECODE_TNS +Word16 ReadTnsData( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); +Word16 DecodeTnsData( + STnsConfig const *pTnsConfig, + Word16 const *stream, /*Q0*/ + Word16 *pnSize, /*Q0*/ + STnsData *pTnsData); + +#else Word16 ReadTnsData( STnsConfig const *pTnsConfig, Decoder_State *st, @@ -8402,6 +8416,7 @@ Word16 DecodeTnsData_ivas_fx( Word16 *pnSize, STnsData *pTnsData ); +#endif void GetParameters( ParamsBitMap const *paramsBitMap, const Word16 nParams, @@ -11062,12 +11077,6 @@ void EncodeTnsData( Word16 *pnBits /* o : number of written bits */ ); -Word16 DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const Word16 *stream, - Word16 *pnSize, - STnsData *pTnsData ); - void WriteTnsData( const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ const Word16 *stream, /* i : internal data stream */ @@ -11075,7 +11084,7 @@ void WriteTnsData( BSTR_ENC_HANDLE hBstr, /* o : bitstream */ Word16 *pnBits /* o : number of written bits */ ); - +#ifndef HARMONIZE_READ_DECODE_TNS void ReadTnsData_ivas( STnsConfig const *pTnsConfig, Decoder_State *st, @@ -11083,6 +11092,13 @@ void ReadTnsData_ivas( Word16 *stream, Word16 *pnSize ); +Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +#endif // HARMONIZE_READ_DECODE_TNS void analysisCldfbEncoder_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word32 *timeIn, /*q11*/ diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 41a2e9842..8a792996a 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -393,8 +393,16 @@ void getTCXparam_fx( move16(); } ELSE - { + { +#ifdef HARMONIZE_READ_DECODE_TNS + + (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st0, &nTnsBits, prm + j, &nTnsParams ); +#else + ReadTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, st0, &nTnsBits, prm + j, &nTnsParams ); +#endif // HARMONIZE_READ_DECODE_TNS + + } hTcxDec->tnsActive[k] = 0; // Q0 move16(); @@ -1351,7 +1359,11 @@ void dec_prm_fx( IF( st->hTcxCfg->fIsTNSAllowed ) { SetTnsConfig( st->hTcxCfg, 1, (Word16) EQ_16( st->last_core_from_bs, ACELP_CORE ) ); +#ifdef HARMONIZE_READ_DECODE_TNS + (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); + #else ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); +#endif // HARMONIZE_READ_DECODE_TNS j = add( j, nTnsParams ); // Q0 } @@ -1675,8 +1687,13 @@ void dec_prm_fx( test(); test(); SetTnsConfig( st->hTcxCfg, 0, ( st->last_core_from_bs == ACELP_CORE ) && ( k == 0 ) ); - +#ifdef HARMONIZE_READ_DECODE_TNS + (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); +#else ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); +#endif // DEBUG + + j = add( j, nTnsParams ); } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index ed170d598..5d04d7936 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -301,7 +301,7 @@ void decoder_tcx_fx( fUseTns = (Word8) DecodeTnsData( hTcxCfg->pCurrentTnsConfig, prm_tns, &tnsSize, - &tnsData ); + &tnsData); } ELSE { @@ -4204,7 +4204,7 @@ void decoder_tcx_invQ_fx( test(); IF( !bfi && hTcxCfg->fIsTNSAllowed ) { - *fUseTns = DecodeTnsData_ivas_fx( hTcxCfg->pCurrentTnsConfig, prm_tns, &tnsSize, tnsData ); + *fUseTns = DecodeTnsData( hTcxCfg->pCurrentTnsConfig, prm_tns, &tnsSize, tnsData ); move16(); } ELSE diff --git a/lib_dec/tns_base_dec_fx.c b/lib_dec/tns_base_dec_fx.c index e245a4674..1b6c6cfae 100644 --- a/lib_dec/tns_base_dec_fx.c +++ b/lib_dec/tns_base_dec_fx.c @@ -21,6 +21,122 @@ typedef Word32 ( *TLinearPredictionFilter )( Word16 order, Word16 const parCoeff /********************************/ /* Interface functions */ /********************************/ + + +#ifdef HARMONIZE_READ_DECODE_TNS +/*---------------------------------------------------------------------* + * ReadTnsData() + * + * + *---------------------------------------------------------------------*/ +Word16 ReadTnsData( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, /*Q0*/ + Word16 *stream, /*Q0*/ + Word16 *pnSize /*Q0*/ +) +{ + Word16 start_bit_pos; + + move16(); + start_bit_pos = st->next_bit_pos; + + IF( GT_16( pTnsConfig->nMaxFilters, 1 ) ) + { + IF( pTnsConfig->allowTnsOnWhite ) + { + IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) + { + ReadFromBitstream_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, st, &stream, pnSize ); + } + ELSE + { + ReadFromBitstream_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, st, &stream, pnSize ); + } + } + ELSE + { + + IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) + { + ReadFromBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, st, &stream, pnSize ); + } + ELSE + { + ReadFromBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, st, &stream, pnSize ); + } + } + } + ELSE + { + ReadFromBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, st, &stream, pnSize ); + } + + move16(); + *pnBits = sub( st->next_bit_pos, start_bit_pos ); + + return TNS_NO_ERROR; +} +/*---------------------------------------------------------------------* + * DecodeTnsData() + * + * + *---------------------------------------------------------------------*/ +Word16 DecodeTnsData( + STnsConfig const *pTnsConfig, + Word16 const *stream, /*Q0*/ + Word16 *pnSize, /*Q0*/ + STnsData *pTnsData) +{ + Word16 result; + + ResetTnsData( pTnsData ); + + IF( GT_16( pTnsConfig->nMaxFilters, 1 ) ) + { + + IF( pTnsConfig->allowTnsOnWhite ) + { + IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) + { + SetParameters_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, pTnsData, &stream, pnSize ); + } + ELSE + { + SetParameters_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); + } + } + ELSE + { + + IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) + { + SetParameters_fx( &tnsEnabledSWBTCX10BitMap, 1, pTnsData, &stream, pnSize ); + } + ELSE + { + SetParameters_fx( &tnsEnabledSWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); + } + + } + } + ELSE + { + SetParameters_fx( &tnsEnabledWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); + + } + + move16(); + result = FALSE; + if ( pTnsData->nFilters > 0 ) + { + move16(); + result = TRUE; + } + return result; +} +#else /*---------------------------------------------------------------------* * ReadTnsData() * @@ -216,3 +332,7 @@ Word16 DecodeTnsData_ivas_fx( return result; } + + + +#endif // HARMONIZE_READ_DECODE_TNS -- GitLab From d94deafb80a799e76f0019ef917345e673c445b6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Feb 2026 12:27:03 +0100 Subject: [PATCH 708/750] FIX_2408_FD_BWE_UPDATE --- lib_com/options.h | 1 + lib_enc/swb_pre_proc_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..d11868f17 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,6 +122,7 @@ #define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ +#define FIX_2408_FD_BWE_UPDATE /* VA: basop issue 2408: bug-fix in the FD BWE memory updates in wb_pre_proc_ivas_fx() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 107d85ccd..fd0c347a3 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -449,7 +449,11 @@ void wb_pre_proc_ivas_fx( test(); test(); test(); +#ifdef FIX_2408_FD_BWE_UPDATE + IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && EQ_32( st_fx->extl_brate, 0 ) ) ) && !ppp_mode ) +#else IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && EQ_32( st_fx->total_brate, 0 ) ) ) && !ppp_mode ) +#endif { Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); -- GitLab From 0793070116598295489ac0605e77aa0ef0b65cfc Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Feb 2026 14:37:04 +0100 Subject: [PATCH 709/750] comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index d11868f17..18cbe8c39 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,7 @@ #define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ -#define FIX_2408_FD_BWE_UPDATE /* VA: basop issue 2408: bug-fix in the FD BWE memory updates in wb_pre_proc_ivas_fx() */ +#define FIX_2408_FD_BWE_UPDATE /* VA: basop issue 2408: bug-fix in the FD BWE memory updates in wb_pre_proc_ivas_fx() */ /* ##################### End NON-BE switches ########################### */ -- GitLab From f8c617e78c045797459b209c9e2020910291e9d9 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 4 Feb 2026 08:43:20 -0500 Subject: [PATCH 710/750] remove 1 not necessary move() --- lib_com/residu_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index b281f11a2..7008b4cf0 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -47,7 +47,6 @@ void residu_ivas_fx( FOR( i = 0; i < l; i++ ) { s64 = W_mult_32_16( x[i], a[0] ); - move32(); FOR( j = 1; j <= m; j++ ) { s64 = W_mac_32_16( s64, x[i - j], a[j] ); -- GitLab From c82c3fc1da3083dd6dc85cd40316d86badec1ea7 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Wed, 4 Feb 2026 17:42:40 +0100 Subject: [PATCH 711/750] issue: #2389 follow up merge !2791 fail fix --- Workspace_msvc/ambi_converter.vcxproj | 6 +++--- Workspace_msvc/decoder.vcxproj | 8 ++++---- Workspace_msvc/encoder.vcxproj | 6 +++--- Workspace_msvc/encoder_fmtsw.vcxproj | 6 +++--- Workspace_msvc/isar_post_rend.vcxproj | 6 +++--- Workspace_msvc/lib_basop.vcxproj | 6 +++--- Workspace_msvc/lib_com.vcxproj | 6 +++--- Workspace_msvc/lib_debug.vcxproj | 6 +++--- Workspace_msvc/lib_dec.vcxproj | 6 +++--- Workspace_msvc/lib_enc.vcxproj | 6 +++--- Workspace_msvc/lib_isar.vcxproj | 6 +++--- Workspace_msvc/lib_lc3plus.vcxproj | 14 ++++---------- Workspace_msvc/lib_rend.vcxproj | 8 ++++---- Workspace_msvc/lib_rend.vcxproj.filters | 1 - Workspace_msvc/lib_util.vcxproj | 6 +++--- Workspace_msvc/renderer.vcxproj | 6 +++--- 16 files changed, 48 insertions(+), 55 deletions(-) diff --git a/Workspace_msvc/ambi_converter.vcxproj b/Workspace_msvc/ambi_converter.vcxproj index 1e9f4a76c..0e17467f0 100644 --- a/Workspace_msvc/ambi_converter.vcxproj +++ b/Workspace_msvc/ambi_converter.vcxproj @@ -14,18 +14,18 @@ ambi_converter {2074FFD6-8056-4C5F-8A08-0B2607D1FEFF} renderer - 10.0 + 10.0.17763.0 Application - v142 + v141 false MultiByte Application - v142 + v141 false MultiByte diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index c58c8c5de..a27712c39 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -14,18 +14,18 @@ decoder {E3DCBC31-7FC9-D127-E000-529F8460D5FD} decoder - 10.0 + 10.0.17763.0 Application - v142 + v141 false MultiByte Application - v142 + v141 false MultiByte @@ -176,4 +176,4 @@ - \ No newline at end of file + diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj index 71484a2da..1dae36d47 100644 --- a/Workspace_msvc/encoder.vcxproj +++ b/Workspace_msvc/encoder.vcxproj @@ -14,18 +14,18 @@ encoder {B3FC9DFC-7268-8660-7C0D-B60BAF02C554} encoder - 10.0 + 10.0.17763.0 Application - v142 + v141 false MultiByte Application - v142 + v141 false MultiByte diff --git a/Workspace_msvc/encoder_fmtsw.vcxproj b/Workspace_msvc/encoder_fmtsw.vcxproj index 9e0ebd6f5..7af057ae8 100644 --- a/Workspace_msvc/encoder_fmtsw.vcxproj +++ b/Workspace_msvc/encoder_fmtsw.vcxproj @@ -14,18 +14,18 @@ encoder_fmtsw {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B} encoder_fmtsw - 10.0 + 10.0.17763.0 Application - v142 + v141 false MultiByte Application - v142 + v141 false MultiByte diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj index b30b36138..0f2063d85 100644 --- a/Workspace_msvc/isar_post_rend.vcxproj +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -14,18 +14,18 @@ isar_post_rend {12374ADC-0E5C-4FDD-B903-71D572413831} isar_post_rend - 10.0 + 10.0.17763.0 Application - v142 + v141 false MultiByte Application - v142 + v141 false MultiByte diff --git a/Workspace_msvc/lib_basop.vcxproj b/Workspace_msvc/lib_basop.vcxproj index c780e577a..8d4f252b5 100644 --- a/Workspace_msvc/lib_basop.vcxproj +++ b/Workspace_msvc/lib_basop.vcxproj @@ -35,18 +35,18 @@ {63747FE7-94BA-410C-8D7F-EB47555DD994} common - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 false MultiByte StaticLibrary - v142 + v141 false MultiByte diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 861ed4432..702c6c1ad 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -13,18 +13,18 @@ {39EC200D-7795-4FF8-B214-B24EDA5526AE} common - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 false MultiByte StaticLibrary - v142 + v141 false MultiByte diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index f277d610f..ef9c58a89 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -13,17 +13,17 @@ {54509728-928B-44D9-A118-A6F92F08B34F} debug - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 MultiByte StaticLibrary - v142 + v141 MultiByte true diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index a16d94d21..ef31eea68 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -14,18 +14,18 @@ lib_dec {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} evs_dec - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 false MultiByte StaticLibrary - v142 + v141 false MultiByte diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 5f72cd678..93a2a8548 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -14,18 +14,18 @@ lib_enc {824DA4CF-06F0-45C9-929A-8792F0E19C3E} evs_enc - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 false MultiByte StaticLibrary - v142 + v141 false MultiByte diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index fb2f69f45..20c636309 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -14,18 +14,18 @@ lib_isar {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} isar - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 false MultiByte StaticLibrary - v142 + v141 false MultiByte diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 8c724de77..ad5139c35 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -22,28 +22,22 @@ {95030B82-70CD-4C6B-84D4-61096035BEA2} Win32Proj LC3_FL - 10.0 + 10.0.17763.0 StaticLibrary true - v142 + v141 Unicode StaticLibrary false - v142 + v141 true Unicode - - v142 - - - v142 - @@ -198,4 +192,4 @@ - \ No newline at end of file + diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index ac8d9ab16..4dba9d236 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -14,18 +14,18 @@ lib_rend {718DE063-A18B-BB72-9150-62B892E6FFA6} evs_dec - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 false MultiByte StaticLibrary - v142 + v141 false MultiByte @@ -212,4 +212,4 @@ - \ No newline at end of file + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 050b97e3d..dfa1253eb 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -122,7 +122,6 @@ rend_c - diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 8dd6391c1..bfbfa8d4c 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -13,17 +13,17 @@ {2FA8F384-0775-F3B7-F8C3-85209222FC70} utility - 10.0 + 10.0.17763.0 StaticLibrary - v142 + v141 MultiByte StaticLibrary - v142 + v141 MultiByte true diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index 9cc2028ea..d6abf6aa3 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -14,18 +14,18 @@ renderer {12B4C8A5-1E06-4E30-B443-D1F916F52B47} renderer - 10.0 + 10.0.17763.0 Application - v142 + v141 false MultiByte Application - v142 + v141 false MultiByte -- GitLab From 37dde11711904924ee763ae383fdcfe5317173d9 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 4 Feb 2026 15:06:19 -0500 Subject: [PATCH 712/750] fix proposal for 2406 --- lib_com/gs_gains_fx.c | 6 +++++- lib_com/options.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 769af2692..f5eb21c0b 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -422,7 +422,7 @@ static void GSC_gain_adj( } ELSE { - Gain_off = 0; + Gain_off = 0; /* For higher bitrate, thus for L_frame == L_FRAME16k as well */ move16(); test(); @@ -460,7 +460,11 @@ static void GSC_gain_adj( } /*mimic ACELP decay of energy for low rates*/ +#ifndef FIX_2406_FIX_GAIN_ON_INACTIVE FOR( i = 0; i < MBANDS_GN; i++ ) +#else + FOR( i = 0; i < Mbands_gn; i++ ) +#endif { old_y_gain[i] = y_gain_tmp[i]; move16(); diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..be695527b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,7 @@ #define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ - +#define FIX_2406_FIX_GAIN_ON_INACTIVE /* VA: basop issue 2406: gain between 6.4 and 8kHz was too weak during inactive content with Fs=16kHz */ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ -- GitLab From e389d9a001929b0ce055fe8228a45e665089b3f7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:40:48 +0100 Subject: [PATCH 713/750] [cleanup] accept FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK --- lib_com/options.h | 1 - lib_util/render_config_reader.c | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..ec4f0dca9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,7 +81,6 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ -#define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 2875298ff..318072fe8 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1264,9 +1264,6 @@ ivas_error RenderConfigReader_checkValues( pRoom_acoustics = &hRenderConfig->roomAcoustics; tab_value_err_count = 0; int16_t wall_idx; -#ifndef FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK - int16_t i; -#endif /* Verify the number of frequency bands in the config input data */ if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) @@ -1339,21 +1336,6 @@ ivas_error RenderConfigReader_checkValues( pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; } } -#ifndef FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK - /* Verify range of distance attenuation parameters: 0.1 <= distAtt[0] <= distAtt[1] */ - /* 0.0 <= distAtt[2] <= 10.0 */ - hRenderConfig->distAtt[0] = max( 0.1f, hRenderConfig->distAtt[0] ); - hRenderConfig->distAtt[1] = max( hRenderConfig->distAtt[0], hRenderConfig->distAtt[1] ); - hRenderConfig->distAtt[2] = max( 0.0f, min( 10.0f, hRenderConfig->distAtt[2] ) ); - - /* Verify range of directivity patterns */ - for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) - { - hRenderConfig->directivity[i * 3] = max( 0.0f, min( 360.0f, hRenderConfig->directivity[i * 3] ) ); - hRenderConfig->directivity[i * 3 + 1] = max( 0.0f, min( 360.0f, hRenderConfig->directivity[i * 3 + 1] ) ); - hRenderConfig->directivity[i * 3 + 2] = max( 0.0f, min( 1.0f, hRenderConfig->directivity[i * 3 + 2] ) ); - } -#endif } -- GitLab From 908ece2b74936d87ef3642c73d595670efe43924 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:44:22 +0100 Subject: [PATCH 714/750] [cleanup] accept FIX_2255_ISAR_RENDER_POSES --- lib_com/options.h | 1 - lib_dec/lib_dec_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ec4f0dca9..b780660ff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index fbd748b84..3b8161030 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1167,18 +1167,12 @@ static ivas_error isar_render_poses( /* hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ /* set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ Word16 num_samples_flushbuffer; -#ifdef FIX_2255_ISAR_RENDER_POSES num_samples_flushbuffer = mult0( shl( numPoses, 1 ) /* shl() == numPoses * BINAURAL_CHANNELS */, div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); -#else - num_samples_flushbuffer = mult0( mult0( numPoses, BINAURAL_CHANNELS ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); -#endif hIvasDec->flushbuffer = (void *) malloc( L_mult0( sizeof( Word16 ), num_samples_flushbuffer ) ); -#ifdef FIX_2255_ISAR_RENDER_POSES if ( hIvasDec->flushbuffer == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); } -#endif set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, num_samples_flushbuffer ); } -- GitLab From 4ed6739ade02a7a691f60d2eddd01e4ef1e32b70 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:45:06 +0100 Subject: [PATCH 715/750] [cleanup] accept FIX_1478_UNINIT_ON_BFI --- lib_com/gs_noisefill_fx.c | 24 ------------------------ lib_com/options.h | 1 - 2 files changed, 25 deletions(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 383e2812d..fb11fc327 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -751,19 +751,11 @@ void highband_exc_dct_in_fx( test(); IF( bfi || LT_32( core_brate, 6000 ) || ( LT_32( core_brate, 8600 ) && EQ_16( coder_type, UNVOICED ) ) ) { -#ifndef FIX_1478_UNINIT_ON_BFI - set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */ -#else set16_fx( noisepb, 13107, last_bin ); /*0.4 in Q15 */ -#endif } ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) || ( GSC_IVAS_mode > 0 && EQ_16( GSC_noisy_speech, 1 ) ) ) { -#ifndef FIX_1478_UNINIT_ON_BFI - set16_fx( noisepb, 13107 /*0.4f*/, MBANDS_GN16k ); -#else set16_fx( noisepb, 13107 /*0.4f*/, last_bin ); -#endif } ELSE { @@ -780,11 +772,7 @@ void highband_exc_dct_in_fx( test(); IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) ) { -#ifndef FIX_1478_UNINIT_ON_BFI - set16_fx( noisepb, 3277, MBANDS_GN ); -#else set16_fx( noisepb, 3277, last_bin ); -#endif } test(); IF( LT_32( core_brate, 6000 ) && LE_16( coder_type, UNVOICED ) ) @@ -1150,19 +1138,11 @@ void highband_exc_dct_in_ivas_fx( test(); IF( bfi || LT_32( core_brate, 6000 ) || ( LT_32( core_brate, 8600 ) && EQ_16( coder_type, UNVOICED ) ) ) { -#ifndef FIX_1478_UNINIT_ON_BFI - set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */ -#else set16_fx( noisepb, 13107, last_bin ); /*0.4 in Q15 */ -#endif } ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) || ( GSC_IVAS_mode > 0 && EQ_16( GSC_noisy_speech, 1 ) ) ) { -#ifndef FIX_1478_UNINIT_ON_BFI - set16_fx( noisepb, 13107 /*0.4f*/, MBANDS_GN16k ); -#else set16_fx( noisepb, 13107 /*0.4f*/, last_bin ); -#endif } ELSE { @@ -1179,11 +1159,7 @@ void highband_exc_dct_in_ivas_fx( IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) ) { -#ifndef FIX_1478_UNINIT_ON_BFI - set16_fx( noisepb, 3277, MBANDS_GN ); -#else set16_fx( noisepb, 3277, last_bin ); -#endif } test(); diff --git a/lib_com/options.h b/lib_com/options.h index b780660ff..44c1f5dfb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ #define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ #define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ -- GitLab From 6f9c758746205aac6f8d9c21fbfb3e90ccb0493a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:45:44 +0100 Subject: [PATCH 716/750] [cleanup] accept FIX_BASOP_2358_SCALING_OOB --- lib_com/options.h | 1 - lib_rend/ivas_objectRenderer_fx.c | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 44c1f5dfb..34cfbf7f6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ #define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ #define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ #define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 8ba74dad8..03b0afe82 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -434,17 +434,9 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( { Word16 i; -#ifdef FIX_BASOP_2358_SCALING_OOB FOR( i = 0; i < num_src; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2358_SCALING_OOB scale_sig32( output_fx[i], output_frame, -4 ); // Q11 - 4 = Q7 -#else - scale_sig32( output_fx[i], L_FRAME48k, -4 ); // Q11 - 4 = Q7 -#endif } IF( NE_32( ( error = ivas_reverb_process_fx( hReverb, transport_config, 0, output_fx, p_reverb_signal_fx, subframe_idx ) ), IVAS_ERR_OK ) ) // Q p_reverb_signal_fx = Q output_fx - 2 = 5 @@ -452,17 +444,9 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( return error; } -#ifdef FIX_BASOP_2358_SCALING_OOB FOR( i = 0; i < num_src; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2358_SCALING_OOB scale_sig32( output_fx[i], output_frame, 4 ); // Q7 + 4 = Q11 -#else - scale_sig32( output_fx[i], L_FRAME48k, 4 ); // Q7 + 4 = Q11 -#endif } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) -- GitLab From c4390ee250c4452b1e3b041398c22fcfa6146527 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:46:24 +0100 Subject: [PATCH 717/750] [cleanup] accept FIX_BASOP_2350_HARM_0B_BWE_2 --- lib_com/options.h | 1 - lib_dec/acelp_core_dec_fx.c | 32 -------------------------------- 2 files changed, 33 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 34cfbf7f6..2d3a3417b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ #define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ #define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ #define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 5dcc848ad..ac9557073 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -74,9 +74,6 @@ ivas_error acelp_core_dec_fx( const Word16 read_sid_info /* i : read SID info flag */ ) { -#ifndef FIX_BASOP_2350_HARM_0B_BWE_2 - Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; -#endif Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ Word16 output_frame; /* frame length at output sampling freq. */ @@ -1898,9 +1895,7 @@ ivas_error acelp_core_dec_fx( st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); } -#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 Word32 synth_fx[L_FRAME48k]; -#endif Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); syn_32_fx = syn_tmp_32_fx + L_SUBFR; @@ -2056,9 +2051,7 @@ ivas_error acelp_core_dec_fx( cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*tmp buffer for save_hb_synth_fx[] */, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); -#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 Copy_Scale_sig_32_16( synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0 -#endif /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) @@ -2210,9 +2203,7 @@ ivas_error acelp_core_dec_fx( Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ } -#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 -#endif st->Q_syn2 = 0; move16(); } @@ -2233,20 +2224,7 @@ ivas_error acelp_core_dec_fx( IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { -#ifdef FIX_BASOP_2350_HARM_0B_BWE_2 hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#else - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - hf_synth_fx( st->hBWE_zero, EVS_MONO, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); - } - ELSE - { - Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 - hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); - Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); - } -#endif } ELSE { @@ -2342,16 +2320,6 @@ ivas_error acelp_core_dec_fx( } } -#ifndef FIX_BASOP_2350_HARM_0B_BWE_2 - IF( NE_16( st->element_mode, EVS_MONO ) ) - { - IF( save_hb_synth_fx16 != NULL ) - { - Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0 - } - Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 - } -#endif pop_wmops(); return error; } -- GitLab From 252677693b35c1b349db561b3f112c16fd54e67e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:47:21 +0100 Subject: [PATCH 718/750] [cleanup] accept FIX_2364_HARM_MULT_HARM --- lib_com/options.h | 1 - lib_enc/ivas_front_vad_fx.c | 4 - lib_enc/multi_harm_fx.c | 346 ------------------------------------ lib_enc/nois_est_fx.c | 10 -- lib_enc/prot_fx_enc.h | 19 -- 5 files changed, 380 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2d3a3417b..b515dcb5f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ #define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ #define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ #define FIX_2376_FIX_USAN_PRE_PROC /* VA: basop issue 2376: Resolve "USAN: SEGV in ivas_compute_core_buffers_fx() */ diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index b4447f2a1..50bf740d7 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -703,11 +703,7 @@ ivas_error front_vad_spar_fx( { cor_strong_limit = &dummy_int; } -#ifndef FIX_2364_HARM_MULT_HARM - loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */ -#else loc_harm = multi_harm_fx( EVS_MONO, st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */ -#endif } scale = getScaleFactor32( epsP_fx, M + 1 ); diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 79a2efca6..317404c7e 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -28,9 +28,7 @@ /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_fx( -#ifdef FIX_2364_HARM_MULT_HARM const Word16 element_mode, /* i : IVAS element_mode Q0 */ -#endif const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ @@ -51,9 +49,7 @@ Word16 multi_harm_fx( Word32 L_acc; Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; Word16 mean_dyn; -#ifdef FIX_2364_HARM_MULT_HARM Word32 tmp2_32; -#endif /*------------------------------------------------------------------* * initialization @@ -132,7 +128,6 @@ Word16 multi_harm_fx( step = 0; move16(); -#ifdef FIX_2364_HARM_MULT_HARM IF( element_mode != EVS_MONO ) { FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ ) @@ -160,7 +155,6 @@ Word16 multi_harm_fx( } } ELSE -#endif { FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ ) { @@ -328,10 +322,8 @@ Word16 multi_harm_fx( Lcor_map_LT_sum = L_deposit_l( 0 ); tmp2 = 0; move16(); -#ifdef FIX_2364_HARM_MULT_HARM tmp2_32 = 0; move32(); -#endif cor_strong = 0; move16(); pt1 = cor_map_LT; // Q15 @@ -339,7 +331,6 @@ Word16 multi_harm_fx( pt2 = cor_map; move16(); -#ifdef FIX_2364_HARM_MULT_HARM IF( element_mode != EVS_MONO ) { FOR( i = 0; i < L; i++ ) @@ -366,7 +357,6 @@ Word16 multi_harm_fx( tmp2 = extract_l( L_shr_sat( tmp2_32, 7 ) ); // q15-> q8 } ELSE -#endif { FOR( i = 0; i < L; i++ ) { @@ -437,339 +427,3 @@ Word16 multi_harm_fx( return harm; } -#ifndef FIX_2364_HARM_MULT_HARM -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ -Word16 multi_harm_ivas_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : input signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ -) -{ - Word16 i, j, k, L, stemp, N_mins, ind_mins[L_FFT / 4], *pt_mins, harm; - Word16 S[L_FFT / 2], flor, step, tmp16, tmp2, Expx2, Expy2; - Word32 tmp2_32; - Word16 corx2, cory2, corxy, cor, cor_map[L_FFT / 2], *pt1, *pt2, cor_strong; - Word32 L_acc; - Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; - Word16 mean_dyn; - - /*------------------------------------------------------------------* - * initialization - *------------------------------------------------------------------*/ - - /* length of the useful part of the spectrum (up to 6.4kHz) */ - L = L_FFT / 2; - move16(); - if ( ( bwidth == NB ) ) - { - /* length of the useful part of the spectrum (up to 3.6kHz) */ - L = 76; - move16(); - } - - Copy( Bin_E, S, L ); - - /*------------------------------------------------------------------* - * searching of spectral maxima and minima - *------------------------------------------------------------------*/ - - pt_mins = ind_mins; - - /* index of the first minimum */ - if ( LT_16( Bin_E[0], Bin_E[1] ) ) - { - *pt_mins++ = 0; - move16(); - } - - FOR( i = 1; i < L - 1; i++ ) - { - /* minimum found */ - test(); - if ( LT_16( Bin_E[i], Bin_E[i - 1] ) && LT_16( Bin_E[i], Bin_E[i + 1] ) ) - { - *pt_mins++ = i; - move16(); - } - } - - /* index of the last minimum */ - IF( LT_16( Bin_E[L - 1], Bin_E[L - 2] ) ) - { - *pt_mins++ = sub( L, 1 ); - move16(); - } - - /* total number of minimas found */ - N_mins = (Word16) ( pt_mins - ind_mins - 1 ); - move16(); - - /*------------------------------------------------------------------* - * calculation of the spectral floor - * subtraction of the spectral floor - *------------------------------------------------------------------*/ - - set16_fx( S, 0, L ); - - IF( N_mins > 0 ) - { - L_acc = L_deposit_l( 0 ); - FOR( i = 0; i < N_mins; ++i ) - { - L_acc = L_mac0( L_acc, Bin_E[ind_mins[i]], 1 ); - } - *sp_floor = extract_l( Mult_32_16( L_acc, div_s( 1, N_mins ) ) ); - move16(); - - set16_fx( S, 0, ind_mins[0] ); - set16_fx( &S[ind_mins[N_mins]], 0, sub( shr( L_FFT, 1 ), ind_mins[N_mins] ) ); - - pt_mins = ind_mins; - flor = 0; - move16(); - step = 0; - move16(); - - FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ ) - { - /* we are at the end of the next minimum */ - IF( EQ_16( i, *pt_mins ) ) - { - pt_mins++; - flor = Bin_E[i]; - move16(); /*Q7*/ - - /* calculate the new step */ - /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/ - - tmp16 = div_s( 1, sub( *pt_mins, i ) ); // Q15 - step = msu_r( L_mult( Bin_E[*pt_mins], tmp16 ), Bin_E[i], tmp16 ); // Q7 (15+7+1-16) - } - - /* subtract the floor */ - S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 ); - move16(); - - /* update the floor */ - flor = add( flor, step ); /*Q7*/ - } - } - - /* Calculate the maximum dynamic per band */ - /* since we are processing 40 bins we will use 1/40 in Q15 to find the mean */ - /* mean_dyn = mean(&S[L-40], 40);*/ - L_acc = L_deposit_l( 0 ); - FOR( i = L - 40; i < L; i++ ) - { - L_acc = L_mac( L_acc, S[i], 819 /* 1 / 40 in Q15 */ ); - } - mean_dyn = round_fx( L_acc ); /*Q7*/ - - /*mean_dyn = 0.6f * *st_mean_avr_dyn + 0.4f * mean_dyn;*/ - L_acc = L_mult( 13107 /*0.4f*/, mean_dyn ); /*Q23*/ - L_acc = L_mac( L_acc, 19661 /*0.6f*/, *st_mean_avr_dyn ); /*Q23*/ - mean_dyn = round_fx( L_acc ); /*Q7*/ - - test(); - IF( LT_16( mean_dyn, 1229 ) /*9.6f*/ && *cor_strong_limit != 0 ) - { - *cor_strong_limit = 0; - move16(); - *st_last_sw_dyn = mean_dyn; - move16(); - } - ELSE IF( GT_16( sub( mean_dyn, *st_last_sw_dyn ), 576 ) /*4.5f*/ ) - { - *cor_strong_limit = 1; - move16(); - } - test(); - if ( LT_32( total_brate, ACELP_9k60 ) || GT_32( total_brate, ACELP_16k40 ) ) - { - *cor_strong_limit = 1; - move16(); - } - - *st_mean_avr_dyn = mean_dyn; - move16(); - - /*------------------------------------------------------------------* - * calculation of the correlation map - *------------------------------------------------------------------*/ - - set16_fx( cor_map, 0, L ); - IF( N_mins > 0 ) - { - Lcorx2 = L_deposit_l( 0 ); - Lcorxy = L_deposit_l( 0 ); - stemp = ind_mins[0]; - move16(); - Lcory2 = L_mult( old_S[stemp], old_S[stemp] ); - k = 1; - move16(); - - FOR( i = add( stemp, 1 ); i <= ind_mins[N_mins]; i++ ) - { - IF( EQ_16( i, ind_mins[k] ) ) - { - /* include the last peak point (new minimum) to the corr. sum */ - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); - - /* calculation of the norm. peak correlation */ - test(); - IF( Lcorx2 != 0 && Lcory2 != 0 ) - { - /* corxy * corxy*/ - tmp16 = sub( norm_l( Lcorxy ), 1 ); - corxy = extract_h( L_shl( Lcorxy, tmp16 ) ); - corxy = mult_r( corxy, corxy ); - /* (corx2 * cory2) */ - Expx2 = norm_l( Lcorx2 ); - Expy2 = norm_l( Lcory2 ); - corx2 = extract_h( L_shl( Lcorx2, Expx2 ) ); - cory2 = extract_h( L_shl( Lcory2, Expy2 ) ); - corx2 = mult_r( corx2, cory2 ); - Expx2 = add( Expy2, Expx2 ); - /* Validate num < den */ - cor = sub( corx2, corxy ); - cor = shr( cor, 15 ); - /* Add 1 to tmp16 & shr by 2 if corxy > corx2 */ - tmp16 = sub( tmp16, cor ); - corxy = shl( corxy, cor ); - corxy = shl( corxy, cor ); - /* cor = corxy * corxy / (corx2 * cory2) */ - corxy = div_s( corxy, corx2 ); - cor = shr_sat( corxy, sub( shl( tmp16, 1 ), Expx2 ) ); /* Q15 */ - } - ELSE - { - cor = 0; - move16(); - } - - /* save the norm. peak correlation in the correlation map */ - FOR( j = ind_mins[k - 1]; j < ind_mins[k]; j++ ) - { - old_S[j] = S[j]; - move16(); - S[j] = shr( cor, 8 ); - move16(); - cor_map[j] = cor; - move16(); - } - - Lcorx2 = L_deposit_l( 0 ); - Lcory2 = L_deposit_l( 0 ); - Lcorxy = L_deposit_l( 0 ); - - k++; - } - Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); - Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); - } - - Copy( S, old_S, ind_mins[0] ); - Copy( &S[ind_mins[N_mins]], &old_S[ind_mins[N_mins]], sub( L, ind_mins[N_mins] ) ); - } - ELSE - { - *sp_floor = Bin_E[0]; - move16(); - } - *sp_floor = mult( *sp_floor, 14231 /* 1.0f / logf( 10.0f ) in Q15 */ ); - move16(); /* Convert to log10() */ - - /*------------------------------------------------------------------* - * updating of the long-term correlation map - * summation of the long-term correlation map - *------------------------------------------------------------------*/ - - Lcor_map_LT_sum = L_deposit_l( 0 ); - tmp2_32 = 0; - move16(); - - cor_strong = 0; - move16(); - pt1 = cor_map_LT; - move16(); - pt2 = cor_map; - move16(); - FOR( i = 0; i < L; i++ ) - { - /* tmp2 += S[i]; */ - tmp2_32 = L_add( tmp2_32, cor_map[i] ); /* tmp2_32 in Q15; max value is 128) */ - - /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */ - *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 ); - move16(); - - /* cor_map_LT_sum += *pt1 */ - Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */ - - if ( GT_16( *pt1, 31130 ) /*0.95f*/ ) - { - cor_strong = 1; - move16(); - } - - pt1++; - pt2++; - } - tmp2 = extract_l( L_shr_sat( tmp2_32, 7 ) ); // q15-> q8 - - IF( ( bwidth == NB ) ) - { - /* cor_map_LT_sum *= 1.53f; */ - /* tmp2 *= 1.53f; */ - Lcor_map_LT_sum = L_shl( Mult_32_16( Lcor_map_LT_sum, 25068 /* 1.53f in Q14 */ ), 1 ); - tmp2 = round_fx( L_mac( L_mult( tmp2, 32767 ), tmp2, 17367 /* 0.53 in Q15 */ ) ); - } - *cor_map_sum = tmp2; - move16(); - - /* final decision about multi-harmonicity */ - harm = 0; - move16(); - test(); - if ( ( L_msu0( Lcor_map_LT_sum, *multi_harm_limit, 64 ) > 0 ) || ( cor_strong != 0 ) ) - { - harm = 1; - move16(); - } - - /*------------------------------------------------------------------* - * updating of the decision threshold - *------------------------------------------------------------------*/ - - stemp = add( *multi_harm_limit, THR_CORR_STEP_FX ); - if ( GT_32( Lcor_map_LT_sum, THR_CORR_FX ) ) /* Q15 */ - { - /* *multi_harm_limit -= THR_CORR_STEP_FX */ - stemp = sub( *multi_harm_limit, THR_CORR_STEP_FX ); - } - - stemp = s_min( stemp, THR_CORR_MAX_FX ); - *multi_harm_limit = s_max( stemp, THR_CORR_MIN_FX ); - move16(); - - IF( N_mins <= 0 ) - { - set16_fx( old_S, 0, L ); - } - IF( S_map != NULL ) - { - Copy( S, S_map, L ); - } - return harm; -} -#endif diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 67e7fbf35..ff6784c4e 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1119,14 +1119,9 @@ void noise_est_fx( { i = 0; move16(); -#ifndef FIX_2364_HARM_MULT_HARM - *loc_harm = multi_harm_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, - st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); -#else test(); *loc_harm = multi_harm_fx( EVS_MONO, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); -#endif move16(); } @@ -2415,13 +2410,8 @@ void noise_est_ivas_fx( { i = 0; move16(); -#ifndef FIX_2364_HARM_MULT_HARM - *loc_harm = multi_harm_ivas_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, - st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); -#else *loc_harm = multi_harm_fx( st_fx->element_mode, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); -#endif move16(); } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 49c438515..633aa9692 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4107,9 +4107,7 @@ Word32 mslvq_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_fx( -#ifdef FIX_2364_HARM_MULT_HARM const Word16 element_mode, /* i : IVAS element_mode Q0 */ -#endif const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ @@ -4124,23 +4122,6 @@ Word16 multi_harm_fx( Word16 S_map[] /* o : short-term correlation map Q7 */ ); -#ifndef FIX_2364_HARM_MULT_HARM -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ -Word16 multi_harm_ivas_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ -); -#endif void pvq_encode_frame_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ -- GitLab From 118b27dfa58062f298e8d7cdf9139a5b4d1a9857 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:49:06 +0100 Subject: [PATCH 719/750] [cleanup] accept FIX_2363_FIND_WSP --- lib_com/options.h | 1 - lib_com/prot_fx.h | 15 ------- lib_enc/find_wsp_fx.c | 58 --------------------------- lib_enc/ivas_core_pre_proc_front_fx.c | 4 -- lib_enc/ivas_core_pre_proc_fx.c | 4 -- lib_enc/ivas_front_vad_fx.c | 4 -- 6 files changed, 86 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b515dcb5f..3cbb3b60f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ #define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ #define FIX_2376_FIX_USAN_PRE_PROC /* VA: basop issue 2376: Resolve "USAN: SEGV in ivas_compute_core_buffers_fx() */ #define FIX_2367_REMOVE_CODE_ICBWE /* VA: basop issue 2367: Remove IC-BWE obsolete code */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c45c2a749..a4612b652 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10910,21 +10910,6 @@ void bands_and_bit_alloc_ivas_fx( const Word16 element_mode, /* i : element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); -#ifndef FIX_2363_FIND_WSP -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ - Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ - const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ - const Word16 tilt_fact, /* i : tilt factor Q15 */ - Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ - Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ - const Word16 gamma, /* i : weighting factor Q15 */ - const Word16 L_look /* i : look-ahead Q0*/ -); -#endif Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( Word16 *x, /* Q0 */ diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index e2353c455..a16f1a95c 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -77,61 +77,3 @@ void find_wsp_fx( deemph_fx( &wsp[L_frame], preemph_fac, lookahead, &wtmp ); } } -#ifndef FIX_2363_FIND_WSP -/*-------------------------------------------------------------------* - * ivas_find_wsp_fx() - * - * Compute weighted speech used in open-loop pitch search - *-------------------------------------------------------------------*/ -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, - /* i : A(z) filter coefficients */ // Q12 - Word16 *Aw_fx, - /* o : weighted A(z) filter coefficients */ // Q12 - const Word16 *speech_fx, - /* i : pointer to the denoised speech frame */ // Q_new - const Word16 tilt_fact, - /* i : tilt factor */ // Q15 - Word16 *wsp_fx, - /* o : poitnter to the weighted speech frame */ // Q_new - Word16 *mem_wsp_fx, - /* i/o: W(Z) denominator memory */ // Q_new - const Word16 gamma, - /* i : weighting factor */ // Q15 - const Word16 L_look /* i : look-ahead Q0*/ -) -{ - Word16 *p_Aw_fx, tmp_fx; - Word16 i_subfr; - - - /*-----------------------------------------------------------------* - * Compute weighted A(z) unquantized for subframes - *-----------------------------------------------------------------*/ - weight_a_subfr_fx( nb_subfr, A_fx, Aw_fx, gamma, M ); - - /*-----------------------------------------------------------------* - * Compute weighted speech for all subframes - *-----------------------------------------------------------------*/ - p_Aw_fx = Aw_fx; - FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr ) - { - Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 ); - p_Aw_fx += ( M + 1 ); - } - p_Aw_fx -= ( M + 1 ); - - /*-----------------------------------------------------------------* - * Weighted speech computation is extended on look-ahead - *-----------------------------------------------------------------*/ - - deemph_fx( wsp_fx, tilt_fact, L_frame, mem_wsp_fx ); - Residu3_fx( p_Aw_fx, &speech_fx[L_frame], &wsp_fx[L_frame], L_look, 0 ); - tmp_fx = *mem_wsp_fx; - deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx ); - return; -} -#endif diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8541b3fd9..6e5a73a96 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1057,11 +1057,7 @@ void pre_proc_front_ivas_fx( move16(); move16(); -#ifndef FIX_2363_FIND_WSP - ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 ); -#else find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR ); -#endif Word16 Q_wsp = *Q_new; move16(); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index e83973437..5288130e6 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1109,11 +1109,7 @@ void ivas_compute_core_buffers_fx( * Compute Weighted Input *---------------------------------------------------------------*/ -#ifndef FIX_2363_FIND_WSP - ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); -#else find_wsp_fx( A_fx, st->speech_enc_pe, st->wspeech_enc, &st->mem_wsp_enc, PREEMPH_FAC_16k, L_FRAME16k, L_LOOK_16k, L_SUBFR, Aw_fx, st->gamma, NB_SUBFR16k ); -#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 50bf740d7..e4cac36d2 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -635,11 +635,7 @@ ivas_error front_vad_spar_fx( st->mem_wsp_q = Q_inp_12k8; move16(); -#ifndef FIX_2363_FIND_WSP - ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 ); -#else find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR ); -#endif IF( st->vad_flag == 0 ) { -- GitLab From d9d7191085253e56df4754e7c3db03d8ec63027b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:49:49 +0100 Subject: [PATCH 720/750] [cleanup] accept FIX_2370_UNUSED_BUFFERS_CORE_ENC --- lib_com/options.h | 1 - lib_enc/ivas_core_enc_fx.c | 28 ---------------------------- 2 files changed, 29 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3cbb3b60f..9fa81cc2e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ #define FIX_2376_FIX_USAN_PRE_PROC /* VA: basop issue 2376: Resolve "USAN: SEGV in ivas_compute_core_buffers_fx() */ #define FIX_2367_REMOVE_CODE_ICBWE /* VA: basop issue 2367: Remove IC-BWE obsolete code */ #define REMOVE_SCALING_SHB_SPEECH /* VA: remove unnecessary scaling and 32-bit buffers from ivas_core_enc_fx() */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 2880c054a..806e33979 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -611,9 +611,6 @@ ivas_error ivas_core_enc_fx( * Postprocessing, BWEs and Updates *---------------------------------------------------------------------*/ -#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC - Word16 tmp_input_fx[L_FRAME48k], tmp_old_input_fx[L_FRAME48k], q_inp[2]; -#endif FOR( n = 0; n < n_CoreChannels; n++ ) { st = sts[n]; @@ -628,18 +625,6 @@ ivas_error ivas_core_enc_fx( move16(); } -#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC - Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame ); - Copy( st->input_fx, tmp_input_fx, input_frame ); - q_inp[0] = st->q_old_inp; - q_inp[1] = st->q_inp; - - Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( -1, st->q_inp ) ); - st->q_inp = -1; - move16(); - st->q_old_inp = -1; - move16(); -#endif /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ @@ -683,7 +668,6 @@ ivas_error ivas_core_enc_fx( * SWB(FB) BWE encoding *---------------------------------------------------------------------*/ -#ifdef FIX_2370_UNUSED_BUFFERS_CORE_ENC Word16 q_inp_orig; q_inp_orig = st->q_inp; move16(); @@ -696,7 +680,6 @@ ivas_error ivas_core_enc_fx( move16(); Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( st->q_inp, q_inp_orig ) ); } -#endif #ifndef REMOVE_SCALING_SHB_SPEECH new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; @@ -813,7 +796,6 @@ ivas_error ivas_core_enc_fx( Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 -#ifdef FIX_2370_UNUSED_BUFFERS_CORE_ENC IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL ) { Scale_sig( st->input_fx, input_frame, sub( q_inp_orig, st->q_inp ) ); @@ -821,7 +803,6 @@ ivas_error ivas_core_enc_fx( move16(); } -#endif /*---------------------------------------------------------------------* * SWB DTX/CNG encoding *---------------------------------------------------------------------*/ @@ -886,15 +867,6 @@ ivas_error ivas_core_enc_fx( #endif } -#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC - Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame ); - Copy( tmp_input_fx, st->input_fx, input_frame ); - st->q_old_inp = q_inp[0]; - move16(); - st->q_inp = q_inp[1]; - move16(); - -#endif /*---------------------------------------------------------------------* * Common updates *---------------------------------------------------------------------*/ -- GitLab From d9f6afcbd5640cc8f0643cc6f1af01d864853371 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:50:25 +0100 Subject: [PATCH 721/750] [cleanup] accept FIX_2376_FIX_USAN_PRE_PROC --- lib_com/options.h | 1 - lib_enc/ivas_core_pre_proc_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9fa81cc2e..d2184237a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2376_FIX_USAN_PRE_PROC /* VA: basop issue 2376: Resolve "USAN: SEGV in ivas_compute_core_buffers_fx() */ #define FIX_2367_REMOVE_CODE_ICBWE /* VA: basop issue 2367: Remove IC-BWE obsolete code */ #define REMOVE_SCALING_SHB_SPEECH /* VA: remove unnecessary scaling and 32-bit buffers from ivas_core_enc_fx() */ #define FIX_2352_COPY_AQ_IN_TCX /* FhG: basop issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 5288130e6..25bd43935 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -707,11 +707,7 @@ void ivas_compute_core_buffers_fx( Word16 i, shift, Q_min; Word16 preemp_len, inp_max; Word16 *preemp_start_idx = NULL; -#ifdef FIX_2376_FIX_USAN_PRE_PROC Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k + L_FILT16k], max_32; -#else - Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; -#endif Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) ); Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) ); -- GitLab From 0e13672084fc92fad37bd0c20366e82ce1ee2ca1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:51:46 +0100 Subject: [PATCH 722/750] [cleanup] accept FIX_2367_REMOVE_CODE_ICBWE --- lib_com/options.h | 1 - lib_dec/ivas_core_dec_fx.c | 7 ------ lib_dec/ivas_stereo_icbwe_dec_fx.c | 2 -- lib_enc/ivas_core_enc_fx.c | 35 ------------------------------ 4 files changed, 45 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d2184237a..e48e0acd8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2367_REMOVE_CODE_ICBWE /* VA: basop issue 2367: Remove IC-BWE obsolete code */ #define REMOVE_SCALING_SHB_SPEECH /* VA: remove unnecessary scaling and 32-bit buffers from ivas_core_enc_fx() */ #define FIX_2352_COPY_AQ_IN_TCX /* FhG: basop issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2353_PTR_INIT /* FhG: basop issue 2353: initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index a7eebafb5..37e09deeb 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1179,13 +1179,6 @@ ivas_error ivas_core_dec_fx( q = 11; move16(); -#ifndef FIX_2367_REMOVE_CODE_ICBWE - if ( hCPE->hStereoDft != NULL ) - { - hCPE->hStereoDft->td_gain_fx[0] = 1; - move32(); - } -#endif stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); test(); test(); diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 1c51fc2d1..a6fdf3aad 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -156,14 +156,12 @@ void stereo_icBWE_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE = hCPE->hStereoICBWE; st = hCPE->hCoreCoder[0]; -#ifdef FIX_2367_REMOVE_CODE_ICBWE if ( hCPE->hStereoDft != NULL ) { hCPE->hStereoDft->td_gain_fx[0] = 1; move32(); } -#endif /*--------------------------------------------------------------------* * skip IC-BWE in case of mono DMX output * * -------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 806e33979..313bbf2e4 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -823,48 +823,13 @@ ivas_error ivas_core_enc_fx( * Inter-channel BWE encoding *-------------------------------------------------------------------*/ -#ifndef FIX_2367_REMOVE_CODE_ICBWE - Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); - Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer - q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer ); -#endif test(); test(); IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL ) { -#ifndef FIX_2367_REMOVE_CODE_ICBWE -#ifdef FIX_2367_REMOVE_CODE_ICBWE - Word16 q_new_swb_speech_buffer = st->q_inp; -#endif - Word32 voice_factors_fx32[CPE_CHANNELS][NB_SUBFR16k]; - stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); - - q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, Q16 ); - Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp - Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 - - stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); -#else stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, st->q_inp ); stereo_icBWE_enc_fx( hCPE, shb_speech_fx, new_swb_speech_buffer_fx_16, st->q_inp, voice_factors_fx[0] ); -#endif -#ifndef FIX_2367_REMOVE_CODE_ICBWE - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - test(); - test(); - test(); - IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) ) - { - } - ELSE - { - hStereoICBWE->prevSpecMapping_fx = 0; - move32(); - } - } -#endif } /*---------------------------------------------------------------------* -- GitLab From d429b6b4dd83017a2a2bb68a5866364aa80108ec Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:52:23 +0100 Subject: [PATCH 723/750] [cleanup] accept REMOVE_SCALING_SHB_SPEECH --- lib_com/ivas_prot_fx.h | 10 ------ lib_com/options.h | 1 - lib_com/prot_fx.h | 6 ---- lib_enc/ivas_core_enc_fx.c | 49 ------------------------------ lib_enc/ivas_stereo_icbwe_enc_fx.c | 12 -------- lib_enc/prot_fx_enc.h | 6 ---- lib_enc/swb_bwe_enc_fx.c | 10 ------ lib_enc/swb_pre_proc_fx.c | 12 -------- 8 files changed, 106 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 409bf870f..11891c6ca 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1359,20 +1359,10 @@ void stereo_tcx_init_dec_fx( void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#ifdef REMOVE_SCALING_SHB_SPEECH const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/ -#else - const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */ - const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ - Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel */ -#endif Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ -#ifdef REMOVE_SCALING_SHB_SPEECH const Word16 *voice_factors_fx /* i : voicing factors Q15 */ -#else - const Word32 *voice_factors_fx /* i : voicing factors Q31 */ -#endif ); void initMdctStereoDecData_fx( diff --git a/lib_com/options.h b/lib_com/options.h index e48e0acd8..19c921ad9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define REMOVE_SCALING_SHB_SPEECH /* VA: remove unnecessary scaling and 32-bit buffers from ivas_core_enc_fx() */ #define FIX_2352_COPY_AQ_IN_TCX /* FhG: basop issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2353_PTR_INIT /* FhG: basop issue 2353: initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 */ #define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a4612b652..02b1654d1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10248,13 +10248,7 @@ void Copy_Scale_sig32( void swb_pre_proc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ -#ifndef REMOVE_SCALING_SHB_SPEECH - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ -#endif Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/ -#ifndef REMOVE_SCALING_SHB_SPEECH - Word16 *Q_shb_spch, -#endif Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers*/ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 313bbf2e4..df8c7c880 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -87,16 +87,8 @@ ivas_error ivas_core_enc_fx( STEREO_ICBWE_ENC_HANDLE hStereoICBWE; STEREO_TD_ENC_DATA_HANDLE hStereoTD; Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; /* Q15 */ -#ifndef REMOVE_SCALING_SHB_SPEECH - Word32 shb_speech_fx32[L_FRAME16k]; - Word32 *new_swb_speech_fx; -#endif Word16 *inp_fx[CPE_CHANNELS]; Word16 *shb_speech_fx; -#ifndef REMOVE_SCALING_SHB_SPEECH - Word16 Q_shb_spch; - Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; -#endif Word16 new_inp_resamp16k_fx[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ Word16 *hb_speech_fx; Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; /* 2 * Q_new */ @@ -114,9 +106,6 @@ ivas_error ivas_core_enc_fx( Word16 max_num_indices_BWE; Word16 i, shift, Q_min; -#ifndef REMOVE_SCALING_SHB_SPEECH - set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); -#endif FOR( i = 0; i < CPE_CHANNELS; i++ ) { set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET ); @@ -129,10 +118,6 @@ ivas_error ivas_core_enc_fx( error = IVAS_ERR_OK; move32(); -#ifndef REMOVE_SCALING_SHB_SPEECH - Q_shb_spch = 0; - move16(); -#endif /*------------------------------------------------------------------* * General initialization *-----------------------------------------------------------------*/ @@ -681,9 +666,6 @@ ivas_error ivas_core_enc_fx( Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( st->q_inp, q_inp_orig ) ); } -#ifndef REMOVE_SCALING_SHB_SPEECH - new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; -#endif new_swb_speech_fx_16 = new_swb_speech_buffer_fx_16 + STEREO_DFT_OVL_MAX; set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); shb_speech_fx = new_inp_resamp16k_fx[n]; /* reuse existing buffer: shb_speech[L_FRAME16k] */ @@ -716,11 +698,7 @@ ivas_error ivas_core_enc_fx( st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 ); } -#ifdef REMOVE_SCALING_SHB_SPEECH swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); -#else - swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); -#endif st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 ); } @@ -732,16 +710,6 @@ ivas_error ivas_core_enc_fx( } } -#ifndef REMOVE_SCALING_SHB_SPEECH - Word16 Q_shb_spch_16 = Q_shb_spch; - move16(); - IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become: - // IF( st->tcxonly == 0 ) - { - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch - Q_shb_spch = add( Q_shb_spch, shift ); -#endif IF( st->hBWE_FD ) { shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); @@ -749,9 +717,6 @@ ivas_error ivas_core_enc_fx( move16(); Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda } -#ifndef REMOVE_SCALING_SHB_SPEECH - } -#endif /* SWB TBE encoder */ test(); @@ -764,11 +729,7 @@ ivas_error ivas_core_enc_fx( Word16 Q_fb_exc; Word16 fb_exc_fx[L_FRAME16k]; -#ifdef REMOVE_SCALING_SHB_SPEECH swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], 0, st->voicing_fx, pitch_buf_fx[n] ); -#else - swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], Q_shb_spch_16, st->voicing_fx, pitch_buf_fx[n] ); -#endif IF( EQ_16( st->extl, FB_TBE ) ) { @@ -783,15 +744,8 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { -#ifndef REMOVE_SCALING_SHB_SPEECH - Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 -#endif /* SWB(FB) BWE encoder */ -#ifdef REMOVE_SCALING_SHB_SPEECH swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_new[n], 1 ) ); -#else - swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); -#endif } Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 @@ -813,9 +767,6 @@ ivas_error ivas_core_enc_fx( IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && ( GE_16( input_frame, L_FRAME32k ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) { /* SHB DTX/CNG encoder */ -#ifndef REMOVE_SCALING_SHB_SPEECH - Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 -#endif swb_CNG_enc_fx( st, shb_speech_fx, old_syn_12k8_16k_fx[n] ); } diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 366b93c26..8a1d9f6f0 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -613,20 +613,10 @@ static void icbwe_dft_stereo_param_fx( void stereo_icBWE_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#ifdef REMOVE_SCALING_SHB_SPEECH const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/ -#else - const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel shb_speech_ref_e*/ - const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */ - Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/ -#endif Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ -#ifdef REMOVE_SCALING_SHB_SPEECH const Word16 *voice_factors_fx16 /* i : voicing factors Q15 */ -#else - const Word32 *voice_factors_fx /* i : voicing factors Q31 */ -#endif ) { Word16 i, j, k, nbSubFr; @@ -650,7 +640,6 @@ void stereo_icBWE_enc_fx( Word32 temp1_fx, temp2_fx; Word16 temp1_e, temp2_e, shb_frame_ref_e, shb_frame_nonref_e, gDes_e, tmp, exp; -#ifdef REMOVE_SCALING_SHB_SPEECH Word32 shb_speech_ref_fx[L_FRAME16k]; Word16 shb_speech_ref_e; Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; @@ -663,7 +652,6 @@ void stereo_icBWE_enc_fx( shb_speech_nonref_e = Q15 - shb_speech_nonref_e; Copy_Scale_sig_16_32_no_sat( shb_speech_nonref_fx_16, shb_speech_nonref_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp Copy_Scale_sig_16_32_no_sat( voice_factors_fx16, voice_factors_fx, NB_SUBFR16k, Q16 ); // Q31 -#endif /* initialization */ hStereoDft = hCPE->hStereoDft; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 633aa9692..e2ed6f76d 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -576,14 +576,8 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ -#ifdef REMOVE_SCALING_SHB_SPEECH Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 Q_slb_speech -#else - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ - Word16 Q_shb_speech, - Word16 Q_slb_speech -#endif ); void swb_CNG_enc_fx( diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index e07f79777..0ac0c4958 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -271,14 +271,8 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ -#ifdef REMOVE_SCALING_SHB_SPEECH Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 Q_slb_speech -#else - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ - Word16 Q_shb_speech, - Word16 Q_slb_speech -#endif ) { Word16 i; @@ -311,18 +305,14 @@ void swb_bwe_enc_ivas_fx( move16(); Word16 fb_band_begin; Word16 q_new_input_hp; -#ifdef REMOVE_SCALING_SHB_SPEECH Word16 shb_speech_fx[L_FRAME16k]; Word16 Q_shb_speech; -#endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; -#ifdef REMOVE_SCALING_SHB_SPEECH Q_shb_speech = getScaleFactor16( shb_speech_fx_Q0, L_FRAME16k ); Copy_Scale_sig( shb_speech_fx_Q0, shb_speech_fx, L_FRAME16k, Q_shb_speech ); // Q0 -> Q_shb_spch -#endif /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 107d85ccd..57454f02c 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -774,13 +774,7 @@ void swb_pre_proc_fx( void swb_pre_proc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ -#ifndef REMOVE_SCALING_SHB_SPEECH - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ -#endif Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0 */ -#ifndef REMOVE_SCALING_SHB_SPEECH - Word16 *Q_shb_spch, -#endif Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ @@ -1066,12 +1060,10 @@ void swb_pre_proc_ivas_fx( ELSE /* IVAS_CPE_DFT */ { Word16 out_start_ind, out_end_ind; -#ifdef REMOVE_SCALING_SHB_SPEECH Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; Word32 *new_swb_speech_fx; set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX; -#endif stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, new_swb_speech_fx, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 32000, 0, NULL ); Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( st->q_inp, add( q_reImBuffer, 1 ) ) ); // st->q_inp @@ -1282,10 +1274,6 @@ void swb_pre_proc_ivas_fx( cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); // Q0 -#ifndef REMOVE_SCALING_SHB_SPEECH - *Q_shb_spch = 0; - move16(); -#endif } IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL ) -- GitLab From 8c48d0f1d2c789c3c849268e99a682bc6299606a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:53:34 +0100 Subject: [PATCH 724/750] [cleanup] accept FIX_2352_COPY_AQ_IN_TCX --- lib_com/options.h | 1 - lib_dec/ivas_stereo_mdct_core_dec_fx.c | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 19c921ad9..d2acbaa32 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2352_COPY_AQ_IN_TCX /* FhG: basop issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2353_PTR_INIT /* FhG: basop issue 2353: initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 */ #define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ #define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index d61e541e9..403aafa37 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -385,31 +385,15 @@ void stereo_mdct_core_dec_fx( #ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI IF( !bfi ) { -#ifdef FIX_2352_COPY_AQ_IN_TCX FOR( ch = 0; ch < nChannels; ch++ ) -#else - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) -#endif { -#ifdef FIX_2352_COPY_AQ_IN_TCX Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], i_mult( nSubframes[ch], M ), sub( Q16, Q12 ) ); /* Q16 */ -#else - Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ -#endif } } #else -#ifdef FIX_2352_COPY_AQ_IN_TCX FOR( ch = 0; ch < nChannels; ch++ ) -#else - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) -#endif { -#ifdef FIX_2352_COPY_AQ_IN_TCX Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], nSubframes[ch] * M, sub( Q16, Q12 ) ); /* Q16 */ -#else - Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ -#endif } #endif -- GitLab From f1e73e7f2517d65abe23da22f4a6bc91b0b5176a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:54:08 +0100 Subject: [PATCH 725/750] [cleanup] accept FIX_2353_PTR_INIT --- lib_com/options.h | 1 - lib_dec/dec_tcx_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d2acbaa32..cfe1b94bb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2353_PTR_INIT /* FhG: basop issue 2353: initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 */ #define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ #define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index ed170d598..78e95b7a6 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4025,9 +4025,7 @@ void decoder_tcx_ivas_fx( move16(); fUseTns = 0; /* flag that is set if TNS data is present */ move16(); -#ifdef FIX_2353_PTR_INIT prm_sqQ = NULL; -#endif set16_fx( xn_buf_fx, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); -- GitLab From 0c87adf0e6e837d0f372ee012a30c0491068392f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:54:46 +0100 Subject: [PATCH 726/750] [cleanup] accept FIX_2356_GET_CHAN_ENERGIES --- lib_com/options.h | 1 - lib_enc/ivas_mct_enc_mct_fx.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index cfe1b94bb..1c23c53e0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ #define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 84bc74dd9..bb5ecbb68 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -88,33 +88,21 @@ void getChannelEnergies_fx( gb = find_guarded_bits_fx( (Word32) L_subframe ); -#ifndef FIX_2356_GET_CHAN_ENERGIES - sum2_e = st->hTcxEnc->spectrum_e[0]; - move16(); -#endif nrg[ch] = 0; move32(); -#ifdef FIX_2356_GET_CHAN_ENERGIES nrg_e[ch] = 0; /* if the mantissa is 0, the exponent gets set to sum2_e inside BASOP_Util_Add_Mant32Exp() */ move16(); -#endif FOR( n = 0; n < nSubframes; n++ ) { -#ifdef FIX_2356_GET_CHAN_ENERGIES sum2_e = st->hTcxEnc->spectrum_e[n]; move16(); -#endif sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb ); // 31 - sum2_e nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); move32(); -#ifndef FIX_2356_GET_CHAN_ENERGIES - sum2_e = st->hTcxEnc->spectrum_e[0]; - move16(); -#endif } nrg[ch] = Sqrt32( nrg[ch], &nrg_e[ch] ); // nrg_e -- GitLab From dd4fad6ae79eb89d9b33dea0ba5fd653b08e6247 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:56:40 +0100 Subject: [PATCH 727/750] [cleanup] accept FIX_2355_IGF_EXP_POWERSPEC --- lib_com/options.h | 1 - lib_enc/igf_enc_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1c23c53e0..576f6bf21 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ #define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index deed347b3..72a26b248 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -4271,10 +4271,8 @@ void IGFEncApplyStereo_fx( { pPowerSpectrumParameter_fx[0] = NULL; pPowerSpectrumParameter_fx[1] = NULL; -#ifdef FIX_2355_IGF_EXP_POWERSPEC exp_pPowerSpectrumParameter_fx[0] = NULL; exp_pPowerSpectrumParameter_fx[1] = NULL; -#endif pPowerSpectrumParameterMsInv_fx[0] = NULL; pPowerSpectrumParameterMsInv_fx[1] = NULL; q_pPowerSpectrumParameterMsInv_fx[0] = NULL; @@ -4297,9 +4295,7 @@ void IGFEncApplyStereo_fx( ELSE { pPowerSpectrumParameter_fx[ch] = NULL; -#ifdef FIX_2355_IGF_EXP_POWERSPEC exp_pPowerSpectrumParameter_fx[ch] = NULL; -#endif } IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrumParameter_fx[ch], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode ); -- GitLab From 06f9fd19c1f8bf973ad947b74b0deb2fa8544643 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:57:14 +0100 Subject: [PATCH 728/750] [cleanup] accept FIX_2319_CLDFB_INIT_FLAGS --- lib_com/cldfb_evs_fx.c | 2 -- lib_com/options.h | 1 - 2 files changed, 3 deletions(-) diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c index 8e8b6565f..a5f9da62a 100644 --- a/lib_com/cldfb_evs_fx.c +++ b/lib_com/cldfb_evs_fx.c @@ -996,10 +996,8 @@ ivas_error openCldfb( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } -#ifdef FIX_2319_CLDFB_INIT_FLAGS hs->flags = 0; move16(); -#endif hs->type = type; move16(); diff --git a/lib_com/options.h b/lib_com/options.h index 576f6bf21..8946b083d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ #define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ #define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */ -- GitLab From 121f96ae867fd6a9aa46406bcf6d707eea5d6c5d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:58:00 +0100 Subject: [PATCH 729/750] [cleanup] accept FIX_BASOP_2357_OBJECT_EDIT_MSAN --- lib_com/options.h | 1 - lib_dec/ivas_omasa_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8946b083d..b3d6c1648 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ #define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ #define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */ #define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */ diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 1659d4912..d13e17c1f 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -344,16 +344,12 @@ ivas_error ivas_omasa_data_open_fx( move16(); hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; move32(); -#ifdef FIX_BASOP_2357_OBJECT_EDIT_MSAN hMasaIsmData->preprocEneTarget_e[band_idx] = 0; move16(); -#endif hMasaIsmData->preprocEneRealized_fx[band_idx] = 0; move32(); -#ifdef FIX_BASOP_2357_OBJECT_EDIT_MSAN hMasaIsmData->preprocEneRealized_e[band_idx] = 0; move16(); -#endif } hMasaIsmData->objectsEdited = 0; -- GitLab From 448b4fb26f1df95bd28821a29481f6a262a9c4a4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 21:59:25 +0100 Subject: [PATCH 730/750] [cleanup] accept FIX_BASOP_2354_MSAN_DIFF_Q_VALUE --- lib_com/options.h | 1 - lib_rend/ivas_dirac_rend_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b3d6c1648..5ebc06bbc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ #define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */ #define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index e242c9c08..4ca7b0c14 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -253,10 +253,8 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( move16(); hSpatParamRendCom->numIsmDirections = 0; move16(); -#ifdef FIX_BASOP_2354_MSAN_DIFF_Q_VALUE hSpatParamRendCom->q_diffuseness_vector = Q30; move16(); -#endif } /*-----------------------------------------------------------------* -- GitLab From 7f89d0d51b1eb9dbb334d2039ed02089049ca778 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:00:54 +0100 Subject: [PATCH 731/750] [cleanup] accept FIX_2371_REMOVE_UNUSED_ISAR_FCNS --- lib_com/options.h | 1 - lib_isar/isar_PerceptualModel.c | 204 -------------------------------- lib_isar/isar_PredDecoder.c | 18 --- lib_isar/isar_lcld_encoder.c | 12 -- lib_isar/isar_lcld_prot.h | 30 ----- 5 files changed, 265 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5ebc06bbc..95568cc9f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */ #define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index cbc878b7c..b6f0936ab 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -83,37 +83,6 @@ static inline Word16 LogAdd_fx( return iRetVal; } -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS - -/*------------------------------------------------------------------------------------------* - * Function LogAdd() - * - * - *------------------------------------------------------------------------------------------*/ - -static inline Word32 LogAdd( - const Word32 iVal1, - const Word32 iVal2 ) -{ - Word32 iRetVal; - - if ( iVal1 > iVal2 ) - { - iRetVal = iVal1 - iVal2; - iRetVal = ( iRetVal < ( LOG_ADD_TABLE_LENGTH - 1 ) ) ? iRetVal : ( LOG_ADD_TABLE_LENGTH - 1 ); - iRetVal = iVal1 + c_aiLogAddTable[iRetVal]; - } - else - { - iRetVal = iVal2 - iVal1; - iRetVal = ( iRetVal < ( LOG_ADD_TABLE_LENGTH - 1 ) ) ? iRetVal : ( LOG_ADD_TABLE_LENGTH - 1 ); - iRetVal = iVal2 + c_aiLogAddTable[iRetVal]; - } - - return iRetVal; -} - -#endif /*------------------------------------------------------------------------------------------* * Function PerceptualModel() @@ -178,66 +147,6 @@ void PerceptualModel_fx( return; } -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS - -/*------------------------------------------------------------------------------------------* - * Function PerceptualModel() - * - * - *------------------------------------------------------------------------------------------*/ - -void PerceptualModel( - const Word32 iMaxQuantBands, - const Word32 *piRMSEnvelope, - Word32 *piExcitation, - Word32 *piSMR ) -{ - Word32 n; - - for ( n = 0; n < iMaxQuantBands; n++ ) - { - Word32 iSLOffset; - - piExcitation[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope[n] + c_aiBandwidthAdjust48[n]; - - /* Calculate sensation level offset */ - iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; - // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; - - /* Offset envelope by sensation level offset */ - piExcitation[n] -= iSLOffset; - - /* Convert to loudness domain (x^0.3) */ - piExcitation[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; - } - - /* Spread excitation function */ - for ( n = 0; n < iMaxQuantBands; n++ ) - { - Word32 k; - const Word32 *piSpread; - - piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; - piSMR[n] = piExcitation[n] + piSpread[n]; - for ( k = 0; k < iMaxQuantBands; k++ ) - { - if ( k != n ) - { - piSMR[n] = LogAdd( piSMR[n], piExcitation[k] + piSpread[k] ); - } - } - } - - for ( n = 0; n < iMaxQuantBands; n++ ) - { - piSMR[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; - piSMR[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope[n] + c_aiBandwidthAdjust48[n] - piSMR[n]; - } - - return; -} - -#endif /*------------------------------------------------------------------------------------------* @@ -246,119 +155,6 @@ void PerceptualModel( * *------------------------------------------------------------------------------------------*/ -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS - -void PerceptualModelStereo( - const Word32 iMaxQuantBands, - const Word32 *piMSFlags, - const Word32 *piRMSEnvelope0, - const Word32 *piRMSEnvelope1, - Word32 *piExcitation0, - Word32 *piExcitation1, - Word32 *piSMR0, - Word32 *piSMR1 ) -{ - Word32 n; - - for ( n = 0; n < iMaxQuantBands; n++ ) - { - Word32 iMaxRMSEnv; - Word32 iSLOffset; - - iMaxRMSEnv = piRMSEnvelope0[n]; - - piExcitation0[n] = PERCEPTUAL_MODEL_SCALE * iMaxRMSEnv + c_aiBandwidthAdjust48[n]; /* piRMSEnvelope0[n] */ - - /* Calculate sensation level offset */ - iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation0[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; - // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; - - /* Offset envelope by sensation level offset */ - piExcitation0[n] -= iSLOffset; - - /* Convert to loudness domain (x^0.3) */ - piExcitation0[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation0[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; - } - - /* Spread excitation function */ - for ( n = 0; n < iMaxQuantBands; n++ ) - { - Word32 k; - const Word32 *piSpread; - - piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; - piSMR0[n] = piExcitation0[n] + piSpread[n]; - for ( k = 0; k < iMaxQuantBands; k++ ) - { - if ( k != n ) - { - piSMR0[n] = LogAdd( piSMR0[n], piExcitation0[k] + piSpread[k] ); - } - } - } - - for ( n = 0; n < iMaxQuantBands; n++ ) - { - Word32 iMaxRMSEnv; - Word32 iSLOffset; - - iMaxRMSEnv = piRMSEnvelope1[n]; - - piExcitation1[n] = PERCEPTUAL_MODEL_SCALE * iMaxRMSEnv + c_aiBandwidthAdjust48[n]; /* piRMSEnvelope1[n] */ - - /* Calculate sensation level offset */ - iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation1[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; - // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; - - /* Offset envelope by sensation level offset */ - piExcitation1[n] -= iSLOffset; - - /* Convert to loudness domain (x^0.3) */ - piExcitation1[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation1[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; - } - - /* Spread excitation function */ - for ( n = 0; n < iMaxQuantBands; n++ ) - { - Word32 k; - const Word32 *piSpread; - - piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; - piSMR1[n] = piExcitation1[n] + piSpread[n]; - for ( k = 0; k < iMaxQuantBands; k++ ) - { - if ( k != n ) - { - piSMR1[n] = LogAdd( piSMR1[n], piExcitation1[k] + piSpread[k] ); - } - } - } - - for ( n = 0; n < iMaxQuantBands; n++ ) - { - if ( piMSFlags[n] == 1 ) - { - piSMR0[n] = ( piSMR0[n] > piSMR1[n] ) ? piSMR0[n] : piSMR1[n]; - piSMR1[n] = piSMR0[n]; - } - } - - for ( n = 0; n < iMaxQuantBands; n++ ) - { - piSMR0[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR0[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; - piSMR0[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope0[n] + c_aiBandwidthAdjust48[n] - piSMR0[n]; - } - - for ( n = 0; n < iMaxQuantBands; n++ ) - { - piSMR1[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR1[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; - piSMR1[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope1[n] + c_aiBandwidthAdjust48[n] - piSMR1[n]; - } - - return; -} - -#endif void PerceptualModelStereo_fx( const Word32 iMaxQuantBands, diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index 9023009ef..7517239f1 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -359,24 +359,6 @@ Word16 ReadPredictors_fx( return iBitsRead; } -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS -/* PLC_IMPROVEMENT */ -void SetDecodingPassed( - PredictionDecoder *psPredictionDecoder ) -{ - Word32 n, ch; - - for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) - { - for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) - { - psPredictionDecoder->ppiDecodingFailed[ch][n] = 0; - } - } - - return; -} -#endif Word32 AnyDecodingUnresolved( diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 8f6ed3983..9b33cc653 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -772,18 +772,6 @@ Word32 EncodeLCLDFrame( return 0; } -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS -/*------------------------------------------------------------------------------------------* - * Function GetNumGroups() - * - * - *------------------------------------------------------------------------------------------*/ - -Word32 GetNumGroups( LCLDEncoder *psLCLDEncoder ) -{ - return psLCLDEncoder->piNumGroups[0]; -} -#endif /*------------------------------------------------------------------------------------------* * Local functions diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index 16acd9716..aa9cd5107 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -65,11 +65,6 @@ Word32 EncodeLCLDFrame( Word16 *q_final ); -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS -Word32 GetNumGroups( - LCLDEncoder *psLCLDEncoder -); -#endif typedef struct LCLD_DECODER LCLDDecoder; @@ -176,14 +171,6 @@ Word32 CountMSBits( * PereptualModel prototypes *----------------------------------------------------------------------------------*/ -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS -extern void PerceptualModel( - const Word32 iMaxQuantBands, - const Word32 *piRMSEnvelope, - Word32 *piExcitation, - Word32 *piSMR -); -#endif extern void PerceptualModel_fx( const Word32 iMaxQuantBands, @@ -203,18 +190,6 @@ extern void PerceptualModelStereo_fx( Word32 *piSMR1 ); -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS -extern void PerceptualModelStereo( - const Word32 iMaxQuantBands, - const Word32 *piMSFlags, - const Word32 *piRMSEnvelope0, - const Word32 *piRMSEnvelope1, - Word32 *piExcitation0, - Word32 *piExcitation1, - Word32 *piSMR0, - Word32 *piSMR1 -); -#endif /*----------------------------------------------------------------------------------* * PredEncoder/PredDecoder prototypes @@ -346,11 +321,6 @@ Word32 **GetDecodingFailedPrevStatus( LCLDDecoder *psLCLDDecoder ); -#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS -void SetDecodingPassed( - PredictionDecoder *psPredictionDecoder -); -#endif void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder -- GitLab From 524970e65cb00491a5c0fde044cc157480d0ee5d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:01:36 +0100 Subject: [PATCH 732/750] [cleanup] accept FIX_2384_INIT_DEQUANT_COV --- lib_com/options.h | 1 - lib_dec/ivas_mc_param_dec_fx.c | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 95568cc9f..af3e84840 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 70b4b645c..fcfc9f911 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -3142,9 +3142,7 @@ static void ivas_param_mc_dequantize_cov_fx( const PARAM_MC_ILD_MAPPING *h_ild_mapping; Word32 Cy_state_int_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word16 Cy_state_int_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; -#ifdef FIX_2384_INIT_DEQUANT_COV Word16 nY_norm; -#endif set16_fx( Cp_buf_e, Cproto_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); set32_fx( Nrqq_fx, 0, MAX_OUTPUT_CHANNELS ); @@ -3398,38 +3396,26 @@ static void ivas_param_mc_dequantize_cov_fx( Cyp_e += nY_cov; } } -#ifdef FIX_2384_INIT_DEQUANT_COV nY_norm = nY_cov; move16(); -#endif } ELSE { Copy32( Cy_state_int_fx, Cy_state_fx, imult1616( nY_int, nY_int ) ); Copy( Cy_state_int_e, Cy_buf_e, imult1616( nY_int, nY_int ) ); -#ifdef FIX_2384_INIT_DEQUANT_COV nY_norm = nY_int; move16(); -#endif } /*normalize output matrix to a common exponent*/ tmp = 0; -#ifdef FIX_2384_INIT_DEQUANT_COV FOR( k = 0; k < nY_norm * nY_norm; k++ ) -#else - FOR( k = 0; k < nY_int * nY_int; k++ ) -#endif { Cy_state_fx[k] = BASOP_Util_Add_Mant32Exp( Cy_state_fx[k], Cy_buf_e[k], 0, 0, &Cy_buf_e[k] ); move32(); tmp = s_max( tmp, Cy_buf_e[k] ); } -#ifdef FIX_2384_INIT_DEQUANT_COV FOR( k = 0; k < nY_norm * nY_norm; k++ ) -#else - FOR( k = 0; k < nY_int * nY_int; k++ ) -#endif { L_tmp = L_shr( Cy_state_fx[k], sub( tmp, Cy_buf_e[k] ) ); Cy_state_fx[k] = L_tmp; -- GitLab From e70a649a9ec61523ce37ff5c1e1cd9fdbe3b6e6a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:02:11 +0100 Subject: [PATCH 733/750] [cleanup] accept FIX_2383_INIT_Q_A_ITF --- lib_com/options.h | 1 - lib_dec/dec_tcx_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index af3e84840..d60dba021 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 78e95b7a6..8482ef78b 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -1075,10 +1075,8 @@ void decoder_tcx_fx( Word16 predictionGain; /* not counted */ predictionGain = 0; move16(); -#ifdef FIX_2383_INIT_Q_A_ITF Q_A_itf = 15; move16(); -#endif FOR( j = startLine; j < endLine; j++ ) { -- GitLab From 0ffa6c6d8a0b25f9ba804729d8290583f5991236 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:02:50 +0100 Subject: [PATCH 734/750] [cleanup] accept FIX_2382_COPY_AQ_IN_MCT --- lib_com/options.h | 1 - lib_dec/ivas_mct_dec_fx.c | 13 ------------- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 5 ----- 3 files changed, 19 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d60dba021..453714b24 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index b50fb4ae9..62a33352c 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -214,20 +214,14 @@ ivas_error ivas_mct_dec_fx( } } -#ifndef FIX_2382_COPY_AQ_IN_MCT - Word32 Aq_fx_32[6][2][102]; -#endif /* MCT reconstruction and CoreCoder updates */ FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { -#ifdef FIX_2382_COPY_AQ_IN_MCT Word32 Aq_fx_32[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; -#endif hCPE = st_ivas->hCPE[cpe_id]; FOR( n = 0; n < CPE_CHANNELS; n++ ) { -#ifdef FIX_2382_COPY_AQ_IN_MCT #ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI test(); IF( !st_ivas->bfi && NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) @@ -247,20 +241,13 @@ ivas_error ivas_mct_dec_fx( Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[n], i_mult( nSubframes, M ), Q16 - Q12 ); // Q16 } -#else - Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16 -#endif x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 move16(); move16(); } -#ifdef FIX_2382_COPY_AQ_IN_MCT ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32, 1, 20 ); -#else - ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 ); -#endif } test(); diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 403aafa37..8a8c7dc30 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -298,7 +298,6 @@ void stereo_mdct_core_dec_fx( FOR( ch = 0; ch < nChannels; ch++ ) { -#ifdef FIX_2382_COPY_AQ_IN_MCT nSubframes[ch] = 1; /* Q0 */ move16(); @@ -307,10 +306,6 @@ void stereo_mdct_core_dec_fx( nSubframes[ch] = NB_DIV; move16(); } -#else - nSubframes[ch] = EQ_16( sts[ch]->core, TCX_10_CORE ) ? NB_DIV : 1; /* Q0 */ - move16(); -#endif FOR( k = 0; k < nSubframes[ch]; k++ ) { -- GitLab From 28bfdb968bbf02daac5b43018856785b1cf136c5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:03:19 +0100 Subject: [PATCH 735/750] [cleanup] accept FIX_2391_INIT_HQ_GENERIC_OFFSET --- lib_com/options.h | 1 - lib_dec/hq_hr_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 453714b24..825b692e9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index bcc330d61..30a7d4f4a 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -435,10 +435,8 @@ void hq_hr_dec_fx( move16(); HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; -#ifdef FIX_2391_INIT_HQ_GENERIC_OFFSET hq_generic_offset = 0; move16(); -#endif move16(); Q_audio = 0; /* to avoid compilation warnings */ -- GitLab From f5dbeace16f09ced6ff51ea2336843a7f0248cca Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:04:07 +0100 Subject: [PATCH 736/750] [cleanup] accept FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG --- lib_com/options.h | 1 - lib_enc/ivas_stereo_dft_enc_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 825b692e9..13e4ac604 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,7 +94,6 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ -#define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ #define FIX_BASOP_2361_OTR /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */ #define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index d6af9caf0..6aa9673f4 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -3953,16 +3953,10 @@ static void stereo_dft_enc_compute_prm_fx( * Compute Side gains *-----------------------------------------------------------------*/ -#ifdef FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG Copy32( pSideGain, hStereoDft->sidSideGain_fx, STEREO_DFT_BAND_MAX ); /* Copy all sideGain values since BW change may be reverted during CNG */ -#endif FOR( b = 0; b < hStereoDft->nbands; b++ ) { -#ifndef FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG - hStereoDft->sidSideGain_fx[b] = *( pSideGain + b ); - move32(); -#endif /* Quantization */ IF( flag_quant ) -- GitLab From 93b190fc60d4cb326032d52cbb7972e77f161425 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:04:46 +0100 Subject: [PATCH 737/750] [cleanup] accept FIX_1283_STEREO_DFT_COLLAPSE --- lib_com/options.h | 1 - lib_enc/cod_tcx_fx.c | 8 -------- lib_enc/ivas_sce_enc_fx.c | 2 -- 3 files changed, 11 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 13e4ac604..32913a923 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,6 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ #define FIX_BASOP_2361_OTR /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */ -#define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 922ae177a..d2dd0bf03 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -623,11 +623,7 @@ void ShapeSpectrum_ivas_fx( test(); test(); test(); -#ifndef FIX_1283_STEREO_DFT_COLLAPSE - IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) ) -#else IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) ) -#endif { max_low_pre = 0; move32(); @@ -705,11 +701,7 @@ void ShapeSpectrum_ivas_fx( test(); test(); test(); -#ifndef FIX_1283_STEREO_DFT_COLLAPSE - IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) ) -#else IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) ) -#endif { Word16 sf_width; Word16 dist_low, dist_high; diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 3e62c720e..176354490 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -473,10 +473,8 @@ ivas_error create_sce_enc_fx( } st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ -#ifdef FIX_1283_STEREO_DFT_COLLAPSE st->element_brate = -1; move32(); -#endif st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move32(); move32(); -- GitLab From 230c0ae0a05a8f2c7cf49595a863608747101500 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:05:56 +0100 Subject: [PATCH 738/750] [cleanup] accept FIX_2379_REMOVE_previoussynth_fx_32 --- lib_com/options.h | 1 - lib_dec/acelp_core_dec_fx.c | 4 ---- lib_dec/core_switching_dec_fx.c | 8 -------- lib_dec/init_dec_fx.c | 3 --- lib_dec/ivas_core_dec_fx.c | 6 ------ lib_dec/stat_dec.h | 3 --- 6 files changed, 25 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 32913a923..37ad8d099 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,6 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ #define FIX_BASOP_2361_OTR /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */ -#define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index ac9557073..033683a0a 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2105,11 +2105,7 @@ ivas_error acelp_core_dec_fx( } /* save synthesis - needed in case of core switching */ -#ifdef FIX_2379_REMOVE_previoussynth_fx_32 Copy_Scale_sig_32_16( synth_fx, st->previoussynth_fx, output_frame, 0 ); // Q0 -#else - Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 -#endif } ELSE { diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 9d36d2c5e..ae891ae53 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1598,13 +1598,9 @@ ivas_error core_switching_pre_dec_fx( } ELSE { -#ifdef FIX_2379_REMOVE_previoussynth_fx_32 Word32 previoussynth_fx_32[L_FRAME48k]; Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ -#else - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ -#endif st->lp_gainp_fx = 0; move16(); st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ @@ -1687,13 +1683,9 @@ ivas_error core_switching_pre_dec_fx( set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); st->last_coder_type = GENERIC; move16(); -#ifdef FIX_2379_REMOVE_previoussynth_fx_32 Word32 previoussynth_fx_32[L_FRAME48k]; Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ -#else - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ -#endif st->lp_gainp_fx = 0; move16(); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index a3e2c48e3..b8a5fe6de 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -436,9 +436,6 @@ ivas_error init_decoder_fx( set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); -#ifndef FIX_2379_REMOVE_previoussynth_fx_32 - set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k ); -#endif IF( st_fx->element_mode == EVS_MONO ) { diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 37e09deeb..0f9bf2d9b 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -446,9 +446,6 @@ ivas_error ivas_core_dec_fx( move16(); move16(); -#ifndef FIX_2379_REMOVE_previoussynth_fx_32 - Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 -#endif IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) { return error; @@ -558,9 +555,6 @@ ivas_error ivas_core_dec_fx( } } -#ifndef FIX_2379_REMOVE_previoussynth_fx_32 - Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0 -#endif test(); test(); IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index a1646e82e..eafc5dd8a 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1258,9 +1258,6 @@ typedef struct Decoder_State Word16 last_L_frame_ori; Word16 previoussynth_fx[L_FRAME48k]; -#ifndef FIX_2379_REMOVE_previoussynth_fx_32 - Word32 previoussynth_fx_32[L_FRAME48k]; -#endif Word16 old_synth_sw_fx[NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS )]; Word16 delay_buf_out_fx[HQ_DELTA_MAX * HQ_DELAY_COMP]; /*Q0*/ Word32 delay_buf_out32_fx[HQ_DELTA_MAX * HQ_DELAY_COMP]; /*Q11*/ -- GitLab From 1ecc558dffb5b13d3453d00f77dbdf45d6a1baba Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Feb 2026 22:08:25 +0100 Subject: [PATCH 739/750] formatting --- lib_com/prot_fx.h | 6 +++--- lib_enc/ivas_core_enc_fx.c | 14 +++++++------- lib_enc/ivas_mct_enc_mct_fx.c | 1 - lib_enc/ivas_stereo_icbwe_enc_fx.c | 6 +++--- lib_enc/multi_harm_fx.c | 24 ++++++++++++------------ lib_enc/prot_fx_enc.h | 29 ++++++++++++++--------------- lib_enc/swb_bwe_enc_fx.c | 5 ++--- lib_enc/swb_pre_proc_fx.c | 6 +++--- lib_isar/isar_PerceptualModel.c | 1 - lib_isar/isar_PredDecoder.c | 1 - 10 files changed, 44 insertions(+), 49 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 02b1654d1..d914126ab 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10246,9 +10246,9 @@ void Copy_Scale_sig32( ); void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers*/ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index df8c7c880..79a28b63a 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -710,13 +710,13 @@ ivas_error ivas_core_enc_fx( } } - IF( st->hBWE_FD ) - { - shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); - st->Q_old_wtda = add( st->Q_old_wtda, shift ); - move16(); - Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda - } + IF( st->hBWE_FD ) + { + shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); + st->Q_old_wtda = add( st->Q_old_wtda, shift ); + move16(); + Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda + } /* SWB TBE encoder */ test(); diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index bb5ecbb68..c725950b1 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -102,7 +102,6 @@ void getChannelEnergies_fx( nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); move32(); - } nrg[ch] = Sqrt32( nrg[ch], &nrg_e[ch] ); // nrg_e diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 8a1d9f6f0..1fbbd777a 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -612,11 +612,11 @@ static void icbwe_dft_stereo_param_fx( *-------------------------------------------------------------------*/ void stereo_icBWE_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/ Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/ - Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ - const Word16 *voice_factors_fx16 /* i : voicing factors Q15 */ + Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */ + const Word16 *voice_factors_fx16 /* i : voicing factors Q15 */ ) { Word16 i, j, k, nbSubFr; diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 317404c7e..6c0ef3f09 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -29,18 +29,18 @@ /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_fx( const Word16 element_mode, /* i : IVAS element_mode Q0 */ - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : input signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : input signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ ) { Word16 i, j, k, L, stemp, N_mins, ind_mins[L_FFT / 4], *pt_mins, harm; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index e2ed6f76d..030fee944 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -576,9 +576,8 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 Q_slb_speech -); + Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 Q_slb_speech ); void swb_CNG_enc_fx( Encoder_State *st_fx, /* i/o: State structure */ @@ -4102,18 +4101,18 @@ Word32 mslvq_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_fx( const Word16 element_mode, /* i : IVAS element_mode Q0 */ - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ ); diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 0ac0c4958..8dfd67076 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -271,9 +271,8 @@ void swb_bwe_enc_ivas_fx( const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ - Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 Q_slb_speech -) + Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 Q_slb_speech ) { Word16 i; Word16 *new_input_fx; diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 57454f02c..7b97791ff 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -772,9 +772,9 @@ void swb_pre_proc_fx( *-------------------------------------------------------------------*/ void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0 */ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0 */ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index b6f0936ab..3ad12b9a4 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -148,7 +148,6 @@ void PerceptualModel_fx( } - /*------------------------------------------------------------------------------------------* * Function PerceptualModelStereo() * diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index 7517239f1..94d85f2eb 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -360,7 +360,6 @@ Word16 ReadPredictors_fx( } - Word32 AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) { -- GitLab From 2dbe0ae3fc1bda078a785f57ad46acba8c99038f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 5 Feb 2026 09:11:18 +0100 Subject: [PATCH 740/750] comments --- lib_com/gs_gains_fx.c | 4 ++-- lib_com/options.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index f5eb21c0b..5490701f2 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -50,7 +50,7 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const /*========================================================================*/ -/* FUNCTION : void Comp_and_apply_gain_enc_fx */ +/* FUNCTION : void Comp_and_apply_gain_fx */ /*------------------------------------------------------------------------*/ /* PURPOSE : Compute and apply the quantized per band gain */ /*------------------------------------------------------------------------*/ @@ -479,7 +479,7 @@ static void GSC_gain_adj( /*==========================================================================*/ -/* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ +/* FUNCTION : Word16 gsc_gaindec_fx() */ /*--------------------------------------------------------------------------*/ /* PURPOSE : Generic signal frequency band decoding and application */ /*--------------------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index be695527b..142b54952 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,6 +123,7 @@ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ #define FIX_2406_FIX_GAIN_ON_INACTIVE /* VA: basop issue 2406: gain between 6.4 and 8kHz was too weak during inactive content with Fs=16kHz */ + /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ -- GitLab From 1c32b2289ed1a859eb7960d3455e3fd8074b108d Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Thu, 5 Feb 2026 09:25:48 +0100 Subject: [PATCH 741/750] 2389 --- lib_com/prot_fx.h | 2 +- lib_dec/dec_prm_fx.c | 10 ++++------ lib_dec/dec_tcx_fx.c | 2 +- lib_dec/tns_base_dec_fx.c | 7 ++----- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a085a005d..baa38d4cf 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8387,7 +8387,7 @@ Word16 DecodeTnsData( STnsConfig const *pTnsConfig, Word16 const *stream, /*Q0*/ Word16 *pnSize, /*Q0*/ - STnsData *pTnsData); + STnsData *pTnsData ); #else Word16 ReadTnsData( diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 8a792996a..853ac4222 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -393,16 +393,14 @@ void getTCXparam_fx( move16(); } ELSE - { + { #ifdef HARMONIZE_READ_DECODE_TNS (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st0, &nTnsBits, prm + j, &nTnsParams ); #else - + ReadTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, st0, &nTnsBits, prm + j, &nTnsParams ); #endif // HARMONIZE_READ_DECODE_TNS - - } hTcxDec->tnsActive[k] = 0; // Q0 move16(); @@ -1361,7 +1359,7 @@ void dec_prm_fx( SetTnsConfig( st->hTcxCfg, 1, (Word16) EQ_16( st->last_core_from_bs, ACELP_CORE ) ); #ifdef HARMONIZE_READ_DECODE_TNS (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); - #else +#else ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); #endif // HARMONIZE_READ_DECODE_TNS @@ -1693,7 +1691,7 @@ void dec_prm_fx( ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); #endif // DEBUG - + j = add( j, nTnsParams ); } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 5d04d7936..534d34275 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -301,7 +301,7 @@ void decoder_tcx_fx( fUseTns = (Word8) DecodeTnsData( hTcxCfg->pCurrentTnsConfig, prm_tns, &tnsSize, - &tnsData); + &tnsData ); } ELSE { diff --git a/lib_dec/tns_base_dec_fx.c b/lib_dec/tns_base_dec_fx.c index 1b6c6cfae..42fd51df7 100644 --- a/lib_dec/tns_base_dec_fx.c +++ b/lib_dec/tns_base_dec_fx.c @@ -87,7 +87,7 @@ Word16 DecodeTnsData( STnsConfig const *pTnsConfig, Word16 const *stream, /*Q0*/ Word16 *pnSize, /*Q0*/ - STnsData *pTnsData) + STnsData *pTnsData ) { Word16 result; @@ -118,13 +118,11 @@ Word16 DecodeTnsData( { SetParameters_fx( &tnsEnabledSWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); } - } } ELSE { - SetParameters_fx( &tnsEnabledWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); - + SetParameters_fx( &tnsEnabledWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); } move16(); @@ -334,5 +332,4 @@ Word16 DecodeTnsData_ivas_fx( } - #endif // HARMONIZE_READ_DECODE_TNS -- GitLab From ec3d2e41f9f3059ab520a0fd2f1ea18615ff29fe Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 5 Feb 2026 09:28:33 +0100 Subject: [PATCH 742/750] FIX_2392_MSAN_DESTROY_DEC --- lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..5214fc70b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +109,7 @@ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ +#define FIX_2392_MSAN_DESTROY_DEC /* VA: basop issue 2392: fix MSAN in ivas_destroy_dec_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index fbd748b84..46f008648 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -337,6 +337,9 @@ static void init_decoder_config( ) { hDecoderConfig->Opt_AMR_WB = 0; +#ifdef FIX_2392_MSAN_DESTROY_DEC + hDecoderConfig->output_Fs = -1; +#endif hDecoderConfig->nchan_out = 1; hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_INVALID; hDecoderConfig->Opt_LsCustom = 0; @@ -354,6 +357,9 @@ static void init_decoder_config( hDecoderConfig->Opt_aeid_on = 0; hDecoderConfig->Opt_ObjEdit_on = 0; move16(); +#ifdef FIX_2392_MSAN_DESTROY_DEC + move32(); +#endif move16(); move16(); move16(); -- GitLab From 50048d67d79680f1abbaae8dd18064ca66889459 Mon Sep 17 00:00:00 2001 From: Arash Azizi Date: Thu, 5 Feb 2026 09:08:59 +0000 Subject: [PATCH 743/750] Revert "Merge branch..." This reverts merge request !2791 --- lib_com/options.h | 2 +- lib_com/parameter_bitmaping_fx.c | 7 -- lib_com/prot_fx.h | 30 ++------ lib_dec/dec_prm_fx.c | 17 +---- lib_dec/dec_tcx_fx.c | 2 +- lib_dec/tns_base_dec_fx.c | 117 ------------------------------- 6 files changed, 10 insertions(+), 165 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 400b3fa16..0ea316a82 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ -#define HARMONIZE_READ_DECODE_TNS /* FhG: issue 2389: Harmonization of two pairs ReadTnsData() and DecodeTnsData()*/ + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 5a2f8ccfe..4225879e6 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -228,15 +228,8 @@ void SetParameters_fx( IF( s_and( param->pSubParamBitMap != NULL, value > 0 ) ) { pTmp = pParameter; -#ifdef HARMONIZE_READ_DECODE_TNS if ( pSubStruct != NULL ) - { pTmp = pSubStruct; - } -#else - if ( pSubStruct != NULL ) - pTmp = pSubStruct; -#endif SetParameters( param->pSubParamBitMap, value, pTmp, pStream, pnSize ); } } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index baa38d4cf..c45c2a749 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8375,21 +8375,7 @@ void tcx_hm_modify_envelope( Word32 env[], /* i/o: envelope Q16 */ Word16 L_frame /* i: number of spectral lines Q0 */ ); -#ifdef HARMONIZE_READ_DECODE_TNS -Word16 ReadTnsData( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); -Word16 DecodeTnsData( - STnsConfig const *pTnsConfig, - Word16 const *stream, /*Q0*/ - Word16 *pnSize, /*Q0*/ - STnsData *pTnsData ); - -#else Word16 ReadTnsData( STnsConfig const *pTnsConfig, Decoder_State *st, @@ -8416,7 +8402,6 @@ Word16 DecodeTnsData_ivas_fx( Word16 *pnSize, STnsData *pTnsData ); -#endif void GetParameters( ParamsBitMap const *paramsBitMap, const Word16 nParams, @@ -11077,6 +11062,12 @@ void EncodeTnsData( Word16 *pnBits /* o : number of written bits */ ); +Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + void WriteTnsData( const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ const Word16 *stream, /* i : internal data stream */ @@ -11084,7 +11075,7 @@ void WriteTnsData( BSTR_ENC_HANDLE hBstr, /* o : bitstream */ Word16 *pnBits /* o : number of written bits */ ); -#ifndef HARMONIZE_READ_DECODE_TNS + void ReadTnsData_ivas( STnsConfig const *pTnsConfig, Decoder_State *st, @@ -11092,13 +11083,6 @@ void ReadTnsData_ivas( Word16 *stream, Word16 *pnSize ); -Word16 DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const Word16 *stream, - Word16 *pnSize, - STnsData *pTnsData ); - -#endif // HARMONIZE_READ_DECODE_TNS void analysisCldfbEncoder_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word32 *timeIn, /*q11*/ diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 853ac4222..41a2e9842 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -394,13 +394,7 @@ void getTCXparam_fx( } ELSE { -#ifdef HARMONIZE_READ_DECODE_TNS - - (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st0, &nTnsBits, prm + j, &nTnsParams ); -#else - ReadTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, st0, &nTnsBits, prm + j, &nTnsParams ); -#endif // HARMONIZE_READ_DECODE_TNS } hTcxDec->tnsActive[k] = 0; // Q0 move16(); @@ -1357,11 +1351,7 @@ void dec_prm_fx( IF( st->hTcxCfg->fIsTNSAllowed ) { SetTnsConfig( st->hTcxCfg, 1, (Word16) EQ_16( st->last_core_from_bs, ACELP_CORE ) ); -#ifdef HARMONIZE_READ_DECODE_TNS - (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); -#else ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); -#endif // HARMONIZE_READ_DECODE_TNS j = add( j, nTnsParams ); // Q0 } @@ -1685,13 +1675,8 @@ void dec_prm_fx( test(); test(); SetTnsConfig( st->hTcxCfg, 0, ( st->last_core_from_bs == ACELP_CORE ) && ( k == 0 ) ); -#ifdef HARMONIZE_READ_DECODE_TNS - (void) ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); -#else - ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); -#endif // DEBUG - + ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); j = add( j, nTnsParams ); } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 534d34275..ed170d598 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4204,7 +4204,7 @@ void decoder_tcx_invQ_fx( test(); IF( !bfi && hTcxCfg->fIsTNSAllowed ) { - *fUseTns = DecodeTnsData( hTcxCfg->pCurrentTnsConfig, prm_tns, &tnsSize, tnsData ); + *fUseTns = DecodeTnsData_ivas_fx( hTcxCfg->pCurrentTnsConfig, prm_tns, &tnsSize, tnsData ); move16(); } ELSE diff --git a/lib_dec/tns_base_dec_fx.c b/lib_dec/tns_base_dec_fx.c index 42fd51df7..e245a4674 100644 --- a/lib_dec/tns_base_dec_fx.c +++ b/lib_dec/tns_base_dec_fx.c @@ -21,120 +21,6 @@ typedef Word32 ( *TLinearPredictionFilter )( Word16 order, Word16 const parCoeff /********************************/ /* Interface functions */ /********************************/ - - -#ifdef HARMONIZE_READ_DECODE_TNS -/*---------------------------------------------------------------------* - * ReadTnsData() - * - * - *---------------------------------------------------------------------*/ -Word16 ReadTnsData( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, /*Q0*/ - Word16 *stream, /*Q0*/ - Word16 *pnSize /*Q0*/ -) -{ - Word16 start_bit_pos; - - move16(); - start_bit_pos = st->next_bit_pos; - - IF( GT_16( pTnsConfig->nMaxFilters, 1 ) ) - { - IF( pTnsConfig->allowTnsOnWhite ) - { - IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) - { - ReadFromBitstream_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, st, &stream, pnSize ); - } - ELSE - { - ReadFromBitstream_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, st, &stream, pnSize ); - } - } - ELSE - { - - IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) - { - ReadFromBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, st, &stream, pnSize ); - } - ELSE - { - ReadFromBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, st, &stream, pnSize ); - } - } - } - ELSE - { - ReadFromBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, st, &stream, pnSize ); - } - - move16(); - *pnBits = sub( st->next_bit_pos, start_bit_pos ); - - return TNS_NO_ERROR; -} -/*---------------------------------------------------------------------* - * DecodeTnsData() - * - * - *---------------------------------------------------------------------*/ -Word16 DecodeTnsData( - STnsConfig const *pTnsConfig, - Word16 const *stream, /*Q0*/ - Word16 *pnSize, /*Q0*/ - STnsData *pTnsData ) -{ - Word16 result; - - ResetTnsData( pTnsData ); - - IF( GT_16( pTnsConfig->nMaxFilters, 1 ) ) - { - - IF( pTnsConfig->allowTnsOnWhite ) - { - IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) - { - SetParameters_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, pTnsData, &stream, pnSize ); - } - ELSE - { - SetParameters_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); - } - } - ELSE - { - - IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) - { - SetParameters_fx( &tnsEnabledSWBTCX10BitMap, 1, pTnsData, &stream, pnSize ); - } - ELSE - { - SetParameters_fx( &tnsEnabledSWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); - } - } - } - ELSE - { - SetParameters_fx( &tnsEnabledWBTCX20BitMap, 1, pTnsData, &stream, pnSize ); - } - - move16(); - result = FALSE; - if ( pTnsData->nFilters > 0 ) - { - move16(); - result = TRUE; - } - return result; -} -#else /*---------------------------------------------------------------------* * ReadTnsData() * @@ -330,6 +216,3 @@ Word16 DecodeTnsData_ivas_fx( return result; } - - -#endif // HARMONIZE_READ_DECODE_TNS -- GitLab From 77feee6825c5d67e83e3a8412967fcf8b2704319 Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 5 Feb 2026 11:01:27 +0100 Subject: [PATCH 744/750] MR 2797 harmonize InitTnsConfiguration() --- lib_com/options.h | 2 +- lib_com/prot_fx.h | 2 ++ lib_com/tcx_utils_fx.c | 11 ++++++++++- lib_com/tns_base.c | 26 ++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ea316a82..13cd47ee5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,10 +106,10 @@ #define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */ #define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ #define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ +#define FIX_2388_INITTNSCONFIGURATION /* FhG: issue 2388 : harmonizing InitTnsConfiguration() function */ #define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ - /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c45c2a749..625ecc1a3 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3569,6 +3569,7 @@ Word32 DTFS_getEngy_band_wb_fx( Word16 lband, Word16 hband ); +#ifndef FIX_2388_INITTNSCONFIGURATION void InitTnsConfiguration( const Word16 bwidth, const Word16 frameLength, @@ -3577,6 +3578,7 @@ void InitTnsConfiguration( const Word32 total_brate, const Word16 element_mode, const Word16 is_mct ); +#endif void InitTnsConfiguration_ivas_fx( const Word16 bwidth, diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index f73fb5971..c71392b4b 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1969,7 +1969,7 @@ void tcx_noise_filling_with_shift( /*--------------------------------------------------------------- - * InitTnsConfigs() + * () *--------------------------------------------------------------*/ @@ -1984,10 +1984,19 @@ void InitTnsConfigs( { IF( GT_32( total_brate, ACELP_32k ) ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfiguration_ivas_fx( bwidth, shr( L_frame, 1 ), &tnsConfig[0][0], igfStopFreq, total_brate, element_mode, MCT_flag ); +#else InitTnsConfiguration( bwidth, shr( L_frame, 1 ), &tnsConfig[0][0], igfStopFreq, total_brate, element_mode, MCT_flag ); +#endif } +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfiguration_ivas_fx( bwidth, L_frame, &tnsConfig[1][0], igfStopFreq, total_brate, element_mode, MCT_flag ); + InitTnsConfiguration_ivas_fx( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); +#else InitTnsConfiguration( bwidth, L_frame, &tnsConfig[1][0], igfStopFreq, total_brate, element_mode, MCT_flag ); InitTnsConfiguration( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); +#endif } void InitTnsConfigs_ivas_fx( diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 600b2e6fe..babf67cf2 100755 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -72,6 +72,7 @@ static void ITF_GetFilterParameters_fx( Word32 rxx[], const Word16 maxOrder, Wor /* Interface functions */ /********************************/ +#ifndef FIX_2388_INITTNSCONFIGURATION /** Init TNS configuration. * Fills STnsConfig structure with sensible content. * @param nSampleRate Sampling rate of the input. @@ -196,6 +197,7 @@ void InitTnsConfiguration( } return; /*TNS_NO_ERROR;*/ } +#endif /* FIX_2388_INITTNSCONFIGURATION */ void InitTnsConfiguration_ivas_fx( const Word16 bwidth, /*Q0*/ @@ -235,7 +237,11 @@ void InitTnsConfiguration_ivas_fx( IF( LE_32( total_brate, ACELP_32k ) ) { move16(); +#ifdef FIX_2388_INITTNSCONFIGURATION + pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParametersIGF32kHz_LowBR ) / sizeof( tnsParametersIGF32kHz_LowBR[0] ) ); /*Q0*/ +#else pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParametersIGF32kHz_LowBR ), sizeof( tnsParametersIGF32kHz_LowBR[0] ) ); /*Q0*/ +#endif pTnsConfig->pTnsParameters = tnsParametersIGF32kHz_LowBR; } ELSE @@ -243,7 +249,11 @@ void InitTnsConfiguration_ivas_fx( test(); IF( GT_32( nSampleRate, 32000 ) && EQ_32( nSampleRate, L_mult0( 100, frameLength ) ) ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters48kHz_grouped ) / sizeof( tnsParameters48kHz_grouped[0] ) ); /*Q0*/ +#else pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters48kHz_grouped ), sizeof( tnsParameters48kHz_grouped[0] ) ); /*Q0*/ +#endif move16(); pTnsConfig->pTnsParameters = tnsParameters48kHz_grouped; } @@ -259,7 +269,11 @@ void InitTnsConfiguration_ivas_fx( test(); IF( GT_16( element_mode, IVAS_SCE ) && GE_32( total_brate, L_tmp ) ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters32kHz_Stereo ) / sizeof( tnsParameters32kHz_Stereo[0] ) ); /*Q0*/ +#else pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters32kHz_Stereo ), sizeof( tnsParameters32kHz_Stereo[0] ) ); /*Q0*/ +#endif move16(); IF( EQ_32( nSampleRate, L_mult0( 100, frameLength ) ) ) /* sub-frame length is <= 10 ms */ { @@ -274,7 +288,11 @@ void InitTnsConfiguration_ivas_fx( { move16(); +#ifdef FIX_2388_INITTNSCONFIGURATION + pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters32kHz ) / sizeof( tnsParameters32kHz[0] ) ); /*Q0*/ +#else pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters32kHz ), sizeof( tnsParameters32kHz[0] ) ); /*Q0*/ +#endif pTnsConfig->pTnsParameters = tnsParameters32kHz; @@ -289,13 +307,21 @@ void InitTnsConfiguration_ivas_fx( IF( EQ_32( nSampleRate, L_mult0( 100, frameLength ) ) ) /* sub-frame length is <= 10 ms */ { move16(); +#ifdef FIX_2388_INITTNSCONFIGURATION + pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters16kHz_grouped ) / sizeof( tnsParameters16kHz_grouped[0] ) ); /*Q0*/ +#else pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters16kHz_grouped ), sizeof( tnsParameters16kHz_grouped[0] ) ); /*Q0*/ +#endif pTnsConfig->pTnsParameters = tnsParameters16kHz_grouped; } ELSE { move16(); +#ifdef FIX_2388_INITTNSCONFIGURATION + pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters16kHz ) / sizeof( tnsParameters16kHz[0] ) ); /*Q0*/ +#else pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters16kHz ), sizeof( tnsParameters16kHz[0] ) ); /*Q0*/ +#endif pTnsConfig->pTnsParameters = tnsParameters16kHz; } } -- GitLab From 3b002cde3940c58b073ed84e5d65da868678232f Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 5 Feb 2026 11:18:15 +0100 Subject: [PATCH 745/750] clang format --- lib_com/tns_base.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) mode change 100755 => 100644 lib_com/tns_base.c diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c old mode 100755 new mode 100644 index babf67cf2..c0a7cd4e6 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -240,7 +240,7 @@ void InitTnsConfiguration_ivas_fx( #ifdef FIX_2388_INITTNSCONFIGURATION pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParametersIGF32kHz_LowBR ) / sizeof( tnsParametersIGF32kHz_LowBR[0] ) ); /*Q0*/ #else - pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParametersIGF32kHz_LowBR ), sizeof( tnsParametersIGF32kHz_LowBR[0] ) ); /*Q0*/ + pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParametersIGF32kHz_LowBR ), sizeof( tnsParametersIGF32kHz_LowBR[0] ) ); /*Q0*/ #endif pTnsConfig->pTnsParameters = tnsParametersIGF32kHz_LowBR; } @@ -252,7 +252,7 @@ void InitTnsConfiguration_ivas_fx( #ifdef FIX_2388_INITTNSCONFIGURATION pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters48kHz_grouped ) / sizeof( tnsParameters48kHz_grouped[0] ) ); /*Q0*/ #else - pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters48kHz_grouped ), sizeof( tnsParameters48kHz_grouped[0] ) ); /*Q0*/ + pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters48kHz_grouped ), sizeof( tnsParameters48kHz_grouped[0] ) ); /*Q0*/ #endif move16(); pTnsConfig->pTnsParameters = tnsParameters48kHz_grouped; @@ -272,7 +272,7 @@ void InitTnsConfiguration_ivas_fx( #ifdef FIX_2388_INITTNSCONFIGURATION pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters32kHz_Stereo ) / sizeof( tnsParameters32kHz_Stereo[0] ) ); /*Q0*/ #else - pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters32kHz_Stereo ), sizeof( tnsParameters32kHz_Stereo[0] ) ); /*Q0*/ + pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters32kHz_Stereo ), sizeof( tnsParameters32kHz_Stereo[0] ) ); /*Q0*/ #endif move16(); IF( EQ_32( nSampleRate, L_mult0( 100, frameLength ) ) ) /* sub-frame length is <= 10 ms */ @@ -291,7 +291,7 @@ void InitTnsConfiguration_ivas_fx( #ifdef FIX_2388_INITTNSCONFIGURATION pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters32kHz ) / sizeof( tnsParameters32kHz[0] ) ); /*Q0*/ #else - pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters32kHz ), sizeof( tnsParameters32kHz[0] ) ); /*Q0*/ + pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters32kHz ), sizeof( tnsParameters32kHz[0] ) ); /*Q0*/ #endif pTnsConfig->pTnsParameters = tnsParameters32kHz; @@ -320,7 +320,7 @@ void InitTnsConfiguration_ivas_fx( #ifdef FIX_2388_INITTNSCONFIGURATION pTnsConfig->nMaxFilters = (UWord8) ( sizeof( tnsParameters16kHz ) / sizeof( tnsParameters16kHz[0] ) ); /*Q0*/ #else - pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters16kHz ), sizeof( tnsParameters16kHz[0] ) ); /*Q0*/ + pTnsConfig->nMaxFilters = (UWord8) idiv1616( sizeof( tnsParameters16kHz ), sizeof( tnsParameters16kHz[0] ) ); /*Q0*/ #endif pTnsConfig->pTnsParameters = tnsParameters16kHz; } -- GitLab From be0e391d4fa2d07fbc9582daf2c901c667b4e4ee Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 5 Feb 2026 12:38:51 +0100 Subject: [PATCH 746/750] corrected options.h --- lib_com/options.h | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ccece30c..cf9b10a06 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,30 +84,10 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ -#define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ -#define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ -#define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ -#define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ -#define FIX_2376_FIX_USAN_PRE_PROC /* VA: basop issue 2376: Resolve "USAN: SEGV in ivas_compute_core_buffers_fx() */ -#define FIX_2367_REMOVE_CODE_ICBWE /* VA: basop issue 2367: Remove IC-BWE obsolete code */ -#define REMOVE_SCALING_SHB_SPEECH /* VA: remove unnecessary scaling and 32-bit buffers from ivas_core_enc_fx() */ -#define FIX_2352_COPY_AQ_IN_TCX /* FhG: basop issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ -#define FIX_2353_PTR_INIT /* FhG: basop issue 2353: initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 */ -#define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ -#define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ -#define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */ -#define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */ -#define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */ -#define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */ -#define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */ -#define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */ -#define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */ #define FIX_2388_INITTNSCONFIGURATION /* FhG: issue 2388 : harmonizing InitTnsConfiguration() function */ -#define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ -- GitLab From 17ebdc5c026feac54d23b231ca4434ef6e418a59 Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 5 Feb 2026 16:03:06 +0100 Subject: [PATCH 747/750] MR 2388, also harmonizing InitTnsConfigs(), using suffix _fx instead of _ivas_fx --- lib_com/core_com_config_fx.c | 9 ++++++++- lib_com/prot_fx.h | 13 ++++++++++++- lib_com/tcx_utils_fx.c | 29 ++++++++++++++++++----------- lib_com/tns_base.c | 7 ++++++- lib_dec/core_dec_init_fx.c | 4 ++++ lib_dec/core_dec_switch_fx.c | 8 ++++++++ lib_enc/core_enc_init_fx.c | 4 ++++ lib_enc/core_enc_switch_fx.c | 8 ++++++++ lib_enc/ivas_tcx_core_enc_fx.c | 4 ++++ 9 files changed, 72 insertions(+), 14 deletions(-) diff --git a/lib_com/core_com_config_fx.c b/lib_com/core_com_config_fx.c index 1afa2f1a9..cb9723487 100644 --- a/lib_com/core_com_config_fx.c +++ b/lib_com/core_com_config_fx.c @@ -997,8 +997,11 @@ void init_tcx_cfg_ivas_fx( IF( hTcxCfg->fIsTNSAllowed ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); +#else InitTnsConfigs_ivas_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); - +#endif SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } @@ -1253,7 +1256,11 @@ void init_tcx_cfg_fx( IF( hTcxCfg->fIsTNSAllowed ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); +#else InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); +#endif SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9ac21c302..78b87b675 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3580,7 +3580,11 @@ void InitTnsConfiguration( const Word16 is_mct ); #endif +#ifdef FIX_2388_INITTNSCONFIGURATION +void InitTnsConfiguration_fx( +#else void InitTnsConfiguration_ivas_fx( +#endif const Word16 bwidth, const Word16 frameLength, STnsConfig *pTnsConfig, @@ -4225,6 +4229,7 @@ void tcx_noise_filling_with_shift( const Word16 element_mode /* i : IVAS element mode */ ); +#ifndef FIX_2388_INITTNSCONFIGURATION void InitTnsConfigs( const Word16 bwidth, const Word16 L_frame, @@ -4233,8 +4238,14 @@ void InitTnsConfigs( const Word32 total_brate, const Word16 element_mode, const Word16 is_mct ); +#endif -void InitTnsConfigs_ivas_fx( +#ifdef FIX_2388_INITTNSCONFIGURATION +void InitTnsConfigs_fx +#else +void InitTnsConfigs_ivas_fx +#endif +( const Word16 bwidth, const Word16 L_frame, STnsConfig tnsConfig[2][2], diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index c71392b4b..02692d7db 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1969,10 +1969,11 @@ void tcx_noise_filling_with_shift( /*--------------------------------------------------------------- - * () + * InitTnsConfigs() *--------------------------------------------------------------*/ +#ifndef FIX_2388_INITTNSCONFIGURATION void InitTnsConfigs( const Word16 bwidth, /*Q0*/ const Word16 L_frame, /*Q0*/ @@ -1984,22 +1985,19 @@ void InitTnsConfigs( { IF( GT_32( total_brate, ACELP_32k ) ) { -#ifdef FIX_2388_INITTNSCONFIGURATION - InitTnsConfiguration_ivas_fx( bwidth, shr( L_frame, 1 ), &tnsConfig[0][0], igfStopFreq, total_brate, element_mode, MCT_flag ); -#else InitTnsConfiguration( bwidth, shr( L_frame, 1 ), &tnsConfig[0][0], igfStopFreq, total_brate, element_mode, MCT_flag ); -#endif } -#ifdef FIX_2388_INITTNSCONFIGURATION - InitTnsConfiguration_ivas_fx( bwidth, L_frame, &tnsConfig[1][0], igfStopFreq, total_brate, element_mode, MCT_flag ); - InitTnsConfiguration_ivas_fx( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); -#else InitTnsConfiguration( bwidth, L_frame, &tnsConfig[1][0], igfStopFreq, total_brate, element_mode, MCT_flag ); InitTnsConfiguration( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); -#endif } +#endif -void InitTnsConfigs_ivas_fx( +#ifdef FIX_2388_INITTNSCONFIGURATION +void InitTnsConfigs_fx +#else +void InitTnsConfigs_ivas_fx +#endif +( const Word16 bwidth, /*Q0*/ const Word16 L_frame, /*Q0*/ STnsConfig tnsConfig[2][2], @@ -2010,10 +2008,19 @@ void InitTnsConfigs_ivas_fx( { IF( GT_32( total_brate, ACELP_32k ) ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfiguration_fx( bwidth, shr( L_frame, 1 ), &tnsConfig[0][0], igfStopFreq, total_brate, element_mode, MCT_flag ); +#else InitTnsConfiguration_ivas_fx( bwidth, shr( L_frame, 1 ), &tnsConfig[0][0], igfStopFreq, total_brate, element_mode, MCT_flag ); +#endif } +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfiguration_fx( bwidth, L_frame, &tnsConfig[1][0], igfStopFreq, total_brate, element_mode, MCT_flag ); + InitTnsConfiguration_fx( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); +#else InitTnsConfiguration_ivas_fx( bwidth, L_frame, &tnsConfig[1][0], igfStopFreq, total_brate, element_mode, MCT_flag ); InitTnsConfiguration_ivas_fx( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); +#endif } void SetTnsConfig( diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index c0a7cd4e6..faad70777 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -199,7 +199,12 @@ void InitTnsConfiguration( } #endif /* FIX_2388_INITTNSCONFIGURATION */ -void InitTnsConfiguration_ivas_fx( +#ifdef FIX_2388_INITTNSCONFIGURATION +void InitTnsConfiguration_fx +#else +void InitTnsConfiguration_ivas_fx +#endif /* FIX_2388_INITTNSCONFIGURATION */ +( const Word16 bwidth, /*Q0*/ const Word16 frameLength, /*Q0*/ STnsConfig *pTnsConfig, diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 79b75b02f..678d0b3d7 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -240,7 +240,11 @@ void open_decoder_LPD_fx( IF( st->hTcxCfg->fIsTNSAllowed != 0 ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, st->total_brate, st->element_mode, 0 /*is_mct*/ ); +#else InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, st->total_brate, st->element_mode, 0 /*is_mct*/ ); +#endif } /*Constraint for adaptive BPF, otherwise parameter estimation and post-processing not time aligned*/ if ( st->tcxonly == 0 ) diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index b22a48b43..3a9148b76 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -133,7 +133,11 @@ void mode_switch_decoder_LPD_fx( IF( ( st->hTcxCfg->fIsTNSAllowed != 0 ) && st->hIGFDec != NULL ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, total_brate, st->element_mode, 0 /* 0 should be replaced with MCT_flag*/ ); +#else InitTnsConfigs( bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, total_brate, st->element_mode, 0 /* 0 should be replaced with MCT_flag*/ ); +#endif } } } @@ -377,7 +381,11 @@ void mode_switch_decoder_LPD_ivas_fx( IF( st->hTcxCfg->fIsTNSAllowed && st->hIGFDec != NULL && st->hTcxCfg != NULL ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, total_brate, st->element_mode, MCT_flag ); +#else InitTnsConfigs( bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, total_brate, st->element_mode, MCT_flag ); +#endif SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, (Word8) EQ_16( st->element_mode, IVAS_CPE_MDCT ) ); } diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index a8c674170..c944bc5f4 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -361,7 +361,11 @@ static void init_tcx_fx( IF( st->hTcxCfg->fIsTNSAllowed != 0 ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, 0 /*is_mct*/ ); +#else InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, 0 /*is_mct*/ ); +#endif } /* TCX-LTP */ diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index b61609e50..27c429ded 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -109,7 +109,11 @@ void core_coder_mode_switch_fx( move16(); IF( st->hTcxCfg->fIsTNSAllowed != 0 ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); +#else InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); +#endif } st->narrowBand = 0; @@ -333,7 +337,11 @@ void core_coder_mode_switch_ivas_fx( IF( st->hTcxCfg->fIsTNSAllowed ) { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); +#else InitTnsConfigs_ivas_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); +#endif SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, st->element_mode == IVAS_CPE_MDCT ); } diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 709e17ef7..db24fbd35 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -134,7 +134,11 @@ void stereo_tcx_init_enc_fx( test(); IF( !prev_IsTNSAllowed && st->hTcxCfg->fIsTNSAllowed && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) /* may happen in unified stereo when switching stereo technologies */ { +#ifdef FIX_2388_INITTNSCONFIGURATION + InitTnsConfigs_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, total_brate, st->element_mode, 0 ); +#else InitTnsConfigs_ivas_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, total_brate, st->element_mode, 0 ); +#endif SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, 0 ); } -- GitLab From e57647faad4058b20be5b26d55ef6b51428afe7a Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 5 Feb 2026 16:06:57 +0100 Subject: [PATCH 748/750] clang format --- lib_com/prot_fx.h | 16 ++++++++-------- lib_com/tcx_utils_fx.c | 16 ++++++++-------- lib_com/tns_base.c | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 62303f3c7..0b3d4278c 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4245,14 +4245,14 @@ void InitTnsConfigs_fx #else void InitTnsConfigs_ivas_fx #endif -( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); + ( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); void SetAllowTnsOnWhite( STnsConfig tnsConfig[2][2], diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 02692d7db..44c034a20 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1997,14 +1997,14 @@ void InitTnsConfigs_fx #else void InitTnsConfigs_ivas_fx #endif -( - const Word16 bwidth, /*Q0*/ - const Word16 L_frame, /*Q0*/ - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, /*Q0*/ - const Word32 total_brate, /*Q0*/ - const Word16 element_mode, /*Q0*/ - const Word16 MCT_flag /*Q0*/ ) + ( + const Word16 bwidth, /*Q0*/ + const Word16 L_frame, /*Q0*/ + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, /*Q0*/ + const Word32 total_brate, /*Q0*/ + const Word16 element_mode, /*Q0*/ + const Word16 MCT_flag /*Q0*/ ) { IF( GT_32( total_brate, ACELP_32k ) ) { diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index faad70777..8c79d885f 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -204,14 +204,14 @@ void InitTnsConfiguration_fx #else void InitTnsConfiguration_ivas_fx #endif /* FIX_2388_INITTNSCONFIGURATION */ -( - const Word16 bwidth, /*Q0*/ - const Word16 frameLength, /*Q0*/ - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, /*Q0*/ - const Word32 total_brate, /*Q0*/ - const Word16 element_mode, /*Q0*/ - const Word16 is_mct /*Q0*/ ) + ( + const Word16 bwidth, /*Q0*/ + const Word16 frameLength, /*Q0*/ + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, /*Q0*/ + const Word32 total_brate, /*Q0*/ + const Word16 element_mode, /*Q0*/ + const Word16 is_mct /*Q0*/ ) { Word16 iFilter = 0; move16(); -- GitLab From 053f46eaca249bbc9081e457849a775ef970fc54 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 5 Feb 2026 19:42:46 +0100 Subject: [PATCH 749/750] update with main --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 96de1f36f..6afb91c48 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,8 +90,8 @@ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE /* VA: reduction of unnecessary scaling, non-BE part */ #define FIX_2403_COMBINE_PITCH_OL /* VA : basop 2403, reusing common code between EVS and IVAS in pitch_ol */ -#define HARMONIZE_ACELP_ENC /* VA: basop issue 2400: Remove duplicated main ACELP encoder function */ #define FIX_2404_HARM_SIGNAL_CLAS /* VA: basop-2404, harmonize signal_clas and signa_ivas_clas */ +#define HARMONIZE_ACELP_ENC /* VA: basop issue 2400: Remove duplicated main ACELP encoder function */ /* #################### End BE switches ################################## */ -- GitLab From e104a5ec5f7c2bd1daa569812234ac5e48831c61 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 5 Feb 2026 19:47:16 +0100 Subject: [PATCH 750/750] clang-format --- lib_enc/speech_music_classif_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index cd8c13a5f..9db4b6b04 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1157,7 +1157,7 @@ static Word16 sp_mus_classif_gmm_fx( /* calculate weight based on relE (close to 0.01 in low-E regions, close to 1 in high-E regions) */ /*wrelE = 1.0f + relE/15;*/ wrelE = add( 2048, mult_r( relE, 17476 ) ); /* 1/15 in Q18 -> 17476 result in Q11 */ - + wrelE = s_min( wrelE, 2048 ); wrelE = s_max( wrelE, 20 ); -- GitLab